Add TerrainGrid.drawn_level_at() (#46) #131

Merged
liamjd merged 1 commit from 46-drawn-level-query into main 2026-09-27 20:10:33 +01:00
Owner

Adds TerrainGrid.drawn_level_at(cell): the level a tile is drawn at, which for water is the datum rather than the seabed.

Changes

  • drawn_level_at() goes through _kind_for(), so a preset with has_water off draws low ground where it lies. Out-of-bounds cells return the datum, matching level_at().
  • height_at() and _paint_cells() now use it instead of repeating the datum check.
  • The placement highlight and BuildingSite's ghost height switch to it, as does the copied highlight code in tools/screenshot_entrance_arrow.gd.
  • level_at() is unchanged and still used by PlacementRules, slope and pathfinding.

Verification

  • New test/unit/test_terrain_drawn_level.gd: submerged tile, dry tile, low tile on a no-water preset, out-of-bounds cell. Red before the implementation (method missing), green after.
  • Full GUT suite: 748/749 passing, 1 existing pending (#85).
  • Checked headed: shoreline placement highlight now sits on the water surface.

Not done

  • cell_to_world() still uses level_at(), so the entrance arrow sinks if a doorstep lands on water. Pawns also use it, and water is unwalkable, so it was left alone.

Closes #46

🤖 Generated with Claude Code

Adds `TerrainGrid.drawn_level_at(cell)`: the level a tile is *drawn* at, which for water is the datum rather than the seabed. ## Changes - `drawn_level_at()` goes through `_kind_for()`, so a preset with `has_water` off draws low ground where it lies. Out-of-bounds cells return the datum, matching `level_at()`. - `height_at()` and `_paint_cells()` now use it instead of repeating the datum check. - The placement highlight and `BuildingSite`'s ghost height switch to it, as does the copied highlight code in `tools/screenshot_entrance_arrow.gd`. - `level_at()` is unchanged and still used by `PlacementRules`, slope and pathfinding. ## Verification - New `test/unit/test_terrain_drawn_level.gd`: submerged tile, dry tile, low tile on a no-water preset, out-of-bounds cell. Red before the implementation (method missing), green after. - Full GUT suite: 748/749 passing, 1 existing pending (#85). - Checked headed: shoreline placement highlight now sits on the water surface. ## Not done - `cell_to_world()` still uses `level_at()`, so the entrance arrow sinks if a doorstep lands on water. Pawns also use it, and water is unwalkable, so it was left alone. Closes #46 🤖 Generated with [Claude Code](https://claude.com/claude-code)
level_at() returns a submerged tile's seabed, but _paint_cells() draws it at
the datum, so anything positioned by surface_y(level_at(cell)) sank below
the visible sea. drawn_level_at() owns that rule; height_at() and
_paint_cells() now go through it instead of repeating the datum check.

The placement highlight and BuildingSite's ghost height switch to it, which
keeps shoreline highlight quads above the water. level_at() stays for slope,
pathfinding and PlacementRules, which reason about the terrain itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
liamjd merged commit 86df83a87e into main 2026-09-27 20:10:33 +01:00
liamjd deleted branch 46-drawn-level-query 2026-09-27 20:11:01 +01:00
Sign in to join this conversation.
No reviewers
No milestone
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!131
No description provided.