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:
@@ -18,6 +18,23 @@ func create(archetype: int) -> SimEntity:
|
||||
return entity
|
||||
|
||||
|
||||
## Creates an entity under an ID chosen elsewhere: a network client's copy of one the
|
||||
## server made. Iteration stays in ascending ID order.
|
||||
func restore(id: int, archetype: int) -> SimEntity:
|
||||
var entity: SimEntity = SimEntity.new(id, archetype)
|
||||
var newest: bool = id >= _next_id
|
||||
_by_id[id] = entity
|
||||
_next_id = maxi(_next_id, id + 1)
|
||||
if not newest:
|
||||
var ids: Array = _by_id.keys()
|
||||
ids.sort()
|
||||
var sorted: Dictionary = {}
|
||||
for key: int in ids:
|
||||
sorted[key] = _by_id[key]
|
||||
_by_id = sorted
|
||||
return entity
|
||||
|
||||
|
||||
## Returns the entity, or null if it doesn't exist or has been removed.
|
||||
func find(id: int) -> SimEntity:
|
||||
return _by_id.get(id)
|
||||
|
||||
Reference in New Issue
Block a user