forked from MagicBane/Server
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a0e8782af | |||
| 63fa98486b | |||
| 2ca54f3cfa | |||
| dad615db2b | |||
| 134838072d | |||
| 6484e7eb93 | |||
| 32d71d72d1 | |||
| db015f7007 | |||
| a0066bce20 | |||
| 8c2adb760c | |||
| 8aca1a1810 | |||
| 2d4a604709 | |||
| 7b3741fc60 | |||
| 903470e7ae | |||
| 0e190b21e1 | |||
| b6be8815a3 | |||
| d8235954d2 | |||
| 37ca8c90e2 | |||
| b70a076cb2 |
@@ -1,27 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package engine.CollisionEngine;
|
|
||||||
|
|
||||||
import java.awt.geom.Line2D;
|
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Triangle {
|
|
||||||
public Point2D.Float point1;
|
|
||||||
public Point2D.Float point2;
|
|
||||||
public Point2D.Float point3;
|
|
||||||
public ArrayList<Line2D> sides;
|
|
||||||
public boolean collides(Line2D line)
|
|
||||||
{
|
|
||||||
for(Line2D side : sides)
|
|
||||||
if(side.intersectsLine(line))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,6 @@ public class Terrain {
|
|||||||
public Vector2f cell_size = new Vector2f();
|
public Vector2f cell_size = new Vector2f();
|
||||||
public Vector2f cell_count = new Vector2f();
|
public Vector2f cell_count = new Vector2f();
|
||||||
public float terrain_scale;
|
public float terrain_scale;
|
||||||
public Vector2f blend_values = new Vector2f();
|
|
||||||
public Vector2f blend_ratio = new Vector2f();
|
public Vector2f blend_ratio = new Vector2f();
|
||||||
public int heightmap;
|
public int heightmap;
|
||||||
Zone zone;
|
Zone zone;
|
||||||
@@ -63,14 +62,22 @@ public class Terrain {
|
|||||||
// the blending area between child and parent terrains when
|
// the blending area between child and parent terrains when
|
||||||
// they are stitched together.
|
// they are stitched together.
|
||||||
|
|
||||||
this.blend_values.x = this.zone.template.max_blend;
|
float max_blend = this.zone.template.max_blend;
|
||||||
this.blend_values.y = this.zone.template.min_blend;
|
float min_blend = this.zone.template.min_blend;
|
||||||
|
|
||||||
Vector2f major_blend = new Vector2f(this.blend_values.x / this.zone.major_radius,
|
// Zones with a zero blend inherit from their parent terrain
|
||||||
this.blend_values.y / this.zone.major_radius);
|
|
||||||
|
|
||||||
Vector2f minor_blend = new Vector2f(this.blend_values.x / this.zone.minor_radius,
|
if (this.zone.template.max_blend == 0) {
|
||||||
this.blend_values.y / this.zone.minor_radius);
|
Zone parentZone = this.getNextZoneWithTerrain(this.zone.parent);
|
||||||
|
max_blend = parentZone.template.max_blend;
|
||||||
|
min_blend = parentZone.template.min_blend;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2f major_blend = new Vector2f(max_blend / this.zone.major_radius,
|
||||||
|
min_blend / this.zone.major_radius);
|
||||||
|
|
||||||
|
Vector2f minor_blend = new Vector2f(max_blend / this.zone.minor_radius,
|
||||||
|
min_blend / this.zone.minor_radius);
|
||||||
|
|
||||||
if (major_blend.y > 0.4f)
|
if (major_blend.y > 0.4f)
|
||||||
blend_ratio.x = major_blend.y;
|
blend_ratio.x = major_blend.y;
|
||||||
|
|||||||
@@ -9,25 +9,17 @@
|
|||||||
|
|
||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
import engine.CollisionEngine.CollisionManager;
|
|
||||||
import engine.CollisionEngine.MeshData;
|
|
||||||
import engine.CollisionEngine.Triangle;
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.DbObjectType;
|
import engine.Enum.DbObjectType;
|
||||||
import engine.Enum.ProtectionState;
|
import engine.Enum.ProtectionState;
|
||||||
import engine.Enum.TaxType;
|
import engine.Enum.TaxType;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.math.Vector3f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.pmw.tinylog.Logger;
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -35,7 +27,6 @@ import java.sql.SQLException;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@@ -858,167 +849,4 @@ public class dbBuildingHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LOAD_MESH_DATA(){
|
|
||||||
CollisionManager.structure_meshes = new HashMap<>();
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `final_structure_meshes`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
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> meshData = new ArrayList<>();
|
|
||||||
meshData.add(md);
|
|
||||||
CollisionManager.structure_meshes.put(rs.getInt("propID"),meshData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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`")) {
|
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
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<Triangle> triData = new ArrayList<>();
|
|
||||||
triData.add(tri);
|
|
||||||
CollisionManager.mesh_triangles.put(rs.getInt("meshID"),triData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,19 +34,16 @@ public class dbCityHandler extends dbHandlerBase {
|
|||||||
case "zone":
|
case "zone":
|
||||||
Zone zone = new Zone(rs);
|
Zone zone = new Zone(rs);
|
||||||
DbManager.addToCache(zone);
|
DbManager.addToCache(zone);
|
||||||
zone.runAfterLoad();
|
|
||||||
list.add(zone);
|
list.add(zone);
|
||||||
break;
|
break;
|
||||||
case "building":
|
case "building":
|
||||||
Building building = new Building(rs);
|
Building building = new Building(rs);
|
||||||
DbManager.addToCache(building);
|
DbManager.addToCache(building);
|
||||||
building.runAfterLoad();
|
|
||||||
list.add(building);
|
list.add(building);
|
||||||
break;
|
break;
|
||||||
case "city":
|
case "city":
|
||||||
City city = new City(rs);
|
City city = new City(rs);
|
||||||
DbManager.addToCache(city);
|
DbManager.addToCache(city);
|
||||||
city.runAfterLoad();
|
|
||||||
list.add(city);
|
list.add(city);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2022
|
|
||||||
// www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.devcmd.cmds;
|
|
||||||
|
|
||||||
import engine.CollisionEngine.Mesh;
|
|
||||||
import engine.Enum;
|
|
||||||
import engine.devcmd.AbstractDevCmd;
|
|
||||||
import engine.objects.*;
|
|
||||||
|
|
||||||
public class ColliderCmd extends AbstractDevCmd {
|
|
||||||
|
|
||||||
public ColliderCmd() {
|
|
||||||
super("collider");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
|
||||||
AbstractGameObject target) {
|
|
||||||
|
|
||||||
String newline = "\r\n ";
|
|
||||||
String output;
|
|
||||||
if(target.getObjectType().equals(Enum.GameObjectType.Building) == false){
|
|
||||||
throwbackInfo(pc,"Please Select A Building To Show Collider Data");
|
|
||||||
}
|
|
||||||
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 "Displays Information About Colliders";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String _getUsageString() {
|
|
||||||
return "' /collider displays collision info when selected on a building";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -49,33 +49,19 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
float blendedHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
|
float blendedHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||||
|
|
||||||
Vector2f terrainCell = heightmapZone.terrain.getTerrainCell(childZoneLoc);
|
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(childZoneLoc);
|
||||||
Vector2f cell_offset = new Vector2f(terrainCell.x % 1, terrainCell.y % 1);
|
gridSquare.x = (float) Math.floor(gridSquare.x);
|
||||||
|
gridSquare.y = (float) Math.floor(gridSquare.y);
|
||||||
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, "Current Zone : " + currentZone.zoneName);
|
||||||
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);
|
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);
|
||||||
this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName);
|
this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName);
|
||||||
|
|
||||||
this.throwbackInfo(playerCharacter, "Player loc: " + "[" + playerCharacter.loc.x + "]" + "[" + playerCharacter.loc.y + "]" + "[" + playerCharacter.loc.z + "]");
|
this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]");
|
||||||
|
this.throwbackInfo(playerCharacter, "offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
||||||
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, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
|
||||||
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.max_blend + " /" + heightmapZone.template.min_blend);
|
this.throwbackInfo(playerCharacter, "Heightmap blend Values: max/min" + heightmapZone.template.min_blend + " /" + heightmapZone.template.max_blend);
|
||||||
this.throwbackInfo(playerCharacter, "terrain values (max/min): " + heightmapZone.terrain.blend_values.x + " /" + heightmapZone.terrain.blend_values.y);
|
this.throwbackInfo(playerCharacter, "Parent blend Values: nax/min" + parentZone.template.min_blend + " /" + parentZone.template.max_blend);
|
||||||
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
||||||
|
|
||||||
this.throwbackInfo(playerCharacter, "------------");
|
this.throwbackInfo(playerCharacter, "------------");
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
import engine.CollisionEngine.Mesh;
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.BuildingGroup;
|
import engine.Enum.BuildingGroup;
|
||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
@@ -245,6 +244,7 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
for (Regions regions : targetBuilding.getBounds().getRegions()) {
|
for (Regions regions : targetBuilding.getBounds().getRegions()) {
|
||||||
//TODO ADD REGION INFO
|
//TODO ADD REGION INFO
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PlayerCharacter:
|
case PlayerCharacter:
|
||||||
output += newline;
|
output += newline;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
import engine.CollisionEngine.Mesh;
|
import engine.Enum;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class RegionCmd extends AbstractDevCmd {
|
public class RegionCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@ public class RegionCmd extends AbstractDevCmd {
|
|||||||
Regions region = ((AbstractCharacter)target).region;
|
Regions region = ((AbstractCharacter)target).region;
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
this.throwbackInfo(pc, "No Region Found.");
|
this.throwbackInfo(pc, "No Region Found.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(region != null) {
|
if(region != null) {
|
||||||
@@ -47,6 +48,7 @@ public class RegionCmd extends AbstractDevCmd {
|
|||||||
output += "is Outside: " + region.isOutside();
|
output += "is Outside: " + region.isOutside();
|
||||||
this.throwbackInfo(pc, output);
|
this.throwbackInfo(pc, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,21 +9,15 @@
|
|||||||
|
|
||||||
package engine.gameManager;
|
package engine.gameManager;
|
||||||
|
|
||||||
import engine.CollisionEngine.CollisionManager;
|
|
||||||
import engine.CollisionEngine.MeshData;
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.BuildingGroup;
|
import engine.Enum.BuildingGroup;
|
||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.InterestManagement.InterestManager;
|
import engine.InterestManagement.InterestManager;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.CollisionEngine.Mesh;
|
|
||||||
import engine.CollisionEngine.Triangle;
|
|
||||||
import engine.job.JobContainer;
|
import engine.job.JobContainer;
|
||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.UpgradeBuildingJob;
|
import engine.jobs.UpgradeBuildingJob;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector2f;
|
|
||||||
import engine.math.Vector3f;
|
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
@@ -33,9 +27,6 @@ import engine.objects.*;
|
|||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
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.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -47,12 +38,6 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
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>> _stuckLocations = new HashMap<>();
|
||||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
||||||
|
|
||||||
@@ -957,9 +942,6 @@ public enum BuildingManager {
|
|||||||
|
|
||||||
cleanupHirelings(building);
|
cleanupHirelings(building);
|
||||||
|
|
||||||
//rebake colliders for change in rank
|
|
||||||
//BuildingManager.BakeBuildingMeshes(building);
|
|
||||||
BuildingManager.BakeBuildingColliders(building);
|
|
||||||
building.isDeranking.compareAndSet(true, false);
|
building.isDeranking.compareAndSet(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,46 +960,4 @@ public enum BuildingManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void BakeBuildingColliders(Building building){
|
|
||||||
|
|
||||||
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<>();
|
|
||||||
|
|
||||||
//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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ public enum DevCmdManager {
|
|||||||
DevCmdManager.registerDevCmd(new BoundsCmd());
|
DevCmdManager.registerDevCmd(new BoundsCmd());
|
||||||
DevCmdManager.registerDevCmd(new GotoBoundsCmd());
|
DevCmdManager.registerDevCmd(new GotoBoundsCmd());
|
||||||
DevCmdManager.registerDevCmd(new RegionCmd());
|
DevCmdManager.registerDevCmd(new RegionCmd());
|
||||||
DevCmdManager.registerDevCmd(new ColliderCmd());
|
|
||||||
DevCmdManager.registerDevCmd(new SetMaintCmd());
|
DevCmdManager.registerDevCmd(new SetMaintCmd());
|
||||||
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
DevCmdManager.registerDevCmd(new ApplyBonusCmd());
|
||||||
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
DevCmdManager.registerDevCmd(new AuditFailedItemsCmd());
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.gameManager;
|
||||||
|
|
||||||
|
import engine.loot.WorkOrder;
|
||||||
|
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.DelayQueue;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public enum ForgeManager implements Runnable {
|
||||||
|
|
||||||
|
FORGE_MANAGER;
|
||||||
|
|
||||||
|
private final BlockingQueue<WorkOrder> workQueue = new DelayQueue();
|
||||||
|
public static final AtomicInteger workOrder = new AtomicInteger(0);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
WorkOrder workOrder = workQueue.take();
|
||||||
|
|
||||||
|
// Fulfill workOrder
|
||||||
|
|
||||||
|
for (int i = 0; i < workOrder.slotCount; ++i) {
|
||||||
|
|
||||||
|
// Create workOrder items; one for each slot
|
||||||
|
// assigned to this workOrder.
|
||||||
|
|
||||||
|
// if Prefix and suffix are null random roll item
|
||||||
|
// otherwise roll what was asked for
|
||||||
|
|
||||||
|
workOrder.itemCount = workOrder.itemCount - 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (workOrder.itemCount == 0) {
|
||||||
|
|
||||||
|
workOrder.runCompleted = true;
|
||||||
|
|
||||||
|
// Remove this workOrder from any slots on vendor
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resubmit workOrder
|
||||||
|
|
||||||
|
workOrder.completionTime = System.currentTimeMillis() + 10000;
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.loot;
|
||||||
|
|
||||||
|
import engine.gameManager.ForgeManager;
|
||||||
|
import engine.objects.NPC;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.Delayed;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static java.lang.Math.toIntExact;
|
||||||
|
|
||||||
|
public class WorkOrder implements Delayed {
|
||||||
|
|
||||||
|
public int workOrder;
|
||||||
|
public NPC vendor;
|
||||||
|
public int slotCount;
|
||||||
|
public int itemCount;
|
||||||
|
public int itemBase;
|
||||||
|
public String itemName;
|
||||||
|
public int prefixToken;
|
||||||
|
public int suffixToken;
|
||||||
|
public boolean isRandom;
|
||||||
|
public long completionTime;
|
||||||
|
public boolean runCompleted;
|
||||||
|
|
||||||
|
public WorkOrder() {
|
||||||
|
|
||||||
|
this.workOrder = ForgeManager.workOrder.incrementAndGet();
|
||||||
|
this.completionTime = System.currentTimeMillis() + 10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDelay(TimeUnit unit) {
|
||||||
|
|
||||||
|
long timeRemaining = completionTime - System.currentTimeMillis();
|
||||||
|
return unit.convert(timeRemaining, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NotNull Delayed o) {
|
||||||
|
return toIntExact(this.completionTime - ((WorkOrder) o).completionTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
package engine.mobileAI.Threads;
|
package engine.mobileAI.Threads;
|
||||||
|
|
||||||
import engine.gameManager.ConfigManager;
|
import engine.gameManager.ConfigManager;
|
||||||
import engine.mobileAI.MobAI;
|
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
|
import engine.mobileAI.MobAI;
|
||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.server.MBServerStatics;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
public class MobAIThread implements Runnable{
|
public class MobAIThread implements Runnable{
|
||||||
@@ -14,23 +21,27 @@ public class MobAIThread implements Runnable{
|
|||||||
public static int AI_PULSE_MOB_THRESHOLD = 200;
|
public static int AI_PULSE_MOB_THRESHOLD = 200;
|
||||||
public static int AI_PATROL_DIVISOR = 15;
|
public static int AI_PATROL_DIVISOR = 15;
|
||||||
public static float AI_CAST_FREQUENCY;
|
public static float AI_CAST_FREQUENCY;
|
||||||
|
|
||||||
// Thread constructor
|
// Thread constructor
|
||||||
|
|
||||||
public MobAIThread() {
|
public MobAIThread() {
|
||||||
Logger.info(" MobAIThread thread has started!");
|
|
||||||
|
//cache config value for mobile casting delay
|
||||||
|
|
||||||
|
AI_CAST_FREQUENCY = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue());
|
||||||
|
AI_BASE_AGGRO_RANGE = (int) (60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//cache config value for mobile casting delay
|
|
||||||
AI_CAST_FREQUENCY = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue());
|
Logger.info(" MobAIThread thread has started!");
|
||||||
AI_BASE_AGGRO_RANGE = (int)(60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()));
|
|
||||||
while (true) {
|
while (true) {
|
||||||
for (Zone zone : ZoneManager.getAllZones()) {
|
|
||||||
|
|
||||||
for (Mob mob : zone.zoneMobSet) {
|
|
||||||
|
|
||||||
|
for (Zone zone : ZoneManager.getAllZones())
|
||||||
|
for (Mob mob : zone.zoneMobSet)
|
||||||
try {
|
try {
|
||||||
if (mob != null)
|
if (mob != null)
|
||||||
MobAI.DetermineAction(mob);
|
MobAI.DetermineAction(mob);
|
||||||
@@ -38,10 +49,10 @@ public class MobAIThread implements Runnable{
|
|||||||
Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e);
|
Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startAIThread() {
|
public static void startAIThread() {
|
||||||
Thread aiThread;
|
Thread aiThread;
|
||||||
aiThread = new Thread(new MobAIThread());
|
aiThread = new Thread(new MobAIThread());
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import engine.Enum.ItemType;
|
|||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.loot.WorkOrder;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
@@ -455,9 +456,18 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
switch (msg.getActionType()) {
|
switch (msg.getActionType()) {
|
||||||
|
|
||||||
case ACTION_PRODUCE:
|
case ACTION_PRODUCE:
|
||||||
boolean isRandom = false;
|
|
||||||
if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0)
|
boolean isRandom = msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0;
|
||||||
isRandom = true;
|
|
||||||
|
WorkOrder workOrder = new WorkOrder();
|
||||||
|
workOrder.vendor = vendorNPC;
|
||||||
|
workOrder.isRandom = isRandom;
|
||||||
|
workOrder.itemBase = msg.getItemUUID();
|
||||||
|
workOrder.itemCount = msg.getTotalProduction();
|
||||||
|
workOrder.prefixToken = msg.getpToken();
|
||||||
|
workOrder.suffixToken = msg.getsToken();
|
||||||
|
workOrder.itemName = msg.getName();
|
||||||
|
|
||||||
//Create Multiple Item Function.. Fill all empty slots
|
//Create Multiple Item Function.. Fill all empty slots
|
||||||
if (msg.isMultiple()) {
|
if (msg.isMultiple()) {
|
||||||
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size();
|
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size();
|
||||||
|
|||||||
@@ -9,22 +9,14 @@
|
|||||||
|
|
||||||
package engine.net.client.handlers;
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.Enum;
|
||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.ChatManager;
|
|
||||||
import engine.CollisionEngine.CollisionManager;
|
|
||||||
import engine.gameManager.MovementManager;
|
import engine.gameManager.MovementManager;
|
||||||
import engine.math.Vector3fImmutable;
|
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.ClientNetMsg;
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
import engine.net.client.msg.MoveToPointMsg;
|
import engine.net.client.msg.MoveToPointMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.server.MBServerStatics;
|
|
||||||
|
|
||||||
import java.awt.geom.Line2D;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class MoveToPointHandler extends AbstractClientMsgHandler {
|
public class MoveToPointHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
@@ -40,32 +32,6 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
|
|||||||
if(pc == null)
|
if(pc == null)
|
||||||
return true;
|
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);
|
MovementManager.movement(msg, pc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -766,6 +766,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
cityObjectMap.put(gameObject.getObjectType(), gameObject);
|
cityObjectMap.put(gameObject.getObjectType(), gameObject);
|
||||||
|
|
||||||
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
treeObject = (Building) cityObjectMap.get(GameObjectType.Building);
|
||||||
|
treeObject.runAfterLoad();
|
||||||
|
|
||||||
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
cityObject = (City) cityObjectMap.get(GameObjectType.City);
|
||||||
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
zoneObject = (Zone) cityObjectMap.get(GameObjectType.Zone);
|
||||||
|
|
||||||
@@ -797,10 +799,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
City.lastCityUpdate = System.currentTimeMillis();
|
City.lastCityUpdate = System.currentTimeMillis();
|
||||||
treeObject.setLoc(treeObject.getLoc());
|
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);
|
InterestManager.setObjectDirty(treeObject);
|
||||||
|
|
||||||
serverRealm.addCity(cityObject.getObjectUUID());
|
serverRealm.addCity(cityObject.getObjectUUID());
|
||||||
|
|||||||
@@ -9,13 +9,11 @@
|
|||||||
|
|
||||||
package engine.objects;
|
package engine.objects;
|
||||||
|
|
||||||
import engine.CollisionEngine.Triangle;
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.Enum.*;
|
import engine.Enum.*;
|
||||||
import engine.InterestManagement.RealmMap;
|
import engine.InterestManagement.RealmMap;
|
||||||
import engine.InterestManagement.Terrain;
|
import engine.InterestManagement.Terrain;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
import engine.CollisionEngine.Mesh;
|
|
||||||
import engine.db.archive.CityRecord;
|
import engine.db.archive.CityRecord;
|
||||||
import engine.db.archive.DataWarehouse;
|
import engine.db.archive.DataWarehouse;
|
||||||
import engine.db.archive.MineRecord;
|
import engine.db.archive.MineRecord;
|
||||||
@@ -36,7 +34,6 @@ import engine.net.client.msg.UpdateObjectMsg;
|
|||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.awt.geom.Rectangle2D;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -102,9 +99,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
private ConcurrentHashMap<Integer, Condemned> condemned;
|
private ConcurrentHashMap<Integer, Condemned> condemned;
|
||||||
private ArrayList<Building> children = null;
|
private ArrayList<Building> children = null;
|
||||||
|
|
||||||
public ArrayList<Mesh> buildingMeshes;
|
|
||||||
public Rectangle2D.Float buildingRect;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
*/
|
*/
|
||||||
@@ -293,30 +287,7 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
public final City getCity() {
|
public final City getCity() {
|
||||||
|
|
||||||
if (this.parentZone == null)
|
return ZoneManager.getCityAtLocation(this.getLoc());
|
||||||
return null;
|
|
||||||
|
|
||||||
if (this.getBlueprint() != null && this.getBlueprint().isSiegeEquip() && this.protectionState.equals(ProtectionState.PROTECTED)) {
|
|
||||||
if (this.getGuild() != null) {
|
|
||||||
if (this.getGuild().getOwnedCity() != null) {
|
|
||||||
if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.halfExtents))
|
|
||||||
return this.getGuild().getOwnedCity();
|
|
||||||
} else {
|
|
||||||
Bane bane = Bane.getBaneByAttackerGuild(this.getGuild());
|
|
||||||
|
|
||||||
if (bane != null) {
|
|
||||||
if (bane.getCity() != null) {
|
|
||||||
if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.halfExtents))
|
|
||||||
return bane.getCity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.parentZone.guild_zone == false)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return City.getCity(this.parentZone.playerCityUUID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,9 +980,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
if (this.upgradeDateTime != null)
|
if (this.upgradeDateTime != null)
|
||||||
BuildingManager.submitUpgradeJob(this);
|
BuildingManager.submitUpgradeJob(this);
|
||||||
|
|
||||||
//BuildingManager.BakeBuildingMeshes(this);
|
|
||||||
BuildingManager.BakeBuildingColliders(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import engine.gameManager.*;
|
|||||||
import engine.job.JobContainer;
|
import engine.job.JobContainer;
|
||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.UpgradeNPCJob;
|
import engine.jobs.UpgradeNPCJob;
|
||||||
|
import engine.loot.WorkOrder;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
@@ -37,6 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
||||||
@@ -52,6 +54,8 @@ public class NPC extends AbstractCharacter {
|
|||||||
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
||||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||||
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
||||||
|
|
||||||
|
public CopyOnWriteArrayList<WorkOrder> workOrders = new CopyOnWriteArrayList();
|
||||||
public HashMap<Integer, MobEquipment> equip = null;
|
public HashMap<Integer, MobEquipment> equip = null;
|
||||||
public int runeSetID = 0;
|
public int runeSetID = 0;
|
||||||
public int extraRune2 = 0;
|
public int extraRune2 = 0;
|
||||||
|
|||||||
@@ -309,12 +309,6 @@ public class WorldServer {
|
|||||||
Logger.info("Initializing Errant Guild");
|
Logger.info("Initializing Errant Guild");
|
||||||
Guild.getErrantGuild();
|
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");
|
Logger.info("Loading zone template data");
|
||||||
DbManager.ZoneQueries.LOAD_ALL_ZONE_TEMPLATES();
|
DbManager.ZoneQueries.LOAD_ALL_ZONE_TEMPLATES();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user