N5: Replicate building, world damage, tide and loot

Built pieces, props' health, opened chests and the tide's schedule now reach
clients as WORLD messages on the reliable channel, and each player is told
what they carry as OWN messages.

- NetWorld: the WORLD and OWN wire formats, and world_hash(), a digest of
  everything replicated this way.
- WorldSender: one message after each tick in which something changed, the
  same for everyone, and the whole state for someone joining or a new match.
  StructureSet and PropSet keep the change lists it reads.
- ClientWorld: applies them to the client's world, so pieces and broken props
  are solid for prediction. A piece's health follows from its building and
  damage, so building costs nothing on the wire.
- Placing ahead of the server: a provisional piece goes up with the command
  and is replaced by the server's, or taken back once a snapshot shows the
  server had its chance. Snapshots carry the newest WORLD number for that.
- Protocol version 3.

A test plays a whole scripted match on a real island with a ClientGame
attached and compares the two worlds' hashes throughout.

Closes #36

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 14:27:58 -05:00
co-authored by Claude Opus 5.5
parent 63ef7b1968
commit 6b21e9d4f1
24 changed files with 1547 additions and 42 deletions
+25 -14
View File
@@ -165,25 +165,36 @@ static func _traps_a_player(sim: Simulation, boxes: Array[AABB]) -> bool:
for entity: SimEntity in sim.entities.entities():
if entity.archetype != SimEntity.ARCHETYPE_PLAYER or entity.health <= 0:
continue
var feet: Vector3 = entity.position
var height: float = Movement.body_height(entity)
for box: AABB in boxes:
if not _body_overlaps(box, feet, height):
continue
if box.end.y - feet.y > Tuning.STEP_HEIGHT:
return true
if would_trap(entity, boxes):
return true
return false
## True if `player`'s body overlaps the boxes by more than a step.
static func would_trap(player: SimEntity, boxes: Array[AABB]) -> bool:
var feet: Vector3 = player.position
var height: float = Movement.body_height(player)
for box: AABB in boxes:
if not _body_overlaps(box, feet, height):
continue
if box.end.y - feet.y > Tuning.STEP_HEIGHT:
return true
return false
static func _lift_players(sim: Simulation, boxes: Array[AABB]) -> void:
for entity: SimEntity in sim.entities.entities():
if entity.archetype != SimEntity.ARCHETYPE_PLAYER:
continue
var feet: Vector3 = entity.position
var height: float = Movement.body_height(entity)
for box: AABB in boxes:
if _body_overlaps(box, feet, height) and box.end.y > entity.position.y:
entity.position.y = box.end.y
if entity.archetype == SimEntity.ARCHETYPE_PLAYER:
lift(entity, boxes)
## Lifts `player` onto any low step of the boxes it is standing in.
static func lift(player: SimEntity, boxes: Array[AABB]) -> void:
var feet: Vector3 = player.position
var height: float = Movement.body_height(player)
for box: AABB in boxes:
if _body_overlaps(box, feet, height) and box.end.y > player.position.y:
player.position.y = box.end.y
static func _body_overlaps(box: AABB, feet: Vector3, height: float) -> bool: