Pawn record and Pawns registry #77

Closed
opened 2026-09-07 20:56:28 +01:00 by liamjd · 1 comment
Owner

Part of milestone #4. game.gd spawns one pawn in _ready() and drops the reference, so nothing can enumerate pawns, select one, or reposition them after the terrain regenerates.

Follow the Building / Buildings split: the record is the truth, the node is one way of drawing it.

Design:

  • Pawn extends Entity (RefCounted) record: id (registry-assigned, never reused), cell: Vector2i, state (IDLE, MOVING), speed (tiles per second). Milestone #5 issue #74 adds role to this record.
  • The current scene script becomes PawnView extends Node3D: it owns the capsule and, in the mover issue, the walking. It holds its record's id, not the record.
  • Pawns extends Node3D registry: spawn(cell) -> Pawn, remove(id), get(id), all(), view_for(id). Receives map by injection from game.gd, as Buildings does, so it works standalone in tests with no views.
  • Spawns a configurable count (exported, default 3) onto map.random_walkable_position() with a seeded RNG so the layout is reproducible per run seed. [For dev only, not a gameplay mechanic.]
  • On map.regenerated, despawns every pawn and respawns onto the new main region. A pawn from the previous map may be floating or underwater otherwise.
  • Pawn Y position: the tile's drawn surface plus half pawn_height. See #46 for why surface_y(level_at(cell)) is wrong on shoreline tiles; use height_at() or drawn_level_at() once it exists.
  • GameState.pawn_spawned(pawn) / pawn_removed(pawn) signals, matching the building signals.

AC:

  • The scene script is renamed to PawnView; Pawn is the record. Run the editor scan after the rename or every use of the type fails to parse.
  • Unit tests through the registry without a map: spawn assigns increasing ids, remove frees the id and never reuses it, all() reflects both.
  • Headed check: the configured number of pawns appear on the main landmass, and pressing R (reroll) repositions them onto the new one.
Part of milestone #4. game.gd spawns one pawn in `_ready()` and drops the reference, so nothing can enumerate pawns, select one, or reposition them after the terrain regenerates. Follow the `Building` / `Buildings` split: the record is the truth, the node is one way of drawing it. Design: - `Pawn extends Entity` (RefCounted) record: `id` (registry-assigned, never reused), `cell: Vector2i`, `state` (IDLE, MOVING), `speed` (tiles per second). Milestone #5 issue #74 adds `role` to this record. - The current scene script becomes `PawnView extends Node3D`: it owns the capsule and, in the mover issue, the walking. It holds its record's id, not the record. - `Pawns extends Node3D` registry: `spawn(cell) -> Pawn`, `remove(id)`, `get(id)`, `all()`, `view_for(id)`. Receives `map` by injection from game.gd, as `Buildings` does, so it works standalone in tests with no views. - Spawns a configurable count (exported, default 3) onto `map.random_walkable_position()` with a seeded RNG so the layout is reproducible per run seed. [For dev only, not a gameplay mechanic.] - On `map.regenerated`, despawns every pawn and respawns onto the new main region. A pawn from the previous map may be floating or underwater otherwise. - Pawn Y position: the tile's drawn surface plus half `pawn_height`. See #46 for why `surface_y(level_at(cell))` is wrong on shoreline tiles; use `height_at()` or `drawn_level_at()` once it exists. - `GameState.pawn_spawned(pawn)` / `pawn_removed(pawn)` signals, matching the building signals. AC: - The scene script is renamed to `PawnView`; `Pawn` is the record. Run the editor scan after the rename or every use of the type fails to parse. - Unit tests through the registry without a map: spawn assigns increasing ids, remove frees the id and never reuses it, `all()` reflects both. - Headed check: the configured number of pawns appear on the main landmass, and pressing R (reroll) repositions them onto the new one.
Author
Owner

Follow this ticket with #80, #78 and #81 to see some gameplay progression

Follow this ticket with #80, #78 and #81 to see some gameplay progression
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder#77
No description provided.