Manages navigation and pathfinding for a scene
The NavigationManager handles all pathfinding-related functionality including:
- Navigation grid setup and management
- Pathfinding system initialization
- Path calculation between points
- Navigation debug visualization
Constructors
new(scene_width : Int32, scene_height : Int32)
SourceInstance methods
clear_navigation
Clears navigation data and resets system
Sourcedraw_navigation_debug(camera_offset : RL::Vector2)
Draws debug visualization for navigation system
Renders the navigation grid, showing walkable and blocked cells.
Only draws when debug mode is enabled.
- camera_offset : Camera offset for proper positioning
Sourceexport_navigation_data
Exports navigation data for external tools
Sourcefind_path(start_x : Int32, start_y : Int32, end_x : Int32, end_y : Int32) : Array(RL::Vector2) | Nil
Finds a path between two points using A* pathfinding
Returns an array of waypoints from start to end position, or nil if
no path exists. Coordinates are in world space.
- start_x : Starting X coordinate in world space
- start_y : Starting Y coordinate in world space
- end_x : Target X coordinate in world space
- end_y : Target Y coordinate in world space
Returns: Array of Vector2 waypoints, or nil if no path found
Sourceget_navigation_stats
Gets navigation statistics for debugging
Sourcegrid_cell_size
Navigation grid cell size (default: 10 pixels per cell)
Sourcegrid_cell_size=(grid_cell_size : Int32)
Navigation grid cell size (default: 10 pixels per cell)
Sourceimport_navigation_data(json_data : String)
Imports navigation data from external source
Sourceinitialized?
Checks if navigation system is properly initialized
Sourceis_navigable?(x : Int32, y : Int32) : Bool
Checks if a specific position is navigable
- x : X coordinate in world space
- y : Y coordinate in world space
Returns: true if the position can be navigated to
Sourcenavigation_grid
Navigation grid for pathfinding
Sourcenavigation_grid=(navigation_grid : Navigation::NavigationGrid | Nil)
Navigation grid for pathfinding
Sourceoptimize_navigation
Optimizes navigation grid by removing unnecessary nodes
Sourcepathfinder=(pathfinder : Navigation::AStarAlgorithm | Nil)
Sourcescene_height=(scene_height : Int32)
Sourcescene_width
Scene dimensions for navigation setup
Sourcescene_width=(scene_width : Int32)
Scene dimensions for navigation setup
Sourcesetup_navigation(walkable_area : WalkableArea | Nil = nil)
Sets up navigation grid and pathfinding system
Creates a navigation grid based on scene dimensions and initializes
the A* pathfinder. Must be called before using pathfinding.
- walkable_area : Optional walkable area for navigation constraints
Sourceupdate_navigation(walkable_area : WalkableArea | Nil = nil)
Updates navigation grid based on scene changes
Recalculates walkable cells when scene layout changes.
Should be called when walkable areas are modified.
- walkable_area : Updated walkable area definition
Source