Browse Source

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

lakebane-master
FatBoy-DOTC 6 months ago
parent
commit
fb1d6a3248
  1. 12
      src/engine/objects/Building.java

12
src/engine/objects/Building.java

@ -12,6 +12,7 @@ package engine.objects;
import engine.Enum; import engine.Enum;
import engine.Enum.*; import engine.Enum.*;
import engine.InterestManagement.HeightMap; import engine.InterestManagement.HeightMap;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.RealmMap; import engine.InterestManagement.RealmMap;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.db.archive.CityRecord; import engine.db.archive.CityRecord;
@ -394,7 +395,7 @@ public class Building extends AbstractWorldObject {
this.rank = newRank; this.rank = newRank;
// New rank means new mesh // New rank means new mesh
int oldMeshID = this.meshUUID;
newMeshUUID = this.getBlueprint().getMeshForRank(this.rank); newMeshUUID = this.getBlueprint().getMeshForRank(this.rank);
this.meshUUID = newMeshUUID; this.meshUUID = newMeshUUID;
@ -428,6 +429,15 @@ public class Building extends AbstractWorldObject {
BuildingManager.cleanupHirelings(this); BuildingManager.cleanupHirelings(this);
this.isDeranking.compareAndSet(true, false); 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() { public final int getOwnerUUID() {

Loading…
Cancel
Save