bonus code cleanup
This commit is contained in:
@@ -33,7 +33,6 @@ import engine.net.client.msg.ApplyBuildingEffectMsg;
|
||||
import engine.net.client.msg.UpdateObjectMsg;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -12,6 +12,8 @@ package engine.objects;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.math.Bounds;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Area;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@@ -45,5 +47,10 @@ public class MeshBounds {
|
||||
Bounds.meshBoundsCache = DbManager.BuildingQueries.LOAD_MESH_BOUNDS();
|
||||
}
|
||||
|
||||
|
||||
public Area getArea(){
|
||||
Polygon area = new Polygon();
|
||||
area.addPoint((int) this.minX, (int) this.minZ);
|
||||
area.addPoint((int) this.maxX, (int) this.maxZ);
|
||||
return new Area(area);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.server.MBServerStatics;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Area;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -360,4 +362,12 @@ public class Regions {
|
||||
public boolean isExit() {
|
||||
return exit;
|
||||
}
|
||||
|
||||
public Area getArea(){
|
||||
Polygon area = new Polygon();
|
||||
for( Vector3f point : this.regionPoints){
|
||||
area.addPoint((int) point.x, (int) point.z);
|
||||
}
|
||||
return new Area(area);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,19 @@
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import java.awt.geom.Area;
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -65,6 +67,8 @@ public class Zone extends AbstractWorldObject {
|
||||
|
||||
public Terrain terrain = null;
|
||||
|
||||
public Area navMesh;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
@@ -181,8 +185,27 @@ public class Zone extends AbstractWorldObject {
|
||||
|
||||
ZoneManager.populateZoneCollections(this);
|
||||
|
||||
this.bakeNavMesh();
|
||||
|
||||
}
|
||||
|
||||
public void bakeNavMesh(){
|
||||
int xPoint = (int)(this.loc.x - this.bounds.getHalfExtents().x);
|
||||
int zPoint = (int) (this.loc.z - this.bounds.getHalfExtents().y);
|
||||
int extentsX = (int) (this.bounds.getHalfExtents().x * 2);
|
||||
int extentsZ = (int) (this.bounds.getHalfExtents().y * 2);
|
||||
|
||||
this.navMesh = new Area(new Rectangle(xPoint, zPoint, extentsX, extentsZ));
|
||||
|
||||
for(Building building : this.zoneBuildingSet){
|
||||
for(Regions region : building.getBounds().getRegions())
|
||||
this.navMesh.add(region.getArea());
|
||||
|
||||
MeshBounds meshBounds = Bounds.meshBoundsCache.get(building.getMeshUUID());
|
||||
if(meshBounds != null)
|
||||
this.navMesh.subtract(meshBounds.getArea());
|
||||
}
|
||||
}
|
||||
/* Method sets a default value for player cities
|
||||
* otherwise using values derived from the loadnum
|
||||
* field in the obj_zone database table.
|
||||
|
||||
Reference in New Issue
Block a user