B2: Grid building and placement preview

Server-authoritative grid building with wall, floor, ramp, roof and
breakwater pieces in driftwood, stone and salvage iron, plus a client
placement ghost.

- StructureSet: pieces in grid slots (floor, two wall edges, cell
  volume), their collision boxes in SimGround, and touching-neighbour
  links kept up to date for B3. Ramps are stairs of 0.4 m steps; walls
  over lower ground get a skirt down to the terrain; roofs are a low
  stepped pyramid. Pieces are part of the state hash.
- Building: target() snaps look and position to a slot, and check()
  validates any slot as if a hostile client chose it: state, range,
  occupancy, trapping a player, cost and support. Fire in build mode
  places at most 10 pieces a second; players in a low step are lifted.
- Levels are half a cell (2 m) apart, so ground pieces sit within a
  metre of the builder's feet instead of being half buried.
- Client: StructureView draws pieces from their boxes in plank, course
  or panel strips; ramps draw as a sloped deck. BuildGhost shows sea
  green or rust red from the same target() and check().
- Tests: 15 sim tests (targeting, every rejection, overlap, support,
  stairs climbable, skirts, determinism, 24 builders at 10 pieces a
  second within the tick budget) and 5 client tests (ghost states,
  ghost agrees with the server, view sync, mesh orientation).
- Capture scenarios build_fort and build_fort_side.

Closes #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 14:23:29 -05:00
co-authored by Claude Opus 5.5
parent b847ba9695
commit f35ebf7171
21 changed files with 1327 additions and 0 deletions
+20
View File
@@ -201,6 +201,26 @@ const MATERIALS: Dictionary = {
"stone": {"health": 300, "build_seconds": 5.0},
"salvage_iron": {"health": 500, "build_seconds": 9.0},
}
## Pieces are GRID_CELL_METRES on a side and tall, and snap across to the grid. Up and
## down they snap to levels BUILD_LEVEL_METRES apart, half a cell, so a piece built on
## the ground is never more than a metre above or below the builder's feet. Level 0 is
## the starting sea level; levels run from BUILD_MIN_LEVEL to BUILD_MAX_LEVEL.
const BUILD_LEVEL_METRES: float = 2.0
const BUILD_MIN_LEVEL: int = -8
const BUILD_MAX_LEVEL: int = 63
## A piece's centre must be within this distance of the builder's eye.
const BUILD_RANGE: float = 9.5
## Ticks between placements while fire is held: 10 pieces a second.
const BUILD_INTERVAL_TICKS: int = 3
## Looking further up than this, in degrees, targets the level above.
const BUILD_LOOK_UP_DEGREES: float = 35.0
## Looking further down than this puts floors, ramps and roofs in the builder's own cell.
const BUILD_LOOK_DOWN_DEGREES: float = 40.0
const WALL_THICKNESS: float = 0.3
const BREAKWATER_THICKNESS: float = 0.6
const FLOOR_THICKNESS: float = 0.2
## Ramps are stairs of this many steps, so each riser can be stepped up.
const RAMP_STEPS: int = 10
const BREAKWATER_MAX_HEAD: float = 6.0
const BREAKWATER_WEAR_PER_METRE: float = 2.0
const BREACH_FLOW_METRES_PER_SECOND: float = 1.5