Spawn wave instruction

This commit is contained in:
Anuken
2022-04-25 18:52:33 -04:00
parent 1ac7317986
commit aab6c3a9df
9 changed files with 82 additions and 16 deletions

View File

@@ -2781,8 +2781,8 @@ public class UnitTypes{
float life = lifetime / Mathf.lerp(fin, 1f, 0.5f);
spawnBullets.add(new BasicBulletType(spd * fin, 45){{
drag = 0.002f;
width = 8f;
height = 10f;
width = 12f;
height = 11f;
lifetime = life + 5f;
weaveRandom = false;
hitSize = 5f;

View File

@@ -1340,6 +1340,7 @@ public class LExecutor{
public void run(LExecutor exec){
switch(rule){
case waveTimer -> state.rules.waveTimer = exec.bool(value);
case wave -> state.wave = exec.numi(value);
case currentWaveTime -> state.wavetime = exec.numf(value) * 60f;
case waves -> state.rules.waves = exec.bool(value);
case attackMode -> state.rules.attackMode = exec.bool(value);
@@ -1562,5 +1563,40 @@ public class LExecutor{
}
}
public static class SpawnWaveI implements LInstruction{
public int x, y;
public SpawnWaveI(){
}
public SpawnWaveI(int x, int y){
this.x = x;
this.y = y;
}
@Override
public void run(LExecutor exec){
float
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){
if(group.type == null || (group.spawn != -1 && group.spawn != packed)) continue;
int spawned = group.getSpawned(state.wave - 1);
float spread = tilesize * 2;
for(int i = 0; i < spawned; i++){
Tmp.v1.rnd(spread);
Unit unit = group.createUnit(state.rules.waveTeam, state.wave - 1);
unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y);
Vars.spawner.spawnEffect(unit);
}
}
}
}
//endregion
}

View File

@@ -1234,6 +1234,36 @@ public class LStatements{
}
}
@RegisterStatement("spawnwave")
public static class SpawnWaveStatement extends LStatement{
public String x = "10", y = "10";
@Override
public void build(Table table){
table.add("x ");
fields(table, x, str -> x = str);
table.add(" y ");
fields(table, y, str -> y = str);
}
@Override
public boolean privileged(){
return true;
}
@Override
public Color color(){
return Pal.logicWorld;
}
@Override
public LInstruction build(LAssembler builder){
return new SpawnWaveI(builder.var(x), builder.var(y));
}
}
@RegisterStatement("setrule")
public static class SetRuleStatement extends LStatement{
public LogicRule rule = LogicRule.waveSpacing;

View File

@@ -4,6 +4,7 @@ public enum LogicRule{
currentWaveTime,
waveTimer,
waves,
wave,
waveSpacing,
attackMode,
enemyCoreBuildRadius,

View File

@@ -162,7 +162,7 @@ public class Floor extends Block{
}
PixmapRegion image = Core.atlas.getPixmap(icons()[0]);
PixmapRegion edge = Core.atlas.getPixmap("edge-stencil");
PixmapRegion edge = Core.atlas.getPixmap(Core.atlas.find(name + "-edge-stencil", "edge-stencil"));
Pixmap result = new Pixmap(edge.width, edge.height);
for(int x = 0; x < edge.width; x++){