N10: Playable network client

The client program now turns a connection into a match someone can play.

- ClientSession: a ClientGame, the keyboard and mouse as commands
  (ClientInput), and a MatchView of the client's own copy of the world.
- ClientMirror writes what the client is showing into that world every
  frame: other players from the recent past, its own player where it was
  predicted, items, the barge, the clock and the sea. The existing views
  draw it unchanged.
- LocalServer: offline play is the same ServerLoop and NetGame in the same
  process, with packets handed across in memory, so there is one path.
- main.gd: --connect=HOST[:PORT] joins a server, otherwise an offline
  match; --autoplay and --client-seconds=N for scripts and checks.
- The camera aboard the barge follows the player's own place on the deck.

Tests drive a scripted client through a whole match on a real server over
loopback UDP, lobby to results, and through an offline match. `make
client-check` does it with two real processes, and `make client-captures`
renders what the client sees.

Closes #77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 14:50:52 -05:00
co-authored by Claude Opus 5.5
parent 6b21e9d4f1
commit 9a36ae8615
25 changed files with 1089 additions and 13 deletions
+14 -6
View File
@@ -2,8 +2,9 @@
## built pieces and everything that moves, all drawn from one Simulation, with the
## third-person camera on a player's shoulder. It only reads the simulation.
##
## A match gets a new Simulation, so it gets a new MatchView. Until snapshots arrive
## (v0.5) the simulation it reads is the local server's or a replay's.
## A match gets a new Simulation, so it gets a new MatchView. In play the simulation is
## the client's own copy of the world, which ClientMirror fills with what the server
## has sent; captures and tests also point it at a server's or a replay's.
class_name MatchView
extends Node3D
@@ -86,14 +87,21 @@ func sync() -> void:
## Puts the camera on a player's shoulder, looking where they look. `pitch` replaces
## their own pitch when given, in radians, for views such as looking down from a glide.
func follow(entity_id: int, pitch: float = NAN) -> bool:
## their own pitch when given, in radians, for views such as looking down from a glide,
## and `look_yaw` their yaw, for the local player, whose look is newer than any command.
func follow(entity_id: int, pitch: float = NAN, look_yaw: float = NAN) -> bool:
var player: SimEntity = sim.entities.find(entity_id)
if player == null:
return false
var yaw: float = float(player.yaw) / PlayerCommand.YAW_STEPS * TAU
var yaw: float = look_yaw if not is_nan(look_yaw) else float(player.yaw) / PlayerCommand.YAW_STEPS * TAU
var look_pitch: float = pitch if not is_nan(pitch) else float(player.pitch) / PlayerCommand.PITCH_MAX * (PI * 0.5)
camera.transform = rig.solve(player.position, yaw, look_pitch, player.crouching, sim.ground)
# Where the figure is drawn: on the barge's deck that is its own place, not the
# one point the simulation carries every passenger at.
var feet: Vector3 = player.position
var figure: Node3D = entities.figure_of(entity_id)
if figure != null and player.drop_state == Drop.ABOARD:
feet = figure.position
camera.transform = rig.solve(feet, yaw, look_pitch, player.crouching, sim.ground)
camera.fov = rig.fov()
_focus()
return true