Non-recursive door floodfill
This commit is contained in:
@@ -20,6 +20,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class Door extends Wall{
|
public class Door extends Wall{
|
||||||
protected final static Rect rect = new Rect();
|
protected final static Rect rect = new Rect();
|
||||||
|
protected final static Queue<DoorBuild> doorQueue = new Queue<>();
|
||||||
|
|
||||||
public final int timerToggle = timers++;
|
public final int timerToggle = timers++;
|
||||||
public Effect openfx = Fx.dooropen;
|
public Effect openfx = Fx.dooropen;
|
||||||
@@ -56,7 +57,7 @@ public class Door extends Wall{
|
|||||||
|
|
||||||
public class DoorBuild extends Building{
|
public class DoorBuild extends Building{
|
||||||
public boolean open = false;
|
public boolean open = false;
|
||||||
public ObjectSet<DoorBuild> chained = new ObjectSet<>();
|
public Seq<DoorBuild> chained = new Seq<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProximityAdded(){
|
public void onProximityAdded(){
|
||||||
@@ -103,18 +104,19 @@ public class Door extends Wall{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateChained(){
|
public void updateChained(){
|
||||||
chained = new ObjectSet<>();
|
chained = new Seq<>();
|
||||||
flow(chained);
|
doorQueue.clear();
|
||||||
}
|
doorQueue.add(this);
|
||||||
|
|
||||||
public void flow(ObjectSet<DoorBuild> set){
|
while(!doorQueue.isEmpty()){
|
||||||
if(!set.add(this)) return;
|
var next = doorQueue.removeLast();
|
||||||
|
chained.add(next);
|
||||||
|
|
||||||
this.chained = set;
|
for(var b : next.proximity){
|
||||||
|
if(b instanceof DoorBuild d && d.chained != chained){
|
||||||
for(Building b : proximity){
|
d.chained = chained;
|
||||||
if(b instanceof DoorBuild d){
|
doorQueue.addFirst(d);
|
||||||
d.flow(set);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=10de4947bdfc5510ea35ed9f510ffe2a7107ee63
|
archash=50fe096a7d26e76abc9be1ee5b18172d18e1b930
|
||||||
|
|||||||
Reference in New Issue
Block a user