|
|
@ -75,11 +75,14 @@ public class Building extends AbstractWorldObject { |
|
|
|
public int level; |
|
|
|
public int level; |
|
|
|
public AtomicBoolean isDeranking = new AtomicBoolean(false); |
|
|
|
public AtomicBoolean isDeranking = new AtomicBoolean(false); |
|
|
|
public LocalDateTime maintDateTime; |
|
|
|
public LocalDateTime maintDateTime; |
|
|
|
protected Resists resists; |
|
|
|
|
|
|
|
/* The Blueprint class has methods able to derive |
|
|
|
/* The Blueprint class has methods able to derive |
|
|
|
* all defining characteristics of this building, |
|
|
|
* all defining characteristics of this building, |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int blueprintUUID = 0; |
|
|
|
public int blueprintUUID = 0; |
|
|
|
|
|
|
|
public int rank; |
|
|
|
|
|
|
|
public ArrayList<Vector3fImmutable> patrolPoints; |
|
|
|
|
|
|
|
public ProtectionState protectionState = ProtectionState.NONE; |
|
|
|
|
|
|
|
protected Resists resists; |
|
|
|
private float w = 1.0f; |
|
|
|
private float w = 1.0f; |
|
|
|
private Vector3f meshScale = new Vector3f(1.0f, 1.0f, 1.0f); |
|
|
|
private Vector3f meshScale = new Vector3f(1.0f, 1.0f, 1.0f); |
|
|
|
private int doorState = 0; |
|
|
|
private int doorState = 0; |
|
|
@ -88,15 +91,12 @@ public class Building extends AbstractWorldObject { |
|
|
|
private int maxGold; |
|
|
|
private int maxGold; |
|
|
|
private int effectFlags = 0; |
|
|
|
private int effectFlags = 0; |
|
|
|
private String name = ""; |
|
|
|
private String name = ""; |
|
|
|
public int rank; |
|
|
|
|
|
|
|
private boolean ownerIsNPC = true; |
|
|
|
private boolean ownerIsNPC = true; |
|
|
|
private boolean spireIsActive = false; |
|
|
|
private boolean spireIsActive = false; |
|
|
|
private ConcurrentHashMap<String, JobContainer> timers = null; |
|
|
|
private ConcurrentHashMap<String, JobContainer> timers = null; |
|
|
|
private ConcurrentHashMap<String, Long> timestamps = null; |
|
|
|
private ConcurrentHashMap<String, Long> timestamps = null; |
|
|
|
private ConcurrentHashMap<Integer, BuildingFriends> friends; |
|
|
|
private ConcurrentHashMap<Integer, BuildingFriends> friends; |
|
|
|
private ConcurrentHashMap<Integer, Condemned> condemned; |
|
|
|
private ConcurrentHashMap<Integer, Condemned> condemned; |
|
|
|
public ArrayList<Vector3fImmutable> patrolPoints; |
|
|
|
|
|
|
|
public ProtectionState protectionState = ProtectionState.NONE; |
|
|
|
|
|
|
|
private ArrayList<Building> children = null; |
|
|
|
private ArrayList<Building> children = null; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -164,7 +164,7 @@ public class Building extends AbstractWorldObject { |
|
|
|
this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault()); |
|
|
|
this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault()); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e.toString()); |
|
|
|
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -385,14 +385,14 @@ public class Building extends AbstractWorldObject { |
|
|
|
Mine.SendMineAttackMessage(this); |
|
|
|
Mine.SendMineAttackMessage(this); |
|
|
|
|
|
|
|
|
|
|
|
City playerCity = ZoneManager.getCityAtLocation(this.loc); |
|
|
|
City playerCity = ZoneManager.getCityAtLocation(this.loc); |
|
|
|
if(playerCity != null){ |
|
|
|
if (playerCity != null) { |
|
|
|
if(this.getGuild().getNation().equals(playerCity.getTOL().getGuild().getNation())){ |
|
|
|
if (this.getGuild().getNation().equals(playerCity.getTOL().getGuild().getNation())) { |
|
|
|
//friendly building has been attacked, add attacker to city outlaw list
|
|
|
|
//friendly building has been attacked, add attacker to city outlaw list
|
|
|
|
if(!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) |
|
|
|
if (!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) |
|
|
|
playerCity.cityOutlaws.add(attacker.getObjectUUID()); |
|
|
|
playerCity.cityOutlaws.add(attacker.getObjectUUID()); |
|
|
|
for(Mob guard : playerCity.getParent().zoneMobSet) |
|
|
|
for (Mob guard : playerCity.getParent().zoneMobSet) |
|
|
|
if(guard.combatTarget == null) |
|
|
|
if (guard.combatTarget == null) |
|
|
|
guard.setCombatTarget(attacker); |
|
|
|
guard.setCombatTarget(attacker); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -888,72 +888,71 @@ public class Building extends AbstractWorldObject { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void runAfterLoad() { |
|
|
|
public void runAfterLoad() { |
|
|
|
|
|
|
|
|
|
|
|
// Set Parent Zone
|
|
|
|
// Set Parent Zone
|
|
|
|
|
|
|
|
|
|
|
|
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); |
|
|
|
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); |
|
|
|
this.parentZone.zoneBuildingSet.add(this); |
|
|
|
this.parentZone.zoneBuildingSet.add(this); |
|
|
|
|
|
|
|
|
|
|
|
// Lookup building blueprint
|
|
|
|
// Lookup building blueprint
|
|
|
|
|
|
|
|
|
|
|
|
Blueprint blueprint; |
|
|
|
Blueprint blueprint; |
|
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
|
|
|
|
blueprint = Blueprint._meshLookup.get(meshUUID); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
blueprint = this.getBlueprint(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Log error if something went horrible wrong
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((this.blueprintUUID != 0) && (blueprint == null)) |
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); |
|
|
|
blueprint = Blueprint._meshLookup.get(meshUUID); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
blueprint = this.getBlueprint(); |
|
|
|
|
|
|
|
|
|
|
|
// Note: We handle R8 tree edge case for mesh and health
|
|
|
|
// Log error if something went horrible wrong
|
|
|
|
// after city is loaded to avoid recursive result set call
|
|
|
|
|
|
|
|
// in City resulting in a stack ovreflow.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (blueprint != null) { |
|
|
|
if ((this.blueprintUUID != 0) && (blueprint == null)) |
|
|
|
|
|
|
|
Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
// Only switch mesh for player dropped structures
|
|
|
|
// Note: We handle R8 tree edge case for mesh and health
|
|
|
|
|
|
|
|
// after city is loaded to avoid recursive result set call
|
|
|
|
|
|
|
|
// in City resulting in a stack ovreflow.
|
|
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID != 0) |
|
|
|
if (blueprint != null) { |
|
|
|
this.meshUUID = blueprint.getMeshForRank(rank); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.healthMax = blueprint.getMaxHealth(this.rank); |
|
|
|
// Only switch mesh for player dropped structures
|
|
|
|
|
|
|
|
|
|
|
|
// If this object has no blueprint but is a blueprint
|
|
|
|
if (this.blueprintUUID != 0) |
|
|
|
// mesh then set it's current health to max health
|
|
|
|
this.meshUUID = blueprint.getMeshForRank(rank); |
|
|
|
|
|
|
|
|
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
this.healthMax = blueprint.getMaxHealth(this.rank); |
|
|
|
this.setHealth(healthMax); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>()); |
|
|
|
// If this object has no blueprint but is a blueprint
|
|
|
|
|
|
|
|
// mesh then set it's current health to max health
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
if (this.blueprintUUID == 0) |
|
|
|
this.healthMax = 100000; // Structures with no blueprint mesh
|
|
|
|
|
|
|
|
this.setHealth(healthMax); |
|
|
|
this.setHealth(healthMax); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resists = new Resists("Building"); |
|
|
|
this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>()); |
|
|
|
|
|
|
|
|
|
|
|
if (this.parentZone != null) { |
|
|
|
} else { |
|
|
|
if (this.parentBuildingID != 0) { |
|
|
|
this.healthMax = 100000; // Structures with no blueprint mesh
|
|
|
|
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); |
|
|
|
this.setHealth(healthMax); |
|
|
|
if (parentBuilding != null) { |
|
|
|
} |
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
resists = new Resists("Building"); |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Altitude of this building is derived from the heightmap engine.
|
|
|
|
if (this.parentZone != null) { |
|
|
|
|
|
|
|
if (this.parentBuildingID != 0) { |
|
|
|
|
|
|
|
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); |
|
|
|
|
|
|
|
if (parentBuilding != null) { |
|
|
|
|
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); |
|
|
|
|
|
|
|
|
|
|
|
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); |
|
|
|
|
|
|
|
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); |
|
|
|
|
|
|
|
this.setLoc(tempLoc); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Altitude of this building is derived from the heightmap engine.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); |
|
|
|
|
|
|
|
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); |
|
|
|
|
|
|
|
this.setLoc(tempLoc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Submit upgrade job if building is currently set to rank.
|
|
|
|
// Submit upgrade job if building is currently set to rank.
|
|
|
|
|
|
|
|
|
|
|
@ -970,48 +969,36 @@ public class Building extends AbstractWorldObject { |
|
|
|
this.friends = BuildingManager._buildingFriends.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); |
|
|
|
this.friends = BuildingManager._buildingFriends.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); |
|
|
|
this.condemned = BuildingManager._buildingCondemned.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); |
|
|
|
this.condemned = BuildingManager._buildingCondemned.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
|
|
|
|
// Set bounds for this building
|
|
|
|
|
|
|
|
|
|
|
|
if (this.ownerIsNPC) { |
|
|
|
|
|
|
|
if (NPC.getNPC(this.ownerUUID) == null) |
|
|
|
|
|
|
|
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (this.ownerUUID != 0) { |
|
|
|
|
|
|
|
if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) { |
|
|
|
|
|
|
|
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set bounds for this building
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bounds buildingBounds = Bounds.borrow(); |
|
|
|
Bounds buildingBounds = Bounds.borrow(); |
|
|
|
buildingBounds.setBounds(this); |
|
|
|
buildingBounds.setBounds(this); |
|
|
|
this.setBounds(buildingBounds); |
|
|
|
this.setBounds(buildingBounds); |
|
|
|
|
|
|
|
|
|
|
|
//create a new list for children if the building is not a child. children list default is null.
|
|
|
|
//create a new list for children if the building is not a child. children list default is null.
|
|
|
|
//TODO Remove Furniture/Child buildings from building class and move them into a seperate class.
|
|
|
|
//TODO Remove Furniture/Child buildings from building class and move them into a seperate class.
|
|
|
|
|
|
|
|
|
|
|
|
if (this.parentBuildingID == 0) |
|
|
|
if (this.parentBuildingID == 0) |
|
|
|
this.children = new ArrayList<>(); |
|
|
|
this.children = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
if (this.parentBuildingID != 0) { |
|
|
|
if (this.parentBuildingID != 0) { |
|
|
|
Building parent = BuildingManager.getBuildingFromCache(this.parentBuildingID); |
|
|
|
Building parent = BuildingManager.getBuilding(this.parentBuildingID); |
|
|
|
|
|
|
|
|
|
|
|
if (parent != null) { |
|
|
|
if (parent != null) { |
|
|
|
parent.children.add(this); |
|
|
|
parent.children.add(this); |
|
|
|
|
|
|
|
|
|
|
|
//add furniture to region cache. floor and level are reversed in database, //TODO Fix
|
|
|
|
//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); |
|
|
|
Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z); |
|
|
|
|
|
|
|
|
|
|
|
if (region != null) |
|
|
|
|
|
|
|
Regions.FurnitureRegionMap.put(this.getObjectUUID(), region); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (region != null) |
|
|
|
|
|
|
|
Regions.FurnitureRegionMap.put(this.getObjectUUID(), region); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.upgradeDateTime != null) |
|
|
|
} |
|
|
|
BuildingManager.submitUpgradeJob(this); |
|
|
|
|
|
|
|
|
|
|
|
if (this.upgradeDateTime != null) |
|
|
|
|
|
|
|
BuildingManager.submitUpgradeJob(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized boolean setOwner(AbstractCharacter newOwner) { |
|
|
|
public synchronized boolean setOwner(AbstractCharacter newOwner) { |
|
|
@ -1400,10 +1387,7 @@ public class Building extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
public boolean assetIsProtected() { |
|
|
|
public boolean assetIsProtected() { |
|
|
|
|
|
|
|
|
|
|
|
boolean outValue = false; |
|
|
|
boolean outValue = protectionState.equals(ProtectionState.PROTECTED); |
|
|
|
|
|
|
|
|
|
|
|
if (protectionState.equals(ProtectionState.PROTECTED)) |
|
|
|
|
|
|
|
outValue = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (protectionState.equals(ProtectionState.CONTRACT)) |
|
|
|
if (protectionState.equals(ProtectionState.CONTRACT)) |
|
|
|
outValue = true; |
|
|
|
outValue = true; |
|
|
|