rework of world altitude calculation.

This commit is contained in:
2023-09-12 14:51:04 -04:00
parent 5d9d13ce07
commit 045ee73b61
7 changed files with 28 additions and 60 deletions
+1 -48
View File
@@ -56,7 +56,7 @@ public class Zone extends AbstractGameObject {
private boolean isNPCCity = false;
private boolean isPlayerCity = false;
private String hash;
private float worldAltitude = 0;
public float worldAltitude = 0;
private float seaLevel = 0;
//public static ArrayList<Mob> respawnQue = new ArrayList<>();
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
@@ -220,49 +220,6 @@ public class Zone extends AbstractGameObject {
return Icon1;
}
public void generateWorldAltitude() {
if (ZoneManager.getSeaFloor().getObjectUUID() == this.getObjectUUID()) {
this.worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
return;
}
Zone parentZone = this.parent;
Zone currentZone = this;
float altitude = this.absY;
//seafloor only zone with null parent;
while (parentZone != ZoneManager.getSeaFloor()) {
if (parentZone.getHeightMap() != null) {
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone);
altitude += parentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
}
currentZone = parentZone;
parentZone = parentZone.parent;
}
this.worldAltitude = altitude;
if (ZoneManager.getSeaFloor().equals(this))
this.seaLevel = 0;
else if
(this.getHeightMap() != null && this.getHeightMap().getSeaLevel() == 0) {
this.seaLevel = this.parent.seaLevel;
} else if (this.getHeightMap() != null) {
this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel();
} else {
this.seaLevel = this.parent.seaLevel;
}
}
public Zone getParent() {
return this.parent;
}
@@ -420,8 +377,4 @@ public class Zone extends AbstractGameObject {
return seaLevel;
}
public float getWorldAltitude() {
return worldAltitude;
}
}