diff --git a/core/assets-raw/sprites/blocks/units/tank-assembler-top.png b/core/assets-raw/sprites/blocks/units/tank-assembler-top.png new file mode 100644 index 0000000000..93baebe80a Binary files /dev/null and b/core/assets-raw/sprites/blocks/units/tank-assembler-top.png differ diff --git a/core/assets-raw/sprites/blocks/units/tank-assembler.png b/core/assets-raw/sprites/blocks/units/tank-assembler.png index 82423bf477..9db25c43e7 100644 Binary files a/core/assets-raw/sprites/blocks/units/tank-assembler.png and b/core/assets-raw/sprites/blocks/units/tank-assembler.png differ diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index 25dc008953..4be76ffd71 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -387,8 +387,12 @@ public class Drawf{ public static void construct(Building t, TextureRegion region, float rotation, float progress, float speed, float time){ construct(t, region, Pal.accent, rotation, progress, speed, time); } - + public static void construct(Building t, TextureRegion region, Color color, float rotation, float progress, float speed, float time){ + construct(t, region, color, rotation, progress, speed, time, t.block.size * tilesize - 4f); + } + + public static void construct(Building t, TextureRegion region, Color color, float rotation, float progress, float speed, float time, float size){ Shaders.build.region = region; Shaders.build.progress = progress; Shaders.build.color.set(color); @@ -402,7 +406,7 @@ public class Drawf{ Draw.color(Pal.accent); Draw.alpha(speed); - Lines.lineAngleCenter(t.x + Mathf.sin(time, 20f, Vars.tilesize / 2f * t.block.size - 2f), t.y, 90, t.block.size * Vars.tilesize - 4f); + Lines.lineAngleCenter(t.x + Mathf.sin(time, 20f, size / 2f), t.y, 90, size); Draw.reset(); } diff --git a/core/src/mindustry/world/blocks/units/UnitAssembler.java b/core/src/mindustry/world/blocks/units/UnitAssembler.java index 9739c8becf..07d6362ae6 100644 --- a/core/src/mindustry/world/blocks/units/UnitAssembler.java +++ b/core/src/mindustry/world/blocks/units/UnitAssembler.java @@ -36,6 +36,7 @@ public class UnitAssembler extends PayloadBlock{ public int areaSize = 11; public UnitType droneType = UnitTypes.assemblyDrone; public int dronesCreated = 4; + public float droneConstructTime = 60f * 3f; public Seq plans = new Seq<>(4); @@ -137,6 +138,7 @@ public class UnitAssembler extends PayloadBlock{ AssemblerUnitPlan(){} } + /** hbgwerjhbagjegwg */ public static class YeetData{ public Vec2 target; public Block block; @@ -153,11 +155,13 @@ public class UnitAssembler extends PayloadBlock{ public Seq units = new Seq<>(); public Seq modules = new Seq<>(); public BlockSeq blocks = new BlockSeq(); - public float progress, warmup; + public float progress, warmup, droneWarmup; public float invalidWarmup = 0f; public int currentTier = 0; public boolean wasOccupied = false; + public float droneProgress, totalDroneProgress; + public Vec2 getUnitSpawn(){ float len = tilesize * (areaSize + size)/2f; float unitX = x + Geometry.d4x(rotation) * len, unitY = y + Geometry.d4y(rotation) * len; @@ -275,8 +279,10 @@ public class UnitAssembler extends PayloadBlock{ units.removeAll(u -> !u.isAdded() || u.dead || !(u.controller() instanceof AssemblerAI)); - //TODO build up units, don't spawn immediately in batches - if(efficiency() > 0 && units.size < dronesCreated){ + droneWarmup = Mathf.lerpDelta(droneWarmup, units.size < dronesCreated ? efficiency() : 0f, 0.1f); + totalDroneProgress += droneWarmup * Time.delta; + + if(units.size < dronesCreated && (droneProgress += edelta() / droneConstructTime) >= 1f){ var unit = droneType.create(team); if(unit instanceof BuildingTetherc bt){ bt.building(this); @@ -287,6 +293,7 @@ public class UnitAssembler extends PayloadBlock{ Fx.spawn.at(unit); units.add(unit); + droneProgress = 0f; } //TODO units should pick up and move payloads into position @@ -359,8 +366,15 @@ public class UnitAssembler extends PayloadBlock{ Draw.z(Layer.blockOver + 0.1f); - //TODO top? - //Draw.rect(topRegion, x, y); + Draw.rect(topRegion, x, y); + + //draw drone construction + if(droneWarmup > 0){ + //TODO draw it - better animations? + Draw.draw(Layer.blockOver + 0.2f, () -> { + Drawf.construct(this, droneType.fullIcon, Pal.accent, 0f, droneProgress, droneWarmup, totalDroneProgress, 14f); + }); + } Vec2 spawn = getUnitSpawn(); @@ -437,7 +451,8 @@ public class UnitAssembler extends PayloadBlock{ @Override public boolean acceptPayload(Building source, Payload payload){ var plan = plan(); - return this.payload == null && payload instanceof BuildPayload bp && plan.requirements.contains(b -> b.block == bp.block() && blocks.get(bp.block()) < b.amount); + return (this.payload == null || source instanceof UnitAssemblerModuleBuild) && + payload instanceof BuildPayload bp && plan.requirements.contains(b -> b.block == bp.block() && blocks.get(bp.block()) < b.amount); } @Override diff --git a/core/src/mindustry/world/blocks/units/UnitAssemblerModule.java b/core/src/mindustry/world/blocks/units/UnitAssemblerModule.java index 201e4514a6..0ec38f6054 100644 --- a/core/src/mindustry/world/blocks/units/UnitAssemblerModule.java +++ b/core/src/mindustry/world/blocks/units/UnitAssemblerModule.java @@ -20,6 +20,7 @@ public class UnitAssemblerModule extends PayloadBlock{ super(name); rotate = true; rotateDraw = false; + acceptsPayload = true; } @Override @@ -81,7 +82,7 @@ public class UnitAssemblerModule extends PayloadBlock{ @Override public boolean acceptPayload(Building source, Payload payload){ - return link != null && this.payload == null && link.acceptPayload(source, payload); + return link != null && this.payload == null && link.acceptPayload(this, payload); } @Override