forked from MagicBane/Server
Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fe4f32302 | |||
| d6ad0ecbd3 | |||
| efdf19f22e | |||
| 76a71b5984 | |||
| cf09f447bd | |||
| 8dc6a0627c | |||
| 8b095976ef | |||
| 83606046ba | |||
| adcf3fd9b6 | |||
| e983a32b5d | |||
| 9d8f800c2a | |||
| 05e90d495f | |||
| 18f70b6d5c | |||
| 86c8e985be | |||
| b6b5db41bd | |||
| d573534f6d | |||
| 06df109a18 | |||
| f077370034 | |||
| 94e16bdf3d | |||
| a52f0941b7 | |||
| 840dc83987 | |||
| 5b9d1dd6eb | |||
| 6215e15e82 | |||
| e8a39e596e | |||
| 90b516bbb9 | |||
| 561170eb44 | |||
| 68920f150d | |||
| a54e8c2176 | |||
| c77f38dec1 | |||
| 5a57677013 | |||
| 306c64d236 | |||
| 0b05e661c7 | |||
| a94a400102 | |||
| 4bff36d7bb | |||
| 969b36e6fd | |||
| 688553e6c6 | |||
| 4f057ee851 | |||
| fd47c90f4f | |||
| 253ca2344e | |||
| 95f09a255e | |||
| 31ea74f98c | |||
| 67c474dbdf | |||
| c65a713bae | |||
| e3641872d0 | |||
| c25fdf3823 | |||
| 7c28efb47c | |||
| c92316f03e | |||
| e330f190fe | |||
| ae52735131 | |||
| 59025c2585 | |||
| 6354eb2893 | |||
| 3ad97a7ce3 | |||
| f8cbeb4cc6 | |||
| f1e41e47cf |
@@ -0,0 +1,27 @@
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
import engine.objects.Building;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CollisionManager {
|
||||
public static HashMap<Integer, ArrayList<MeshData>> structure_meshes;
|
||||
public static HashMap<Integer,ArrayList<Triangle>> mesh_triangles;
|
||||
public static boolean CollisionDetected(Building building, Line2D travelLine, float charHeight, float charY){
|
||||
|
||||
if(building.buildingRect != null)
|
||||
if(!travelLine.intersects(building.buildingRect) && !building.buildingRect.contains(travelLine.getP1()) && !building.buildingRect.contains(travelLine.getP2()))
|
||||
return false;
|
||||
|
||||
for(Mesh mesh : building.buildingMeshes)
|
||||
if(mesh.collides(travelLine))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.Building;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Mesh {
|
||||
public ArrayList<Triangle> triangles;
|
||||
public Vector3f mesh_end_point;
|
||||
public Vector3f mesh_ref_point;
|
||||
public Vector3f mesh_location;
|
||||
public float mesh_max_y;
|
||||
public float mesh_min_y;
|
||||
public Vector3f mesh_scale;
|
||||
public int mesh_id;
|
||||
public int parent_prop_id;
|
||||
public int parent_structure_id;
|
||||
public int parentUUID;
|
||||
public Rectangle2D.Float mesh_bounds;
|
||||
public MeshData meshData;
|
||||
|
||||
public void update(){
|
||||
this.BakeTriangles();
|
||||
}
|
||||
public Vector3f getLocation(){
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentUUID);
|
||||
int degrees = (int)Math.toDegrees(parentBuilding.getBounds().getQuaternion().angleY);
|
||||
Vector3f parentLoc = new Vector3f(parentBuilding.loc.x,parentBuilding.loc.y,parentBuilding.loc.z);
|
||||
Vector3f offsetLoc = parentLoc.add(this.meshData.loc);
|
||||
Vector3f rotatedPoint = Vector3f.rotateAroundPoint(offsetLoc,parentLoc,degrees);
|
||||
return rotatedPoint;
|
||||
}
|
||||
|
||||
public void BakeTriangles(){
|
||||
|
||||
if(CollisionManager.mesh_triangles.containsKey(this.meshData.meshID) == false){
|
||||
Logger.error("Failed To Bake Triangles For Mesh: " + this.meshData.meshID);
|
||||
return;
|
||||
}
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentUUID);
|
||||
int degrees = (int)Math.toDegrees(parentBuilding.getBounds().getQuaternion().angleY);
|
||||
Vector3f parentLoc = new Vector3f(parentBuilding.loc.x,parentBuilding.loc.y,parentBuilding.loc.z);
|
||||
Vector3f offsetLoc = parentLoc.add(this.meshData.loc);
|
||||
|
||||
for(Triangle tri : CollisionManager.mesh_triangles.get(this.meshData.meshID)) {
|
||||
|
||||
Triangle newTri = new Triangle();
|
||||
|
||||
Vector3f Point1 = offsetLoc.add(new Vector3f(tri.point1.x,offsetLoc.y,tri.point1.y));
|
||||
Vector3f Point2 = offsetLoc.add(new Vector3f(tri.point2.x,offsetLoc.y,tri.point2.y));
|
||||
Vector3f Point3 = offsetLoc.add(new Vector3f(tri.point3.x,offsetLoc.y,tri.point3.y));
|
||||
|
||||
Vector3f rotatedPoint1 = Vector3f.rotateAroundPoint(Point1,offsetLoc,degrees);
|
||||
Vector3f rotatedPoint2 = Vector3f.rotateAroundPoint(Point2,offsetLoc,degrees);
|
||||
Vector3f rotatedPoint3 = Vector3f.rotateAroundPoint(Point3,offsetLoc,degrees);
|
||||
|
||||
newTri.point1 = new Point2D.Float(rotatedPoint1.x,rotatedPoint1.z);
|
||||
newTri.point2 = new Point2D.Float(rotatedPoint2.x,rotatedPoint2.z);
|
||||
newTri.point3 = new Point2D.Float(rotatedPoint3.x,rotatedPoint3.z);
|
||||
|
||||
newTri.sides = new ArrayList<>();
|
||||
newTri.sides.add(new Line2D.Float(newTri.point1,newTri.point2));
|
||||
newTri.sides.add(new Line2D.Float(newTri.point2,newTri.point3));
|
||||
newTri.sides.add(new Line2D.Float(newTri.point3,newTri.point1));
|
||||
|
||||
this.triangles.add(newTri);
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean collides(Line2D line){
|
||||
for(Triangle tri : this.triangles)
|
||||
if(tri.collides(line))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
|
||||
public class MeshData {
|
||||
public int propID;
|
||||
public int meshID;
|
||||
public Vector3f loc;
|
||||
public Vector3f scale;
|
||||
public Vector3f refPoint;
|
||||
public Vector3f endPoint;
|
||||
public float maxY;
|
||||
public float minY;
|
||||
}
|
||||
+8
-7
@@ -1,18 +1,19 @@
|
||||
package engine.collisionEngine;
|
||||
package engine.CollisionEngine;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MeshTriangle {
|
||||
public class Triangle {
|
||||
public Point2D.Float point1;
|
||||
public Point2D.Float point2;
|
||||
public Point2D.Float point3;
|
||||
public ArrayList<Line2D.Float> sides;
|
||||
|
||||
public boolean collides(Line2D.Float line){
|
||||
for(Line2D.Float side : sides)
|
||||
if(line.intersectsLine(side))
|
||||
public ArrayList<Line2D> sides;
|
||||
public boolean collides(Line2D line)
|
||||
{
|
||||
for(Line2D side : sides)
|
||||
if(side.intersectsLine(line))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -1,10 +0,0 @@
|
||||
package engine.collisionEngine;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CollisionManager {
|
||||
public static HashMap<Integer, ArrayList<MeshTriangle>> mesh_triangles;
|
||||
public static HashMap<Integer, ArrayList<MeshData>> structure_meshes;
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package engine.collisionEngine;
|
||||
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.Building;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Mesh {
|
||||
public int parentUUID;
|
||||
public MeshData meshData;
|
||||
private int meshID;
|
||||
public Rectangle2D.Float bounds;
|
||||
public ArrayList<MeshTriangle> triangles;
|
||||
public Vector3f mesh_loc;
|
||||
public Vector3f mesh_ref;
|
||||
public Vector3f mesh_end;
|
||||
public float mesh_maxY;
|
||||
public float mesh_minY;
|
||||
|
||||
public Mesh(MeshData data, int parentUUID){
|
||||
this.meshData = data;
|
||||
this.parentUUID = parentUUID;
|
||||
this.meshID = data.meshID;
|
||||
this.BakeTriangles();
|
||||
this.BakeBounds();
|
||||
}
|
||||
|
||||
public void BakeTriangles(){
|
||||
|
||||
if(CollisionManager.mesh_triangles.containsKey(this.meshID) == false)
|
||||
return; // no triangle data to bake
|
||||
|
||||
this.triangles = new ArrayList<>();
|
||||
|
||||
Building building = BuildingManager.getBuilding(this.parentUUID);
|
||||
if(building == null)
|
||||
return; // can't continue without a building to base location offsets from
|
||||
|
||||
Vector3f adjustedBuildingLoc = new Vector3f(building.loc.x,building.loc.y, building.loc.z * -1);
|
||||
int rotDegrees = (int)Math.toDegrees(building.getBounds().getQuaternion().angleY);
|
||||
this.mesh_loc = Vector3f.rotateAroundPoint(adjustedBuildingLoc.add(this.meshData.mesh_loc),adjustedBuildingLoc,rotDegrees);
|
||||
this.mesh_ref = Vector3f.rotateAroundPoint(adjustedBuildingLoc.add(this.meshData.mesh_ref),adjustedBuildingLoc,rotDegrees);
|
||||
this.mesh_end = Vector3f.rotateAroundPoint(adjustedBuildingLoc.add(this.meshData.mesh_end),adjustedBuildingLoc,rotDegrees);
|
||||
this.mesh_minY = adjustedBuildingLoc.y + this.meshData.mesh_minY;
|
||||
this.mesh_maxY = adjustedBuildingLoc.y + this.meshData.mesh_maxY;
|
||||
|
||||
for(MeshTriangle tri : CollisionManager.mesh_triangles.get(this.meshID)){
|
||||
|
||||
Vector3f point1 = this.mesh_loc.add(new Vector3f(tri.point1.x,this.mesh_loc.y,tri.point1.y));
|
||||
Vector3f point2 = this.mesh_loc.add(new Vector3f(tri.point2.x,this.mesh_loc.y,tri.point2.y));
|
||||
Vector3f point3 = this.mesh_loc.add(new Vector3f(tri.point3.x,this.mesh_loc.y,tri.point3.y));
|
||||
|
||||
Vector3f rotatedPoint1 = Vector3f.rotateAroundPoint(point1,this.mesh_loc,rotDegrees);
|
||||
Vector3f rotatedPoint2 = Vector3f.rotateAroundPoint(point2,this.mesh_loc,rotDegrees);
|
||||
Vector3f rotatedPoint3 = Vector3f.rotateAroundPoint(point3,this.mesh_loc,rotDegrees);
|
||||
|
||||
MeshTriangle newTri = new MeshTriangle();
|
||||
|
||||
newTri.point1 = new Point2D.Float(rotatedPoint1.x,rotatedPoint1.z);
|
||||
newTri.point2 = new Point2D.Float(rotatedPoint2.x,rotatedPoint2.z);
|
||||
newTri.point3 = new Point2D.Float(rotatedPoint3.x,rotatedPoint3.z);
|
||||
|
||||
newTri.sides = new ArrayList<>();
|
||||
|
||||
newTri.sides.add(new Line2D.Float(newTri.point1,newTri.point2));
|
||||
newTri.sides.add(new Line2D.Float(newTri.point2,newTri.point3));
|
||||
newTri.sides.add(new Line2D.Float(newTri.point3,newTri.point1));
|
||||
|
||||
this.triangles.add(newTri);
|
||||
}
|
||||
}
|
||||
|
||||
public void BakeBounds(){
|
||||
float width = (this.mesh_ref.x - this.mesh_end.x) * 0.5f;
|
||||
float height = (this.mesh_ref.z - this.mesh_end.z) * 0.5f;
|
||||
this.bounds = new Rectangle2D.Float(this.mesh_ref.x,this.mesh_ref.z,width,height);
|
||||
}
|
||||
|
||||
public boolean collides(AbstractCharacter mover, Vector3fImmutable destination){
|
||||
|
||||
if(mover == null)
|
||||
return false;
|
||||
|
||||
Line2D.Float line = new Line2D.Float(new Point2D.Float(mover.loc.x,mover.loc.z * -1),new Point2D.Float(destination.x,destination.z * -1));
|
||||
float footHeight = mover.loc.y;
|
||||
float headHeight = mover.loc.y + mover.characterHeight;
|
||||
|
||||
if(line.intersects(this.bounds) == false)
|
||||
return false; // character path doesn't cross over this mesh
|
||||
|
||||
if(footHeight > this.mesh_maxY || headHeight < this.mesh_minY)
|
||||
return false; //character is either above or below the bounds of this mesh
|
||||
|
||||
for(MeshTriangle tri : this.triangles)
|
||||
if(tri.collides(line))
|
||||
return true; //character's path directly hits part of this mesh
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean losBlocked(AbstractCharacter looker, Vector3fImmutable target){
|
||||
|
||||
float headHeight = looker.loc.y + looker.characterHeight;
|
||||
float targetAlt = target.y;
|
||||
|
||||
Line2D.Float eyeLine = new Line2D.Float(new Point2D.Float(looker.loc.x,looker.loc.z * -1),new Point2D.Float(target.x,target.z * -1));
|
||||
|
||||
if(eyeLine.intersects(this.bounds) == false)
|
||||
return false; // character eye-line doesn't cross over this mesh
|
||||
|
||||
if(targetAlt > this.mesh_maxY && headHeight > this.mesh_maxY)
|
||||
return false; // both characters are above this mesh
|
||||
|
||||
if(targetAlt < this.mesh_maxY && headHeight < this.mesh_maxY)
|
||||
return false; // both characters are below this mesh
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package engine.collisionEngine;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
|
||||
public class MeshData {
|
||||
public int propID;
|
||||
public int meshID;
|
||||
public Vector3f mesh_loc;
|
||||
public Vector3f mesh_ref;
|
||||
public Vector3f mesh_end;
|
||||
public float mesh_maxY;
|
||||
public float mesh_minY;
|
||||
|
||||
public MeshData(int propID,int meshID, Vector3f meshLoc, Vector3f meshRef, Vector3f meshEnd, float maxY, float minY){
|
||||
this.propID = propID;
|
||||
this.meshID = meshID;
|
||||
this.mesh_loc = meshLoc;
|
||||
this.mesh_ref = meshRef;
|
||||
this.mesh_end = meshEnd;
|
||||
this.mesh_maxY = maxY;
|
||||
this.mesh_minY = minY;
|
||||
}
|
||||
}
|
||||
@@ -9,22 +9,25 @@
|
||||
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.CollisionEngine.CollisionManager;
|
||||
import engine.CollisionEngine.MeshData;
|
||||
import engine.CollisionEngine.Triangle;
|
||||
import engine.Enum;
|
||||
import engine.Enum.DbObjectType;
|
||||
import engine.Enum.ProtectionState;
|
||||
import engine.Enum.TaxType;
|
||||
import engine.collisionEngine.CollisionManager;
|
||||
import engine.collisionEngine.MeshData;
|
||||
import engine.collisionEngine.MeshTriangle;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@@ -32,6 +35,7 @@ import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -853,69 +857,168 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean LOAD_STRUCTURE_MESHES() {
|
||||
|
||||
public void LOAD_MESH_DATA(){
|
||||
CollisionManager.structure_meshes = new HashMap<>();
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `final_structure_meshes`;")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `final_structure_meshes`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
CollisionManager.structure_meshes = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
int propId = rs.getInt("propID");
|
||||
int meshId = rs.getInt("meshID");
|
||||
Vector3f meshLoc = new Vector3f(rs.getFloat("locX"),rs.getFloat("locY"),rs.getFloat("locZ"));
|
||||
Vector3f meshRef = new Vector3f(rs.getFloat("refX"),rs.getFloat("refY"),rs.getFloat("refZ"));
|
||||
Vector3f meshEnd = new Vector3f(rs.getFloat("endX"),rs.getFloat("endY"),rs.getFloat("endZ"));
|
||||
float maxY = rs.getFloat("maxY");
|
||||
float minY = rs.getFloat("minY");
|
||||
MeshData data = new MeshData(propId,meshId,meshLoc,meshRef,meshEnd,maxY,minY);
|
||||
if(CollisionManager.structure_meshes.containsKey(propId)){
|
||||
CollisionManager.structure_meshes.get(propId).add(data);
|
||||
MeshData md = new MeshData();
|
||||
md.propID = rs.getInt("propID");
|
||||
md.meshID = rs.getInt("meshID");
|
||||
md.loc = new Vector3f(rs.getFloat("locX"), rs.getFloat("locY"),rs.getFloat("locz"));
|
||||
md.scale = new Vector3f(rs.getFloat("scaleX"), rs.getFloat("scaleY"),rs.getFloat("scaleZ"));
|
||||
md.refPoint = new Vector3f(rs.getFloat("refX"), rs.getFloat("refY"),rs.getFloat("refZ"));
|
||||
md.endPoint = new Vector3f(rs.getFloat("endX"), rs.getFloat("endY"),rs.getFloat("endZ"));
|
||||
md.minY = rs.getFloat("minY");
|
||||
md.maxY = rs.getFloat("maxY");
|
||||
if(CollisionManager.structure_meshes.containsKey(rs.getInt("propID"))){
|
||||
CollisionManager.structure_meshes.get(rs.getInt("propID")).add(md);
|
||||
} else{
|
||||
ArrayList<MeshData> addList = new ArrayList<>();
|
||||
addList.add(data);
|
||||
CollisionManager.structure_meshes.put(propId,addList);
|
||||
ArrayList<MeshData> meshData = new ArrayList<>();
|
||||
meshData.add(md);
|
||||
CollisionManager.structure_meshes.put(rs.getInt("propID"),meshData);
|
||||
}
|
||||
}
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean LOAD_MESH_TRIANGLES() {
|
||||
|
||||
public void LOAD_MESH_TRIANGLE_DATA(){
|
||||
CollisionManager.mesh_triangles = new HashMap<>();
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `final_mesh_triangles`;")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `final_mesh_triangles`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
CollisionManager.mesh_triangles = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
int meshId = rs.getInt("meshID");
|
||||
Point2D.Float point1 = new Point2D.Float(rs.getFloat("P1X"), rs.getFloat("P1Z"));
|
||||
Point2D.Float point2 = new Point2D.Float(rs.getFloat("P2X"), rs.getFloat("P2Z"));
|
||||
Point2D.Float point3 = new Point2D.Float(rs.getFloat("P3X"), rs.getFloat("P3Z"));
|
||||
|
||||
MeshTriangle newTri = new MeshTriangle();
|
||||
newTri.point1 = point1;
|
||||
newTri.point2 = point2;
|
||||
newTri.point3 = point3;
|
||||
|
||||
if(CollisionManager.mesh_triangles.containsKey(meshId)){
|
||||
CollisionManager.mesh_triangles.get(meshId).add(newTri);
|
||||
Triangle tri = new Triangle();
|
||||
tri.point1 = new Point2D.Float(rs.getFloat("P1X"),rs.getFloat("P1Z"));
|
||||
tri.point2 = new Point2D.Float(rs.getFloat("P2X"),rs.getFloat("P2Z"));
|
||||
tri.point3 = new Point2D.Float(rs.getFloat("P3X"),rs.getFloat("P3Z"));
|
||||
if(CollisionManager.mesh_triangles.containsKey(rs.getInt("meshID"))){
|
||||
CollisionManager.mesh_triangles.get(rs.getInt("meshID")).add(tri);
|
||||
} else{
|
||||
ArrayList<MeshTriangle> addList = new ArrayList<>();
|
||||
addList.add(newTri);
|
||||
CollisionManager.mesh_triangles.put(meshId,addList);
|
||||
ArrayList<Triangle> triData = new ArrayList<>();
|
||||
triData.add(tri);
|
||||
CollisionManager.mesh_triangles.put(rs.getInt("meshID"),triData);
|
||||
}
|
||||
|
||||
}
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void LOAD_PROP_MESHES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_structure_meshes`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.prop_meshes = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
if(BuildingManager.prop_meshes.containsKey(rs.getInt("propID")) == false){
|
||||
ArrayList<Integer> meshList = new ArrayList<>();
|
||||
meshList.add(rs.getInt("meshID"));
|
||||
BuildingManager.prop_meshes.put(rs.getInt("propID"),meshList);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList<Integer> meshes = BuildingManager.prop_meshes.get(rs.getInt("propID"));
|
||||
meshes.add(rs.getInt("meshID"));
|
||||
//BuildingManager.prop_meshes.get(rs.getInt("propID")).add(rs.getInt("meshID"));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void LOAD_MESH_DATA_OLD() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_triangles`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.mesh_triangle_points = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
|
||||
ArrayList<Float> floatPoints = new ArrayList<>();
|
||||
for(String f : rs.getString("vertices").split(";"))
|
||||
{
|
||||
floatPoints.add(Float.parseFloat(f));
|
||||
}
|
||||
ArrayList<Vector3f> triPoints = new ArrayList<>();
|
||||
for(int i = 0; i < floatPoints.size(); i += 3){
|
||||
triPoints.add(new Vector3f(floatPoints.get(i),floatPoints.get(i+1),floatPoints.get(i+2)));
|
||||
}
|
||||
|
||||
if(BuildingManager.mesh_triangle_points.containsKey(rs.getInt("meshID")) == false){
|
||||
ArrayList<ArrayList<Vector3f>> newPoints = new ArrayList<>();
|
||||
newPoints.add(triPoints);
|
||||
BuildingManager.mesh_triangle_points.put(rs.getInt("meshID"),newPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildingManager.mesh_triangle_points.get(rs.getInt("meshID")).add(triPoints);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_heights`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.mesh_heights = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
|
||||
if(BuildingManager.mesh_heights.containsKey(rs.getInt("meshID")) == false){
|
||||
Vector2f heights = new Vector2f(rs.getFloat("maxY"),rs.getFloat("minY"));
|
||||
BuildingManager.mesh_heights.put(rs.getInt("meshID"),heights);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_MESH_BOUNDING_BOXES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_mesh_bounding_boxes`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
BuildingManager.mesh_bounding_boxes = new HashMap<>();
|
||||
while (rs.next()) {
|
||||
int meshID = rs.getInt("meshId");
|
||||
if(BuildingManager.mesh_bounding_boxes.containsKey(meshID) == false){
|
||||
float endX = Float.parseFloat(rs.getString("mesh_end_point").split(";")[0]);
|
||||
float endZ = Float.parseFloat(rs.getString("mesh_end_point").split(";")[1]);
|
||||
float refX = Float.parseFloat(rs.getString("mesh_ref_point").split(";")[0]);
|
||||
float refZ = Float.parseFloat(rs.getString("mesh_ref_point").split(";")[1]);
|
||||
|
||||
|
||||
Vector2f topLeft = new Vector2f(refX,refZ);
|
||||
float width = Math.abs(Math.abs(endX)-Math.abs(refX));
|
||||
float height = Math.abs(Math.abs(endZ)-Math.abs(refZ));
|
||||
Rectangle2D boundRect = new Rectangle2D.Float();
|
||||
boundRect.setRect(topLeft.x,topLeft.y,width,height);
|
||||
BuildingManager.mesh_bounding_boxes.put(meshID,boundRect);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,26 +9,11 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.Enum;
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.TargetColor;
|
||||
import engine.collisionEngine.Mesh;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.util.StringUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
/**
|
||||
* @author
|
||||
*/
|
||||
public class ColliderCmd extends AbstractDevCmd {
|
||||
|
||||
public ColliderCmd() {
|
||||
@@ -38,42 +23,38 @@ public class ColliderCmd extends AbstractDevCmd {
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
// Arg Count Check
|
||||
if (words.length != 1) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
if (pc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String newline = "\r\n ";
|
||||
String output = "----------Collider Information----------" + newline;
|
||||
if(target.getObjectType().equals(GameObjectType.Building) == false)
|
||||
throwbackInfo(pc, "You Must Select A Building");
|
||||
|
||||
Building building = (Building)target;
|
||||
output += "Mesh Count: " + ((Building) target).buildingMeshes.size() + newline;
|
||||
for(Mesh mesh : building.buildingMeshes){
|
||||
output += "------------------------------" + newline;
|
||||
output += "Mesh ID: " + mesh.meshData.meshID + newline;
|
||||
output += "Mesh Tri Count: " + mesh.triangles.size() + newline;
|
||||
output += "Mesh Bounds: " + mesh.bounds + newline;
|
||||
output += "Mesh Min/Max: " + mesh.mesh_minY + " / " + mesh.mesh_maxY + newline;
|
||||
output += "Location Inside: " + mesh.bounds.contains(pc.loc.x,pc.loc.z * -1) + newline;
|
||||
output += "------------------------------" + newline;
|
||||
String output;
|
||||
if(target.getObjectType().equals(Enum.GameObjectType.Building) == false){
|
||||
throwbackInfo(pc,"Please Select A Building To Show Collider Data");
|
||||
}
|
||||
throwbackInfo(pc, output);
|
||||
Building building = (Building)target;
|
||||
output = "Collision Info:" + newline;
|
||||
output += "Total Meshes: " + building.buildingMeshes.size() + newline;
|
||||
for(Mesh mesh : building.buildingMeshes){
|
||||
output += "-----------------------------" + newline;
|
||||
output += "Mesh ID: " + mesh.mesh_id + newline;
|
||||
output += "Mesh Location: " + mesh.mesh_location + newline;
|
||||
output += "Mesh Scale: " + mesh.mesh_scale + newline;
|
||||
output += "Mesh Min/Max: " + mesh.mesh_min_y + "/" + mesh.mesh_max_y + newline;
|
||||
output += "Mesh Triangle Count: " + mesh.triangles.size() + newline;
|
||||
output += "Mesh Rect: " + mesh.mesh_bounds + newline;
|
||||
output += "-----------------------------" + newline;
|
||||
}
|
||||
|
||||
throwbackInfo(pc,output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Gets information on an Object.";
|
||||
return "Displays Information About Colliders";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /info targetID'";
|
||||
return "' /collider displays collision info when selected on a building";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.Enum;
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.GameObjectType;
|
||||
@@ -244,7 +245,6 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
for (Regions regions : targetBuilding.getBounds().getRegions()) {
|
||||
//TODO ADD REGION INFO
|
||||
}
|
||||
|
||||
break;
|
||||
case PlayerCharacter:
|
||||
output += newline;
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
public class RegionCmd extends AbstractDevCmd {
|
||||
|
||||
@@ -37,7 +37,6 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
Regions region = ((AbstractCharacter)target).region;
|
||||
if (region == null) {
|
||||
this.throwbackInfo(pc, "No Region Found.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(region != null) {
|
||||
@@ -48,7 +47,6 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
output += "is Outside: " + region.isOutside();
|
||||
this.throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,18 +9,21 @@
|
||||
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.CollisionEngine.CollisionManager;
|
||||
import engine.CollisionEngine.MeshData;
|
||||
import engine.Enum;
|
||||
import engine.Enum.BuildingGroup;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.collisionEngine.CollisionManager;
|
||||
import engine.collisionEngine.Mesh;
|
||||
import engine.collisionEngine.MeshData;
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.CollisionEngine.Triangle;
|
||||
import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.UpgradeBuildingJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
@@ -30,6 +33,9 @@ import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
@@ -41,6 +47,12 @@ public enum BuildingManager {
|
||||
|
||||
BUILDINGMANAGER;
|
||||
|
||||
public static HashMap<Integer,ArrayList<Integer>> prop_meshes = new HashMap<>();
|
||||
public static HashMap<Integer, Vector2f> mesh_heights = new HashMap<>();
|
||||
public static HashMap<Integer,ArrayList<ArrayList<Vector3f>>> mesh_triangle_points = new HashMap<>();
|
||||
|
||||
public static HashMap<Integer, Rectangle2D> mesh_bounding_boxes = new HashMap<>();
|
||||
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
||||
|
||||
@@ -945,9 +957,10 @@ public enum BuildingManager {
|
||||
|
||||
cleanupHirelings(building);
|
||||
|
||||
//rebake colliders for change in rank
|
||||
//BuildingManager.BakeBuildingMeshes(building);
|
||||
BuildingManager.BakeBuildingColliders(building);
|
||||
building.isDeranking.compareAndSet(true, false);
|
||||
|
||||
BakeColliders(building);
|
||||
}
|
||||
|
||||
public static Building getBuildingAtLocation(Vector3fImmutable loc) {
|
||||
@@ -965,17 +978,46 @@ public enum BuildingManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void BakeColliders(Building building){
|
||||
int propID = building.meshUUID;
|
||||
public static void BakeBuildingColliders(Building building){
|
||||
|
||||
if(CollisionManager.structure_meshes.containsKey(propID) == false) {
|
||||
Logger.error("Bake for PropID: " + propID + " Failed");
|
||||
if(CollisionManager.structure_meshes.containsKey(building.meshUUID) == false) {
|
||||
Logger.error("No Meshes Found For Structure: " + building.meshUUID);
|
||||
return;
|
||||
}
|
||||
|
||||
//create the empty array of meshes
|
||||
building.buildingMeshes = new ArrayList<>();
|
||||
for(MeshData data : CollisionManager.structure_meshes.get(propID)){
|
||||
building.buildingMeshes.add(new Mesh(data,building.getObjectUUID()));
|
||||
|
||||
//create the actual meshes from the stored mesh data
|
||||
for(MeshData meshData : CollisionManager.structure_meshes.get(building.meshUUID)){
|
||||
if(meshData.meshID == 0)
|
||||
continue;
|
||||
|
||||
int degrees = (int)Math.toDegrees(building.getBounds().getQuaternion().angleY);
|
||||
|
||||
Mesh generatedMesh = new Mesh();
|
||||
|
||||
generatedMesh.meshData = meshData;
|
||||
|
||||
Vector3f buildingLoc = new Vector3f(building.loc.x,building.loc.y,building.loc.z);
|
||||
|
||||
Vector3f offset_mesh_loc = buildingLoc.add(meshData.loc);
|
||||
Vector3f offset_mesh_end = buildingLoc.add(meshData.endPoint);
|
||||
Vector3f offset_mesh_ref = buildingLoc.add(meshData.refPoint);
|
||||
|
||||
generatedMesh.mesh_location = Vector3f.rotateAroundPoint(offset_mesh_loc,buildingLoc,degrees);
|
||||
generatedMesh.mesh_end_point = Vector3f.rotateAroundPoint(offset_mesh_end,buildingLoc,degrees);
|
||||
generatedMesh.mesh_ref_point = Vector3f.rotateAroundPoint(offset_mesh_ref,buildingLoc,degrees);
|
||||
|
||||
generatedMesh.mesh_max_y = building.loc.y + meshData.maxY;
|
||||
generatedMesh.mesh_min_y = building.loc.y + meshData.minY;
|
||||
generatedMesh.mesh_scale = meshData.scale;
|
||||
generatedMesh.mesh_id = meshData.meshID;
|
||||
generatedMesh.parent_prop_id = meshData.propID;
|
||||
generatedMesh.parent_structure_id = building.meshUUID;
|
||||
generatedMesh.parentUUID = building.getObjectUUID();
|
||||
generatedMesh.update();
|
||||
building.buildingMeshes.add(generatedMesh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new PrintResistsCmd());
|
||||
DevCmdManager.registerDevCmd(new PrintLocationCmd());
|
||||
DevCmdManager.registerDevCmd(new InfoCmd());
|
||||
DevCmdManager.registerDevCmd(new ColliderCmd());
|
||||
DevCmdManager.registerDevCmd(new aiInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new SimulateBootyCmd());
|
||||
DevCmdManager.registerDevCmd(new GetHeightCmd());
|
||||
@@ -141,6 +140,7 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new BoundsCmd());
|
||||
DevCmdManager.registerDevCmd(new GotoBoundsCmd());
|
||||
DevCmdManager.registerDevCmd(new RegionCmd());
|
||||
DevCmdManager.registerDevCmd(new ColliderCmd());
|
||||
DevCmdManager.registerDevCmd(new SetMaintCmd());
|
||||
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
||||
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
||||
|
||||
@@ -45,27 +45,22 @@ public enum MaintenanceManager {
|
||||
// Deduct upkeep and build list of buildings
|
||||
// which did not have funds available
|
||||
|
||||
try {
|
||||
for (Building building : maintList)
|
||||
if (chargeUpkeep(building) == false)
|
||||
derankList.add(building);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
for (Building building : maintList) {
|
||||
|
||||
if (chargeUpkeep(building) == false)
|
||||
derankList.add(building);
|
||||
}
|
||||
// Reset maintenance dates for these buildings
|
||||
|
||||
for (Building building : maintList)
|
||||
for (Building building : maintList) {
|
||||
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
|
||||
|
||||
}
|
||||
// Derak or destroy buildings that did not
|
||||
// have funds available.
|
||||
|
||||
try {
|
||||
for (Building building : derankList)
|
||||
building.destroyOrDerank(null);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
for (Building building : derankList)
|
||||
building.destroyOrDerank(null);
|
||||
|
||||
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
|
||||
}
|
||||
|
||||
@@ -9,14 +9,22 @@
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.CollisionEngine.CollisionManager;
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class MoveToPointHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@@ -32,6 +40,32 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
|
||||
if(pc == null)
|
||||
return true;
|
||||
|
||||
//check for collisions
|
||||
Line2D travelLine = new Line2D.Float();
|
||||
Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon());
|
||||
travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z);
|
||||
if(BuildingManager.getBuildingAtLocation(pc.loc) != null){
|
||||
Building current = BuildingManager.getBuildingAtLocation(pc.loc);
|
||||
if (CollisionManager.CollisionDetected(current, travelLine, pc.getCharacterHeight(), pc.loc.y)) {
|
||||
ChatManager.chatSystemInfo(pc, "Collision Detected With : " + current.getName() + " Rect: " + current.buildingRect);
|
||||
//msg.setEndCoord();
|
||||
MovementManager.movement(msg, pc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(pc.loc, 1000, MBServerStatics.MASK_BUILDING);
|
||||
for(AbstractWorldObject awo : awoList){
|
||||
Building building = (Building)awo;
|
||||
if(travelLine.intersects(building.buildingRect) || building.buildingRect.contains(travelLine.getP1()) || building.buildingRect.contains(travelLine.getP2())) {
|
||||
if (CollisionManager.CollisionDetected(building, travelLine, pc.getCharacterHeight(), pc.loc.y)) {
|
||||
ChatManager.chatSystemInfo(pc, "Collision Detected With : " + building.getName() + " Rect: " + building.buildingRect);
|
||||
//msg.setEndCoord();
|
||||
MovementManager.movement(msg, pc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//ChatManager.chatSystemInfo(pc, "No Collision Detected");
|
||||
MovementManager.movement(msg, pc);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
|
||||
public float characterHeight = 0;
|
||||
protected CharacterItemManager charItemManager;
|
||||
private final ReentrantReadWriteLock healthLock = new ReentrantReadWriteLock();
|
||||
public short level;
|
||||
|
||||
@@ -9,12 +9,13 @@
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import engine.CollisionEngine.Triangle;
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.RealmMap;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.collisionEngine.Mesh;
|
||||
import engine.CollisionEngine.Mesh;
|
||||
import engine.db.archive.CityRecord;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.db.archive.MineRecord;
|
||||
@@ -35,6 +36,7 @@ import engine.net.client.msg.UpdateObjectMsg;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -101,6 +103,7 @@ public class Building extends AbstractWorldObject {
|
||||
private ArrayList<Building> children = null;
|
||||
|
||||
public ArrayList<Mesh> buildingMeshes;
|
||||
public Rectangle2D.Float buildingRect;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
@@ -1007,7 +1010,8 @@ public class Building extends AbstractWorldObject {
|
||||
if (this.upgradeDateTime != null)
|
||||
BuildingManager.submitUpgradeJob(this);
|
||||
|
||||
BuildingManager.BakeColliders(this);
|
||||
//BuildingManager.BakeBuildingMeshes(this);
|
||||
BuildingManager.BakeBuildingColliders(this);
|
||||
}
|
||||
|
||||
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
||||
|
||||
+23
-18
@@ -842,6 +842,7 @@ public class NPC extends AbstractCharacter {
|
||||
else
|
||||
this.guild = Guild.getGuild(this.guildUUID);
|
||||
|
||||
|
||||
if (this.guild == null)
|
||||
this.guild = Guild.getErrantGuild();
|
||||
|
||||
@@ -871,23 +872,27 @@ public class NPC extends AbstractCharacter {
|
||||
if (this.building != null)
|
||||
NPCManager.slotCharacterInBuilding(this);
|
||||
|
||||
this.symbol = this.contract.getIconID();
|
||||
this.modTypeTable = this.contract.getNPCModTypeTable();
|
||||
this.modSuffixTable = this.contract.getNpcModSuffixTable();
|
||||
this.itemModTable = this.contract.getItemModTable();
|
||||
int VID = this.contract.getVendorID();
|
||||
if (this.contract != null) {
|
||||
this.symbol = this.contract.getIconID();
|
||||
this.modTypeTable = this.contract.getNPCModTypeTable();
|
||||
this.modSuffixTable = this.contract.getNpcModSuffixTable();
|
||||
this.itemModTable = this.contract.getItemModTable();
|
||||
int VID = this.contract.getVendorID();
|
||||
|
||||
if (VID != 0)
|
||||
this.vendorID = VID;
|
||||
else
|
||||
this.vendorID = 1; //no vendor items
|
||||
if (VID != 0)
|
||||
this.vendorID = VID;
|
||||
else
|
||||
this.vendorID = 1; //no vendor items
|
||||
}
|
||||
|
||||
this.healthMax = this.mobBase.getHealthMax();
|
||||
this.manaMax = 0;
|
||||
this.staminaMax = 0;
|
||||
this.setHealth(this.healthMax);
|
||||
this.mana.set(this.manaMax);
|
||||
this.stamina.set(this.staminaMax);
|
||||
if (this.mobBase != null) {
|
||||
this.healthMax = this.mobBase.getHealthMax();
|
||||
this.manaMax = 0;
|
||||
this.staminaMax = 0;
|
||||
this.setHealth(this.healthMax);
|
||||
this.mana.set(this.manaMax);
|
||||
this.stamina.set(this.staminaMax);
|
||||
}
|
||||
|
||||
if (this.parentZone.guild_zone)
|
||||
if (NPC.GetNPCProfits(this) == null)
|
||||
@@ -906,11 +911,11 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
this.charItemManager.load();
|
||||
|
||||
if (equipmentSetID != 0 && LootManager._bootySetMap.get(equipmentSetID) == null)
|
||||
Logger.error("Invalid equipSet: " + equipmentSetID + " contract: " + this.contractUUID + " npc: " + this.getObjectUUID());
|
||||
|
||||
this.equip = loadEquipmentSet(this.equipmentSetID);
|
||||
|
||||
if (this.equip == null)
|
||||
this.equip = new HashMap<>();
|
||||
|
||||
try {
|
||||
|
||||
DbManager.NPCQueries.LOAD_ALL_ITEMS_TO_PRODUCE(this);
|
||||
|
||||
@@ -165,6 +165,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
private boolean wasTripped75 = false;
|
||||
private boolean wasTripped50 = false;
|
||||
private boolean wasTripped25 = false;
|
||||
private float characterHeight = 0;
|
||||
private boolean lastSwimming = false;
|
||||
private boolean isTeleporting = false;
|
||||
private boolean dirtyLoad = true;
|
||||
@@ -5426,6 +5427,10 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
this.lastStamUpdateTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public float getCharacterHeight() {
|
||||
return characterHeight;
|
||||
}
|
||||
|
||||
public boolean isEnteredWorld() {
|
||||
return enteredWorld;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class Zone extends AbstractWorldObject {
|
||||
|
||||
public final int playerCityUUID;
|
||||
public final String zoneName;
|
||||
public float major_radius;
|
||||
public float minor_radius;
|
||||
public final float major_radius;
|
||||
public final float minor_radius;
|
||||
public final float xOffset;
|
||||
public final float zOffset;
|
||||
public final float yOffset;
|
||||
@@ -76,6 +76,9 @@ public class Zone extends AbstractWorldObject {
|
||||
this.templateID = rs.getInt("template");
|
||||
this.zoneName = rs.getString("zone_name");
|
||||
this.peace_zone = rs.getByte("peace_zone");
|
||||
|
||||
this.major_radius = rs.getFloat("major_radius");
|
||||
this.minor_radius = rs.getFloat("minor_radius");
|
||||
this.xOffset = rs.getFloat("xOffset");
|
||||
this.zOffset = rs.getFloat("zOffset");
|
||||
this.yOffset = rs.getFloat("yOffset");
|
||||
@@ -160,18 +163,6 @@ public class Zone extends AbstractWorldObject {
|
||||
if (ZoneManager.seaFloor == null)
|
||||
ZoneManager.seaFloor = this;
|
||||
|
||||
// Guild zones use the enum CityBoundsType to adjust
|
||||
// city size. All other zones derive from the JSON
|
||||
// stored within its template.
|
||||
|
||||
if (this.template == null) {
|
||||
this.minor_radius = Enum.CityBoundsType.ZONE.halfExtents;
|
||||
this.major_radius = Enum.CityBoundsType.ZONE.halfExtents;
|
||||
} else {
|
||||
this.minor_radius = this.template.minor_radius;
|
||||
this.major_radius = this.template.major_radius;
|
||||
}
|
||||
|
||||
this.setParent();
|
||||
this.setBounds();
|
||||
|
||||
@@ -201,7 +192,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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -309,16 +309,18 @@ public class WorldServer {
|
||||
Logger.info("Initializing Errant Guild");
|
||||
Guild.getErrantGuild();
|
||||
|
||||
Logger.info("Loading Server Collision Meshes.");
|
||||
//DbManager.BuildingQueries.LOAD_PROP_MESHES();
|
||||
DbManager.BuildingQueries.LOAD_MESH_DATA();
|
||||
DbManager.BuildingQueries.LOAD_MESH_TRIANGLE_DATA();
|
||||
//DbManager.BuildingQueries.LOAD_MESH_BOUNDING_BOXES();
|
||||
|
||||
Logger.info("Loading zone template data");
|
||||
DbManager.ZoneQueries.LOAD_ALL_ZONE_TEMPLATES();
|
||||
|
||||
Logger.info("Initializing PowersManager.");
|
||||
PowersManager.initPowersManager(true);
|
||||
|
||||
Logger.info("Loading Collider Data");
|
||||
DbManager.BuildingQueries.LOAD_MESH_TRIANGLES();
|
||||
DbManager.BuildingQueries.LOAD_STRUCTURE_MESHES();
|
||||
|
||||
Logger.info("Loading granted Skills for Runes");
|
||||
DbManager.SkillsBaseQueries.LOAD_ALL_RUNE_SKILLS();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user