|
|
@ -28,6 +28,8 @@ import engine.server.MBServerStatics; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.geom.Line2D; |
|
|
|
import java.awt.geom.Line2D; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashSet; |
|
|
|
|
|
|
|
|
|
|
|
public class MoveToPointHandler extends AbstractClientMsgHandler { |
|
|
|
public class MoveToPointHandler extends AbstractClientMsgHandler { |
|
|
|
|
|
|
|
|
|
|
|
public MoveToPointHandler() { |
|
|
|
public MoveToPointHandler() { |
|
|
@ -46,24 +48,28 @@ public class MoveToPointHandler extends AbstractClientMsgHandler { |
|
|
|
Line2D travelLine = new Line2D.Float(); |
|
|
|
Line2D travelLine = new Line2D.Float(); |
|
|
|
Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon()); |
|
|
|
Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon()); |
|
|
|
travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z); |
|
|
|
travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z); |
|
|
|
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(pc.loc, pc.loc.distance(endLoc), MBServerStatics.MASK_BUILDING)){ |
|
|
|
float movementDistance = 185 + pc.loc.distance(endLoc); |
|
|
|
|
|
|
|
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(pc.loc, movementDistance, MBServerStatics.MASK_BUILDING); |
|
|
|
|
|
|
|
for(AbstractWorldObject awo : awoList){ |
|
|
|
Building building = (Building)awo; |
|
|
|
Building building = (Building)awo; |
|
|
|
Rectangle.Float boundsRect = new Rectangle.Float(); |
|
|
|
Rectangle.Float boundsRect = new Rectangle.Float(); |
|
|
|
boundsRect.setRect(building.getBounds().getHalfExtents().x, building.getBounds().getHalfExtents().y, building.getBounds().getHalfExtents().x * 2,building.getBounds().getHalfExtents().y * 2); |
|
|
|
boundsRect.setRect(building.loc.x + building.getBounds().getHalfExtents().x, building.loc.z + building.getBounds().getHalfExtents().y, building.getBounds().getHalfExtents().x * 2,building.getBounds().getHalfExtents().y * 2); |
|
|
|
if(travelLine.intersects(boundsRect)){ |
|
|
|
//if(travelLine.intersects(boundsRect)){
|
|
|
|
//collided with building
|
|
|
|
//collided with building
|
|
|
|
for(Mesh mesh : building.buildingMeshes) |
|
|
|
for(Mesh mesh : building.buildingMeshes) { |
|
|
|
if(mesh.MeshCollides(travelLine,pc.getCharacterHeight())){ |
|
|
|
float height = pc.getCharacterHeight(); |
|
|
|
for(Triangle tri : mesh.triangles){ |
|
|
|
if (height < mesh.meshHeight) { |
|
|
|
if(tri.collides(travelLine)){ |
|
|
|
for (Triangle tri : mesh.triangles) { |
|
|
|
|
|
|
|
if (tri.collides(travelLine)) { |
|
|
|
ChatManager.chatSystemInfo(pc, "Collision Detected"); |
|
|
|
ChatManager.chatSystemInfo(pc, "Collision Detected"); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ChatManager.chatSystemInfo(pc, "No Collision Detected"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MovementManager.movement(msg, pc); |
|
|
|
MovementManager.movement(msg, pc); |
|
|
|