it begins
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
package mindustry.content;
|
package mindustry.content;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.struct.*;
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
|
import mindustry.entities.AllDefs.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -18,6 +19,7 @@ import mindustry.world.blocks.*;
|
|||||||
import mindustry.world.blocks.defense.*;
|
import mindustry.world.blocks.defense.*;
|
||||||
import mindustry.world.blocks.defense.turrets.*;
|
import mindustry.world.blocks.defense.turrets.*;
|
||||||
import mindustry.world.blocks.distribution.*;
|
import mindustry.world.blocks.distribution.*;
|
||||||
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.blocks.liquid.*;
|
import mindustry.world.blocks.liquid.*;
|
||||||
import mindustry.world.blocks.logic.*;
|
import mindustry.world.blocks.logic.*;
|
||||||
import mindustry.world.blocks.power.*;
|
import mindustry.world.blocks.power.*;
|
||||||
@@ -91,7 +93,7 @@ public class Blocks implements ContentList{
|
|||||||
hasShadow = false;
|
hasShadow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Tile tile){}
|
public void draw(){}
|
||||||
public void load(){}
|
public void load(){}
|
||||||
public void init(){}
|
public void init(){}
|
||||||
public boolean isHidden(){
|
public boolean isHidden(){
|
||||||
@@ -110,7 +112,7 @@ public class Blocks implements ContentList{
|
|||||||
{
|
{
|
||||||
variants = 0;
|
variants = 0;
|
||||||
}
|
}
|
||||||
public void draw(Tile tile){}
|
public void draw(){}
|
||||||
};
|
};
|
||||||
|
|
||||||
cliff = new Cliff("cliff");
|
cliff = new Cliff("cliff");
|
||||||
@@ -511,13 +513,10 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
int topRegion = reg("-top");
|
int topRegion = reg("-top");
|
||||||
|
|
||||||
drawer = tile -> {
|
drawer = entity -> {
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, entity.x(), entity.y());
|
||||||
|
|
||||||
GenericCrafterEntity entity = tile.ent();
|
|
||||||
|
|
||||||
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f) * entity.warmup);
|
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f) * entity.warmup);
|
||||||
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy());
|
Draw.rect(reg(topRegion), entity.x(), entity.y());
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
};
|
};
|
||||||
}};
|
}};
|
||||||
@@ -538,24 +537,22 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name), Core.atlas.find(name + "-weave")};
|
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name), Core.atlas.find(name + "-weave")};
|
||||||
|
|
||||||
drawer = tile -> {
|
drawer = entity -> {
|
||||||
GenericCrafterEntity entity = tile.ent();
|
Draw.rect(reg(bottomRegion), entity.x(), entity.y());
|
||||||
|
Draw.rect(reg(weaveRegion), entity.x(), entity.y(), entity.totalProgress);
|
||||||
Draw.rect(reg(bottomRegion), tile.drawx(), tile.drawy());
|
|
||||||
Draw.rect(reg(weaveRegion), tile.drawx(), tile.drawy(), entity.totalProgress);
|
|
||||||
|
|
||||||
Draw.color(Pal.accent);
|
Draw.color(Pal.accent);
|
||||||
Draw.alpha(entity.warmup);
|
Draw.alpha(entity.warmup);
|
||||||
|
|
||||||
Lines.lineAngleCenter(
|
Lines.lineAngleCenter(
|
||||||
tile.drawx() + Mathf.sin(entity.totalProgress, 6f, Vars.tilesize / 3f * size),
|
entity.x() + Mathf.sin(entity.totalProgress, 6f, Vars.tilesize / 3f * size),
|
||||||
tile.drawy(),
|
entity.y(),
|
||||||
90,
|
90,
|
||||||
size * Vars.tilesize / 2f);
|
size * Vars.tilesize / 2f);
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, entity.x(), entity.y());
|
||||||
};
|
};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@@ -1039,7 +1036,7 @@ public class Blocks implements ContentList{
|
|||||||
liquidCapacity = 20f;
|
liquidCapacity = 20f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
liquidTank = new LiquidTank("liquid-tank"){{
|
liquidTank = new LiquidRouter("liquid-tank"){{
|
||||||
requirements(Category.liquid, ItemStack.with(Items.titanium, 25, Items.metaglass, 25));
|
requirements(Category.liquid, ItemStack.with(Items.titanium, 25, Items.metaglass, 25));
|
||||||
size = 3;
|
size = 3;
|
||||||
liquidCapacity = 1500f;
|
liquidCapacity = 1500f;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import mindustry.game.Team;
|
|||||||
import mindustry.gen.TileOp;
|
import mindustry.gen.TileOp;
|
||||||
import mindustry.world.Block;
|
import mindustry.world.Block;
|
||||||
import mindustry.world.Tile;
|
import mindustry.world.Tile;
|
||||||
import mindustry.world.blocks.Floor;
|
import mindustry.world.blocks.environment.Floor;
|
||||||
|
|
||||||
import static mindustry.Vars.content;
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import mindustry.game.Team;
|
|||||||
import mindustry.gen.TileOp;
|
import mindustry.gen.TileOp;
|
||||||
import mindustry.world.Block;
|
import mindustry.world.Block;
|
||||||
import mindustry.world.Tile;
|
import mindustry.world.Tile;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.modules.*;
|
import mindustry.world.modules.*;
|
||||||
|
|
||||||
import static mindustry.Vars.state;
|
import static mindustry.Vars.state;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import mindustry.ui.*;
|
|||||||
import mindustry.ui.Cicon;
|
import mindustry.ui.Cicon;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import mindustry.maps.filters.GenerateFilter.*;
|
|||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import arc.util.*;
|
|||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.net;
|
import static mindustry.Vars.net;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import mindustry.*;
|
|||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.world;
|
import static mindustry.Vars.world;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import mindustry.ctype.*;
|
|||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.collisions;
|
import static mindustry.Vars.collisions;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import arc.struct.IntSet.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import mindustry.content.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class MinimapRenderer implements Disposable{
|
|||||||
texture.draw(pixmap, 0, 0);
|
texture.draw(pixmap, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
int color = colorFor(world.tile(tile.x, tile.y));
|
int color = colorFor(world.tile(tile.x, tile.y));
|
||||||
pixmap.draw(tile.x, pixmap.getHeight() - 1 - tile.y, color);
|
pixmap.draw(tile.x, pixmap.getHeight() - 1 - tile.y, color);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package mindustry.maps.filters;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.maps.filters.FilterOption.*;
|
import mindustry.maps.filters.FilterOption.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
public class DistortFilter extends GenerateFilter{
|
public class DistortFilter extends GenerateFilter{
|
||||||
float scl = 40, mag = 5;
|
float scl = 40, mag = 5;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import mindustry.gen.*;
|
|||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import arc.scene.ui.layout.*;
|
|||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.ctype.ContentType;
|
import mindustry.ctype.ContentType;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.content;
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import mindustry.game.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import mindustry.graphics.*;
|
|||||||
import mindustry.graphics.MultiPacker.*;
|
import mindustry.graphics.MultiPacker.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
import mindustry.world.meta.values.*;
|
import mindustry.world.meta.values.*;
|
||||||
@@ -159,13 +159,13 @@ public class Block extends UnlockableContent{
|
|||||||
protected Array<String> cacheRegionStrings = new Array<>();
|
protected Array<String> cacheRegionStrings = new Array<>();
|
||||||
protected ObjectMap<Class<?>, Cons2> configurations = new ObjectMap<>();
|
protected ObjectMap<Class<?>, Cons2> configurations = new ObjectMap<>();
|
||||||
|
|
||||||
protected Array<Tile> tempTiles = new Array<>();
|
//TODO move
|
||||||
protected Array<Tilec> tempTileEnts = new Array<>();
|
|
||||||
protected TextureRegion[] generatedIcons;
|
protected TextureRegion[] generatedIcons;
|
||||||
protected TextureRegion[] variantRegions, editorVariantRegions;
|
protected TextureRegion[] variantRegions, editorVariantRegions;
|
||||||
protected TextureRegion region, editorIcon;
|
public TextureRegion region, editorIcon;
|
||||||
|
|
||||||
protected static TextureRegion[][] cracks;
|
//TODO move
|
||||||
|
public static TextureRegion[][] cracks;
|
||||||
|
|
||||||
/** Dump timer ID.*/
|
/** Dump timer ID.*/
|
||||||
protected final int timerDump = timers++;
|
protected final int timerDump = timers++;
|
||||||
@@ -177,6 +177,34 @@ public class Block extends UnlockableContent{
|
|||||||
this.solid = false;
|
this.solid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO rename to draw() once class refactoring is done.
|
||||||
|
public void drawBase(Tile tile){
|
||||||
|
//delegates to entity unless it is null
|
||||||
|
if(tile.entity != null){
|
||||||
|
tile.entity.draw();
|
||||||
|
}else{
|
||||||
|
Draw.rect(region, tile.drawx(), tile.drawy(), rotate ? tile.rotation * 90 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return a custom minimap color for this or 0 to use default colors. */
|
||||||
|
public int minimapColor(Tile tile){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean outputsItems(){
|
||||||
|
return hasItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns whether ot not this block can be place on the specified */
|
||||||
|
public boolean canPlaceOn(Tile tile){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBreak(Tile tile){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #reg(int)}. */
|
/** Adds a region by name to be loaded, with the final name "{name}-suffix". Returns an ID to looks this region up by in {@link #reg(int)}. */
|
||||||
protected int reg(String suffix){
|
protected int reg(String suffix){
|
||||||
cacheRegionStrings.add(name + suffix);
|
cacheRegionStrings.add(name + suffix);
|
||||||
@@ -438,26 +466,37 @@ public class Block extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(entityType == null){
|
if(entityType == null){
|
||||||
//assign default value for now
|
|
||||||
entityType = TileEntity::create;
|
|
||||||
|
|
||||||
//attempt to find the first declared class and use it as the entity type
|
//attempt to find the first declared class and use it as the entity type
|
||||||
try{
|
try{
|
||||||
Class<?>[] classes = getClass().getDeclaredClasses();
|
Class<?>[] classes = getClass().getDeclaredClasses();
|
||||||
//first class that is subclass of Tilec
|
Class<?> current = getClass();
|
||||||
Class<?> type = Structs.find(classes, Tilec.class::isAssignableFrom);
|
|
||||||
if(type != null){
|
while(entityType == null && Block.class.isAssignableFrom(current)){
|
||||||
Constructor<? extends Tilec> cons = (Constructor<? extends Tilec>)type.getConstructor();
|
//first class that is subclass of Tilec
|
||||||
entityType = () -> {
|
Class<?> type = Structs.find(classes, Tilec.class::isAssignableFrom);
|
||||||
try{
|
if(type != null){
|
||||||
return cons.newInstance();
|
Constructor<? extends Tilec> cons = (Constructor<? extends Tilec>)type.getConstructor();
|
||||||
}catch(Exception e){
|
entityType = () -> {
|
||||||
throw new RuntimeException(e);
|
try{
|
||||||
}
|
return cons.newInstance();
|
||||||
};
|
}catch(Exception e){
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//scan through every superclass looking for it
|
||||||
|
current = current.getSuperclass();
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(Throwable ignored){
|
}catch(Throwable ignored){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(entityType == null){
|
||||||
|
//assign default value
|
||||||
|
entityType = TileEntity::create;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCost = 0f;
|
buildCost = 0f;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import mindustry.content.*;
|
|||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.modules.*;
|
import mindustry.world.modules.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -92,17 +92,17 @@ public class Tile implements Position{
|
|||||||
|
|
||||||
/** Configure a tile with the current, local player. */
|
/** Configure a tile with the current, local player. */
|
||||||
public void configure(Object value){
|
public void configure(Object value){
|
||||||
Call.onTileConfig(player, this, value);
|
if(entity != null) Call.onTileConfig(player, entity, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configureAny(Object value){
|
public void configureAny(Object value){
|
||||||
Call.onTileConfig(null, this, value);
|
if(entity != null) Call.onTileConfig(null, entity, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
//@SuppressWarnings("unchecked")
|
||||||
public <T extends TileEntity> T ent(){
|
//public <T extends TileEntity> T ent(){
|
||||||
return (T)entity;
|
// return (T)entity;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public float worldx(){
|
public float worldx(){
|
||||||
return x * tilesize;
|
return x * tilesize;
|
||||||
@@ -216,7 +216,7 @@ public class Tile implements Position{
|
|||||||
|
|
||||||
recache();
|
recache();
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
block.onProximityUpdate(entity);
|
entity.onProximityUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ public class Tile implements Position{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean solid(){
|
public boolean solid(){
|
||||||
return block.solid || (entity != null && block.isSolidFor(entity));
|
return block.solid || (entity != null && entity.checkSolid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean breakable(){
|
public boolean breakable(){
|
||||||
@@ -475,7 +475,7 @@ public class Tile implements Position{
|
|||||||
protected void preChanged(){
|
protected void preChanged(){
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
//only call removed() for the center block - this only gets called once.
|
//only call removed() for the center block - this only gets called once.
|
||||||
block.removed(entity);
|
entity.onRemoved();
|
||||||
entity.removeFromProximity();
|
entity.removeFromProximity();
|
||||||
|
|
||||||
//remove this tile's dangling entities
|
//remove this tile's dangling entities
|
||||||
@@ -527,9 +527,9 @@ public class Tile implements Position{
|
|||||||
}else if(!world.isGenerating()){
|
}else if(!world.isGenerating()){
|
||||||
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
||||||
for(Point2 p : Geometry.d4){
|
for(Point2 p : Geometry.d4){
|
||||||
Tile tile = world.tile(x + p.x, y + p.y);
|
Tilec tile = world.ent(x + p.x, y + p.y);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
tile.block().onProximityUpdate(entity);
|
tile.onProximityUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package mindustry.world.blocks;
|
|||||||
|
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
|
import arc.util.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -82,9 +83,8 @@ public interface Autotiler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
default boolean blends(Tile tile, int rotation, int direction){
|
default boolean blends(Tile tile, int rotation, int direction){
|
||||||
Tile other = tile.getNearby(Mathf.mod(rotation - direction, 4));
|
Tilec other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4));
|
||||||
if(other != null) other = other.link();
|
return other != null && other.team() == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation(), other.block());
|
||||||
return other != null && other.team() == tile.team() && blends(tile, rotation, other.x, other.y, other.rotation(), other.block());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
|
default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
|
||||||
|
|||||||
@@ -62,15 +62,13 @@ public class BuildBlock extends Block{
|
|||||||
@Remote(called = Loc.server)
|
@Remote(called = Loc.server)
|
||||||
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
|
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
|
||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
float healthf = tile.entity == null ? 1f : tile.entity.healthf();
|
float healthf = tile.entity.healthf();
|
||||||
tile.setBlock(block, team, (int)rotation);
|
tile.setBlock(block, team, (int)rotation);
|
||||||
if(tile.entity != null){
|
tile.entity.health(block.health * healthf);
|
||||||
tile.entity.health(block.health * healthf);
|
|
||||||
}
|
|
||||||
//last builder was this local client player, call placed()
|
//last builder was this local client player, call placed()
|
||||||
if(!headless && builderID == player.unit().id()){
|
if(!headless && builderID == player.unit().id()){
|
||||||
if(!skipConfig){
|
if(!skipConfig){
|
||||||
tile.block().playerPlaced(tile);
|
tile.entity.playerPlaced();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Fx.placeBlock.at(tile.drawx(), tile.drawy(), block.size);
|
Fx.placeBlock.at(tile.drawx(), tile.drawy(), block.size);
|
||||||
@@ -102,7 +100,7 @@ public class BuildBlock extends Block{
|
|||||||
|
|
||||||
public static void constructed(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
|
public static void constructed(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
|
||||||
Call.onConstructFinish(tile, block, builderID, rotation, team, skipConfig);
|
Call.onConstructFinish(tile, block, builderID, rotation, team, skipConfig);
|
||||||
tile.block().placed(tile);
|
tile.entity.placed();
|
||||||
|
|
||||||
Events.fire(new BlockBuildEndEvent(tile, Groups.unit.getByID(builderID), team, false));
|
Events.fire(new BlockBuildEndEvent(tile, Groups.unit.getByID(builderID), team, false));
|
||||||
if(shouldPlay()) Sounds.place.at(tile, calcPitch(true));
|
if(shouldPlay()) Sounds.place.at(tile, calcPitch(true));
|
||||||
@@ -113,94 +111,12 @@ public class BuildBlock extends Block{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName(Tile tile){
|
|
||||||
BuildEntity entity = tile.ent();
|
|
||||||
return Core.bundle.format("block.constructing", entity.cblock == null ? entity.previous.localizedName : entity.cblock.localizedName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureRegion getDisplayIcon(Tile tile){
|
|
||||||
BuildEntity entity = tile.ent();
|
|
||||||
return (entity.cblock == null ? entity.previous : entity.cblock).icon(mindustry.ui.Cicon.full);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSolidFor(Tile tile){
|
|
||||||
BuildEntity entity = tile.ent();
|
|
||||||
return entity == null || (entity.cblock != null && entity.cblock.solid) || entity.previous == null || entity.previous.solid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Cursor getCursor(Tile tile){
|
|
||||||
return SystemCursor.hand;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tapped(Tile tile, Playerc player){
|
|
||||||
BuildEntity entity = tile.ent();
|
|
||||||
|
|
||||||
//if the target is constructible, begin constructing
|
|
||||||
if(!headless && entity.cblock != null){
|
|
||||||
if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){
|
|
||||||
control.input.isBuilding = true;
|
|
||||||
}
|
|
||||||
player.builder().addBuild(new BuildRequest(tile.x, tile.y, tile.rotation(), entity.cblock), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyed(Tile tile){
|
|
||||||
Fx.blockExplosionSmoke.at(tile);
|
|
||||||
|
|
||||||
if(!tile.floor().solid && !tile.floor().isLiquid){
|
|
||||||
Effects.rubble(tile.drawx(), tile.drawy(), size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Tile tile){
|
|
||||||
BuildEntity entity = tile.ent();
|
|
||||||
|
|
||||||
//When breaking, don't draw the previous block... since it's the thing you were breaking
|
|
||||||
if(entity.cblock != null && entity.previous == entity.cblock){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity.previous == null || entity.cblock == null) return;
|
|
||||||
|
|
||||||
if(Core.atlas.isFound(entity.previous.icon(Cicon.full))){
|
|
||||||
Draw.rect(entity.previous.icon(Cicon.full), tile.drawx(), tile.drawy(), entity.previous.rotate ? tile.rotation() * 90 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawLayer(Tile tile){
|
|
||||||
|
|
||||||
BuildEntity entity = tile.ent();
|
|
||||||
|
|
||||||
Shaders.blockbuild.color = Pal.accent;
|
|
||||||
|
|
||||||
Block target = entity.cblock == null ? entity.previous : entity.cblock;
|
|
||||||
|
|
||||||
if(target == null) return;
|
|
||||||
|
|
||||||
for(TextureRegion region : target.getGeneratedIcons()){
|
|
||||||
Shaders.blockbuild.region = region;
|
|
||||||
Shaders.blockbuild.progress = entity.progress;
|
|
||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy(), target.rotate ? tile.rotation() * 90 : 0);
|
|
||||||
Draw.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BuildEntity extends TileEntity{
|
public class BuildEntity extends TileEntity{
|
||||||
/**
|
/**
|
||||||
* The recipe of the block that is being constructed.
|
* The recipe of the block that is being constructed.
|
||||||
* If there is no recipe for this block, as is the case with rocks, 'previous' is used.
|
* If there is no recipe for this block, as is the case with rocks, 'previous' is used.
|
||||||
*/
|
*/
|
||||||
public @Nullable
|
public @Nullable Block cblock;
|
||||||
Block cblock;
|
|
||||||
|
|
||||||
public float progress = 0;
|
public float progress = 0;
|
||||||
public float buildCost;
|
public float buildCost;
|
||||||
@@ -214,6 +130,77 @@ public class BuildBlock extends Block{
|
|||||||
private float[] accumulator;
|
private float[] accumulator;
|
||||||
private float[] totalAccumulator;
|
private float[] totalAccumulator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName(){
|
||||||
|
return Core.bundle.format("block.constructing", cblock == null ? previous.localizedName : cblock.localizedName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion getDisplayIcon(){
|
||||||
|
return (cblock == null ? previous : cblock).icon(Cicon.full);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkSolid(){
|
||||||
|
return (cblock != null && cblock.solid) || previous == null || previous.solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cursor getCursor(){
|
||||||
|
return SystemCursor.hand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tapped(Playerc player){
|
||||||
|
//if the target is constructible, begin constructing
|
||||||
|
if(!headless && cblock != null){
|
||||||
|
if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){
|
||||||
|
control.input.isBuilding = true;
|
||||||
|
}
|
||||||
|
player.builder().addBuild(new BuildRequest(tile.x, tile.y, tile.rotation(), cblock), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyed(){
|
||||||
|
Fx.blockExplosionSmoke.at(tile);
|
||||||
|
|
||||||
|
if(!tile.floor().solid && !tile.floor().isLiquid){
|
||||||
|
Effects.rubble(tile.drawx(), tile.drawy(), size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
//When breaking, don't draw the previous block... since it's the thing you were breaking
|
||||||
|
if(cblock != null && previous == cblock){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(previous == null || cblock == null) return;
|
||||||
|
|
||||||
|
if(Core.atlas.isFound(previous.icon(Cicon.full))){
|
||||||
|
Draw.rect(previous.icon(Cicon.full), tile.drawx(), tile.drawy(), previous.rotate ? tile.rotation() * 90 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawLayer(){
|
||||||
|
Shaders.blockbuild.color = Pal.accent;
|
||||||
|
|
||||||
|
Block target = cblock == null ? previous : cblock;
|
||||||
|
|
||||||
|
if(target == null) return;
|
||||||
|
|
||||||
|
for(TextureRegion region : target.getGeneratedIcons()){
|
||||||
|
Shaders.blockbuild.region = region;
|
||||||
|
Shaders.blockbuild.progress = progress;
|
||||||
|
|
||||||
|
Draw.rect(region, tile.drawx(), tile.drawy(), target.rotate ? tile.rotation() * 90 : 0);
|
||||||
|
Draw.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean construct(Unitc builder, @Nullable Tilec core, float amount, boolean configured){
|
public boolean construct(Unitc builder, @Nullable Tilec core, float amount, boolean configured){
|
||||||
if(cblock == null){
|
if(cblock == null){
|
||||||
kill();
|
kill();
|
||||||
@@ -265,8 +252,8 @@ public class BuildBlock extends Block{
|
|||||||
|
|
||||||
if(clampedAmount > 0 && accumulated > 0){ //if it's positive, add it to the core
|
if(clampedAmount > 0 && accumulated > 0){ //if it's positive, add it to the core
|
||||||
if(core != null){
|
if(core != null){
|
||||||
int accepting = core.tile().block().acceptStack(core.tile(), requirements[i].item, accumulated, builder);
|
int accepting = core.acceptStack(requirements[i].item, accumulated, builder);
|
||||||
core.tile().block().handleStack(core.tile(), requirements[i].item, accepting, builder);
|
core.handleStack(requirements[i].item, accepting, builder);
|
||||||
accumulator[i] -= accepting;
|
accumulator[i] -= accepting;
|
||||||
}else{
|
}else{
|
||||||
accumulator[i] -= accumulated;
|
accumulator[i] -= accumulated;
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package mindustry.world.blocks;
|
|
||||||
|
|
||||||
import arc.Core;
|
|
||||||
import arc.graphics.g2d.Draw;
|
|
||||||
import arc.graphics.g2d.TextureRegion;
|
|
||||||
import mindustry.world.Block;
|
|
||||||
import mindustry.world.Tile;
|
|
||||||
import mindustry.world.meta.BlockGroup;
|
|
||||||
import mindustry.world.modules.LiquidModule;
|
|
||||||
|
|
||||||
public class LiquidBlock extends Block{
|
|
||||||
protected TextureRegion liquidRegion, bottomRegion, topRegion;
|
|
||||||
|
|
||||||
public LiquidBlock(String name){
|
|
||||||
super(name);
|
|
||||||
update = true;
|
|
||||||
solid = true;
|
|
||||||
hasLiquids = true;
|
|
||||||
group = BlockGroup.liquids;
|
|
||||||
outputsLiquid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(){
|
|
||||||
super.load();
|
|
||||||
|
|
||||||
liquidRegion = Core.atlas.find(name + "-liquid");
|
|
||||||
topRegion = Core.atlas.find(name + "-top");
|
|
||||||
bottomRegion = Core.atlas.find(name + "-bottom");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureRegion[] generateIcons(){
|
|
||||||
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Tile tile){
|
|
||||||
LiquidModule mod = tile.entity.liquids();
|
|
||||||
|
|
||||||
int rotation = rotate ? tile.rotation() * 90 : 0;
|
|
||||||
|
|
||||||
Draw.rect(bottomRegion, tile.drawx(), tile.drawy(), rotation);
|
|
||||||
|
|
||||||
if(mod.total() > 0.001f){
|
|
||||||
Draw.color(mod.current().color);
|
|
||||||
Draw.alpha(mod.total() / liquidCapacity);
|
|
||||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy(), rotation);
|
|
||||||
Draw.color();
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw.rect(topRegion, tile.drawx(), tile.drawy(), rotation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ public class DeflectorWall extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
DeflectorEntity entity = tile.ent();
|
DeflectorEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class Door extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
DoorEntity entity = tile.ent();
|
DoorEntity entity = tile.ent();
|
||||||
Draw.rect(entity.open ? openRegion : region, tile.drawx(), tile.drawy());
|
Draw.rect(entity.open ? openRegion : region, tile.drawx(), tile.drawy());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class ForceProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
ForceEntity entity = tile.ent();
|
ForceEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.shield == null){
|
if(entity.shield == null){
|
||||||
@@ -149,7 +149,7 @@ public class ForceProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
ForceEntity entity = tile.ent();
|
ForceEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class MendProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
MendEntity entity = tile.ent();
|
MendEntity entity = tile.ent();
|
||||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() || tile.isEnemyCheat() ? 1f : 0f, 0.08f);
|
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() || tile.isEnemyCheat() ? 1f : 0f, 0.08f);
|
||||||
entity.charge += entity.heat * entity.delta();
|
entity.charge += entity.heat * entity.delta();
|
||||||
@@ -97,7 +97,7 @@ public class MendProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
MendEntity entity = tile.ent();
|
MendEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class OverdriveProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
OverdriveEntity entity = tile.ent();
|
OverdriveEntity entity = tile.ent();
|
||||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() ? 1f : 0f, 0.08f);
|
entity.heat = Mathf.lerpDelta(entity.heat, entity.consValid() ? 1f : 0f, 0.08f);
|
||||||
entity.charge += entity.heat * Time.delta();
|
entity.charge += entity.heat * Time.delta();
|
||||||
@@ -101,7 +101,7 @@ public class OverdriveProjector extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
OverdriveEntity entity = tile.ent();
|
OverdriveEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class ShockMine extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
//nope
|
//nope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class Wall extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
if(variants == 0){
|
if(variants == 0){
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LaserTurret extends PowerTurret{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
super.update(tile);
|
super.update(tile);
|
||||||
|
|
||||||
LaserTurretEntity entity = tile.ent();
|
LaserTurretEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public abstract class Turret extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public abstract class Turret extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
|
|
||||||
if(!validateTarget(tile)) entity.target = null;
|
if(!validateTarget(tile)) entity.target = null;
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
hasItems = true;
|
hasItems = true;
|
||||||
itemCapacity = 4;
|
itemCapacity = 4;
|
||||||
conveyorPlacement = true;
|
conveyorPlacement = true;
|
||||||
entityType = ConveyorEntity::new;
|
|
||||||
|
|
||||||
idleSound = Sounds.conveyor;
|
idleSound = Sounds.conveyor;
|
||||||
idleSoundVolume = 0.004f;
|
idleSoundVolume = 0.004f;
|
||||||
@@ -66,39 +65,6 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Tile tile){
|
|
||||||
ConveyorEntity entity = tile.ent();
|
|
||||||
byte rotation = tile.rotation();
|
|
||||||
|
|
||||||
int frame = entity.clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * entity.timeScale())) % 4) : 0;
|
|
||||||
Draw.rect(regions[Mathf.clamp(entity.blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], tile.drawx(), tile.drawy(),
|
|
||||||
tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation * 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldIdleSound(Tile tile){
|
|
||||||
ConveyorEntity entity = tile.ent();
|
|
||||||
return entity.clogHeat <= 0.5f ;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProximityUpdate(Tile tile){
|
|
||||||
super.onProximityUpdate(tile);
|
|
||||||
|
|
||||||
ConveyorEntity entity = tile.ent();
|
|
||||||
int[] bits = buildBlending(tile, tile.rotation(), null, true);
|
|
||||||
entity.blendbits = bits[0];
|
|
||||||
entity.blendsclx = bits[1];
|
|
||||||
entity.blendscly = bits[2];
|
|
||||||
|
|
||||||
if(tile.front() != null && tile.front().entity != null){
|
|
||||||
entity.next = tile.front().entity;
|
|
||||||
entity.nextc = entity.next instanceof ConveyorEntity && entity.next.team() == tile.team() ? (ConveyorEntity)entity.next : null;
|
|
||||||
entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile().rotation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||||
int[] bits = getTiling(req, list);
|
int[] bits = getTiling(req, list);
|
||||||
@@ -119,99 +85,6 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
return new TextureRegion[]{Core.atlas.find(name + "-0-0")};
|
return new TextureRegion[]{Core.atlas.find(name + "-0-0")};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawLayer(Tile tile){
|
|
||||||
ConveyorEntity e = tile.ent();
|
|
||||||
byte rotation = tile.rotation();
|
|
||||||
|
|
||||||
for(int i = 0; i < e.len; i++){
|
|
||||||
Item item = e.ids[i];
|
|
||||||
tr1.trns(rotation * 90, tilesize, 0);
|
|
||||||
tr2.trns(rotation * 90, -tilesize / 2f, e.xs[i] * tilesize / 2f);
|
|
||||||
|
|
||||||
Draw.rect(item.icon(Cicon.medium),
|
|
||||||
(tile.x * tilesize + tr1.x * e.ys[i] + tr2.x),
|
|
||||||
(tile.y * tilesize + tr1.y * e.ys[i] + tr2.y), itemSize, itemSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unitOn(Tile tile, Unitc unit){
|
|
||||||
ConveyorEntity entity = tile.ent();
|
|
||||||
|
|
||||||
if(entity.clogHeat > 0.5f){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.noSleep();
|
|
||||||
|
|
||||||
float speed = this.speed * tilesize / 2.4f;
|
|
||||||
float centerSpeed = 0.1f;
|
|
||||||
float centerDstScl = 3f;
|
|
||||||
float tx = Geometry.d4[tile.rotation()].x, ty = Geometry.d4[tile.rotation()].y;
|
|
||||||
|
|
||||||
float centerx = 0f, centery = 0f;
|
|
||||||
|
|
||||||
if(Math.abs(tx) > Math.abs(ty)){
|
|
||||||
centery = Mathf.clamp((tile.worldy() - unit.y()) / centerDstScl, -centerSpeed, centerSpeed);
|
|
||||||
if(Math.abs(tile.worldy() - unit.y()) < 1f) centery = 0f;
|
|
||||||
}else{
|
|
||||||
centerx = Mathf.clamp((tile.worldx() - unit.x()) / centerDstScl, -centerSpeed, centerSpeed);
|
|
||||||
if(Math.abs(tile.worldx() - unit.x()) < 1f) centerx = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity.len * itemSpace < 0.9f){
|
|
||||||
unit.impulse((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Tile tile){
|
|
||||||
ConveyorEntity e = tile.ent();
|
|
||||||
e.minitem = 1f;
|
|
||||||
e.mid = 0;
|
|
||||||
|
|
||||||
//skip updates if possible
|
|
||||||
if(e.len == 0){
|
|
||||||
e.clogHeat = 0f;
|
|
||||||
e.sleep();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float nextMax = e.aligned ? 1f - Math.max(itemSpace - e.nextc.minitem, 0) : 1f;
|
|
||||||
|
|
||||||
for(int i = e.len - 1; i >= 0; i--){
|
|
||||||
float nextpos = (i == e.len - 1 ? 100f : e.ys[i + 1]) - itemSpace;
|
|
||||||
float maxmove = Mathf.clamp(nextpos - e.ys[i], 0, speed * e.delta());
|
|
||||||
|
|
||||||
e.ys[i] += maxmove;
|
|
||||||
|
|
||||||
if(e.ys[i] > nextMax) e.ys[i] = nextMax;
|
|
||||||
if(e.ys[i] > 0.5 && i > 0) e.mid = i - 1;
|
|
||||||
e.xs[i] = Mathf.approachDelta(e.xs[i], 0, speed*2);
|
|
||||||
|
|
||||||
if(e.ys[i] >= 1f && offloadDir(tile, e.ids[i])){
|
|
||||||
//align X position if passing forwards
|
|
||||||
if(e.aligned){
|
|
||||||
e.nextc.xs[e.nextc.lastInserted] = e.xs[i];
|
|
||||||
}
|
|
||||||
//remove last item
|
|
||||||
e.items().remove(e.ids[i], e.len - i);
|
|
||||||
e.len = Math.min(i, e.len);
|
|
||||||
}else if(e.ys[i] < e.minitem){
|
|
||||||
e.minitem = e.ys[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(e.minitem < itemSpace + (e.blendbits == 1 ? 0.3f : 0f)){
|
|
||||||
e.clogHeat = Mathf.lerpDelta(e.clogHeat, 1f, 0.02f);
|
|
||||||
}else{
|
|
||||||
e.clogHeat = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.noSleep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAccessible(){
|
public boolean isAccessible(){
|
||||||
return true;
|
return true;
|
||||||
@@ -227,88 +100,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.junction : this;
|
Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.junction : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public class ConveyorEntity extends TileEntity{
|
||||||
public int removeStack(Tile tile, Item item, int amount){
|
|
||||||
ConveyorEntity e = tile.ent();
|
|
||||||
e.noSleep();
|
|
||||||
int removed = 0;
|
|
||||||
|
|
||||||
for(int j = 0; j < amount; j++){
|
|
||||||
for(int i = 0; i < e.len; i++){
|
|
||||||
if(e.ids[i] == item){
|
|
||||||
e.remove(i);
|
|
||||||
removed ++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
e.items().remove(item, removed);
|
|
||||||
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getStackOffset(Tile tile, Item item, Vec2 trns){
|
|
||||||
trns.trns(tile.rotation() * 90 + 180f, tilesize / 2f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int acceptStack(Tile tile, Item item, int amount, Teamc source){
|
|
||||||
ConveyorEntity entity = tile.ent();
|
|
||||||
return Math.min((int)(entity.minitem / itemSpace), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleStack(Tile tile, Item item, int amount, Teamc source){
|
|
||||||
ConveyorEntity e = tile.ent();
|
|
||||||
amount = Math.min(amount, itemCapacity - e.len);
|
|
||||||
|
|
||||||
for(int i = amount - 1; i >= 0; i--){
|
|
||||||
e.add(0);
|
|
||||||
e.xs[0] = 0;
|
|
||||||
e.ys[0] = i * itemSpace;
|
|
||||||
e.ids[0] = item;
|
|
||||||
e.items().add(item, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
e.noSleep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptItem(Tile tile, Tile source, Item item){
|
|
||||||
ConveyorEntity e = tile.ent();
|
|
||||||
if(e.len >= capacity) return false;
|
|
||||||
int direction = source == null ? 0 : Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation());
|
|
||||||
return (((direction == 0) && e.minitem >= itemSpace) || ((direction % 2 == 1) && e.minitem > 0.7f)) && (source == null || !(source.block().rotate && (source.rotation() + 2) % 4 == tile.rotation()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleItem(Tile tile, Tile source, Item item){
|
|
||||||
ConveyorEntity e = tile.ent();
|
|
||||||
if(e.len >= capacity) return;
|
|
||||||
|
|
||||||
byte r = tile.rotation();
|
|
||||||
int ang = ((source.relativeTo(tile.x, tile.y) - r));
|
|
||||||
float x = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
|
||||||
|
|
||||||
e.noSleep();
|
|
||||||
e.items().add(item, 1);
|
|
||||||
|
|
||||||
if(Math.abs(source.relativeTo(tile.x, tile.y) - r) == 0){ //idx = 0
|
|
||||||
e.add(0);
|
|
||||||
e.xs[0] = x;
|
|
||||||
e.ys[0] = 0;
|
|
||||||
e.ids[0] = item;
|
|
||||||
}else{ //idx = mid
|
|
||||||
e.add(e.mid);
|
|
||||||
e.xs[e.mid] = x;
|
|
||||||
e.ys[e.mid] = 0.5f;
|
|
||||||
e.ids[e.mid] = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ConveyorEntity extends TileEntity{
|
|
||||||
//parallel array data
|
//parallel array data
|
||||||
Item[] ids = new Item[capacity];
|
Item[] ids = new Item[capacity];
|
||||||
float[] xs = new float[capacity];
|
float[] xs = new float[capacity];
|
||||||
@@ -329,24 +121,199 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
|
|
||||||
float clogHeat = 0f;
|
float clogHeat = 0f;
|
||||||
|
|
||||||
final void add(int o){
|
@Override
|
||||||
for(int i = Math.max(o + 1, len); i > o; i--){
|
public void draw(){
|
||||||
ids[i] = ids[i - 1];
|
byte rotation = tile.rotation();
|
||||||
xs[i] = xs[i - 1];
|
int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0;
|
||||||
ys[i] = ys[i - 1];
|
Draw.rect(regions[Mathf.clamp(blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], tile.drawx(), tile.drawy(),
|
||||||
}
|
tilesize * blendsclx, tilesize * blendscly, rotation * 90);
|
||||||
|
|
||||||
len++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final void remove(int o){
|
@Override
|
||||||
for(int i = o; i < len - 1; i++){
|
public boolean shouldIdleSound(){
|
||||||
ids[i] = ids[i + 1];
|
return clogHeat <= 0.5f ;
|
||||||
xs[i] = xs[i + 1];
|
}
|
||||||
ys[i] = ys[i + 1];
|
|
||||||
|
@Override
|
||||||
|
public void onProximityUpdate(){
|
||||||
|
super.onProximityUpdate();
|
||||||
|
|
||||||
|
int[] bits = buildBlending(tile, rotation(), null, true);
|
||||||
|
blendbits = bits[0];
|
||||||
|
blendsclx = bits[1];
|
||||||
|
blendscly = bits[2];
|
||||||
|
|
||||||
|
if(tile.front() != null && tile.front() != null){
|
||||||
|
next = tile.front();
|
||||||
|
nextc = next instanceof ConveyorEntity && next.team() == tile.team() ? (ConveyorEntity)next : null;
|
||||||
|
aligned = nextc != null && tile.rotation() == next.tile().rotation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawLayer(){
|
||||||
|
byte rotation = tile.rotation();
|
||||||
|
|
||||||
|
for(int i = 0; i < len; i++){
|
||||||
|
Item item = ids[i];
|
||||||
|
tr1.trns(rotation * 90, tilesize, 0);
|
||||||
|
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
|
||||||
|
|
||||||
|
Draw.rect(item.icon(Cicon.medium),
|
||||||
|
(tile.x * tilesize + tr1.x * ys[i] + tr2.x),
|
||||||
|
(tile.y * tilesize + tr1.y * ys[i] + tr2.y), itemSize, itemSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unitOn(Unitc unit){
|
||||||
|
if(clogHeat > 0.5f){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
len--;
|
noSleep();
|
||||||
|
|
||||||
|
float mspeed = speed * tilesize / 2.4f;
|
||||||
|
float centerSpeed = 0.1f;
|
||||||
|
float centerDstScl = 3f;
|
||||||
|
float tx = Geometry.d4[tile.rotation()].x, ty = Geometry.d4[tile.rotation()].y;
|
||||||
|
|
||||||
|
float centerx = 0f, centery = 0f;
|
||||||
|
|
||||||
|
if(Math.abs(tx) > Math.abs(ty)){
|
||||||
|
centery = Mathf.clamp((tile.worldy() - unit.y()) / centerDstScl, -centerSpeed, centerSpeed);
|
||||||
|
if(Math.abs(tile.worldy() - unit.y()) < 1f) centery = 0f;
|
||||||
|
}else{
|
||||||
|
centerx = Mathf.clamp((tile.worldx() - unit.x()) / centerDstScl, -centerSpeed, centerSpeed);
|
||||||
|
if(Math.abs(tile.worldx() - unit.x()) < 1f) centerx = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(len * itemSpace < 0.9f){
|
||||||
|
unit.impulse((tx * mspeed + centerx) * delta(), (ty * mspeed + centery) * delta());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
minitem = 1f;
|
||||||
|
mid = 0;
|
||||||
|
|
||||||
|
//skip updates if possible
|
||||||
|
if(len == 0){
|
||||||
|
clogHeat = 0f;
|
||||||
|
sleep();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float nextMax = aligned ? 1f - Math.max(itemSpace - nextc.minitem, 0) : 1f;
|
||||||
|
|
||||||
|
for(int i = len - 1; i >= 0; i--){
|
||||||
|
float nextpos = (i == len - 1 ? 100f : ys[i + 1]) - itemSpace;
|
||||||
|
float maxmove = Mathf.clamp(nextpos - ys[i], 0, speed * delta());
|
||||||
|
|
||||||
|
ys[i] += maxmove;
|
||||||
|
|
||||||
|
if(ys[i] > nextMax) ys[i] = nextMax;
|
||||||
|
if(ys[i] > 0.5 && i > 0) mid = i - 1;
|
||||||
|
xs[i] = Mathf.approachDelta(xs[i], 0, speed*2);
|
||||||
|
|
||||||
|
if(ys[i] >= 1f && moveForward(ids[i])){
|
||||||
|
//align X position if passing forwards
|
||||||
|
if(aligned){
|
||||||
|
nextc.xs[nextc.lastInserted] = xs[i];
|
||||||
|
}
|
||||||
|
//remove last item
|
||||||
|
items.remove(ids[i], len - i);
|
||||||
|
len = Math.min(i, len);
|
||||||
|
}else if(ys[i] < minitem){
|
||||||
|
minitem = ys[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(minitem < itemSpace + (blendbits == 1 ? 0.3f : 0f)){
|
||||||
|
clogHeat = Mathf.lerpDelta(clogHeat, 1f, 0.02f);
|
||||||
|
}else{
|
||||||
|
clogHeat = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
noSleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int removeStack(Item item, int amount){
|
||||||
|
noSleep();
|
||||||
|
int removed = 0;
|
||||||
|
|
||||||
|
for(int j = 0; j < amount; j++){
|
||||||
|
for(int i = 0; i < len; i++){
|
||||||
|
if(ids[i] == item){
|
||||||
|
remove(i);
|
||||||
|
removed ++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.remove(item, removed);
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getStackOffset(Item item, Vec2 trns){
|
||||||
|
trns.trns(tile.rotation() * 90 + 180f, tilesize / 2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int acceptStack(Item item, int amount, Teamc source){
|
||||||
|
return Math.min((int)(minitem / itemSpace), amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleStack(Item item, int amount, Teamc source){
|
||||||
|
amount = Math.min(amount, itemCapacity - len);
|
||||||
|
|
||||||
|
for(int i = amount - 1; i >= 0; i--){
|
||||||
|
add(0);
|
||||||
|
xs[0] = 0;
|
||||||
|
ys[0] = i * itemSpace;
|
||||||
|
ids[0] = item;
|
||||||
|
items.add(item, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
noSleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptItem(Tilec source, Item item){
|
||||||
|
if(len >= capacity) return false;
|
||||||
|
Tile facing = Edges.getFacingEdge(source.tile(), tile);
|
||||||
|
int direction = Math.abs(facing.relativeTo(tile.x, tile.y) - tile.rotation());
|
||||||
|
return (((direction == 0) && minitem >= itemSpace) || ((direction % 2 == 1) && minitem > 0.7f)) && !(source.block().rotate && (source.rotation() + 2) % 4 == tile.rotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleItem(Tilec source, Item item){
|
||||||
|
if(len >= capacity) return;
|
||||||
|
|
||||||
|
byte r = tile.rotation();
|
||||||
|
Tile facing = Edges.getFacingEdge(source.tile(), tile);
|
||||||
|
int ang = ((facing.relativeTo(tile.x, tile.y) - r));
|
||||||
|
float x = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
||||||
|
|
||||||
|
noSleep();
|
||||||
|
items.add(item, 1);
|
||||||
|
|
||||||
|
if(Math.abs(facing.relativeTo(tile.x, tile.y) - r) == 0){ //idx = 0
|
||||||
|
add(0);
|
||||||
|
xs[0] = x;
|
||||||
|
ys[0] = 0;
|
||||||
|
ids[0] = item;
|
||||||
|
}else{ //idx = mid
|
||||||
|
add(mid);
|
||||||
|
xs[mid] = x;
|
||||||
|
ys[mid] = 0.5f;
|
||||||
|
ids[mid] = item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -377,5 +344,26 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final void add(int o){
|
||||||
|
for(int i = Math.max(o + 1, len); i > o; i--){
|
||||||
|
ids[i] = ids[i - 1];
|
||||||
|
xs[i] = xs[i - 1];
|
||||||
|
ys[i] = ys[i - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
final void remove(int o){
|
||||||
|
for(int i = o; i < len - 1; i++){
|
||||||
|
ids[i] = ids[i + 1];
|
||||||
|
xs[i] = xs[i + 1];
|
||||||
|
ys[i] = ys[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
len--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public class ItemBridge extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
ItemBridgeEntity entity = tile.ent();
|
ItemBridgeEntity entity = tile.ent();
|
||||||
|
|
||||||
entity.time += entity.cycleSpeed * entity.delta();
|
entity.time += entity.cycleSpeed * entity.delta();
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class Junction extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
JunctionEntity entity = tile.ent();
|
JunctionEntity entity = tile.ent();
|
||||||
DirectionalItemBuffer buffer = entity.buffer;
|
DirectionalItemBuffer buffer = entity.buffer;
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
MassDriverEntity entity = tile.ent();
|
MassDriverEntity entity = tile.ent();
|
||||||
Tile link = world.tile(entity.link);
|
Tile link = world.tile(entity.link);
|
||||||
boolean hasLink = linkValid(tile);
|
boolean hasLink = linkValid(tile);
|
||||||
@@ -143,7 +143,7 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class OverflowGate extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
OverflowGateEntity entity = tile.ent();
|
OverflowGateEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.lastItem == null && entity.items().total() > 0){
|
if(entity.lastItem == null && entity.items().total() > 0){
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Router extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
RouterEntity entity = tile.ent();
|
RouterEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.lastItem == null && entity.items().total() > 0){
|
if(entity.lastItem == null && entity.items().total() > 0){
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class Sorter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
SorterEntity entity = tile.ent();
|
SorterEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -17,7 +17,7 @@ public class Cliff extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void drawBase(Tile tile){
|
||||||
int r = tile.rotation();
|
int r = tile.rotation();
|
||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
if((r & (1 << i)) != 0){
|
if((r & (1 << i)) != 0){
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.Draw;
|
||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
import mindustry.world.Tile;
|
|
||||||
|
|
||||||
public class DoubleOverlayFloor extends OverlayFloor{
|
public class DoubleOverlayFloor extends OverlayFloor{
|
||||||
|
|
||||||
@@ -11,7 +10,7 @@ public class DoubleOverlayFloor extends OverlayFloor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.colorl(0.4f);
|
Draw.colorl(0.4f);
|
||||||
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy() - 0.75f);
|
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy() - 0.75f);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
@@ -15,6 +15,7 @@ import mindustry.graphics.MultiPacker.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ public class Floor extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void drawBase(Tile tile){
|
||||||
Mathf.random.setSeed(tile.pos());
|
Mathf.random.setSeed(tile.pos());
|
||||||
|
|
||||||
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
||||||
@@ -161,7 +162,7 @@ public class Floor extends Block{
|
|||||||
|
|
||||||
Floor floor = tile.overlay();
|
Floor floor = tile.overlay();
|
||||||
if(floor != Blocks.air && floor != this){ //ore should never have itself on top, but it's possible, so prevent a crash in that case
|
if(floor != Blocks.air && floor != this){ //ore should never have itself on top, but it's possible, so prevent a crash in that case
|
||||||
floor.draw(tile);
|
floor.drawBase(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.Draw;
|
||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
@@ -12,7 +12,7 @@ public class OverlayFloor extends Floor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void drawBase(Tile tile){
|
||||||
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.Core;
|
import arc.Core;
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.Draw;
|
||||||
@@ -17,7 +17,7 @@ public class Rock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
if(variants > 0){
|
if(variants > 0){
|
||||||
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.worldx(), tile.worldy());
|
||||||
}else{
|
}else{
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package mindustry.world;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.*;
|
||||||
import arc.graphics.g2d.TextureRegion;
|
import arc.util.*;
|
||||||
import arc.util.Tmp;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.StaticWall;
|
|
||||||
|
|
||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ public class StaticTree extends StaticWall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void drawBase(Tile tile){
|
||||||
TextureRegion r = Tmp.tr1;
|
TextureRegion r = Tmp.tr1;
|
||||||
r.set(region);
|
r.set(region);
|
||||||
int crop = (region.getWidth() - tilesize*4) / 2;
|
int crop = (region.getWidth() - tilesize*4) / 2;
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.Core;
|
import arc.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import mindustry.graphics.CacheLayer;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.world;
|
||||||
|
|
||||||
public class StaticWall extends Rock{
|
public class StaticWall extends Rock{
|
||||||
TextureRegion large;
|
TextureRegion large;
|
||||||
@@ -22,7 +22,7 @@ public class StaticWall extends Rock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void drawBase(Tile tile){
|
||||||
int rx = tile.x / 2 * 2;
|
int rx = tile.x / 2 * 2;
|
||||||
int ry = tile.y / 2 * 2;
|
int ry = tile.y / 2 * 2;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.Draw;
|
||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
@@ -16,7 +16,7 @@ public class TreeBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){}
|
public void drawBase(Tile tile){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawLayer(Tile tile){
|
public void drawLayer(Tile tile){
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
package mindustry.world.blocks.liquid;
|
package mindustry.world.blocks.liquid;
|
||||||
|
|
||||||
import arc.Core;
|
import arc.*;
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.*;
|
||||||
import arc.graphics.g2d.TextureRegion;
|
import mindustry.entities.AllDefs.*;
|
||||||
import mindustry.type.Liquid;
|
import mindustry.type.*;
|
||||||
import mindustry.world.Block;
|
import mindustry.world.*;
|
||||||
import mindustry.world.Edges;
|
|
||||||
import mindustry.world.Tile;
|
|
||||||
|
|
||||||
public class ArmoredConduit extends Conduit{
|
public class ArmoredConduit extends Conduit{
|
||||||
public TextureRegion capRegion;
|
public TextureRegion capRegion;
|
||||||
@@ -23,7 +21,7 @@ public class ArmoredConduit extends Conduit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
// draw the cap when a conduit would normally leak
|
// draw the cap when a conduit would normally leak
|
||||||
|
|||||||
@@ -42,15 +42,6 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProximityUpdate(Tile tile){
|
|
||||||
super.onProximityUpdate(tile);
|
|
||||||
|
|
||||||
ConduitEntity entity = tile.ent();
|
|
||||||
int[] bits = buildBlending(tile, tile.rotation(), null, true);
|
|
||||||
entity.blendbits = bits[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list){
|
||||||
int[] bits = getTiling(req, list);
|
int[] bits = getTiling(req, list);
|
||||||
@@ -88,50 +79,54 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
return otherblock.hasLiquids && otherblock.outputsLiquid && lookingAt(tile, rotation, otherx, othery, otherrot, otherblock);
|
return otherblock.hasLiquids && otherblock.outputsLiquid && lookingAt(tile, rotation, otherx, othery, otherrot, otherblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Tile tile){
|
|
||||||
ConduitEntity entity = tile.ent();
|
|
||||||
int rotation = tile.rotation() * 90;
|
|
||||||
|
|
||||||
Draw.colorl(0.34f);
|
|
||||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
|
||||||
|
|
||||||
Draw.color(tile.entity.liquids().current().color);
|
|
||||||
Draw.alpha(entity.smoothLiquid);
|
|
||||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
|
||||||
Draw.color();
|
|
||||||
|
|
||||||
Draw.rect(topRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Tile tile){
|
|
||||||
ConduitEntity entity = tile.ent();
|
|
||||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids().currentAmount() / liquidCapacity, 0.05f);
|
|
||||||
|
|
||||||
if(tile.entity.liquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){
|
|
||||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids().current());
|
|
||||||
entity.noSleep();
|
|
||||||
}else{
|
|
||||||
entity.sleep();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextureRegion[] generateIcons(){
|
public TextureRegion[] generateIcons(){
|
||||||
return new TextureRegion[]{Core.atlas.find("conduit-bottom"), Core.atlas.find(name + "-top-0")};
|
return new TextureRegion[]{Core.atlas.find("conduit-bottom"), Core.atlas.find(name + "-top-0")};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public class ConduitEntity extends LiquidBlockEntity{
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
|
||||||
tile.entity.noSleep();
|
|
||||||
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f)
|
|
||||||
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ConduitEntity extends TileEntity{
|
|
||||||
public float smoothLiquid;
|
public float smoothLiquid;
|
||||||
|
|
||||||
int blendbits;
|
int blendbits;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
int rotation = rotation() * 90;
|
||||||
|
|
||||||
|
Draw.colorl(0.34f);
|
||||||
|
Draw.rect(botRegions[blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||||
|
|
||||||
|
Draw.color(liquids.current().color);
|
||||||
|
Draw.alpha(smoothLiquid);
|
||||||
|
Draw.rect(botRegions[blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||||
|
Draw.color();
|
||||||
|
|
||||||
|
Draw.rect(topRegions[blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProximityUpdate(){
|
||||||
|
super.onProximityUpdate();
|
||||||
|
|
||||||
|
blendbits = buildBlending(tile, tile.rotation(), null, true)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||||
|
noSleep();
|
||||||
|
return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f)
|
||||||
|
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
smoothLiquid = Mathf.lerpDelta(smoothLiquid, liquids.currentAmount() / liquidCapacity, 0.05f);
|
||||||
|
|
||||||
|
if(liquids.total() > 0.001f && timer(timerFlow, 1)){
|
||||||
|
moveLiquid(tile.getNearbyEntity(tile.rotation()), leakResistance, liquids.current());
|
||||||
|
noSleep();
|
||||||
|
}else{
|
||||||
|
sleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
51
core/src/mindustry/world/blocks/liquid/LiquidBlock.java
Normal file
51
core/src/mindustry/world/blocks/liquid/LiquidBlock.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package mindustry.world.blocks.liquid;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
|
public class LiquidBlock extends Block{
|
||||||
|
protected TextureRegion liquidRegion, bottomRegion, topRegion;
|
||||||
|
|
||||||
|
public LiquidBlock(String name){
|
||||||
|
super(name);
|
||||||
|
update = true;
|
||||||
|
solid = true;
|
||||||
|
hasLiquids = true;
|
||||||
|
group = BlockGroup.liquids;
|
||||||
|
outputsLiquid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(){
|
||||||
|
super.load();
|
||||||
|
|
||||||
|
liquidRegion = Core.atlas.find(name + "-liquid");
|
||||||
|
topRegion = Core.atlas.find(name + "-top");
|
||||||
|
bottomRegion = Core.atlas.find(name + "-bottom");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureRegion[] generateIcons(){
|
||||||
|
return new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LiquidBlockEntity extends TileEntity{
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
int rotation = rotate ? rotation() * 90 : 0;
|
||||||
|
Draw.rect(bottomRegion, x, y, rotation);
|
||||||
|
|
||||||
|
if(liquids.total() > 0.001f){
|
||||||
|
Draw.color(liquids.current().color);
|
||||||
|
Draw.alpha(liquids.total() / liquidCapacity);
|
||||||
|
Draw.rect(liquidRegion, x, y, rotation);
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.rect(topRegion, x, y, rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package mindustry.world.blocks.liquid;
|
|||||||
|
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.entities.AllDefs.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.distribution.*;
|
import mindustry.world.blocks.distribution.*;
|
||||||
@@ -20,7 +21,7 @@ public class LiquidBridge extends ItemBridge{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
ItemBridgeEntity entity = tile.ent();
|
ItemBridgeEntity entity = tile.ent();
|
||||||
|
|
||||||
entity.time += entity.cycleSpeed * Time.delta();
|
entity.time += entity.cycleSpeed * Time.delta();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mindustry.world.blocks.liquid;
|
|||||||
|
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.entities.AllDefs.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.distribution.*;
|
import mindustry.world.blocks.distribution.*;
|
||||||
@@ -20,7 +21,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
ItemBridgeEntity entity = tile.ent();
|
ItemBridgeEntity entity = tile.ent();
|
||||||
|
|
||||||
entity.time += entity.cycleSpeed * Time.delta();
|
entity.time += entity.cycleSpeed * Time.delta();
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package mindustry.world.blocks.liquid;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
|
import mindustry.entities.AllDefs.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
public class LiquidJunction extends LiquidBlock{
|
public class LiquidJunction extends LiquidBlock{
|
||||||
@@ -26,7 +26,7 @@ public class LiquidJunction extends LiquidBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.rect(name, tile.worldx(), tile.worldy());
|
Draw.rect(name, tile.worldx(), tile.worldy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
package mindustry.world.blocks.liquid;
|
|
||||||
|
|
||||||
import arc.*;
|
|
||||||
import arc.graphics.g2d.*;
|
|
||||||
import mindustry.type.*;
|
|
||||||
import mindustry.world.*;
|
|
||||||
import mindustry.world.blocks.*;
|
|
||||||
import mindustry.world.meta.*;
|
|
||||||
|
|
||||||
//TODO implement later
|
|
||||||
public class LiquidOverflowGate extends LiquidBlock{
|
|
||||||
public int topRegion;
|
|
||||||
|
|
||||||
public LiquidOverflowGate(String name){
|
|
||||||
super(name);
|
|
||||||
rotate = true;
|
|
||||||
topRegion = reg("-top");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStats(){
|
|
||||||
super.setStats();
|
|
||||||
stats.remove(BlockStat.liquidCapacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBars(){
|
|
||||||
super.setBars();
|
|
||||||
bars.remove("liquid");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Tile tile){
|
|
||||||
Draw.rect(name, tile.drawx(), tile.drawy());
|
|
||||||
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy(), tile.rotation() * 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextureRegion[] generateIcons(){
|
|
||||||
return new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Tile getLiquidDestination(Tile tile, Tile source, Liquid liquid){
|
|
||||||
int dir = source.relativeTo(tile.x, tile.y);
|
|
||||||
dir = (dir + 4) % 4;
|
|
||||||
Tile next = tile.getNearby(dir).link();
|
|
||||||
if(!next.block().acceptLiquid(next, tile, liquid, 0.0001f) && !(next.block() instanceof LiquidOverflowGate || next.block() instanceof LiquidJunction)){
|
|
||||||
return tile;
|
|
||||||
}
|
|
||||||
return next.block().getLiquidDestination(next, tile, liquid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package mindustry.world.blocks.liquid;
|
package mindustry.world.blocks.liquid;
|
||||||
|
|
||||||
import mindustry.type.Liquid;
|
import mindustry.gen.*;
|
||||||
import mindustry.world.Tile;
|
import mindustry.type.*;
|
||||||
import mindustry.world.blocks.LiquidBlock;
|
|
||||||
|
|
||||||
public class LiquidRouter extends LiquidBlock{
|
public class LiquidRouter extends LiquidBlock{
|
||||||
|
|
||||||
@@ -10,16 +9,18 @@ public class LiquidRouter extends LiquidBlock{
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public class LiquidRouterEntity extends LiquidBlockEntity{
|
||||||
public void update(Tile tile){
|
|
||||||
|
|
||||||
if(tile.entity.liquids().total() > 0.01f){
|
@Override
|
||||||
tryDumpLiquid(tile, tile.entity.liquids().current());
|
public void updateTile(){
|
||||||
|
if(liquids.total() > 0.01f){
|
||||||
|
dumpLiquid(liquids.current());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
|
||||||
|
return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
|
||||||
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package mindustry.world.blocks.liquid;
|
|
||||||
|
|
||||||
public class LiquidTank extends LiquidRouter{
|
|
||||||
|
|
||||||
public LiquidTank(String name){
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@ public class Battery extends PowerDistributor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.color(emptyLightColor, fullLightColor, tile.entity.power().status);
|
Draw.color(emptyLightColor, fullLightColor, tile.entity.power().status);
|
||||||
Fill.square(tile.drawx(), tile.drawy(), tilesize * size / 2f - 1);
|
Fill.square(tile.drawx(), tile.drawy(), tilesize * size / 2f - 1);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class ImpactReactor extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
FusionReactorEntity entity = tile.ent();
|
FusionReactorEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.consValid() && entity.power().status >= 0.99f){
|
if(entity.consValid() && entity.power().status >= 0.99f){
|
||||||
@@ -95,7 +95,7 @@ public class ImpactReactor extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
FusionReactorEntity entity = tile.ent();
|
FusionReactorEntity entity = tile.ent();
|
||||||
|
|
||||||
Draw.rect(reg(bottomRegion), tile.drawx(), tile.drawy());
|
Draw.rect(reg(bottomRegion), tile.drawx(), tile.drawy());
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
ItemLiquidGeneratorEntity entity = tile.ent();
|
ItemLiquidGeneratorEntity entity = tile.ent();
|
||||||
|
|
||||||
//Note: Do not use this delta when calculating the amount of power or the power efficiency, but use it for resource consumption if necessary.
|
//Note: Do not use this delta when calculating the amount of power or the power efficiency, but use it for resource consumption if necessary.
|
||||||
@@ -152,7 +152,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
ItemLiquidGeneratorEntity entity = tile.ent();
|
ItemLiquidGeneratorEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LightBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
LightEntity entity = tile.ent();
|
LightEntity entity = tile.ent();
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
NuclearReactorEntity entity = tile.ent();
|
NuclearReactorEntity entity = tile.ent();
|
||||||
|
|
||||||
ConsumeLiquid cliquid = consumes.get(ConsumeType.liquid);
|
ConsumeLiquid cliquid = consumes.get(ConsumeType.liquid);
|
||||||
@@ -159,7 +159,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
NuclearReactorEntity entity = tile.ent();
|
NuclearReactorEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.power;
|
||||||
|
|
||||||
import mindustry.world.Block;
|
import mindustry.world.Block;
|
||||||
import mindustry.world.meta.BlockGroup;
|
import mindustry.world.meta.BlockGroup;
|
||||||
@@ -24,7 +24,7 @@ public class PowerDiode extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
super.update(tile);
|
super.update(tile);
|
||||||
|
|
||||||
if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower || tile.back().team() != tile.front().team()) return;
|
if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower || tile.back().team() != tile.front().team()) return;
|
||||||
@@ -69,7 +69,7 @@ public class PowerDiode extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy(), 0);
|
Draw.rect(region, tile.drawx(), tile.drawy(), 0);
|
||||||
Draw.rect(arrow, tile.drawx(), tile.drawy(), rotate ? tile.rotation() * 90 : 0);
|
Draw.rect(arrow, tile.drawx(), tile.drawy(), rotate ? tile.rotation() * 90 : 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package mindustry.world.blocks.power;
|
package mindustry.world.blocks.power;
|
||||||
|
|
||||||
import mindustry.world.blocks.PowerBlock;
|
|
||||||
|
|
||||||
public class PowerDistributor extends PowerBlock{
|
public class PowerDistributor extends PowerBlock{
|
||||||
|
|
||||||
public PowerDistributor(String name){
|
public PowerDistributor(String name){
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -177,7 +176,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
tile.entity.power().graph.update();
|
tile.entity.power().graph.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class SolarGenerator extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
tile.<GeneratorEntity>ent().productionEfficiency = state.rules.solarPowerMultiplier < 0 ? (state.rules.lighting ? 1f - state.rules.ambientLight.a : 1f) : state.rules.solarPowerMultiplier;
|
tile.<GeneratorEntity>ent().productionEfficiency = state.rules.solarPowerMultiplier < 0 ? (state.rules.lighting ? 1f - state.rules.ambientLight.a : 1f) : state.rules.solarPowerMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ThermalGenerator extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
GeneratorEntity entity = tile.ent();
|
GeneratorEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.productionEfficiency > 0.1f && Mathf.chance(0.05 * entity.delta())){
|
if(entity.productionEfficiency > 0.1f && Mathf.chance(0.05 * entity.delta())){
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class Cultivator extends GenericCrafter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
super.update(tile);
|
super.update(tile);
|
||||||
|
|
||||||
CultivatorEntity entity = tile.ent();
|
CultivatorEntity entity = tile.ent();
|
||||||
@@ -70,7 +70,7 @@ public class Cultivator extends GenericCrafter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
CultivatorEntity entity = tile.ent();
|
CultivatorEntity entity = tile.ent();
|
||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class Drill extends Block{
|
|||||||
public void drawCracks(Tile tile){}
|
public void drawCracks(Tile tile){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
float s = 0.3f;
|
float s = 0.3f;
|
||||||
float ts = 0.6f;
|
float ts = 0.6f;
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ public class Drill extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
DrillEntity entity = tile.ent();
|
DrillEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.dominantItem == null){
|
if(entity.dominantItem == null){
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class Fracker extends SolidPump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
FrackerEntity entity = tile.ent();
|
FrackerEntity entity = tile.ent();
|
||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||||
@@ -69,7 +69,7 @@ public class Fracker extends SolidPump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
FrackerEntity entity = tile.ent();
|
FrackerEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.consValid()){
|
if(entity.consValid()){
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import arc.math.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
|
import mindustry.entities.AllDefs.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -13,8 +14,6 @@ import mindustry.world.*;
|
|||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class GenericCrafter extends Block{
|
public class GenericCrafter extends Block{
|
||||||
public ItemStack outputItem;
|
public ItemStack outputItem;
|
||||||
public LiquidStack outputLiquid;
|
public LiquidStack outputLiquid;
|
||||||
@@ -24,7 +23,7 @@ public class GenericCrafter extends Block{
|
|||||||
public Effect updateEffect = Fx.none;
|
public Effect updateEffect = Fx.none;
|
||||||
public float updateEffectChance = 0.04f;
|
public float updateEffectChance = 0.04f;
|
||||||
|
|
||||||
public Cons<Tile> drawer = null;
|
public Cons<GenericCrafterEntity> drawer = null;
|
||||||
public Prov<TextureRegion[]> drawIcons = null;
|
public Prov<TextureRegion[]> drawIcons = null;
|
||||||
|
|
||||||
public GenericCrafter(String name){
|
public GenericCrafter(String name){
|
||||||
@@ -70,7 +69,7 @@ public class GenericCrafter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
if(drawer == null){
|
if(drawer == null){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
}else{
|
}else{
|
||||||
@@ -84,7 +83,7 @@ public class GenericCrafter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
GenericCrafterEntity entity = tile.ent();
|
GenericCrafterEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.consValid()){
|
if(entity.consValid()){
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class GenericSmelter extends GenericCrafter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
GenericCrafterEntity entity = tile.ent();
|
GenericCrafterEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class Incinerator extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
IncineratorEntity entity = tile.ent();
|
IncineratorEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.consValid()){
|
if(entity.consValid()){
|
||||||
@@ -38,7 +38,7 @@ public class Incinerator extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
IncineratorEntity entity = tile.ent();
|
IncineratorEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class LiquidConverter extends GenericCrafter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
GenericCrafterEntity entity = tile.ent();
|
GenericCrafterEntity entity = tile.ent();
|
||||||
ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid);
|
ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import mindustry.graphics.Layer;
|
|||||||
import mindustry.type.Liquid;
|
import mindustry.type.Liquid;
|
||||||
import mindustry.ui.Cicon;
|
import mindustry.ui.Cicon;
|
||||||
import mindustry.world.Tile;
|
import mindustry.world.Tile;
|
||||||
import mindustry.world.blocks.LiquidBlock;
|
import mindustry.world.blocks.liquid.LiquidBlock;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
@@ -45,7 +45,7 @@ public class Pump extends LiquidBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.rect(name, tile.drawx(), tile.drawy());
|
Draw.rect(name, tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
Draw.color(tile.entity.liquids().current().color);
|
Draw.color(tile.entity.liquids().current().color);
|
||||||
@@ -102,7 +102,7 @@ public class Pump extends LiquidBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
float tiles = 0f;
|
float tiles = 0f;
|
||||||
Liquid liquidDrop = null;
|
Liquid liquidDrop = null;
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class Separator extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
GenericCrafterEntity entity = tile.ent();
|
GenericCrafterEntity entity = tile.ent();
|
||||||
@@ -74,7 +74,7 @@ public class Separator extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
GenericCrafterEntity entity = tile.ent();
|
GenericCrafterEntity entity = tile.ent();
|
||||||
|
|
||||||
entity.totalProgress += entity.warmup * entity.delta();
|
entity.totalProgress += entity.warmup * entity.delta();
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class SolidPump extends Pump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
SolidPumpEntity entity = tile.ent();
|
SolidPumpEntity entity = tile.ent();
|
||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||||
@@ -88,7 +88,7 @@ public class SolidPump extends Pump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
SolidPumpEntity entity = tile.ent();
|
SolidPumpEntity entity = tile.ent();
|
||||||
|
|
||||||
float fraction = 0f;
|
float fraction = 0f;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class ItemSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
ItemSourceEntity entity = tile.ent();
|
ItemSourceEntity entity = tile.ent();
|
||||||
@@ -66,7 +66,7 @@ public class ItemSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
ItemSourceEntity entity = tile.ent();
|
ItemSourceEntity entity = tile.ent();
|
||||||
if(entity.outputItem == null) return;
|
if(entity.outputItem == null) return;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class LiquidSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
LiquidSourceEntity entity = tile.ent();
|
LiquidSourceEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.source == null){
|
if(entity.source == null){
|
||||||
@@ -64,7 +64,7 @@ public class LiquidSource extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
LiquidSourceEntity entity = tile.ent();
|
LiquidSourceEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package mindustry.world.blocks.sandbox;
|
package mindustry.world.blocks.sandbox;
|
||||||
|
|
||||||
import mindustry.world.blocks.PowerBlock;
|
import mindustry.world.blocks.power.PowerBlock;
|
||||||
import mindustry.world.meta.BlockStat;
|
import mindustry.world.meta.BlockStat;
|
||||||
|
|
||||||
public class PowerVoid extends PowerBlock{
|
public class PowerVoid extends PowerBlock{
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
CoreEntity entity = tile.ent();
|
CoreEntity entity = tile.ent();
|
||||||
|
|
||||||
//TODO implement
|
//TODO implement
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class LaunchPad extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
//TODO broken
|
//TODO broken
|
||||||
@@ -69,7 +69,7 @@ public class LaunchPad extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
|
|
||||||
if(state.isCampaign() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale())){
|
if(state.isCampaign() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale())){
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class Unloader extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
UnloaderEntity entity = tile.ent();
|
UnloaderEntity entity = tile.ent();
|
||||||
|
|
||||||
if(tile.entity.timer(timerUnload, speed / entity.timeScale()) && tile.entity.items().total() == 0){
|
if(tile.entity.timer(timerUnload, speed / entity.timeScale()) && tile.entity.items().total() == 0){
|
||||||
@@ -110,7 +110,7 @@ public class Unloader extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
UnloaderEntity entity = tile.ent();
|
UnloaderEntity entity = tile.ent();
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class CommandCenter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
CommandCenterEntity entity = tile.ent();
|
CommandCenterEntity entity = tile.ent();
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class MechPad extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
MechFactoryEntity entity = tile.ent();
|
MechFactoryEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.player != null){
|
if(entity.player != null){
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class RepairPoint extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public class RepairPoint extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
RepairPointEntity entity = tile.ent();
|
RepairPointEntity entity = tile.ent();
|
||||||
|
|
||||||
boolean targetIsBeingRepaired = false;
|
boolean targetIsBeingRepaired = false;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks.units;
|
||||||
|
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
@@ -116,7 +116,7 @@ public class UnitFactory extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(){
|
||||||
UnitFactoryEntity entity = tile.ent();
|
UnitFactoryEntity entity = tile.ent();
|
||||||
TextureRegion region = unitType.icon(Cicon.full);
|
TextureRegion region = unitType.icon(Cicon.full);
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ public class UnitFactory extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void updateTile(){
|
||||||
UnitFactoryEntity entity = tile.ent();
|
UnitFactoryEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.spawned >= maxSpawn){
|
if(entity.spawned >= maxSpawn){
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package mindustry.world.meta.values;
|
|||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
public class FloorValue implements StatValue{
|
public class FloorValue implements StatValue{
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import mindustry.content.*;
|
|||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
|
||||||
import mindustry.world.blocks.power.*;
|
import mindustry.world.blocks.power.*;
|
||||||
import mindustry.world.modules.*;
|
import mindustry.world.modules.*;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import mindustry.tools.ImagePacker.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user