Browse Source

destroy and remove form cache and DB all buildinsg within city when its being destroyed

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
3bcda38bb7
  1. 35
      src/engine/workthreads/DestroyCityThread.java

35
src/engine/workthreads/DestroyCityThread.java

@ -19,6 +19,7 @@ package engine.workthreads; @@ -19,6 +19,7 @@ package engine.workthreads;
*/
import engine.Enum;
import engine.gameManager.BuildingManager;
import engine.gameManager.DbManager;
import engine.gameManager.GuildManager;
import engine.gameManager.ZoneManager;
@ -53,7 +54,6 @@ public class DestroyCityThread implements Runnable { @@ -53,7 +54,6 @@ public class DestroyCityThread implements Runnable {
// Member variable assignment
cityZone = city.getParent();
newParent = cityZone.getParent();
formerGuild = city.getTOL().getGuild();
// Former guild loses it's tree!
@ -99,36 +99,15 @@ public class DestroyCityThread implements Runnable { @@ -99,36 +99,15 @@ public class DestroyCityThread implements Runnable {
if (cityBuilding.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE))
continue;
// All buildings are moved to a location relative
// to their new parent zone
localCoords = ZoneManager.worldToLocal(cityBuilding.getLoc(), newParent);
DbManager.BuildingQueries.MOVE_BUILDING(cityBuilding.getObjectUUID(), newParent.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
// All buildings are re-parented to a zone one node
// higher in the tree (continent) as we will be
// deleting the city zone very shortly.
if (cityBuilding.getParentZoneID() != newParent.getParentZoneID())
cityBuilding.setParentZone(newParent);
// No longer a tree, no longer any protection contract!
cityBuilding.setProtectionState(Enum.ProtectionState.NONE);
// Destroy all remaining city assets
if ((cityBuilding.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK)
|| (cityBuilding.getBlueprint().isWallPiece())
|| (cityBuilding.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.SHRINE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.TOL)
|| (cityBuilding.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.SPIRE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.WAREHOUSE)) {
//destroy all buildings if we are destroying the city itself
if (cityBuilding.getRank() != -1)
cityBuilding.setRank(-1);
if(BuildingManager.getBuildingFromCache(cityBuilding.getObjectUUID()) != null){
cityBuilding.removeFromCache();
DbManager.BuildingQueries.DELETE_FROM_DATABASE(cityBuilding);
}
}
if (city.getRealm() != null)

Loading…
Cancel
Save