Send natural wave command

This commit is contained in:
MEEP of Faith
2022-08-25 01:22:10 -07:00
parent d117e156fe
commit ada2c7f872
4 changed files with 41 additions and 9 deletions

View File

@@ -1999,7 +1999,7 @@ lst.getblock = Get tile data at any location.
lst.setblock = Set tile data at any location. lst.setblock = Set tile data at any location.
lst.spawnunit = Spawn unit at a location. lst.spawnunit = Spawn unit at a location.
lst.applystatus = Apply or clear a status effect from a unit. 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.explosion = Create an explosion at a location.
lst.setrate = Set processor execution speed in instructions/tick. 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. 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. unitlocate.group = Building group to look for.
lenum.idle = Don't move, but keep building/mining.\nThe default state. 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.stop = Stop moving/mining/building.
lenum.unbind = Completely disable logic control.\nResume standard AI. lenum.unbind = Completely disable logic control.\nResume standard AI.
lenum.move = Move to exact position. lenum.move = Move to exact position.

View File

@@ -1634,12 +1634,14 @@ public class LExecutor{
} }
public static class SpawnWaveI implements LInstruction{ public static class SpawnWaveI implements LInstruction{
public WaveType type;
public int x, y; public int x, y;
public SpawnWaveI(){ public SpawnWaveI(){
} }
public SpawnWaveI(int x, int y){ public SpawnWaveI(WaveType type, int x, int y){
this.type = type;
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
@@ -1648,9 +1650,14 @@ public class LExecutor{
public void run(LExecutor exec){ public void run(LExecutor exec){
if(net.client()) return; if(net.client()) return;
if(type == WaveType.natural){
logic.skipWave(); //TODO: Does this sync?
return;
}
float float
spawnX = World.unconv(exec.numf(x)), spawnX = World.unconv(exec.numf(x)),
spawnY = World.unconv(exec.numf(y)); spawnY = World.unconv(exec.numf(y));
int packed = Point2.pack(exec.numi(x), exec.numi(y)); int packed = Point2.pack(exec.numi(x), exec.numi(y));
for(SpawnGroup group : state.rules.spawns){ for(SpawnGroup group : state.rules.spawns){

View File

@@ -1291,16 +1291,32 @@ public class LStatements{
@RegisterStatement("spawnwave") @RegisterStatement("spawnwave")
public static class SpawnWaveStatement extends LStatement{ public static class SpawnWaveStatement extends LStatement{
public WaveType type = WaveType.simulation;
public String x = "10", y = "10"; public String x = "10", y = "10";
@Override @Override
public void build(Table table){ public void build(Table table){
rebuild(table);
}
table.add("x "); void rebuild(Table table){
fields(table, x, str -> x = str); table.clearChildren();
table.add(" y "); table.button(b -> {
fields(table, y, str -> y = str); 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 @Override
@@ -1310,7 +1326,7 @@ public class LStatements{
@Override @Override
public LInstruction build(LAssembler builder){ 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 @Override

View File

@@ -0,0 +1,8 @@
package mindustry.logic;
public enum WaveType{
natural,
simulation;
public static final WaveType[] all = values();
}