N11: Build ghost, client flood and shot effects in the playable client

- Build ghost: ClientSession shows a BuildGhost in build mode while the
  client plays, asking Building.check() of its own world and predicted
  player with the mouse's newest look, so it agrees with the server.
- Flooded basins: ClientMirror.follow_flood() spreads the client's flood
  as the server's tide tick does, from the tide and the pieces it has.
  WaterView passes a mask of flooded cells (Flood.pours says when it
  changed) to the sea shader, which leaves dry cells undrawn.
- Shots, impacts and swings: a new FX message (NetFx) goes unreliably on
  the state channel next to each snapshot, with what happened within
  NET_FX_RADIUS_METRES of what the client watches or involving that
  player. ClientGame keeps them in `fx` for views and sound. They change
  no state, so a lost one is a missed flash; sending them reliably would
  add to the traffic a bad link can least afford (N8). The fuzzer covers
  the new parser.
- Captures: client_build and client_build_refused show the ghost in its
  allowed and refused tints; client_basin rings shore ground with
  breakwaters and plays until the tide stands over it, and the server,
  the client's flood and the drawn sea all keep the basin dry.
- Tests: NetFx round trips, limits and malformed input; a landed player's
  shots and impacts reach a client, each matching a server event; the
  client keeps a ringed basin dry through the first rise, floods it with
  no ring, catches up after a long frame; the water mask follows pours.

The held item is still not drawn; that needs the models (A4, #44).

Closes #78

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 02:24:16 -05:00
co-authored by Claude Opus 5.5
parent 2973abf144
commit 57faefb81a
22 changed files with 810 additions and 9 deletions
+27
View File
@@ -16,6 +16,8 @@ var link: NetClient = null
var local: LocalServer = null
## The picture of the current match's world, or null before there is one.
var view: MatchView = null
## Where a piece would go, in build mode while playing. A child of `view`.
var ghost: BuildGhost = null
## Every match phase this client has been in, in order, without repeats.
var phases: Array[int] = []
## Frames in which the client's own player was in the match, and frames pumped.
@@ -130,19 +132,44 @@ func _show(delta: float) -> void:
remove_child(view)
view.queue_free()
view = null
ghost = null
if _viewed != null:
view = MatchView.new()
view.setup(_viewed, 0)
add_child(view)
move_child(view, 0)
ghost = BuildGhost.new()
ghost.visible = false
view.add_child(ghost)
if view == null:
return
view.entities.local_id = mirror.own_id if mirror.own_id != 0 else view.entities.local_id
view.entities.barge_at = mirror.barge_at
view.rig.update_aim(input.aiming() and mirror.own_id != 0, delta)
view.sync()
_show_ghost()
if mirror.own_id != 0:
# The player's own look is newer than any command made from it.
view.follow(mirror.own_id, input.pitch, input.yaw)
elif mirror.watched_id == 0 or not view.follow(mirror.watched_id):
view.overview()
## The build ghost, in build mode while this client plays: the piece the next build
## would place, asked of the client's own world and predicted player, as the server
## will ask its own. Its look is the newest the mouse has given.
func _show_ghost() -> void:
if ghost == null:
return
var player: SimEntity = game.prediction.player
if not (input.build_mode and game.playing() and mirror.own_id != 0 and Building.is_allowed(player)):
ghost.visible = false
return
var yaw: int = player.yaw
var pitch: int = player.pitch
var look: PlayerCommand = PlayerCommand.from_input(0, Vector2.ZERO, input.yaw, input.pitch)
player.yaw = look.yaw
player.pitch = look.pitch
ghost.update(game.world, player, input.build_kind, input.material)
player.yaw = yaw
player.pitch = pitch