Repository navigation
feat(engine): split the save record into world and players - #425
Merged
Merged
Conversation
A flag with `scope: thing` used to land in one global bag, so opening one chest opened every chest that shared the flag. The save state is now a record: `world` holds game-scoped values, per-placement values keyed by placement id, and removed-thing markers; `players[playerId]` holds each player's position and map, with room for bag and stats later. A `scope: thing` write resolves against the placement that ran the action (`PlacementIdComponent.id`), falling back to `world` when there is none. `evaluateCondition` stays pure — it reads a resolved view passed in, never the ECS. The player id comes from the host (GSettings `player-id`, filled once on first read), never from a peer id, so it survives a rejoin. `migrateSaveRecord` lifts an old flat bag into `world.flags` losslessly, and the runtime snapshot keeps that flat `flags` field while adding `thingFlags`, `removedThings`, `players` and `localPlayerId`. Saving at rest is not part of this: the record only lives in memory.
JumpLink
force-pushed
the
feat/world-player-record
branch
from
November 24, 2026 13:44
b59bf1a to
6dbd4eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A flag with
scope: thingused to land in one global bag, so opening one chest opened every chest that shared the flag. The save state becomes a record instead:worldis the host's; each player owns their own entry. Bag and stats get a typed place inPlayerRecordlater (M5), and writing the record to disk is M8 — this one keeps it in memory.How
scope: thingwrite resolves against the placement that ran the action, keyed byPlacementIdComponent.id(=ObjectPlacement.id, never an Excalibur entity id). With no placement in reach it falls back toworld.flags.evaluateConditionstays pure:resolvedFlagView(record, placementId)builds the view and hands it in, so conditions never reach into the ECS.player-id, empty by default and filled on first read — threadedEngine.setLocalPlayerId→ loader → scene → system. It is stored, not derived, and it is nevergeneratePeerId(): a rejoin must find the same player.migrateSaveRecordlifts an old flat flag bag intoworld.flagsand leaves everything else empty — lossless, and existing projects (Kokiri Forest) load unchanged.RuntimeSnapshotnow extendsSaveSnapshot:flagsstays the flat game-scoped bag it always was, joined bythingFlags,removedThings,playersandlocalPlayerId, soGetStatus→runtimekeeps working and says more.Editor
scope: thingwas not reachable from the UI, so the new-flag dialog grew a "Remembered by" choice — two radio rows ("The whole game" / "Each thing on its own") rather than a dropdown, because at phone width a combo ellipsised its own value away. German strings inde.po.Verified
Two chests sharing one thing-scoped flag, played through the running app and read back over D-Bus:
flags['chest-open']thingFlagsfalse{}false{ 'p-chest-a': { 'chest-open': true } }false{ 'p-chest-a': …, 'p-chest-b': { 'chest-open': true } }found-a-chest(game scope) flips totrueon the first touch and stays.playerscarries the local player's map and tile.Specs cover two players in one world, a thing-scoped flag on two placements, removed markers, the migration and the snapshot shape.