Erekir parallel tech tree changes

This commit is contained in:
Anuken
2022-02-20 13:32:25 -05:00
parent 02966a0911
commit 74233fdc2c
9 changed files with 67 additions and 58 deletions

View File

@@ -21,8 +21,6 @@ import mindustry.world.blocks.environment.*;
import static mindustry.Vars.*;
public class Tile implements Position, QuadTreeObject, Displayable{
private static boolean tileChangeLock = false;
private static boolean tilePreChangeLock = false;
private static final TileChangeEvent tileChange = new TileChangeEvent();
private static final TilePreChangeEvent preChange = new TilePreChangeEvent();
private static final ObjectSet<Building> tileSet = new ObjectSet<>();
@@ -632,34 +630,13 @@ public class Tile implements Position, QuadTreeObject, Displayable{
protected void fireChanged(){
if(!world.isGenerating()){
//A TileChangeEvent may cause other TileChangeEvents to occur, and if that happens, allocate a new instance.
boolean wasLocked = tileChangeLock;
var eventInst = wasLocked ? new TileChangeEvent() : tileChange;
tileChangeLock = true;
Events.fire(eventInst.set(this));
//unlock after it's done
if(!wasLocked){
tileChangeLock = false;
}
Events.fire(tileChange.set(this));
}
}
protected void firePreChanged(){
if(!world.isGenerating()){
//same as above
boolean wasLocked = tilePreChangeLock;
var eventInst = wasLocked ? new TilePreChangeEvent() : preChange;
tilePreChangeLock = true;
Events.fire(eventInst.set(this));
if(!wasLocked){
tilePreChangeLock = false;
}
Events.fire(preChange.set(this));
}
}

View File

@@ -81,10 +81,7 @@ public class ItemSource extends Block{
while(counter >= limit){
items.set(outputItem, 1);
if(dump(outputItem)){
//for debugging only
produced(outputItem);
}
dump(outputItem);
items.set(outputItem, 0);
counter -= limit;
}