Interface Pathfinder
public interface Pathfinder
A Pathfinder is a class that can find a path between two positions while following a given set of
rules.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Aborts the running pathfinding process.@NonNull CompletionStage<PathfinderResult>
findPath
(@NonNull PathPosition start, @NonNull PathPosition target, List<@NonNull PathFilter> filters) Tries to find a Path between the twoPathPosition
's provided with the given filters.@NonNull CompletionStage<PathfinderResult>
findPath
(@NonNull PathPosition start, @NonNull PathPosition target, List<PathFilter> sharedFilters, List<@NonNull PathFilterStage> filterStages) Tries to find a Path between the twoPathPosition
's provided with the given filter-containers.
-
Method Details
-
findPath
@NonNull @NonNull CompletionStage<PathfinderResult> findPath(@NonNull @NonNull PathPosition start, @NonNull @NonNull PathPosition target, @Nullable List<@NonNull PathFilter> filters) Tries to find a Path between the twoPathPosition
's provided with the given filters.- Parameters:
filters
- A list ofPathFilter
's to apply to the pathfinding process.- Returns:
- An
CompletionStage
that will contain aPathfinderResult
.
-
findPath
@NonNull @NonNull CompletionStage<PathfinderResult> findPath(@NonNull @NonNull PathPosition start, @NonNull @NonNull PathPosition target, @Nullable List<PathFilter> sharedFilters, @Nullable List<@NonNull PathFilterStage> filterStages) Tries to find a Path between the twoPathPosition
's provided with the given filter-containers.Other than the
findPath(PathPosition, PathPosition, List)
method, this method allows for more complex filtering by usingPathFilterStage
's.The filters in the stages will be applied in the order they are provided. If a filter in a stage returns false, the next stage will be checked. Only one stage needs to return true for the path to be considered valid.
- Parameters:
start
- The start position of the path.target
- The target position of the path.sharedFilters
- A list ofPathFilter
's, which will be applied to all stages.filterStages
- A list ofPathFilterStage
's to apply to the pathfinding- Returns:
- An
CompletionStage
that will contain aPathfinderResult
. - API Note:
- The stages will be checked in the order they are provided. The sharedFilters will be applied before the stages.
-
abort
void abort()Aborts the running pathfinding process.In this context aborts means that the pathfinding process will be stopped and the result will be
PathState.ABORTED
.
-