diff --git a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java index f47eafc237..f1fe85005b 100644 --- a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java @@ -161,6 +161,7 @@ public class EntityProcess extends BaseProcessor{ Log.debug(""); } + /* //generate special render layer interfaces for(DrawLayer layer : DrawLayer.values()){ //create the DrawLayer interface that entities need to implement @@ -171,7 +172,7 @@ public class EntityProcess extends BaseProcessor{ .addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class); inter.addMethod(MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build()); write(inter); - } + }*/ }else if(round == 2){ //round 2: get component classes and generate interfaces for them //parse groups @@ -182,6 +183,7 @@ public class EntityProcess extends BaseProcessor{ groupDefs.add(new GroupDefinition(group.name(), ClassName.bestGuess(packageName + "." + interfaceName(types.first())), types, an.spatial(), an.mapping(), collides)); } + /* //add special generated groups for(DrawLayer layer : DrawLayer.values()){ String name = "DrawLayer" + Strings.capitalize(layer.name()) + "c"; @@ -190,7 +192,7 @@ public class EntityProcess extends BaseProcessor{ //add manual inclusions of entities to be added to this group def.manualInclusions.addAll(allDefs.select(s -> allComponents(s).contains(comp -> comp.interfaces().contains(in -> in.name().equals(name))))); groupDefs.add(def); - } + }*/ ObjectMap usedNames = new ObjectMap<>(); ObjectMap> extraNames = new ObjectMap<>(); @@ -457,12 +459,13 @@ public class EntityProcess extends BaseProcessor{ } } + /* for(DrawLayer layer : DrawLayer.values()){ MethodSpec.Builder groupDraw = MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())) .addModifiers(Modifier.PUBLIC, Modifier.STATIC); groupDraw.addStatement("$L.draw($L::$L)", layer.name(), "DrawLayer" + Strings.capitalize(layer.name()) + "c", "draw" + Strings.capitalize(layer.name())); groupsBuilder.addMethod(groupDraw.build()); - } + }*/ groupsBuilder.addMethod(groupResize.build()); groupsBuilder.addMethod(groupUpdate.build()); diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index e74c0529d0..16b73c4a71 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -25,7 +25,7 @@ public class Renderer implements ApplicationListener{ public final LightRenderer lights = new LightRenderer(); public final Pixelator pixelator = new Pixelator(); - public FrameBuffer effectBuffer = new FrameBuffer(2, 2); + public FrameBuffer effectBuffer = new FrameBuffer(); private Bloom bloom; private FxProcessor fx = new FxProcessor(); private Color clearColor = new Color(0f, 0f, 0f, 1f); @@ -181,21 +181,22 @@ public class Renderer implements ApplicationListener{ graphics.clear(clearColor); - if(!graphics.isHidden() && (Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")) && (effectBuffer.getWidth() != graphics.getWidth() || effectBuffer.getHeight() != graphics.getHeight())){ + //TODO 'animated water' is a bad name for this etting + if(Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")){ effectBuffer.resize(graphics.getWidth(), graphics.getHeight()); } Draw.proj(camera); - beginFx(); + //beginFx(); drawBackground(); blocks.floor.checkChanges(); blocks.floor.drawFloor(); - Groups.drawFloor(); - Groups.drawFloorOver(); + //Groups.drawFloor(); + //Groups.drawFloorOver(); blocks.processBlocks(); blocks.drawShadows(); @@ -334,8 +335,6 @@ public class Renderer implements ApplicationListener{ } public void takeMapScreenshot(){ - Groups.drawGroundShadows(); - int w = world.width() * tilesize, h = world.height() * tilesize; int memory = w * h * 4 / 1024 / 1024; diff --git a/core/src/mindustry/entities/AllDefs.java b/core/src/mindustry/entities/AllDefs.java index b042733b89..090218ef40 100644 --- a/core/src/mindustry/entities/AllDefs.java +++ b/core/src/mindustry/entities/AllDefs.java @@ -34,4 +34,9 @@ class AllDefs{ class sync{ } + + @GroupDef(Drawc.class) + class draw{ + + } } diff --git a/core/src/mindustry/entities/def/DecalComp.java b/core/src/mindustry/entities/def/DecalComp.java index cb95bd4ad2..775f3d85de 100644 --- a/core/src/mindustry/entities/def/DecalComp.java +++ b/core/src/mindustry/entities/def/DecalComp.java @@ -8,14 +8,14 @@ import mindustry.gen.*; @EntityDef(value = {Decalc.class}, pooled = true) @Component -abstract class DecalComp implements Drawc, Timedc, Rotc, Posc, DrawLayerFloorc{ +abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{ @Import float x, y, rotation; Color color = new Color(1, 1, 1, 1); TextureRegion region; @Override - public void drawFloor(){ + public void draw(){ Draw.color(color); Draw.alpha(1f - Mathf.curve(fin(), 0.98f)); Draw.rect(region, x, y, rotation); diff --git a/core/src/mindustry/entities/def/DrawComp.java b/core/src/mindustry/entities/def/DrawComp.java index 123c6a14ed..d94de2d4df 100644 --- a/core/src/mindustry/entities/def/DrawComp.java +++ b/core/src/mindustry/entities/def/DrawComp.java @@ -6,4 +6,8 @@ import mindustry.gen.*; @Component abstract class DrawComp implements Posc{ abstract float clipSize(); + + void draw(){ + + } } diff --git a/core/src/mindustry/entities/def/LegsComp.java b/core/src/mindustry/entities/def/LegsComp.java index d4d651bac0..22d5acb64f 100644 --- a/core/src/mindustry/entities/def/LegsComp.java +++ b/core/src/mindustry/entities/def/LegsComp.java @@ -6,7 +6,7 @@ import mindustry.annotations.Annotations.*; import mindustry.gen.*; @Component -abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc, Unitc, Legsc, ElevationMovec{ +abstract class LegsComp implements Posc, Flyingc, Hitboxc, Unitc, Legsc, ElevationMovec{ @Import float x, y; float baseRotation; @@ -18,9 +18,4 @@ abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed)); walkTime += Time.delta()*len/1f; } - - @Override - public void drawGroundUnder(){ - type().drawLegs(this); - } } diff --git a/core/src/mindustry/entities/def/MinerComp.java b/core/src/mindustry/entities/def/MinerComp.java index 6cb6013b9f..bf485ded2f 100644 --- a/core/src/mindustry/entities/def/MinerComp.java +++ b/core/src/mindustry/entities/def/MinerComp.java @@ -17,7 +17,7 @@ import mindustry.world.*; import static mindustry.Vars.*; @Component -abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{ +abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ @Import float x, y, rotation; transient float mineTimer; @@ -80,7 +80,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{ } @Override - public void drawGround(){ + public void draw(){ if(!mining()) return; float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f); float swingScl = 12f, swingMag = tilesize / 8f; diff --git a/core/src/mindustry/entities/def/UnitComp.java b/core/src/mindustry/entities/def/UnitComp.java index 89e15106b5..e8b8d3d664 100644 --- a/core/src/mindustry/entities/def/UnitComp.java +++ b/core/src/mindustry/entities/def/UnitComp.java @@ -18,8 +18,7 @@ import mindustry.world.blocks.environment.*; import static mindustry.Vars.*; @Component -abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, - DrawLayerGroundc, DrawLayerFlyingc, DrawLayerGroundShadowsc, DrawLayerFlyingShadowsc, Syncc{ +abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, Syncc{ @Import float x, y, rotation, elevation; private UnitController controller; @@ -172,32 +171,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox @Override public void draw(){ - type.drawEngine(this); - type.drawBody(this); - type.drawWeapons(this); - if(type.drawCell) type.drawCell(this); - if(type.drawItems) type.drawItems(this); - type.drawLight(this); - } - - @Override - public void drawFlyingShadows(){ - if(isFlying()) type.drawShadow(this); - } - - @Override - public void drawGroundShadows(){ - type.drawOcclusion(this); - } - - @Override - public void drawFlying(){ - if(isFlying()) draw(); - } - - @Override - public void drawGround(){ - if(isGrounded()) draw(); + type.draw(this); } @Override diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index 4a23460600..4a88a96ba6 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -29,8 +29,8 @@ public class BlockRenderer implements Disposable{ private int lastCamX, lastCamY, lastRangeX, lastRangeY; private float brokenFade = 0f; - private FrameBuffer shadows = new FrameBuffer(2, 2); - private FrameBuffer fog = new FrameBuffer(2, 2); + private FrameBuffer shadows = new FrameBuffer(); + private FrameBuffer fog = new FrameBuffer(); private Array outArray2 = new Array<>(); private Array shadowEvents = new Array<>(); private boolean displayStatus = false; diff --git a/core/src/mindustry/graphics/CacheLayer.java b/core/src/mindustry/graphics/CacheLayer.java index 6363efae98..ab354acf1f 100644 --- a/core/src/mindustry/graphics/CacheLayer.java +++ b/core/src/mindustry/graphics/CacheLayer.java @@ -8,6 +8,7 @@ import arc.graphics.gl.*; import static mindustry.Vars.renderer; public enum CacheLayer{ + //TODO water animation breaks when tar/slag is present water{ @Override public void begin(){ diff --git a/core/src/mindustry/graphics/LightRenderer.java b/core/src/mindustry/graphics/LightRenderer.java index a95c9489a2..9cef65c8d7 100644 --- a/core/src/mindustry/graphics/LightRenderer.java +++ b/core/src/mindustry/graphics/LightRenderer.java @@ -17,7 +17,7 @@ public class LightRenderer{ private static final int scaling = 4; private float[] vertices = new float[24]; - private FrameBuffer buffer = new FrameBuffer(2, 2); + private FrameBuffer buffer = new FrameBuffer(); private Array lights = new Array<>(); public void add(Runnable run){ @@ -185,9 +185,7 @@ public class LightRenderer{ return; } - if(buffer.getWidth() != Core.graphics.getWidth()/scaling || buffer.getHeight() != Core.graphics.getHeight()/scaling){ - buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling); - } + buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling); Draw.color(); buffer.begin(Color.clear); diff --git a/core/src/mindustry/graphics/Pixelator.java b/core/src/mindustry/graphics/Pixelator.java index acaa6bebca..18846c3e67 100644 --- a/core/src/mindustry/graphics/Pixelator.java +++ b/core/src/mindustry/graphics/Pixelator.java @@ -12,7 +12,7 @@ import static arc.Core.*; import static mindustry.Vars.renderer; public class Pixelator implements Disposable{ - private FrameBuffer buffer = new FrameBuffer(2, 2); + private FrameBuffer buffer = new FrameBuffer(); { buffer.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest); @@ -34,9 +34,7 @@ public class Pixelator implements Disposable{ int w = (int)(Core.camera.width * renderer.landScale()); int h = (int)(Core.camera.height * renderer.landScale()); - if(!graphics.isHidden() && (buffer.getWidth() != w || buffer.getHeight() != h)){ - buffer.resize(w, h); - } + buffer.resize(w, h); buffer.begin(); renderer.draw(); diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index a5a8de4cc2..a73ed23f18 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -114,6 +114,21 @@ public class UnitType extends UnlockableContent{ //region drawing + public void draw(Unitc unit){ + //TODO set Z for these things + + drawShadow(unit); + drawOcclusion(unit); + + if(unit instanceof Legsc) drawLegs((Legsc)unit); + drawEngine(unit); + drawBody(unit); + drawWeapons(unit); + if(drawCell) drawCell(unit); + if(drawItems) drawItems(unit); + drawLight(unit); + } + public void drawShadow(Unitc unit){ Draw.color(shadowColor); Draw.rect(region, unit.x() + shadowTX * unit.elevation(), unit.y() + shadowTY * unit.elevation(), unit.rotation() - 90);