Class LocalCollision
java.lang.Object
org.rspeer.game.coord.collision.LocalCollision
Provides high-level collision and reachability utilities for determining whether
tiles or scene nodes near the local player can be walked to or interacted with.
Definitions
Walkable
A tile is considered walkable if the local player can pathfind to that tile using normal movement rules:- The tile is not collision-blocked (objects, walls, floor blockers).
- The tile is part of the local player's flood-filled reachable region.
- Diagonal and directional blocking rules are respected.
In other words: walkable = pathable = reachable by movement.
Interactable
A tile or scene node is considered interactable if the player can stand on at least one valid adjacent walkable tile and interact from there.Interactable does not require the target tile to be walkable itself. For example:
- A wall object occupies its tile (not walkable) but is still interactable.
- A large object may be interactable from some sides but not others.
- Doors, chests, and NPCs are often interactable without the tile itself being walkable.
In short: interactable = the player can stand somewhere and reach it with an action.
Purpose
This class consolidates collision checking, reachability tracking, and interactability logic into a simple interface used by pathfinding, targeting, object interaction, and movement systems.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CoordAttempts to find a tile the player can stand on in order to interact with the given scene node.static CoordgetInteractableCoord(Coord coord) Finds a walkable tile from which the player can interact with the given coordinate.Returns a snapshot of all locally reachable tiles according to the most recent flood-fill computation.static Coord[]static booleanDetermines whether any tile occupied by the given scene node is walkable from the local player's current position.static booleanisEntityAreaWalkable(LocalReachability reachability, Coord src, SceneNode target) Determines whether any coordinate within the node'sCoordAreais walkable from the given source location.static booleanisInteractable(SceneNode node) Determines whether the given scene node is interactable from at least one walkable position around it.static booleanisInteractable(Coord coord) Returns whether the given coordinate is interactable, meaning that a walkable tile exists from which the player can interact with it.static booleanisWalkable(LocalReachability reachability, Coord src, Coord target) Core reachability check.static booleanisWalkable(Coord coord) Returns whether the given coordinate is walkable from the local player's current position.
-
Constructor Details
-
LocalCollision
public LocalCollision()
-
-
Method Details
-
isEntityAreaWalkable
Determines whether any tile occupied by the given scene node is walkable from the local player's current position. Useful for large multi-tile entities.- Parameters:
node- the scene node to test- Returns:
trueif at least one tile of the node is walkable
-
isEntityAreaWalkable
public static boolean isEntityAreaWalkable(LocalReachability reachability, Coord src, SceneNode target) Determines whether any coordinate within the node'sCoordAreais walkable from the given source location.- Parameters:
reachability- reachability map to usesrc- source coordinate (usually player's location)target- the scene node- Returns:
trueif any node tile is walkable
-
isWalkable
Returns whether the given coordinate is walkable from the local player's current position.- Parameters:
coord- the tile to test- Returns:
trueif tile is reachable and not blocked
-
isWalkable
Core reachability check. A tile is reachable if:- It is not collision-blocked.
- It lies within the player's flood-filled reachable region.
- Parameters:
reachability- cached reachability mapsrc- source coordinatetarget- the coordinate to test- Returns:
trueif the tile is reachable
-
getInteractableCoord
Attempts to find a tile the player can stand on in order to interact with the given scene node. This is useful for multi-tile objects or objects with blocked tiles inside their footprint.- Parameters:
node- the object/NPC/scene node to interact with- Returns:
- the first walkable tile that allows interaction, or
nullif none exist
-
getInteractableCoord
Finds a walkable tile from which the player can interact with the given coordinate. If the tile itself is walkable, it is returned directly. Otherwise adjacent cardinal tiles are tested using collision-aware movement rules.- Parameters:
coord- the target coordinate- Returns:
- a walkable adjacent tile suitable for interaction, or
nullif none exist
-
isInteractable
Determines whether the given scene node is interactable from at least one walkable position around it.- Parameters:
node- the scene node- Returns:
trueif any tile of the node is interactable
-
isInteractable
Returns whether the given coordinate is interactable, meaning that a walkable tile exists from which the player can interact with it.- Parameters:
coord- the tile to test- Returns:
trueif interactable
-
getWalkableCoords
-
getWalkableCoordSnapshot
-