TerrainGrid: add a query for the level a tile is drawn at, not the level it was sampled at #46
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
liamjd/UntitledColonyBuilder#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
TerrainGrid.level_at()returns a tile's sampled level, which for a submerged tile is its seabed. But_paint_cells()deliberately draws submerged tiles at_datum_indexinstead, so the sea reads as one flat surface rather than a lumpy bed:So for water,
surface_y(level_at(cell))is not the height the tile is drawn at — it is somewhere below it, by however deep the seabed happens to be. Any caller that positions something on the ground by that expression puts it underwater.There is no public query for the drawn level.
height_at()already contains the correction, but it takes world-space X/Z and returns a global Y, so it does not fit a caller that has a cell and wants a level.Where this already bites
#37's placement highlight draws one quad per footprint cell at
surface_y(level_at(cell)). On a shoreline site the quads over water sink beneath the visible surface and disappear — exactly when the player most needs to see which tiles are rejecting the placement.The building ghost in
PlacementControllerreads the same expression to find the height of the tallest tile under the footprint, so it has the same flaw.Proposed change
Add a public query to
TerrainGridalongsidelevel_at():Then have
height_at()use it rather than repeating the datum check inline, so the rule lives in one place.Notes
_kind_for()is the existing test for water and already handlespreset.has_waterbeing off, sodrawn_level_at()should go through it rather than comparing against_datum_indexdirectly. A preset with water disabled has no water, and low ground is still ground — the same trapis_walkable()documents.level_at(), which returns_datum_indexrather than erroring.level_at()is the right answer for slope, pathfinding andPlacementRules, which reason about the terrain rather than about what is on screen. This is not a replacement.Acceptance criteria
drawn_level_at()returns the datum for a submerged tile and the sampled level for dry land.preset.has_wateroff, it equalslevel_at()for every cell.height_at()is expressed in terms of it rather than duplicating the check.test/unit/test_terrain_*.gd: a submerged tile, a dry tile, a low dry tile on a no-water preset, and an out-of-bounds cell.