auto update NPC slot location and reload on mesh change for buildings

This commit is contained in:
2024-05-21 17:01:23 -05:00
parent 6d16eccc24
commit fb1d6a3248
+11 -1
View File
@@ -12,6 +12,7 @@ package engine.objects;
import engine.Enum;
import engine.Enum.*;
import engine.InterestManagement.HeightMap;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.RealmMap;
import engine.InterestManagement.WorldGrid;
import engine.db.archive.CityRecord;
@@ -394,7 +395,7 @@ public class Building extends AbstractWorldObject {
this.rank = newRank;
// New rank means new mesh
int oldMeshID = this.meshUUID;
newMeshUUID = this.getBlueprint().getMeshForRank(this.rank);
this.meshUUID = newMeshUUID;
@@ -428,6 +429,15 @@ public class Building extends AbstractWorldObject {
BuildingManager.cleanupHirelings(this);
this.isDeranking.compareAndSet(true, false);
if(oldMeshID != this.meshUUID) {
//move NPCs to new slot locations if the mesh was changed and force reload them
int index = 0;
for (AbstractCharacter hireling : this.hirelings.keySet()) {
hireling.setLoc(BuildingManager._slotLocations.get(newMeshUUID).get(index).getLocation());
InterestManager.reloadCharacter(hireling);
}
}
}
public final int getOwnerUUID() {