Browse Source

Refactored Zone to new system

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
bf06734a9b
  1. 68
      src/engine/objects/Zone.java

68
src/engine/objects/Zone.java

@ -29,6 +29,8 @@ import java.util.concurrent.ConcurrentHashMap; @@ -29,6 +29,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class Zone extends AbstractWorldObject {
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
public static long lastRespawn = 0;
public final Set<Building> zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
@ -58,8 +60,6 @@ public class Zone extends AbstractWorldObject { @@ -58,8 +60,6 @@ public class Zone extends AbstractWorldObject {
public float global_height = 0;
public float seaLevel = 0f;
public float sea_level_offset = 0;
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
public static long lastRespawn = 0;
public float major_radius;
public float minor_radius;
public float min_blend;
@ -121,36 +121,6 @@ public class Zone extends AbstractWorldObject { @@ -121,36 +121,6 @@ public class Zone extends AbstractWorldObject {
}
@Override
public void runAfterLoad() {
// First zone is always the seafloor
if (ZoneManager.seaFloor == null)
ZoneManager.seaFloor = this;
if (this.terrain_type.equals("NONE"))
this.terrain = null;
else
this.terrain = new Terrain(this);
//this needs to be here specifically for new zones created after server boot (e.g. player city zones)
Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID);
this.setParent(parentZone);
if (this.min_level == 0 && parentZone != null) {
this.min_level = parentZone.min_level;
this.max_level = parentZone.max_level;
}
if (parentZone != null)
parentZone.addNode(this);
ZoneManager.populateZoneCollections(this);
}
public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) {
if (zone.template == 0 && zone.playerCityUUID == 0)
@ -204,6 +174,30 @@ public class Zone extends AbstractWorldObject { @@ -204,6 +174,30 @@ public class Zone extends AbstractWorldObject {
}
}
@Override
public void runAfterLoad() {
// First zone is always the seafloor
if (ZoneManager.seaFloor == null)
ZoneManager.seaFloor = this;
if (this.terrain_type.equals("NONE"))
this.terrain = null;
else
this.terrain = new Terrain(this);
this.setParent();
if (this.min_level == 0 && this.parent != null) {
this.min_level = this.parent.min_level;
this.max_level = this.parent.max_level;
}
ZoneManager.populateZoneCollections(this);
}
/* Method sets a default value for player cities
* otherwise using values derived from the loadnum
* field in the obj_zone database table.
@ -217,14 +211,13 @@ public class Zone extends AbstractWorldObject { @@ -217,14 +211,13 @@ public class Zone extends AbstractWorldObject {
}
public void setParent(final Zone value) {
public void setParent() {
this.parent = value;
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
this.parent = ZoneManager.getZoneByZoneID(parentZoneID);
// Seafloor
if (this.parent == null) {
if (ZoneManager.seaFloor.equals(this)) {
this.absX = this.xOffset;
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
this.global_height = MBServerStatics.SEA_FLOOR_ALTITUDE;
@ -274,7 +267,7 @@ public class Zone extends AbstractWorldObject { @@ -274,7 +267,7 @@ public class Zone extends AbstractWorldObject {
// Macro zones have icons.
if (this.guild_zone == true)
if (this.guild_zone)
return false;
if (this.parent == null)
@ -318,6 +311,7 @@ public class Zone extends AbstractWorldObject { @@ -318,6 +311,7 @@ public class Zone extends AbstractWorldObject {
return this.parent.equals(ZoneManager.seaFloor);
}
public void setHash() {
this.hash = DataWarehouse.hasher.encrypt(this.getObjectUUID());

Loading…
Cancel
Save