class

PointClickEngine::Navigation::NavigationGrid

Inherits Reference < Object

Grid-based navigation mesh for pathfinding

The NavigationGrid provides a grid-based representation of walkable areas in the game world. It handles coordinate conversion between world space and grid space, and manages walkable/non-walkable cell states.

Constructors

from_scene(scene : Scenes::Scene, width : Int32, height : Int32, cell_size : Int32 = PointClickEngine::Core::GameConstants::DEFAULT_NAVIGATION_CELL_SIZE, character_radius : Float32 = PointClickEngine::Core::GameConstants::DEFAULT_CHARACTER_RADIUS) : NavigationGrid

Creates a grid from scene data

Source
new(width : Int32, height : Int32, cell_size : Int32 = PointClickEngine::Core::GameConstants::DEFAULT_NAVIGATION_CELL_SIZE)
Source

Instance methods

cell_size
Source
cell_size=(cell_size : Int32)
Source
clear

Clears all walkable data (makes everything walkable)

Source
clone

Creates a copy of this grid

Source
fill_non_walkable

Fills all walkable data (makes everything non-walkable)

Source
get_walkable_neighbors(grid_x : Int32, grid_y : Int32, allow_diagonal : Bool = true) : Array(Tuple(Int32, Int32))

Gets all walkable cells adjacent to a given position

Source
grid_to_world(grid_x : Int32, grid_y : Int32) : Tuple(Float32, Float32)

Converts grid coordinates to world coordinates (center of cell)

Source
height
Source
height=(height : Int32)
Source
in_bounds?(world_x : Float32, world_y : Float32) : Bool

Checks if world coordinates are within grid bounds

Source
is_walkable?(x : Int32, y : Int32) : Bool

Checks if a grid cell is walkable

Source
set_circle_walkable(center_x : Float32, center_y : Float32, radius : Float32, walkable : Bool)

Marks a circular area as walkable or not walkable

Source
set_rect_walkable(x : Int32, y : Int32, width : Int32, height : Int32, walkable : Bool)

Marks a rectangular area as walkable or not walkable

Source
set_walkable(x : Int32, y : Int32, walkable : Bool)

Sets walkable state for a specific grid cell

Source
to_s(io : IO) : Nil

String representation for debugging

Source
valid_grid_coords?(grid_x : Int32, grid_y : Int32) : Bool

Checks if grid coordinates are valid

Source
walkable

Grid data

Source
walkable=(walkable : Array(Array(Bool)))

Grid data

Source
walkable_cell_count

Counts total walkable cells

Source
walkable_percentage

Gets walkable percentage

Source
width

Grid dimensions

Source
width=(width : Int32)

Grid dimensions

Source
world_bounds

Gets the bounds of the grid in world coordinates

Source
world_to_grid(world_x : Float32, world_y : Float32) : Tuple(Int32, Int32)

Converts world coordinates to grid coordinates

Source