diff --git a/core/assets/maps/fungalPass.msav b/core/assets/maps/fungalPass.msav index 2415d16ae4..c154c2e4db 100644 Binary files a/core/assets/maps/fungalPass.msav and b/core/assets/maps/fungalPass.msav differ diff --git a/core/src/mindustry/ai/WaveSpawner.java b/core/src/mindustry/ai/WaveSpawner.java index 151ff65418..43882cfbbe 100644 --- a/core/src/mindustry/ai/WaveSpawner.java +++ b/core/src/mindustry/ai/WaveSpawner.java @@ -3,6 +3,7 @@ package mindustry.ai; import arc.*; import arc.func.*; import arc.math.*; +import arc.math.geom.*; import arc.struct.*; import arc.util.*; import mindustry.annotations.Annotations.*; @@ -17,10 +18,11 @@ import mindustry.world.*; import static mindustry.Vars.*; public class WaveSpawner{ - private static final float margin = 40f, coreMargin = tilesize * 3.5f; + private static final float margin = 40f, coreMargin = tilesize * 2f, maxSteps = 30; private Seq spawns = new Seq<>(); private boolean spawning = false; + private boolean any = false; public WaveSpawner(){ Events.on(WorldLoadEvent.class, e -> reset()); @@ -92,7 +94,33 @@ public class WaveSpawner{ Building firstCore = state.teams.playerCores().first(); for(Building core : state.rules.waveTeam.cores()){ Tmp.v1.set(firstCore).sub(core).limit(coreMargin + core.block().size * tilesize /2f * Mathf.sqrt2); - cons.accept(core.x + Tmp.v1.x, core.y + Tmp.v1.y, false); + + boolean valid = false; + int steps = 0; + + //keep moving forward until the max step amount is reached + while(steps++ < maxSteps){ + int tx = world.toTile(core.x + Tmp.v1.x), ty = world.toTile(core.y + Tmp.v1.y); + any = false; + Geometry.circle(tx, ty, world.width(), world.height(), 3, (x, y) -> { + if(world.solid(x, y)){ + any = true; + } + }); + + //nothing is in the way, spawn it + if(!any){ + valid = true; + break; + }else{ + //make the vector longer + Tmp.v1.setLength(Tmp.v1.len() + tilesize*1.1f); + } + } + + if(valid){ + cons.accept(core.x + Tmp.v1.x, core.y + Tmp.v1.y, false); + } } } }