Class LocalPath<T extends Locatable>

Type Parameters:
T - locatable node type
All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>, SequencedCollection<T>

public class LocalPath<T extends Locatable> extends AbstractPath<T>
Ordered local path that selects the furthest loaded same-plane node near the player.
  • Field Details

    • DEFAULT_STEP_DISTANCE

      public static final int DEFAULT_STEP_DISTANCE
      Default maximum direct distance of a selected node from the player.
      See Also:
  • Constructor Details

    • LocalPath

      public LocalPath()
      Creates an empty forward local path.
    • LocalPath

      public LocalPath(Collection<? extends T> nodes)
      Creates a local path from a collection.
      Parameters:
      nodes - initial ordered nodes; null creates an empty path
    • LocalPath

      @SafeVarargs public LocalPath(T... nodes)
      Creates a local path from ordered varargs nodes.
      Parameters:
      nodes - initial nodes
  • Method Details

    • closest

      public T closest()
      Finds the node closest to the local player.
      Returns:
      same-plane node nearest to the local player, or null
    • closest

      public T closest(Tile origin)
      Finds the same-plane node nearest to an origin by squared X/Y distance.
      Parameters:
      origin - comparison origin
      Returns:
      nearest node, or null for null origin, empty path, or no same-plane node
    • next

      public T next()
      Selects the next default-distance node.
      Specified by:
      next in class AbstractPath<T extends Locatable>
      Returns:
      next node within DEFAULT_STEP_DISTANCE, or null
    • next

      public T next(int maximumDistance)
      Selects the next node relative to the local player.
      Parameters:
      maximumDistance - positive same-plane direct-distance limit
      Returns:
      furthest eligible node in the traversal direction, or null
    • next

      public T next(Tile origin, int maximumDistance)
      Deterministic node selection form useful for route planning and testing.
      Parameters:
      origin - explicit comparison origin
      maximumDistance - positive same-plane direct-distance limit
      Returns:
      furthest eligible node in the traversal direction, or null
    • getFurthestOnMap

      public T getFurthestOnMap()
      Returns the furthest eligible default-distance node.
      Returns:
      next default-distance node, or null; alias for next()
    • walk

      public boolean walk()
      Advances with the default four-tile handoff threshold.
      Specified by:
      walk in class AbstractPath<T extends Locatable>
      Returns:
      true when movement is healthy or a native walk was accepted
    • walk

      public boolean walk(int advanceDistance)
      Walks the next loaded segment without replacing a healthy destination. A new segment is queued only when idle or when the current destination is within advanceDistance tiles, producing continuous movement across longer paths.
      Parameters:
      advanceDistance - non-negative remaining-distance handoff threshold
      Returns:
      true when movement remains healthy or a new destination was accepted
    • isFinished

      public boolean isFinished()
      Tests whether the exact traversal endpoint has been reached.
      Returns:
      whether the traversal endpoint is the player's exact tile
    • isFinished

      public boolean isFinished(int radius)
      Tests same-plane proximity to the endpoint in the current traversal direction.
      Parameters:
      radius - inclusive non-negative Chebyshev radius
      Returns:
      true when an endpoint exists and the player is within its radius
    • getLastWalkedPath

      public static LocalPath<? extends Locatable> getLastWalkedPath()
      Returns the last path used by walk().
      Returns:
      most recent local path whose walking remained healthy or dispatched successfully