Migrating From v0.2.X to v0.3.X

GridSettings → GridSettingsBuilder

GridSettings has been replaced with GridSettingsBuilder.

Replace


#![allow(unused)]
fn main() {
let grid_settings = GridSettings {
    width: 16,
    height: 16,
    chunk_size: 4,
    collision: true,
    ..Default::default()
}

let grid = CardinalGrid::new(&grid_settings);
}

with


#![allow(unused)]
fn main() {
let grid_settings = GridSettingsBuilder::new_2d(16, 16)
    .chunk_size(4)
    .enable_collision()
    .build()

let grid = CardinalGrid::new(&grid_settings);
}

GridPos → AgentPos

GridPos has been renamed to AgentPos. This is just a simple rename for clarity.

Point → NavCell, Nav | Wall -> Passable, Impassable

Point has been reworked for clarity. Point has been renamed to NavCell but the API has been updated to remove user's need to interact with NavCell for normal use.

Grid functions now take the Nav enum to definite mobility and movement cost for a Grid cell.

Replace


#![allow(unused)]
fn main() {
// Creates a wall at grid cell 8,8,0
grid.set_point(UVec3::new(8, 8, 0), Point::new(u32::MAX, true));
// Set the cost for a passable grid cell
grid.set_point(UVec3::new(4, 4, 0), Point::new(4, false));
}

with


#![allow(unused)]
fn main() {
grid.set_nav(UVec3::new(8, 8, 0), Nav::Impassable);
grid.set_nav(UVec3::new(4, 4, 0), Nav::Passable(4));
}

Pathfind Component Rework, New PathfindMode

The Pathfind component has been reworked with chaining setup functions to ensure configuration can be added in the future without breaking changes.

PathfindMode enum was added set which pathfinding method is desired.

Before


#![allow(unused)]
fn main() {
// You may have forced an A* path like this before
.insert(Pathfind {
    goal: UVec3::new(8, 8, 0),
    use_astar: true,
})
// or the shorthand for regular HPA*
.insert(Pathfind::new(UVec3::new(8, 8, 0)))
// shorthand A*
.insert(Pathfind::new_astar(UVec3::new(8, 8, 4)))
}

Is now


#![allow(unused)]
fn main() {
.insert(Pathfind::new(UVec3::(8, 8, 0).mode(PathfindMode::AStar)))

// You can use the new_2d and new_3d constructors without creating a UVec as well
.insert(Pathfind::new_2d(8, 8))
.insert(Pathfind::new_3d(8, 8, 4).mode(PathfindMode::AStar))
}

DebugMap → DebugGrid, DebugGridBuilder, & DebugOffset

DebugMap has been renamed to DebugGrid for clarity and a builder pattern has been added to make it cleaner to configure.

It was recommended before to put DebugMap as the child of your Grid entity, but it is now required.

Change


#![allow(unused)]
fn main() {
grid_entity.with_child((
    DebugMap {
        tile_width: 8,
        tile_height: 8,
        map_type: DebugMapType::Square,
        draw_chunks: true,
        draw_points: false,
        draw_entrances: true,
        draw_cached_paths: false,
    },
    Transform::from_translation(offset.extend(0.0)),
));
}

to


#![allow(unused)]
fn main() {
grid_entity.with_child((
    DebugGridBuilder::new(8, 8)
        .enable_chunks()
        .enable_entrances()
        .build(),
    // Add the offset to the debug gizmo so that it aligns with your tilemap.
    DebugOffset(Vec2::new(-360.0, -500.0)),
));
}

DebugMapType has been renamed to DebugTilemapType. You only need to set it if you're using isometric. DebugGridBuilder::new(8, 8).isometric().build().

DebugPath

tile_width, tile_height, and map_type has been removed from the DebugPath component.

These fields are now determined by getting the attached DebugGrid based on the entities relationship to the Grid component. Ensure that you add the AgentOfGrid relationship to your pathfinding (player/npc etc) entities.

Replace


#![allow(unused)]
fn main() {
.insert(DebugPath {
    tile_width: 8,
    tile_height: 8,
    map_type: DebugMapType::Square,
    color,
    draw_unrefined: false,
})
}

with


#![allow(unused)]
fn main() {
.insert(DebugPath::new(color))
.insert(AgentOfGrid(grid_entity))
}