diff --git a/annotations/src/main/resources/classids.properties b/annotations/src/main/resources/classids.properties index ed82e2bef1..676138b813 100644 --- a/annotations/src/main/resources/classids.properties +++ b/annotations/src/main/resources/classids.properties @@ -4,6 +4,7 @@ dagger=0 draug=10 mindustry.entities.def.BulletComp=1 mindustry.entities.def.DecalComp=2 +mindustry.entities.def.EffectComp=15 mindustry.entities.def.FireComp=3 mindustry.entities.def.GroundEffectComp=4 mindustry.entities.def.PlayerComp=5 diff --git a/annotations/src/main/resources/revisions/EffectEntity/0.json b/annotations/src/main/resources/revisions/EffectEntity/0.json new file mode 100644 index 0000000000..4e23d76400 --- /dev/null +++ b/annotations/src/main/resources/revisions/EffectEntity/0.json @@ -0,0 +1 @@ +{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index 436d08a21b..7de7103c0c 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -208,8 +208,6 @@ public class Renderer implements ApplicationListener{ blocks.floor.drawLayer(CacheLayer.walls); blocks.floor.endDraw(); - - blocks.drawBlocks(); //draw stuff diff --git a/core/src/mindustry/entities/Effects.java b/core/src/mindustry/entities/Effects.java index 2f1eb20faf..86f3defddd 100644 --- a/core/src/mindustry/entities/Effects.java +++ b/core/src/mindustry/entities/Effects.java @@ -42,7 +42,7 @@ public class Effects{ Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y); if(view.overlaps(pos)){ - Effectc entity = effect.ground ? GroundEffectEntity.create() : StandardEffectEntity.create(); + Effectc entity = EffectEntity.create(); entity.effect(effect); entity.rotation(rotation); entity.data(data); diff --git a/core/src/mindustry/entities/def/BuilderComp.java b/core/src/mindustry/entities/def/BuilderComp.java index 361a703a21..ce3ba8af6f 100644 --- a/core/src/mindustry/entities/def/BuilderComp.java +++ b/core/src/mindustry/entities/def/BuilderComp.java @@ -23,7 +23,7 @@ import java.util.*; import static mindustry.Vars.*; @Component -abstract class BuilderComp implements Unitc, DrawLayerFlyingc{ +abstract class BuilderComp implements Unitc{ static final Vec2[] vecs = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()}; @Import float x, y, rotation; @@ -197,8 +197,12 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{ } @Override - public void drawFlying(){ + public void draw(){ if(!isBuilding()) return; + + //TODO check correctness + Draw.z(Layer.flyingUnit); + BuildRequest request = buildRequest(); Tile tile = world.tile(request.x, request.y); diff --git a/core/src/mindustry/entities/def/BulletComp.java b/core/src/mindustry/entities/def/BulletComp.java index 6a24ab61c2..db5b3b3b77 100644 --- a/core/src/mindustry/entities/def/BulletComp.java +++ b/core/src/mindustry/entities/def/BulletComp.java @@ -11,7 +11,7 @@ import static mindustry.Vars.*; @EntityDef(value = {Bulletc.class}, pooled = true) @Component -abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc, DrawLayerBulletsc{ +abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{ Object data; BulletType type; float damage; diff --git a/core/src/mindustry/entities/def/EffectComp.java b/core/src/mindustry/entities/def/EffectComp.java index b090a256f2..52ba2e7c66 100644 --- a/core/src/mindustry/entities/def/EffectComp.java +++ b/core/src/mindustry/entities/def/EffectComp.java @@ -5,13 +5,15 @@ import mindustry.annotations.Annotations.*; import mindustry.entities.*; import mindustry.gen.*; +@EntityDef(value = {Effectc.class, Childc.class}, pooled = true) @Component abstract class EffectComp implements Posc, Drawc, Timedc, Rotc, Childc{ Color color = new Color(Color.white); Effect effect; Object data; - void draw(){ + @Override + public void draw(){ effect.render(id(), color, time(), rotation(), x(), y(), data); } diff --git a/core/src/mindustry/entities/def/GroundEffectComp.java b/core/src/mindustry/entities/def/GroundEffectComp.java deleted file mode 100644 index a080ad3aac..0000000000 --- a/core/src/mindustry/entities/def/GroundEffectComp.java +++ /dev/null @@ -1,14 +0,0 @@ -package mindustry.entities.def; - -import mindustry.annotations.Annotations.*; -import mindustry.gen.*; - -@EntityDef(value = {GroundEffectc.class, Childc.class}, pooled = true) -@Component -abstract class GroundEffectComp implements Effectc, DrawLayerFloorOverc{ - - @Override - public void drawFloorOver(){ - draw(); - } -} diff --git a/core/src/mindustry/entities/def/PuddleComp.java b/core/src/mindustry/entities/def/PuddleComp.java index 60de284777..a5d65d537a 100644 --- a/core/src/mindustry/entities/def/PuddleComp.java +++ b/core/src/mindustry/entities/def/PuddleComp.java @@ -10,6 +10,7 @@ import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.gen.*; +import mindustry.graphics.*; import mindustry.type.*; import mindustry.world.*; @@ -18,7 +19,7 @@ import static mindustry.entities.Puddles.maxLiquid; @EntityDef(value = {Puddlec.class}, pooled = true) @Component -abstract class PuddleComp implements Posc, DrawLayerFloorOverc, Puddlec{ +abstract class PuddleComp implements Posc, Puddlec{ private static final int maxGeneration = 2; private static final Color tmp = new Color(); private static final Rect rect = new Rect(); @@ -89,7 +90,9 @@ abstract class PuddleComp implements Posc, DrawLayerFloorOverc, Puddlec{ } @Override - public void drawFloorOver(){ + public void draw(){ + Draw.z(Layer.debris - 1); + seeds = id(); boolean onLiquid = tile.floor().isLiquid; float f = Mathf.clamp(amount / (maxLiquid / 1.5f)); diff --git a/core/src/mindustry/entities/def/StandardEffectComp.java b/core/src/mindustry/entities/def/StandardEffectComp.java deleted file mode 100644 index 5622a589e4..0000000000 --- a/core/src/mindustry/entities/def/StandardEffectComp.java +++ /dev/null @@ -1,14 +0,0 @@ -package mindustry.entities.def; - -import mindustry.annotations.Annotations.*; -import mindustry.gen.*; - -@EntityDef(value = {StandardEffectc.class, Childc.class}, pooled = true) -@Component -abstract class StandardEffectComp implements Effectc, DrawLayerEffectsc{ - - @Override - public void drawEffects(){ - draw(); - } -} diff --git a/core/src/mindustry/graphics/Layer.java b/core/src/mindustry/graphics/Layer.java index 21ad9a530d..3c1a7d50b6 100644 --- a/core/src/mindustry/graphics/Layer.java +++ b/core/src/mindustry/graphics/Layer.java @@ -20,6 +20,9 @@ public class Layer{ //base block layer - most blocks go here block = 30, + //things drawn over blocks (intermediate layer) + blockOver = 35, + //blocks currently in progress *shaders used* TODO perhaps put shaders into their own category blockBuilding = 40, diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index 4dc805e892..98fdefdb63 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -1,9 +1,11 @@ package mindustry.type; import arc.func.*; +import arc.graphics.g2d.*; import mindustry.annotations.Annotations.*; import mindustry.ctype.*; import mindustry.gen.*; +import mindustry.graphics.*; public abstract class Weather extends MappableContent{ protected float duration = 100f; @@ -39,7 +41,7 @@ public abstract class Weather extends MappableContent{ @EntityDef(value = {Weatherc.class}, pooled = true, isFinal = false) @Component - abstract class WeatherComp implements Posc, DrawLayerWeatherc{ + abstract class WeatherComp implements Posc, Drawc{ Weather weather; void init(Weather weather){ @@ -47,7 +49,8 @@ public abstract class Weather extends MappableContent{ } @Override - public void drawWeather(){ + public void draw(){ + Draw.z(Layer.weather); weather.draw(); } diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 9e651ca5c3..01ddc3c95a 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -199,14 +199,6 @@ public class Block extends UnlockableContent{ return sum / size / size; } - public void drawLayer(Tile tile){ - if(tile.entity != null) tile.entity.drawLayer(); - } - - public void drawLayer2(Tile tile){ - if(tile.entity != null) tile.entity.drawLayer2(); - } - /** Drawn when you are placing a block. */ public void drawPlace(int x, int y, int rotation, boolean valid){ } diff --git a/core/src/mindustry/world/blocks/defense/ShockMine.java b/core/src/mindustry/world/blocks/defense/ShockMine.java index d2fe426c25..9c2714925c 100644 --- a/core/src/mindustry/world/blocks/defense/ShockMine.java +++ b/core/src/mindustry/world/blocks/defense/ShockMine.java @@ -22,21 +22,11 @@ public class ShockMine extends Block{ destructible = true; solid = false; targetable = false; - layer = Layer.overlay; rebuildable = false; } public class ShockMineEntity extends TileEntity{ - @Override - public void drawLayer(){ - super.draw(); - Draw.color(team.color); - Draw.alpha(0.22f); - Fill.rect(x, y, 2f, 2f); - Draw.color(); - } - @Override public void drawTeam(){ //no @@ -44,7 +34,11 @@ public class ShockMine extends Block{ @Override public void draw(){ - //nope + super.draw(); + Draw.color(team.color); + Draw.alpha(0.22f); + Fill.rect(x, y, 2f, 2f); + Draw.color(); } @Override diff --git a/core/src/mindustry/world/blocks/distribution/Conveyor.java b/core/src/mindustry/world/blocks/distribution/Conveyor.java index cdf4f6a751..e10bdb80f6 100644 --- a/core/src/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/mindustry/world/blocks/distribution/Conveyor.java @@ -10,8 +10,8 @@ import arc.util.ArcAnnotate.*; import arc.util.*; import arc.util.io.*; import mindustry.content.*; -import mindustry.gen.*; import mindustry.entities.units.*; +import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; @@ -36,7 +36,6 @@ public class Conveyor extends Block implements Autotiler{ super(name); rotate = true; update = true; - layer = Layer.overlay; group = BlockGroup.transportation; hasItems = true; itemCapacity = 4; @@ -127,6 +126,19 @@ public class Conveyor extends Block implements Autotiler{ int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0; Draw.rect(regions[Mathf.clamp(blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], x, y, tilesize * blendsclx, tilesize * blendscly, rotation * 90); + + //TODO is clustering necessary? does it create garbage? + Draw.z(Layer.blockOver); + + 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 @@ -150,21 +162,6 @@ public class Conveyor extends Block implements Autotiler{ } } - @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){ diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index 26f3728028..b5438c62ea 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -32,7 +32,6 @@ public class ItemBridge extends Block{ update = true; solid = true; hasPower = true; - layer = Layer.power; expanded = true; itemCapacity = 10; configurable = true; diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 1d394fe54e..d0f65c6737 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -375,8 +375,6 @@ public class PowerNode extends PowerBlock{ public void drawLayer(){ if(Core.settings.getInt("lasersopacity") == 0) return; - Tilec entity = tile.ent(); - for(int i = 0; i < power.links.size; i++){ Tilec link = world.ent(power.links.get(i)); diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index f8aa13e2c9..1b73576797 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -31,7 +31,6 @@ public class CoreBlock extends StorageBlock{ flags = EnumSet.of(BlockFlag.core, BlockFlag.producer); activeSound = Sounds.respawning; activeSoundVolume = 1f; - layer = Layer.overlay; } @Remote(called = Loc.server) diff --git a/gradle.properties b/gradle.properties index 6b1870e26c..2a30384661 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=67f230afedd76d2d12ba3bb3e07116f8f0edd526 +archash=7c888f92ae770e9dc3b07439c32f64cc67c2a6a6