From be2b29ccc79231bd4a9ea1d62ec6e9f51842affe Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 9 Sep 2023 08:38:00 -0400 Subject: [PATCH] New method implemented. --- src/engine/gameManager/BuildingManager.java | 32 +++------------------ 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 3fe97f9b..78094707 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -364,42 +364,18 @@ public enum BuildingManager { if (building.getRank() < 1) { - for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) { + for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) + BuildingManager.removeHireling(building, slottedNPC); - if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC) - ((NPC) slottedNPC).remove(); - else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob) - NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building); - } return; } // Delete hireling if building has deranked. - for (AbstractCharacter hireling : building.getHirelings().keySet()) { - - NPC npc = null; - Mob mob = null; - if (hireling.getObjectType() == Enum.GameObjectType.NPC) - npc = (NPC) hireling; - else if (hireling.getObjectType() == Enum.GameObjectType.Mob) - mob = (Mob) hireling; + for (AbstractCharacter hireling : building.getHirelings().keySet()) { if (building.getHirelings().get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank())) - - if (npc != null) { - if (!npc.remove()) - Logger.error("Failed to remove npc " + npc.getObjectUUID() - + "from Building " + building.getObjectUUID()); - else - building.getHirelings().remove(npc); - } else if (mob != null) { - if (!NPCManager.removeMobileFromBuilding(mob, building)) - Logger.error("Failed to remove npc " + npc.getObjectUUID() - + "from Building " + building.getObjectUUID()); - else - building.getHirelings().remove(npc); - } + BuildingManager.removeHireling(building, hireling); }