Fixed minimap not updating when build team changes
This commit is contained in:
@@ -49,6 +49,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
static final float timeToSleep = 60f * 1, timeToUncontrol = 60f * 6;
|
||||
static final ObjectSet<Building> tmpTiles = new ObjectSet<>();
|
||||
static final Seq<Building> tempBuilds = new Seq<>();
|
||||
static final BuildTeamChangeEvent teamChangeEvent = new BuildTeamChangeEvent();
|
||||
static int sleepingEntities = 0;
|
||||
|
||||
@Import float x, y, health, maxHealth;
|
||||
@@ -1258,9 +1259,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
|
||||
/** Changes this building's team in a safe manner. */
|
||||
public void changeTeam(Team next){
|
||||
Team last = this.team;
|
||||
indexer.removeIndex(tile);
|
||||
this.team = next;
|
||||
indexer.addIndex(tile);
|
||||
Events.fire(teamChangeEvent.set(last, self()));
|
||||
}
|
||||
|
||||
public boolean canPickup(){
|
||||
|
||||
@@ -284,6 +284,21 @@ public class EventType{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after a building's team changes.
|
||||
* Event object is reused, do not nest!
|
||||
* */
|
||||
public static class BuildTeamChangeEvent{
|
||||
public Team previous;
|
||||
public Building build;
|
||||
|
||||
public BuildTeamChangeEvent set(Team previous, Building build){
|
||||
this.build = build;
|
||||
this.previous = previous;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when a core block is placed/removed or its team is changed. */
|
||||
public static class CoreChangeEvent{
|
||||
public CoreBuild core;
|
||||
|
||||
@@ -33,13 +33,18 @@ public class MinimapRenderer{
|
||||
updateAll();
|
||||
});
|
||||
|
||||
//make sure to call on the graphics thread
|
||||
Events.on(TileChangeEvent.class, event -> {
|
||||
//TODO don't update when the minimap is off?
|
||||
if(!ui.editor.isShown()){
|
||||
update(event.tile);
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(BuildTeamChangeEvent.class, event -> {
|
||||
if(!ui.editor.isShown()){
|
||||
update(event.build.tile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Pixmap getPixmap(){
|
||||
|
||||
Reference in New Issue
Block a user