diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 0fae24229e..0d4e1af00f 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1999,7 +1999,7 @@ lst.getblock = Get tile data at any location. lst.setblock = Set tile data at any location. lst.spawnunit = Spawn unit at a location. lst.applystatus = Apply or clear a status effect from a unit. -lst.spawnwave = Simulate a wave being spawned at an arbitrary location.\nWill not increment the wave counter. +lst.spawnwave = Spawn a wave. lst.explosion = Create an explosion at a location. lst.setrate = Set processor execution speed in instructions/tick. lst.fetch = Lookup units, cores, players or buildings by index.\nIndices start at 0 and end at their returned count. @@ -2139,6 +2139,7 @@ unitlocate.outy = Output Y coordinate. unitlocate.group = Building group to look for. lenum.idle = Don't move, but keep building/mining.\nThe default state. +lenum.simulation = Will not increment the wave counter. lenum.stop = Stop moving/mining/building. lenum.unbind = Completely disable logic control.\nResume standard AI. lenum.move = Move to exact position. diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 1c9faa9dc7..16a0e7012c 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1634,12 +1634,14 @@ public class LExecutor{ } public static class SpawnWaveI implements LInstruction{ + public WaveType type; public int x, y; public SpawnWaveI(){ } - public SpawnWaveI(int x, int y){ + public SpawnWaveI(WaveType type, int x, int y){ + this.type = type; this.x = x; this.y = y; } @@ -1648,9 +1650,14 @@ public class LExecutor{ public void run(LExecutor exec){ if(net.client()) return; + if(type == WaveType.natural){ + logic.skipWave(); //TODO: Does this sync? + return; + } + float - spawnX = World.unconv(exec.numf(x)), - spawnY = World.unconv(exec.numf(y)); + spawnX = World.unconv(exec.numf(x)), + spawnY = World.unconv(exec.numf(y)); int packed = Point2.pack(exec.numi(x), exec.numi(y)); for(SpawnGroup group : state.rules.spawns){ diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index cb10027821..4cc4b0cc8e 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -1291,16 +1291,32 @@ public class LStatements{ @RegisterStatement("spawnwave") public static class SpawnWaveStatement extends LStatement{ + public WaveType type = WaveType.simulation; public String x = "10", y = "10"; @Override public void build(Table table){ + rebuild(table); + } - table.add("x "); - fields(table, x, str -> x = str); + void rebuild(Table table){ + table.clearChildren(); - table.add(" y "); - fields(table, y, str -> y = str); + table.button(b -> { + b.label(() -> type.name()).growX().wrap().labelAlign(Align.center); + b.clicked(() -> showSelect(b, WaveType.all, type, o -> { + type = o; + rebuild(table); + }, 1, c -> c.width(150f))); + }, Styles.logict, () -> {}).size(160f, 40f).padLeft(2).color(table.color); + + if(type == WaveType.simulation){ + table.add("x "); + fields(table, x, str -> x = str); + + table.add(" y "); + fields(table, y, str -> y = str); + } } @Override @@ -1310,7 +1326,7 @@ public class LStatements{ @Override public LInstruction build(LAssembler builder){ - return new SpawnWaveI(builder.var(x), builder.var(y)); + return new SpawnWaveI(type, builder.var(x), builder.var(y)); } @Override diff --git a/core/src/mindustry/logic/WaveType.java b/core/src/mindustry/logic/WaveType.java new file mode 100644 index 0000000000..a1741481d7 --- /dev/null +++ b/core/src/mindustry/logic/WaveType.java @@ -0,0 +1,8 @@ +package mindustry.logic; + +public enum WaveType{ + natural, + simulation; + + public static final WaveType[] all = values(); +}