CollisionGrid class
A 2D grid representing walkability for pathfinding.
Each cell is either walkable (true) or blocked (false). Used by Pathfinder for A* pathfinding on tile-based maps.
Example:
final grid = CollisionGrid(width: 10, height: 10);
// Block some tiles
grid.setBlocked(5, 5);
grid.setBlocked(5, 6);
// Check walkability
if (grid.isWalkable(3, 3)) {
print('Tile is walkable');
}
Constructors
- CollisionGrid({required int width, required int height})
- Creates a new collision grid with all tiles initially walkable.
-
CollisionGrid.fromData(List<
List< data)bool> > - Creates a collision grid from existing data.
Properties
- blockedCount → int
-
Count the number of blocked tiles.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
Height of the grid in tiles.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- walkableCount → int
-
Count the number of walkable tiles.
no setter
- width → int
-
Width of the grid in tiles.
final
Methods
-
clear(
) → void - Clear the grid, making all tiles walkable.
-
copy(
) → CollisionGrid - Create a copy of this grid.
-
fill(
) → void - Fill the grid, making all tiles blocked.
-
isBlocked(
int x, int y) → bool - Check if a tile is blocked (not walkable).
-
isWalkable(
int x, int y) → bool - Check if a tile is walkable.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
int x, int y, bool walkable) → void - Set the walkability of a tile directly.
-
setBlocked(
int x, int y) → void - Mark a tile as blocked (not walkable).
-
setRegionBlocked(
int x, int y, int regionWidth, int regionHeight) → void - Mark a rectangular region as blocked.
-
setRegionWalkable(
int x, int y, int regionWidth, int regionHeight) → void - Mark a rectangular region as walkable.
-
setWalkable(
int x, int y) → void - Mark a tile as walkable.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited