Map rule for air spawns (#9922)

* air use spawns

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>

* add the rule

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>

* add rule in ui

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>

* bundle

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>

* tie it to rules.waves

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>

* :)

Contributing.md says yes

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>

* indent

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>

---------

Signed-off-by: Jason <131086642+JasonP01@users.noreply.github.com>
This commit is contained in:
Jason
2024-06-16 06:34:47 +02:00
committed by GitHub
parent 2d4d38990d
commit f26b03dc6c
5 changed files with 17 additions and 5 deletions

View File

@@ -152,14 +152,21 @@ public class WaveSpawner{
}
private void eachFlyerSpawn(int filterPos, Floatc2 cons){
boolean airUseSpawns = state.rules.airUseSpawns;
for(Tile tile : spawns){
if(filterPos != -1 && filterPos != tile.pos()) continue;
float angle = Angles.angle(world.width() / 2f, world.height() / 2f, tile.x, tile.y);
float trns = Math.max(world.width(), world.height()) * Mathf.sqrt2 * tilesize;
float spawnX = Mathf.clamp(world.width() * tilesize / 2f + Angles.trnsx(angle, trns), -margin, world.width() * tilesize + margin);
float spawnY = Mathf.clamp(world.height() * tilesize / 2f + Angles.trnsy(angle, trns), -margin, world.height() * tilesize + margin);
cons.get(spawnX, spawnY);
if(!airUseSpawns){
float angle = Angles.angle(world.width() / 2f, world.height() / 2f, tile.x, tile.y);
float trns = Math.max(world.width(), world.height()) * Mathf.sqrt2 * tilesize;
float spawnX = Mathf.clamp(world.width() * tilesize / 2f + Angles.trnsx(angle, trns), -margin, world.width() * tilesize + margin);
float spawnY = Mathf.clamp(world.height() * tilesize / 2f + Angles.trnsy(angle, trns), -margin, world.height() * tilesize + margin);
cons.get(spawnX, spawnY);
}else{
cons.get(tile.worldx(), tile.worldy());
}
}
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam)){

View File

@@ -29,6 +29,8 @@ public class Rules{
public boolean waveSending = true;
/** Whether waves are spawnable at all. */
public boolean waves;
/** Whether air units spawn at spawns instead of the edge of the map */
public boolean airUseSpawns = false;
/** Whether the game objective is PvP. Note that this enables automatic hosting. */
public boolean pvp;
/** Whether is waiting for players enabled in PvP. */

View File

@@ -215,6 +215,7 @@ public class CustomRulesDialog extends BaseDialog{
check("@rules.wavesending", b -> rules.waveSending = b, () -> rules.waveSending, () -> rules.waves);
check("@rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer, () -> rules.waves);
check("@rules.waitForWaveToEnd", b -> rules.waitEnemies = b, () -> rules.waitEnemies, () -> rules.waves && rules.waveTimer);
check("@rules.airUseSpawns", b -> rules.airUseSpawns = b, () -> rules.airUseSpawns, () -> rules.waves);
numberi("@rules.wavelimit", f -> rules.winWave = f, () -> rules.winWave, () -> rules.waves, 0, Integer.MAX_VALUE);
number("@rules.wavespacing", false, f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f, () -> rules.waves && rules.waveTimer, 1, Float.MAX_VALUE);
//this is experimental, because it's not clear that 0 makes it default.