From 5858fa4de4efdc09890597795168f74dc878cf95 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 08:20:28 -0400 Subject: [PATCH] R8 bonus application moved to City --- src/engine/objects/Building.java | 29 +------------------------- src/engine/objects/City.java | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 2b85d26d..aa06721d 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -994,34 +994,6 @@ public class Building extends AbstractWorldObject { } } - // Apply health bonus and special mesh for realm if applicable - if ((this.getCity() != null) && this.getCity().getTOL() != null && (this.getCity().getTOL().rank == 8)) { - - // Update mesh accordingly - if (this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) - this.meshUUID = Realm.getRealmMesh(this.getCity()); - - // Apply realm capital health bonus. - // Do not apply bonus to banestones or TOL's. *** Refactor: - // Possibly only protected buildings? Needs some thought. - - float missingHealth = 0; - - if (this.health.get() != 0) - missingHealth = this.healthMax - this.health.get(); - - if ((this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) - && (this.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)) { - this.healthMax += (this.healthMax * Realm.getRealmHealthMod(this.getCity())); - - if (this.health.get() != 0) - this.health.set(this.healthMax - missingHealth); - - if (this.health.get() > this.healthMax) - this.health.set(this.healthMax); - } - } - // Set bounds for this building Bounds buildingBounds = Bounds.borrow(); @@ -1043,6 +1015,7 @@ public class Building extends AbstractWorldObject { //add furniture to region cache. floor and level are reversed in database, //TODO Fix Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z); + if (region != null) Regions.FurnitureRegionMap.put(this.getObjectUUID(), region); } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 9bca4b2c..a27dc5a8 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -761,6 +761,41 @@ public class City extends AbstractWorldObject { } } + // Apply health bonus and special mesh for realm if applicable + + if (this.getTOL().rank == 8) { + + // Update mesh accordingly + + this.getTOL().meshUUID = Realm.getRealmMesh(this); + + // Apply realm capital health bonus. + // Do not apply bonus to banestones or TOL's. *** Refactor: + // Possibly only protected buildings? Needs some thought. + + float missingHealth = 0; + + if (this.health.get() != 0) + missingHealth = this.healthMax - this.health.get(); + + for (Building building : this.parentZone.zoneBuildingSet) { + + if (building.getBlueprint() != null && + building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE && + building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) { + + building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this)); + + if (this.health.get() != 0) + this.health.set(this.healthMax - missingHealth); + + if (this.health.get() > this.healthMax) + this.health.set(this.healthMax); + } + + } + } + // Banes are loaded for this city from the database at this point if (this.getBane() == null)