class

PointClickEngine::Navigation::Pathfinding

Inherits Reference < Object

Pathfinding system using component-based architecture

This Pathfinding class delegates responsibilities to specialized components:

  • NavigationGrid: Grid management and walkable areas
  • AStarAlgorithm: Core A* pathfinding implementation
  • PathOptimizer: Path smoothing and optimization
  • HeuristicCalculator: Distance calculation strategies
  • MovementValidator: Movement rules and validation
  • PathfindingDebugRenderer: Debug visualization

Constructors

for_grid_based(grid : NavigationGrid) : Pathfinding
Source
for_point_and_click(grid : NavigationGrid) : Pathfinding

Creates pathfinding system with optimal settings for different game types

Source
for_strategy(grid : NavigationGrid) : Pathfinding
Source
new(grid : NavigationGrid, heuristic_calculator : HeuristicCalculator | Nil = nil, movement_validator : MovementValidator | Nil = nil)
Source

Instance methods

algorithm
Source
algorithm=(algorithm : AStarAlgorithm)
Source
calculate_path_length(path : Array(RL::Vector2)) : Float32

Calculates actual path length

Source
configure(allow_diagonal : Bool | Nil = nil, prevent_corner_cutting : Bool | Nil = nil, heuristic_method : HeuristicCalculator::Method | Nil = nil, max_search_nodes : Int32 | Nil = nil)

Updates pathfinding settings

Source
debug_renderer
Source
debug_renderer=(debug_renderer : PathfindingDebugRenderer)
Source
disable_debug

Disables debug rendering

Source
draw_character_info(character_pos : RL::Vector2, target_pos : RL::Vector2 | Nil = nil)
Source
draw_grid(color_walkable : RL::Color = RL::GREEN, color_blocked : RL::Color = RL::RED, alpha : UInt8 = 100_u8)

Debug rendering methods

Source
draw_grid_stats(x : Int32 = 10, y : Int32 = 10)
Source
draw_path(path : Array(RL::Vector2), color : RL::Color = RL::YELLOW, thickness : Float32 = 3.0_f32)
Source
draw_performance_info(x : Int32, y : Int32, path_length : Float32)
Source
enable_debug

Enables debug rendering

Source
enable_debug=(enable_debug : Bool)
Source
estimate_path_cost(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32) : Float32

Calculates approximate path cost without finding full path

Source
find_closest_point_on_path(path : Array(RL::Vector2), position : RL::Vector2) : NamedTuple(point: RL::Vector2, index: Int32, distance: Float32)

Finds closest point on path to a given position

Source
find_partial_path(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32, max_distance : Float32 = 100.0_f32) : Array(RL::Vector2) | Nil

Finds partial path when full path is not available

Source
find_path(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32) : Array(RL::Vector2) | Nil

Finds an optimal path between two world positions

Source
find_path(start_pos : RL::Vector2, end_pos : RL::Vector2) : Array(RL::Vector2) | Nil

Finds path using Vector2 positions

Source
find_path_with_optimization(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32, optimization : Symbol = :normal) : Array(RL::Vector2) | Nil

Finds path with specific optimization level

Source
get_heuristic_calculator

Gets the heuristic calculator for external configuration

Source
get_movement_validator

Gets the movement validator for external configuration

Source
get_stats

Gets pathfinding statistics from last operation

Source
grid

Core components

Source
grid=(grid : NavigationGrid)

Core components

Source
is_path_valid?(path : Array(RL::Vector2)) : Bool

Validates if an existing path is still walkable

Source
optimize_paths

Pathfinding settings

Source
optimize_paths=(optimize_paths : Bool)

Pathfinding settings

Source
optimize_performance

Optimizes pathfinding performance for the current grid

Source
optimizer
Source
optimizer=(optimizer : PathOptimizer)
Source
path_exists?(start_x : Float32, start_y : Float32, end_x : Float32, end_y : Float32) : Bool

Checks if a path exists without returning the full path

Source
path_exists?(start_pos : RL::Vector2, end_pos : RL::Vector2) : Bool

Checks if a path exists using Vector2 positions

Source
to_s(io : IO) : Nil

String representation

Source
toggle_debug

Toggles debug rendering

Source
validate_system

Validates entire pathfinding system

Source