forked from MagicBane/Server
Compare commits
23 Commits
hull4
...
mesh-colliders
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c432a5c9e | |||
| 655a54ce2a | |||
| eafe00555f | |||
| d53b5d03a4 | |||
| 92d8ed9e3f | |||
| 45b2443982 | |||
| 3775fb336b | |||
| f7a8ca33fc | |||
| c45265b085 | |||
| 79400b6b0e | |||
| 2bff826a10 | |||
| d5fc87c233 | |||
| 78a0416b19 | |||
| eb5bc14974 | |||
| 7e99e8c7a4 | |||
| 9b0f4d5aef | |||
| b58049968f | |||
| 9bf0d3f7d1 | |||
| 8300c47e4a | |||
| c73fcc19f2 | |||
| f93573177a | |||
| fe9c6437d8 | |||
| c110ffc4b1 |
@@ -0,0 +1,10 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package engine.collisionEngine;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MeshTriangle {
|
||||
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))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,18 @@ 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.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@@ -848,5 +853,69 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean LOAD_STRUCTURE_MESHES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
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);
|
||||
} else{
|
||||
ArrayList<MeshData> addList = new ArrayList<>();
|
||||
addList.add(data);
|
||||
CollisionManager.structure_meshes.put(propId,addList);
|
||||
}
|
||||
}
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean LOAD_MESH_TRIANGLES() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
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);
|
||||
} else{
|
||||
ArrayList<MeshTriangle> addList = new ArrayList<>();
|
||||
addList.add(newTri);
|
||||
CollisionManager.mesh_triangles.put(meshId,addList);
|
||||
}
|
||||
|
||||
}
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,16 +34,19 @@ public class dbCityHandler extends dbHandlerBase {
|
||||
case "zone":
|
||||
Zone zone = new Zone(rs);
|
||||
DbManager.addToCache(zone);
|
||||
zone.runAfterLoad();
|
||||
list.add(zone);
|
||||
break;
|
||||
case "building":
|
||||
Building building = new Building(rs);
|
||||
DbManager.addToCache(building);
|
||||
building.runAfterLoad();
|
||||
list.add(building);
|
||||
break;
|
||||
case "city":
|
||||
City city = new City(rs);
|
||||
DbManager.addToCache(city);
|
||||
city.runAfterLoad();
|
||||
list.add(city);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
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() {
|
||||
super("collider");
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Gets information on an Object.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "' /info targetID'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,18 +49,32 @@ public class GetHeightCmd extends AbstractDevCmd {
|
||||
|
||||
float blendedHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||
|
||||
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(childZoneLoc);
|
||||
gridSquare.x = (float) Math.floor(gridSquare.x);
|
||||
gridSquare.y = (float) Math.floor(gridSquare.y);
|
||||
Vector2f terrainCell = heightmapZone.terrain.getTerrainCell(childZoneLoc);
|
||||
Vector2f cell_offset = new Vector2f(terrainCell.x % 1, terrainCell.y % 1);
|
||||
|
||||
terrainCell.x = (float) Math.floor(terrainCell.x);
|
||||
terrainCell.y = (float) Math.floor(terrainCell.y);
|
||||
|
||||
|
||||
short top_left_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x][(int) terrainCell.y];
|
||||
short top_right_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x + 1][(int) terrainCell.y];
|
||||
short bottom_left_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x][(int) terrainCell.y + 1];
|
||||
short bottom_right_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x + 1][(int) terrainCell.y + 1];
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
|
||||
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);
|
||||
this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName);
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Player loc: " + "[" + playerCharacter.loc.x + "]" + "[" + playerCharacter.loc.y + "]" + "[" + playerCharacter.loc.z + "]");
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Terrain Cell : " + "[" + terrainCell.x + "]" + "[" + terrainCell.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Cell Offset : " + "[" + cell_offset.x + "]" + "[" + cell_offset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Pixels : " + "[" + top_left_pixel + "]" + "[" + top_right_pixel + "]");
|
||||
this.throwbackInfo(playerCharacter, "Pixels : " + "[" + bottom_left_pixel + "]" + "[" + bottom_right_pixel + "]");
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Child Zone Offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.min_blend + " /" + heightmapZone.template.max_blend);
|
||||
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.max_blend + " /" + heightmapZone.template.min_blend);
|
||||
this.throwbackInfo(playerCharacter, "terrain values (max/min): " + heightmapZone.terrain.blend_values.x + " /" + heightmapZone.terrain.blend_values.y);
|
||||
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ 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.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.UpgradeBuildingJob;
|
||||
@@ -943,6 +946,8 @@ public enum BuildingManager {
|
||||
cleanupHirelings(building);
|
||||
|
||||
building.isDeranking.compareAndSet(true, false);
|
||||
|
||||
BakeColliders(building);
|
||||
}
|
||||
|
||||
public static Building getBuildingAtLocation(Vector3fImmutable loc) {
|
||||
@@ -960,4 +965,17 @@ public enum BuildingManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void BakeColliders(Building building){
|
||||
int propID = building.meshUUID;
|
||||
|
||||
if(CollisionManager.structure_meshes.containsKey(propID) == false) {
|
||||
Logger.error("Bake for PropID: " + propID + " Failed");
|
||||
return;
|
||||
}
|
||||
building.buildingMeshes = new ArrayList<>();
|
||||
for(MeshData data : CollisionManager.structure_meshes.get(propID)){
|
||||
building.buildingMeshes.add(new Mesh(data,building.getObjectUUID()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ 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());
|
||||
|
||||
@@ -45,22 +45,27 @@ public enum MaintenanceManager {
|
||||
// Deduct upkeep and build list of buildings
|
||||
// which did not have funds available
|
||||
|
||||
for (Building building : maintList) {
|
||||
|
||||
if (chargeUpkeep(building) == false)
|
||||
derankList.add(building);
|
||||
try {
|
||||
for (Building building : maintList)
|
||||
if (chargeUpkeep(building) == false)
|
||||
derankList.add(building);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
// 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.
|
||||
|
||||
for (Building building : derankList)
|
||||
building.destroyOrDerank(null);
|
||||
try {
|
||||
for (Building building : derankList)
|
||||
building.destroyOrDerank(null);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
|
||||
}
|
||||
|
||||
@@ -766,8 +766,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
cityObjectMap.put(gameObject.getObjectType(), gameObject);
|
||||
|
||||
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
||||
treeObject.runAfterLoad();
|
||||
|
||||
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
||||
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
||||
|
||||
@@ -799,6 +797,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
treeObject.setLoc(treeObject.getLoc());
|
||||
|
||||
// As this is a new static object set it's dirtyFlag
|
||||
// so players already near it will have the object loaded.
|
||||
|
||||
InterestManager.setObjectDirty(treeObject);
|
||||
|
||||
serverRealm.addCity(cityObject.getObjectUUID());
|
||||
|
||||
@@ -45,6 +45,7 @@ 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;
|
||||
|
||||
@@ -14,6 +14,7 @@ import engine.Enum.*;
|
||||
import engine.InterestManagement.RealmMap;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.collisionEngine.Mesh;
|
||||
import engine.db.archive.CityRecord;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.db.archive.MineRecord;
|
||||
@@ -99,6 +100,8 @@ public class Building extends AbstractWorldObject {
|
||||
private ConcurrentHashMap<Integer, Condemned> condemned;
|
||||
private ArrayList<Building> children = null;
|
||||
|
||||
public ArrayList<Mesh> buildingMeshes;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
@@ -1003,6 +1006,8 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
if (this.upgradeDateTime != null)
|
||||
BuildingManager.submitUpgradeJob(this);
|
||||
|
||||
BuildingManager.BakeColliders(this);
|
||||
}
|
||||
|
||||
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
||||
|
||||
+18
-23
@@ -842,7 +842,6 @@ public class NPC extends AbstractCharacter {
|
||||
else
|
||||
this.guild = Guild.getGuild(this.guildUUID);
|
||||
|
||||
|
||||
if (this.guild == null)
|
||||
this.guild = Guild.getErrantGuild();
|
||||
|
||||
@@ -872,27 +871,23 @@ public class NPC extends AbstractCharacter {
|
||||
if (this.building != null)
|
||||
NPCManager.slotCharacterInBuilding(this);
|
||||
|
||||
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();
|
||||
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
|
||||
|
||||
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);
|
||||
}
|
||||
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)
|
||||
@@ -911,10 +906,10 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
this.charItemManager.load();
|
||||
|
||||
this.equip = loadEquipmentSet(this.equipmentSetID);
|
||||
if (equipmentSetID != 0 && LootManager._bootySetMap.get(equipmentSetID) == null)
|
||||
Logger.error("Invalid equipSet: " + equipmentSetID + " contract: " + this.contractUUID + " npc: " + this.getObjectUUID());
|
||||
|
||||
if (this.equip == null)
|
||||
this.equip = new HashMap<>();
|
||||
this.equip = loadEquipmentSet(this.equipmentSetID);
|
||||
|
||||
try {
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ 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;
|
||||
@@ -5427,10 +5426,6 @@ 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 final float major_radius;
|
||||
public final float minor_radius;
|
||||
public float major_radius;
|
||||
public float minor_radius;
|
||||
public final float xOffset;
|
||||
public final float zOffset;
|
||||
public final float yOffset;
|
||||
@@ -76,9 +76,6 @@ 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");
|
||||
@@ -163,6 +160,18 @@ 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();
|
||||
|
||||
@@ -192,7 +201,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.template.major_radius, this.template.minor_radius), 0.0f);
|
||||
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.major_radius, this.minor_radius), 0.0f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -315,6 +315,10 @@ public class WorldServer {
|
||||
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