mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Add an object type parameter for raycasting
This commit is contained in:
@@ -145,14 +145,15 @@ public final class CollisionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Casts a ray into the world to check for impenetrable objects from the given {@code start} position to the
|
* Casts a ray into the world to check for impenetrable objects from the given {@code start} position to the
|
||||||
* {@code end} position using Bresenham's line algorithm.
|
* {@code end} position using Bresenham's line algorithm.
|
||||||
*
|
*
|
||||||
* @param start The start position of the ray.
|
* @param start The start position of the ray.
|
||||||
* @param end The end position of the ray.
|
* @param end The end position of the ray.
|
||||||
|
* @param objectType
|
||||||
* @return {@code true} if an impenetrable object was hit, {@code false} otherwise.
|
* @return {@code true} if an impenetrable object was hit, {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean raycast(Position start, Position end) {
|
public boolean raycast(Position start, Position end, EntityType objectType) {
|
||||||
Preconditions.checkArgument(start.getHeight() == end.getHeight(), "Positions must be on the same height");
|
Preconditions.checkArgument(start.getHeight() == end.getHeight(), "Positions must be on the same height");
|
||||||
|
|
||||||
if (start.equals(end)) {
|
if (start.equals(end)) {
|
||||||
@@ -221,7 +222,7 @@ public final class CollisionManager {
|
|||||||
Direction direction = Direction.fromDeltas(currX - lastX, currY - lastY);
|
Direction direction = Direction.fromDeltas(currX - lastX, currY - lastY);
|
||||||
Position last = new Position(lastX, lastY, start.getHeight());
|
Position last = new Position(lastX, lastY, start.getHeight());
|
||||||
|
|
||||||
if (!traversable(last, EntityType.PROJECTILE, direction)) {
|
if (!traversable(last, objectType, direction)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user