forked from MagicBane/Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.1 KiB
27 lines
1.1 KiB
package engine.CollisionEngine; |
|
|
|
import engine.math.Vector3f; |
|
import engine.objects.Building; |
|
|
|
import java.awt.*; |
|
import java.awt.geom.Line2D; |
|
|
|
public class CollisionManager { |
|
public static boolean CollisionDetected(Building building, Line2D travelLine, float charHeight, float charY){ |
|
Rectangle.Float boundsRect = new Rectangle.Float(); |
|
Vector3f topLeft = new Vector3f(building.loc.x - building.getBounds().getHalfExtents().x,building.loc.y,building.loc.z - building.getBounds().getHalfExtents().y); |
|
|
|
boundsRect.setRect(topLeft.x, topLeft.z, building.getBounds().getHalfExtents().x * 2,building.getBounds().getHalfExtents().y * 2); |
|
if(travelLine.intersects(boundsRect)){ |
|
//collided with building |
|
for(Mesh mesh : building.buildingMeshes) { |
|
if (mesh.MeshCollides(travelLine,charHeight, charY)) { |
|
//ChatManager.chatSystemInfo(pc, "Collision Detected"); |
|
//MovementManager.movement(msg, pc); |
|
return true; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
}
|
|
|