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:
@@ -28,6 +28,8 @@ var props: PropSet = PropSet.new()
|
||||
var sea_level: float = Tuning.SEA_LEVEL_START
|
||||
## Damage per second to a player underwater with no breath left. Set by the tide phase.
|
||||
var drown_dps: int = Tuning.TIDE_PHASES[0]["drown_dps"]
|
||||
## Every built piece. Their boxes are part of `ground`.
|
||||
var structures: StructureSet = StructureSet.new()
|
||||
## The sky barge, from start_drop() on. Null in matches and tests that start on foot.
|
||||
var drop: Drop = null
|
||||
|
||||
@@ -147,7 +149,10 @@ func _apply_command(player: SimEntity, command: PlayerCommand) -> void:
|
||||
player.action_cooldown -= 1
|
||||
if command == null or not command.is_pressed(PlayerCommand.BUTTON_FIRE):
|
||||
return
|
||||
if not Building.is_allowed(player):
|
||||
return
|
||||
if command.is_pressed(PlayerCommand.BUTTON_BUILD):
|
||||
Building.act(self, player, command)
|
||||
return
|
||||
if command.selection == BOATHOOK_SLOT:
|
||||
Harvest.swing(player, ground, props, events)
|
||||
@@ -202,6 +207,7 @@ func state_hash() -> String:
|
||||
buffer.put_32(drown_dps)
|
||||
buffer.put_64(props.count())
|
||||
buffer.put_data(props.health.to_byte_array())
|
||||
structures.write_state(buffer)
|
||||
|
||||
var hasher: HashingContext = HashingContext.new()
|
||||
hasher.start(HashingContext.HASH_SHA256)
|
||||
|
||||
Reference in New Issue
Block a user