Class LocalCollision


  • public class LocalCollision
    extends Object
    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 Detail

      • LocalCollision

        public LocalCollision()
    • Method Detail

      • isEntityAreaWalkable

        public static boolean isEntityAreaWalkable​(SceneNode node)
        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:
        true if 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's CoordArea is walkable from the given source location.
        Parameters:
        reachability - reachability map to use
        src - source coordinate (usually player's location)
        target - the scene node
        Returns:
        true if any node tile is walkable
      • isWalkable

        public static boolean isWalkable​(Coord coord)
        Returns whether the given coordinate is walkable from the local player's current position.
        Parameters:
        coord - the tile to test
        Returns:
        true if tile is reachable and not blocked
      • isWalkable

        public static boolean isWalkable​(LocalReachability reachability,
                                         Coord src,
                                         Coord target)
        Core reachability check. A tile is reachable if:
        1. It is not collision-blocked.
        2. It lies within the player's flood-filled reachable region.
        Parameters:
        reachability - cached reachability map
        src - source coordinate
        target - the coordinate to test
        Returns:
        true if the tile is reachable
      • getInteractableCoord

        public static Coord getInteractableCoord​(SceneNode node)
        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 null if none exist
      • getInteractableCoord

        public static Coord getInteractableCoord​(Coord coord)
        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 null if none exist
      • isInteractable

        public static boolean isInteractable​(SceneNode node)
        Determines whether the given scene node is interactable from at least one walkable position around it.
        Parameters:
        node - the scene node
        Returns:
        true if any tile of the node is interactable
      • isInteractable

        public static boolean isInteractable​(Coord coord)
        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:
        true if interactable
      • getWalkableCoords

        public static Set<Coord> getWalkableCoords()
        Returns a snapshot of all locally reachable tiles according to the most recent flood-fill computation.
        Returns:
        an immutable set of all reachable coordinates around the player