Start refactor to use templates

This commit is contained in:
2023-10-20 17:01:42 -04:00
parent cb0ba901de
commit 091b1a1d5b
8 changed files with 46 additions and 64 deletions
+11 -37
View File
@@ -34,6 +34,8 @@ public class Zone extends AbstractWorldObject {
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<>());
public ZoneTemplate template;
public final int playerCityUUID;
public final String zoneName;
public final float xOffset;
@@ -58,17 +60,7 @@ public class Zone extends AbstractWorldObject {
public boolean guild_zone;
public String hash;
public float global_height = 0;
public float seaLevel = 0f;
public float sea_level_offset = 0;
public float major_radius;
public float minor_radius;
public float min_blend;
public float max_blend;
public String sea_level_type;
public float sea_level;
public String terrain_type;
public float terrain_max_y;
public int terrain_image;
public Terrain terrain = null;
@@ -93,26 +85,6 @@ public class Zone extends AbstractWorldObject {
this.icon3 = rs.getString("icon3");
this.min_level = rs.getInt("min_level");
this.max_level = rs.getInt("max_level");
this.major_radius = rs.getFloat("major_radius");
this.minor_radius = rs.getFloat("minor_radius");
this.min_blend = rs.getFloat("min_blend");
this.max_blend = rs.getFloat("max_blend");
this.sea_level_type = rs.getString("sea_level_type");
this.sea_level_offset = rs.getFloat("sea_level");
this.terrain_type = rs.getString("terrain_type");
this.terrain_max_y = rs.getFloat("terrain_max_y");
this.terrain_image = rs.getInt("terrain_image");
// Configuration for player cities
if (this.guild_zone) {
this.max_blend = 128;
this.min_blend = 128;
this.terrain_max_y = 5;
this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
this.terrain_type = "PLANAR";
}
// If zone doesn't yet hava a hash then write it back to the zone table
@@ -177,12 +149,14 @@ public class Zone extends AbstractWorldObject {
@Override
public void runAfterLoad() {
this.template = ZoneManager._zone_templates.get(this.templateID);
// First zone is always the seafloor
if (ZoneManager.seaFloor == null)
ZoneManager.seaFloor = this;
if (this.terrain_type.equals("NONE"))
if (this.template.terrain_type.equals("NONE"))
this.terrain = null;
else
this.terrain = new Terrain(this);
@@ -207,7 +181,7 @@ public class Zone extends AbstractWorldObject {
// Set initial bounds object
this.bounds = Bounds.borrow();
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.major_radius, this.minor_radius), 0.0f);
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.template.major_radius, this.template.minor_radius), 0.0f);
}
@@ -225,7 +199,7 @@ public class Zone extends AbstractWorldObject {
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
this.global_height = MBServerStatics.SEA_FLOOR_ALTITUDE;
this.absZ = this.zOffset;
this.seaLevel = 0;
this.sea_level = 0;
this.setBounds();
return;
}
@@ -253,15 +227,15 @@ public class Zone extends AbstractWorldObject {
return;
}
switch (this.sea_level_type) {
switch (this.template.sea_level_type) {
case "WORLD":
this.sea_level = world_sea_level + this.sea_level_offset;
this.sea_level = world_sea_level + this.template.sea_level;
break;
case "PARENT":
this.sea_level = this.parent.sea_level + this.sea_level_offset;
this.sea_level = this.parent.sea_level + this.template.sea_level;
break;
case "SELF":
this.sea_level = this.global_height + this.sea_level_offset;
this.sea_level = this.global_height + this.template.sea_level;
break;
}
}