Allow spawnpoint edits in-game (closes Anuken/Mindustry-Suggestions/issues/5754)

This commit is contained in:
Anuken 2025-07-24 14:47:32 -04:00
parent 3e860c5f29
commit 9696ddf993
4 changed files with 31 additions and 2 deletions

View file

@ -23,13 +23,18 @@ public class WaveSpawner{
private static final float margin = 0f, coreMargin = tilesize * 2f, maxSteps = 30;
private int tmpCount;
private Seq<Tile> spawns = new Seq<>();
private Seq<Tile> spawns = new Seq<>(false);
private boolean spawning = false;
private boolean any = false;
private Tile firstSpawn = null;
public WaveSpawner(){
Events.on(WorldLoadEvent.class, e -> reset());
Events.on(TileOverlayChangeEvent.class, e -> {
if(e.previous == Blocks.spawn) spawns.remove(e.tile);
if(e.overlay == Blocks.spawn) spawns.add(e.tile);
});
}
@Nullable

View file

@ -414,6 +414,22 @@ public class EventType{
}
}
/**
* Called when a tile changes its overlay. Do not cache or use with a timer.
* Do not modify any tiles inside listener code.
* */
public static class TileOverlayChangeEvent{
public Tile tile;
public Floor previous, overlay;
public TileOverlayChangeEvent set(Tile tile, Floor previous, Floor overlay){
this.tile = tile;
this.previous = previous;
this.overlay = overlay;
return this;
}
}
/**
* Called after a building's team changes.
* Event object is reused, do not nest!

View file

@ -24,6 +24,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
private static final TileChangeEvent tileChange = new TileChangeEvent();
private static final TilePreChangeEvent preChange = new TilePreChangeEvent();
private static final TileFloorChangeEvent floorChange = new TileFloorChangeEvent();
private static final TileOverlayChangeEvent overlayChange = new TileOverlayChangeEvent();;
private static final ObjectSet<Building> tileSet = new ObjectSet<>();
/**
@ -408,9 +409,16 @@ public class Tile implements Position, QuadTreeObject, Displayable{
public void setOverlay(Block block){
if(this.overlay == block) return;
var prev = this.overlay;
this.overlay = (Floor)block;
recache();
if(!world.isGenerating()){
Events.fire(overlayChange.set(this, prev, this.overlay));
}
if(!world.isGenerating() && build != null){
build.onProximityUpdate();
}

View file

@ -26,4 +26,4 @@ org.gradle.caching=true
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
android.enableR8.fullMode=false
archash=82df0d1a93
archash=071fdffaf2