From fb1d6a3248b8955c7fbab4da82044d01322a6336 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 21 May 2024 17:01:23 -0500 Subject: [PATCH] auto update NPC slot location and reload on mesh change for buildings --- src/engine/objects/Building.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index e7728433..71c883da 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -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() {