Grid and map primitives #2

Closed
opened 2026-08-06 21:51:48 +00:00 by icub3d · 0 comments
Owner

Stand up src/world/ with the spatial types the rest of M1 builds on, and a map that
can be authored as data rather than hardcoded.

Follow src/character/ exactly — it is the reference implementation for a data-backed
subsystem: an authored *Def type (src/character/definition.rs), a validated registry
(src/character/registry.rs), and a plugin that drives loading. Reuse the existing
RonAsset trait in src/data/loader.rs; claim a *.map.ron compound extension so map
files never contend with any other definition type.

Scope

  • GridPos newtype over IVec3 — no bare IVec3 passed around (CLAUDE.md § Code Style).
  • Tile: at minimum walkable/blocked and a height. Cover and LOS properties are M2 —
    leave room, do not implement them.
  • MapDef / MapAsset implementing RonAsset, with validation at load: unknown tile
    references, out-of-bounds spawn points, and duplicate ids fail at startup naming the
    offending id, never silently.
  • One small hand-authored test map in assets/data/maps/, big enough for two units to
    need to move toward each other.

Acceptance criteria

  • Neighbour, distance, and bounds math has unit tests.
  • A malformed map file fails the load with the offending id in the message.
  • cargo test parses the shipped map file, so a bad edit fails CI rather than
    someone's first run.
  • Iteration over map data is deterministic — no HashMap iteration order anywhere
    that could affect an outcome.
Stand up `src/world/` with the spatial types the rest of M1 builds on, and a map that can be authored as data rather than hardcoded. Follow `src/character/` exactly — it is the reference implementation for a data-backed subsystem: an authored `*Def` type (`src/character/definition.rs`), a validated registry (`src/character/registry.rs`), and a plugin that drives loading. Reuse the existing `RonAsset` trait in `src/data/loader.rs`; claim a `*.map.ron` compound extension so map files never contend with any other definition type. ## Scope - `GridPos` newtype over `IVec3` — no bare `IVec3` passed around (`CLAUDE.md` § Code Style). - `Tile`: at minimum walkable/blocked and a height. Cover and LOS properties are M2 — leave room, do not implement them. - `MapDef` / `MapAsset` implementing `RonAsset`, with validation at load: unknown tile references, out-of-bounds spawn points, and duplicate ids fail at startup naming the offending id, never silently. - One small hand-authored test map in `assets/data/maps/`, big enough for two units to need to move toward each other. ## Acceptance criteria - [ ] Neighbour, distance, and bounds math has unit tests. - [ ] A malformed map file fails the load with the offending id in the message. - [ ] `cargo test` parses the shipped map file, so a bad edit fails CI rather than someone's first run. - [ ] Iteration over map data is deterministic — no `HashMap` iteration order anywhere that could affect an outcome.
Sign in to join this conversation.
No description provided.