castle-web-cli 0.4.231 → 0.4.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +51 -3
- package/dist/castleJson.d.ts +4 -2
- package/dist/castleJson.js +2 -0
- package/dist/check.d.ts +3 -1
- package/dist/check.js +11 -1
- package/dist/devSessionStorage.js +47 -1
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +5 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +5 -0
- package/dist/save-deck.js +37 -4
- package/dist/serve.js +3 -0
- package/dist/serverBundle.js +5 -3
- package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +79 -2
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +1 -1
- package/kits/base/sdk/commands.d.ts +14 -0
- package/kits/base/sdk/hub.d.ts +6 -2
- package/kits/base/sdk/hub.js +13 -0
- package/kits/base/sdk/multiplayer.js +17 -1
- package/kits/base/sdk/save.js +2 -1
- package/kits/base/sdk/server/hub.d.ts +87 -0
- package/kits/base/sdk/server/hub.js +70 -0
- package/kits/base/sdk/server/platformHandle.d.ts +31 -1
- package/kits/base/sdk/server/storage.d.ts +13 -0
- package/kits/base/sdk/server/storage.js +46 -0
- package/kits/base/sdk/server/wrapper.d.ts +36 -5
- package/kits/base/sdk/server/wrapper.js +83 -8
- package/kits/hub-game/CLAUDE.md +352 -12
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +345 -32
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +251 -0
- package/kits/hub-game/code/client/ballot.js +467 -0
- package/kits/hub-game/code/client/build.js +22 -0
- package/kits/hub-game/code/client/chat.js +12 -0
- package/kits/hub-game/code/client/chrome.js +1334 -50
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/decor.js +509 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/grab.js +363 -20
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +328 -15
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/idle.js +163 -22
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +205 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/shot.js +92 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +131 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +538 -47
- package/kits/hub-game/code/client/tiers.js +541 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +98 -1
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +470 -97
- package/kits/hub-game/code/client/yours.js +199 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/actions.js +133 -0
- package/kits/hub-game/code/server/actors.js +14 -1
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +82 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/earned.js +461 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +232 -0
- package/kits/hub-game/code/server/grab.js +296 -11
- package/kits/hub-game/code/server/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1317 -52
- package/kits/hub-game/code/server/idle.js +30 -11
- package/kits/hub-game/code/server/index.js +2 -2
- package/kits/hub-game/code/server/labels.js +28 -2
- package/kits/hub-game/code/server/manifest.js +424 -8
- package/kits/hub-game/code/server/menu.js +133 -0
- package/kits/hub-game/code/server/npcs.js +830 -80
- package/kits/hub-game/code/server/party.js +13 -2
- package/kits/hub-game/code/server/players.js +22 -0
- package/kits/hub-game/code/server/say.js +8 -2
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +124 -0
- package/kits/hub-game/code/server/vis.js +113 -0
- package/kits/hub-game/code/server/wear.js +128 -11
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/shot.js +19 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1083 -85
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2440 -61
- package/kits/hub-game/docs/home-pieces.md +64 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +2 -0
- package/kits/hub-game/package.json +2 -1
- package/kits/hub-game/scripts/check.mjs +78 -11
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -17
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
- package/kits/hub-game/scripts/test-avatar.mjs +540 -7
- package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
- package/kits/hub-game/scripts/test-build.mjs +31 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +694 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
- package/kits/hub-game/scripts/test-decor.mjs +457 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1194 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +186 -3
- package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +864 -3
- package/kits/hub-game/scripts/test-hats.mjs +483 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1228 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +1000 -0
- package/kits/hub-game/scripts/test-idle.mjs +361 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +596 -0
- package/kits/hub-game/scripts/test-manifest.mjs +282 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
- package/kits/hub-game/scripts/test-menu.mjs +296 -0
- package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-party.mjs +22 -1
- package/kits/hub-game/scripts/test-picker.mjs +314 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-shot.mjs +756 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +416 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
- package/kits/hub-game/scripts/test-tiers.mjs +666 -3
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/hub-game/scripts/test-vis.mjs +343 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
- package/kits/hub-game/scripts/test-yours.mjs +372 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/physics-2d/CLAUDE.md +9 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +288 -1
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +370 -1
- package/kits/physics-3d/CLAUDE.md +1391 -0
- package/kits/physics-3d/behaviors/Player.jsx +921 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +12 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +98 -10
- package/kits/physics-3d/engine3d/actornode.js +86 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +96 -0
- package/kits/physics-3d/engine3d/gait.js +118 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +507 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +37 -19
- package/kits/physics-3d/engine3d/optimize.js +58 -5
- package/kits/physics-3d/engine3d/orbitinput.js +755 -0
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/shadowfade.js +882 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +870 -87
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
- package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +12 -2
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +4588 -0
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +13 -1
- package/kits/physics-3d/scripts/test-static-passes.mjs +1 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +635 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +474 -12
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +97 -19
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -27,8 +27,15 @@ export function claim(sim, playerId, ids, handovers) {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
//
|
|
31
|
-
|
|
30
|
+
// Legacy decks spend eight checks on the first eight ids, unchanged. Opt-in
|
|
31
|
+
// decks skip ineligible ids before spending those checks. Scanning at most
|
|
32
|
+
// 256 ids bounds lookups/reach tests even for an arbitrarily long bad packet;
|
|
33
|
+
// only eight eligible candidates can reach the takeover/handover work.
|
|
34
|
+
let checks = 0;
|
|
35
|
+
for (const id of ids.slice(0, sim.eligibleClaims === true ? 256 : 8)) {
|
|
36
|
+
if (sim.eligibleClaims === true && checks >= 8) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
32
39
|
const entry = sim.objects.get(id);
|
|
33
40
|
if (!entry?.claimable || entry.owner === playerId) {
|
|
34
41
|
continue;
|
|
@@ -37,6 +44,7 @@ export function claim(sim, playerId, ids, handovers) {
|
|
|
37
44
|
if (!Limits.withinReach(player.at, at)) {
|
|
38
45
|
continue;
|
|
39
46
|
}
|
|
47
|
+
checks += 1;
|
|
40
48
|
if (entry.owner && !mayTakeOver(sim, entry, player, at)) {
|
|
41
49
|
continue;
|
|
42
50
|
}
|
|
@@ -80,6 +80,18 @@ export function sceneGround(scenePath = MAIN_SCENE) {
|
|
|
80
80
|
return text ? (JSON.parse(text).ground ?? null) : null;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// Scene-level multiplayer options, read from the scene this session simulates.
|
|
84
|
+
export function sceneOptions(scenePath = MAIN_SCENE) {
|
|
85
|
+
const text = sceneTexts[`/${resolveScenePath(scenePath)}`];
|
|
86
|
+
return text ? JSON.parse(text) : null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// The scene's optional ground-cell table; the hub validates its contract.
|
|
90
|
+
export function sceneCells(scenePath = MAIN_SCENE) {
|
|
91
|
+
const text = sceneTexts[`/${resolveScenePath(scenePath)}`];
|
|
92
|
+
return text ? (JSON.parse(text).cells ?? null) : null;
|
|
93
|
+
}
|
|
94
|
+
|
|
83
95
|
// Shallow-merge each component in engine precedence order: defaults, blueprint,
|
|
84
96
|
// then scene instance values.
|
|
85
97
|
function resolveComponents(actor) {
|
|
@@ -11,7 +11,11 @@ import {
|
|
|
11
11
|
number,
|
|
12
12
|
} from '@imports/castle.real-time/code/server/limits.js';
|
|
13
13
|
import { readScene, resolveScenePath, sceneGround } from './sceneBodies.js';
|
|
14
|
+
// A namespace read, so a test's stand-in for the scene loader that predates
|
|
15
|
+
// `sceneOptions` still loads: it has no options and the key stays off.
|
|
16
|
+
import * as SceneBodies from './sceneBodies.js';
|
|
14
17
|
import * as Limits from './limits.js';
|
|
18
|
+
import { eligibleClaims } from '../options.js';
|
|
15
19
|
|
|
16
20
|
const DEG = Math.PI / 180;
|
|
17
21
|
|
|
@@ -57,6 +61,9 @@ export async function createSimulation(scenePath) {
|
|
|
57
61
|
await RAPIER.init();
|
|
58
62
|
const sim = emptySim();
|
|
59
63
|
sim.scenePath = resolveScenePath(scenePath);
|
|
64
|
+
if (eligibleClaims(SceneBodies.sceneOptions?.(sim.scenePath))) {
|
|
65
|
+
sim.eligibleClaims = true;
|
|
66
|
+
}
|
|
60
67
|
buildGround(sim);
|
|
61
68
|
buildScene(sim);
|
|
62
69
|
return sim;
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
// object is drawn from interpolated network poses a render delay behind.
|
|
9
9
|
|
|
10
10
|
import * as Avatars from '../client/avatars.js';
|
|
11
|
+
import { easeWalkSpeed, walkFrameTime } from '../client/gait.js';
|
|
11
12
|
import * as Clock from '@imports/castle.real-time/code/client/clock.js';
|
|
12
13
|
import * as Interpolate from '@imports/castle.real-time/code/client/interpolate.js';
|
|
13
14
|
import * as Ownership from '@imports/castle.real-time/code/client/ownership.js';
|
|
14
15
|
import * as Smoothing from '@imports/castle.real-time/code/client/smooth.js';
|
|
15
16
|
import * as Poses from '../client/poses.js';
|
|
16
17
|
import * as Steer from '../client/steer.js';
|
|
18
|
+
import { eligibleClaims } from '../options.js';
|
|
17
19
|
import { connectSession } from '@imports/castle.real-time/code/client/connection.js';
|
|
18
20
|
import { showSoloBadge, updateSoloBadge } from '@imports/castle.real-time/code/client/soloBadge.js';
|
|
19
21
|
import { showJoinOverlay } from '@imports/castle.real-time/code/client/joinOverlay.js';
|
|
@@ -53,6 +55,13 @@ const deckSystem = {
|
|
|
53
55
|
...import.meta.glob('/code/systems/multiplayer.js'),
|
|
54
56
|
};
|
|
55
57
|
|
|
58
|
+
// Read only in this browser system; the track helpers are also imported by
|
|
59
|
+
// Node probes. No gait-module dependency on the deck's physics-3d version.
|
|
60
|
+
const castleJson = Object.values(import.meta.glob('/castle.json', { eager: true, import: 'default' }))[0] ?? {};
|
|
61
|
+
export function gaitModel() {
|
|
62
|
+
return castleJson.gait === 'model';
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
// The engine system owns connection-wide state and runtime actor lifecycles. The
|
|
57
66
|
// system registry calls `installSystem` once for each created engine runtime.
|
|
58
67
|
// Install one multiplayer system into an engine runtime. Return null when a
|
|
@@ -213,6 +222,9 @@ class MultiplayerSystem {
|
|
|
213
222
|
if (this.holding) {
|
|
214
223
|
return;
|
|
215
224
|
}
|
|
225
|
+
if (gaitModel()) {
|
|
226
|
+
this.walkTimeHint = walkFrameTime((this.walkFrame ??= {}));
|
|
227
|
+
}
|
|
216
228
|
const local = scene.actorWith('Player');
|
|
217
229
|
if (this.settleFrames > 0) {
|
|
218
230
|
this.settleFrames -= 1;
|
|
@@ -454,6 +466,25 @@ class MultiplayerSystem {
|
|
|
454
466
|
this.clampedTo = { x, y, z };
|
|
455
467
|
}
|
|
456
468
|
}
|
|
469
|
+
// A re-entering object starts at its current pose, without sliding from
|
|
470
|
+
// the last pose this client saw before it left the interest set.
|
|
471
|
+
// An entry row under an older epoch than the last handover seen is a
|
|
472
|
+
// new object reusing the id: nothing this client kept about the old one
|
|
473
|
+
// (its handover, or holding it) applies.
|
|
474
|
+
const entryRows = msg.oin?.length ? new Map((msg.os ?? []).map(([id, ...row]) => [id, row])) : null;
|
|
475
|
+
for (const id of msg.oin ?? []) {
|
|
476
|
+
if (entryRows.get(id)?.[7] < this.handed.get(id)?.epoch) {
|
|
477
|
+
this.forgetObject(id);
|
|
478
|
+
this.own.mine.delete(id);
|
|
479
|
+
this.own.asked.delete(id);
|
|
480
|
+
this.own.released.delete(id);
|
|
481
|
+
}
|
|
482
|
+
this.objects.delete(id);
|
|
483
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
484
|
+
Smoothing.forget(this.shown, id);
|
|
485
|
+
this.written.delete(id);
|
|
486
|
+
this.live.delete(id);
|
|
487
|
+
}
|
|
457
488
|
for (const [id, ...row] of msg.os ?? []) {
|
|
458
489
|
this.sampleObject(msg, id, row);
|
|
459
490
|
}
|
|
@@ -558,6 +589,11 @@ class MultiplayerSystem {
|
|
|
558
589
|
|
|
559
590
|
// The Transform follows the body at the next physics step. It is moved
|
|
560
591
|
// now so this frame's reach checks and report read the seed as well.
|
|
592
|
+
// The engine is told first (`touch`): a scene may hold an actor still
|
|
593
|
+
// (physics-3d `"engine": { "staticActors": true }`). Only actors with
|
|
594
|
+
// a dynamic or kinematic Body are objects here (server world.js), and
|
|
595
|
+
// those are never still; the touch costs nothing then.
|
|
596
|
+
scene.touch?.(id);
|
|
561
597
|
Poses.applyPose(transform, seed);
|
|
562
598
|
}
|
|
563
599
|
const [vx, vy, vz, wx, wy, wz] = velocity;
|
|
@@ -594,6 +630,7 @@ class MultiplayerSystem {
|
|
|
594
630
|
// An owned object is simulated here, and is live once it is let go.
|
|
595
631
|
// Writing the older network pose over it would undo a local push.
|
|
596
632
|
if (this.own.mine.has(id)) {
|
|
633
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
597
634
|
if (dynamic) {
|
|
598
635
|
this.live.set(id, Steer.makeState());
|
|
599
636
|
}
|
|
@@ -610,9 +647,13 @@ class MultiplayerSystem {
|
|
|
610
647
|
)
|
|
611
648
|
: null;
|
|
612
649
|
if (network && this.isLive(id, network, body, transform, me)) {
|
|
650
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
613
651
|
Steer.steer(body, network, this.live.get(id), dt, now, world, player);
|
|
614
652
|
} else if (!this.live.has(id)) {
|
|
615
|
-
|
|
653
|
+
scene.touch?.(id);
|
|
654
|
+
this.drawInterpolated(id, track, actor, body, at, dt, scene, now);
|
|
655
|
+
} else if (gaitModel()) {
|
|
656
|
+
this.objectWalkSpeeds?.delete(id);
|
|
616
657
|
}
|
|
617
658
|
}
|
|
618
659
|
}
|
|
@@ -649,7 +690,7 @@ class MultiplayerSystem {
|
|
|
649
690
|
// Draw an object from its track at the render time `at`, on both its Transform
|
|
650
691
|
// and its rapier body. A pose already written, with the body still there, is
|
|
651
692
|
// not written again, so a body at rest can sleep.
|
|
652
|
-
drawInterpolated(id, track, actor, body, at, dt) {
|
|
693
|
+
drawInterpolated(id, track, actor, body, at, dt, scene, wall) {
|
|
653
694
|
const sampled = Interpolate.sampleAt(track, at, Poses.blend);
|
|
654
695
|
if (!sampled) {
|
|
655
696
|
return;
|
|
@@ -657,6 +698,15 @@ class MultiplayerSystem {
|
|
|
657
698
|
|
|
658
699
|
// Smooth the sampled target to absorb small steps from uneven delivery.
|
|
659
700
|
const pose = Smoothing.smooth(this.shown, id, sampled, dt, Poses);
|
|
701
|
+
if (gaitModel()) {
|
|
702
|
+
const speed = easeWalkSpeed((this.objectWalkSpeeds ??= new Map()), id, track, at, dt, wall);
|
|
703
|
+
const node = scene.three?.nodes?.get(actor.id)?.node;
|
|
704
|
+
if (node) {
|
|
705
|
+
node.userData.walkSpeedHint = speed;
|
|
706
|
+
node.userData.walkTimeHint = this.walkTimeHint;
|
|
707
|
+
node.userData.walkHintAt = wall;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
660
710
|
const written = this.written.get(id);
|
|
661
711
|
if (written && Poses.same(written, pose) && bodyAt(body, pose)) {
|
|
662
712
|
return;
|
|
@@ -673,6 +723,7 @@ class MultiplayerSystem {
|
|
|
673
723
|
// Apply each other player's pose, spawning its avatar and name tag when needed.
|
|
674
724
|
applyPlayerPoses(scene, at, dt) {
|
|
675
725
|
const others = this.net.others();
|
|
726
|
+
const wall = gaitModel() ? performance.now() : undefined;
|
|
676
727
|
for (const [playerId, username] of others) {
|
|
677
728
|
const track = this.players.get(playerId);
|
|
678
729
|
const sampled = track && Interpolate.sampleAt(track, at, Poses.blend);
|
|
@@ -687,10 +738,19 @@ class MultiplayerSystem {
|
|
|
687
738
|
if (!look) {
|
|
688
739
|
continue;
|
|
689
740
|
}
|
|
690
|
-
Avatars.showPlayer(this.avatars, scene, playerId, look.username ?? null, pose, {
|
|
741
|
+
const actor = Avatars.showPlayer(this.avatars, scene, playerId, look.username ?? null, pose, {
|
|
691
742
|
blueprint: look.blueprint,
|
|
692
743
|
userId: this.net.userId(playerId),
|
|
693
744
|
});
|
|
745
|
+
if (gaitModel()) {
|
|
746
|
+
const speed = easeWalkSpeed((this.playerWalkSpeeds ??= new Map()), playerId, track, at, dt, wall);
|
|
747
|
+
const node = scene.three?.nodes?.get(actor.id)?.node;
|
|
748
|
+
if (node) {
|
|
749
|
+
node.userData.walkSpeedHint = speed;
|
|
750
|
+
node.userData.walkTimeHint = this.walkTimeHint;
|
|
751
|
+
node.userData.walkHintAt = wall;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
694
754
|
}
|
|
695
755
|
Avatars.dropMissing(this.avatars, scene, others);
|
|
696
756
|
Avatars.animate(this.avatars, scene, dt);
|
|
@@ -720,6 +780,7 @@ class MultiplayerSystem {
|
|
|
720
780
|
// Remove history and smoothing state after a player leaves the SDK roster.
|
|
721
781
|
dropPlayer(playerId) {
|
|
722
782
|
this.players.delete(playerId);
|
|
783
|
+
if (gaitModel()) {this.playerWalkSpeeds?.delete(playerId);}
|
|
723
784
|
Smoothing.forget(this.shown, playerId);
|
|
724
785
|
}
|
|
725
786
|
|
|
@@ -782,7 +843,9 @@ class MultiplayerSystem {
|
|
|
782
843
|
const objects = game.claimable?.(scene, this) ?? this.claimable(scene);
|
|
783
844
|
const claims = Ownership.toClaim(
|
|
784
845
|
this.own,
|
|
785
|
-
|
|
846
|
+
eligibleClaims(scene.data)
|
|
847
|
+
? objects.filter(([id]) => scene.getActor(id)?.components.Body?.type === 'dynamic')
|
|
848
|
+
: objects,
|
|
786
849
|
me,
|
|
787
850
|
this.otherPlaces(now),
|
|
788
851
|
now,
|
|
@@ -929,6 +992,12 @@ class MultiplayerSystem {
|
|
|
929
992
|
game.reset?.(scene, this);
|
|
930
993
|
Avatars.clearAvatars(this.avatars, scene);
|
|
931
994
|
this.players.clear();
|
|
995
|
+
if (gaitModel()) {
|
|
996
|
+
this.playerWalkSpeeds?.clear();
|
|
997
|
+
this.objectWalkSpeeds?.clear();
|
|
998
|
+
delete this.walkFrame;
|
|
999
|
+
delete this.walkTimeHint;
|
|
1000
|
+
}
|
|
932
1001
|
this.objects.clear();
|
|
933
1002
|
this.own = Ownership.makeOwnership();
|
|
934
1003
|
this.granted.clear();
|
|
@@ -954,6 +1023,7 @@ class MultiplayerSystem {
|
|
|
954
1023
|
// starts afresh.
|
|
955
1024
|
forgetObject(id) {
|
|
956
1025
|
this.objects.delete(id);
|
|
1026
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
957
1027
|
this.live.delete(id);
|
|
958
1028
|
this.written.delete(id);
|
|
959
1029
|
this.handed.delete(id);
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
6
|
+
"test": "node scripts/test-own-name-tag.mjs && node scripts/test-eligible-claims.mjs",
|
|
7
|
+
"check": "eslint . && npm test && node --input-type=module -e \"const { bundleProject } = await import('../../cli/dist/bundle.js'); await bundleProject('.');\"",
|
|
7
8
|
"format": "prettier --write \"code/**/*.js\" castle.json package.json"
|
|
8
9
|
},
|
|
9
10
|
"dependencies": {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
`ownership-legacy.json` was recorded from the unmodified multiplayer system,
|
|
2
|
+
server ownership, poses and world modules at HEAD 4290fc44005a5b53cdde1f0506504e40d9fa84e1, before the eligibleClaims
|
|
3
|
+
change. The four changed runtime modules were read with `git show HEAD:<path>`
|
|
4
|
+
into `/tmp/house-ownership-baseline/code/`, and the recorder was run with
|
|
5
|
+
`OWNERSHIP_BASELINE_DIR=file:///tmp/house-ownership-baseline/`. `record-ownership-session.mjs` drives those real modules and the real
|
|
6
|
+
rate-limited real-time transport with deterministic body APIs and clock; only
|
|
7
|
+
browser UI, SDK connection and bundler globs are replaced. The transcript covers
|
|
8
|
+
WORLD/STATE rows, initial grant, owner reports, rate-limited asks, releases,
|
|
9
|
+
handover-induced map reorder and starvation, persistent state, and contested
|
|
10
|
+
claims (hold, tie, nearer claimant and timeout). Tests compare literal stdout
|
|
11
|
+
bytes to this fixture; they never regenerate it.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
[multiplayer] placed by the session
|
|
2
|
+
[["server",{"k":"w","t":0,"localMs":0,"ps":[],"os":[["dish",1,0,0,0,0,0,1,0],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish",0,0,0,0,0,0,0,0,0],["door-0",0,0,0,0,0,0,0,0,0],["door-1",0,0,0,0,0,0,0,0,0],["door-2",0,0,0,0,0,0,0,0,0],["door-3",0,0,0,0,0,0,0,0,0],["door-4",0,0,0,0,0,0,0,0,0],["door-5",0,0,0,0,0,0,0,0,0],["door-6",0,0,0,0,0,0,0,0,0],["door-7",0,0,0,0,0,0,0,0,0],["door-8",0,0,0,0,0,0,0,0,0],["door-9",0,0,0,0,0,0,0,0,0],["door-10",0,0,0,0,0,0,0,0,0],["door-11",0,0,0,0,0,0,0,0,0],["ball",0,0,0,0,0,0,0,0,0]]}],["client",{"k":"i","p":[0,0,0,0],"c":["dish","door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball"],"r":[],"o":[],"s":{}}],["server",{"k":"s","t":120,"localMs":120,"ps":[],"os":[["dish",1,0,0,0,0,0,1,1],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish","cook",0,0,0,0,0,0,1]]}],["held",150],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball"],"r":[],"o":[["dish",1,0,0,0,0,0,1,0,0,0,0,0,0,1,2,0]]}],["server",{"k":"s","t":240,"localMs":240,"ps":[],"os":[["dish",1,0,0,0,0,0,1,1],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":["dish"],"o":[["dish",1,0,0,0,0,0,1,0,0,0,0,0,0,1,3,0]]}],["server",{"k":"s","t":360,"localMs":360,"ps":[],"os":[["dish",1,0,0,0,0,0,1,2],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish",0,0,0,0,0,0,0,2]]}],["server",{"k":"s","t":480,"localMs":480,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[["dish",0,0,0,0,0,0,0,3]]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":[],"o":[]}],["server",{"k":"s","t":480,"localMs":480,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":[],"o":[]}],["server",{"k":"s","t":720,"localMs":720,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[20,0,0,0],"c":[],"r":[],"o":[]}],["server",{"k":"s","t":840,"localMs":840,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":960,"localMs":960,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[],"s":{"score":1}}],["server",{"k":"s","t":1080,"localMs":1080,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":1320,"localMs":1320,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":1560,"localMs":1560,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["client",{"k":"i","p":[0,0,0,0],"c":["door-0","door-1","door-2","door-3","door-4","door-5","door-6","door-7","door-8","door-9","door-10","door-11","ball","dish"],"r":[],"o":[]}],["server",{"k":"s","t":1800,"localMs":1800,"ps":[],"os":[["dish",1,0,0,0,0,0,1,3],["door-0",0,0,0,0,0,0,1,0],["door-1",0,0,0,0,0,0,1,0],["door-2",0,0,0,0,0,0,1,0],["door-3",0,0,0,0,0,0,1,0],["door-4",0,0,0,0,0,0,1,0],["door-5",0,0,0,0,0,0,1,0],["door-6",0,0,0,0,0,0,1,0],["door-7",0,0,0,0,0,0,1,0],["door-8",0,0,0,0,0,0,1,0],["door-9",0,0,0,0,0,0,1,0],["door-10",0,0,0,0,0,0,1,0],["door-11",0,0,0,0,0,0,1,0],["ball",2,0,0,0,0,0,1,0]],"own":[]}],["contest",[]],["contest",[]],["contest",[["ball","cook",0,0,0,0,0,0,1]]],["contest",[["ball","cook",0,0,0,0,0,0,2]]]]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Run the real kit modules in Node: replace bundler globs and browser-only UI,
|
|
2
|
+
// keeping ownership, poses, tracks, and the rate-limited wire transport intact.
|
|
3
|
+
import { register } from 'node:module';
|
|
4
|
+
|
|
5
|
+
export async function loadKit(scene = { actors: [] }) {
|
|
6
|
+
register(new URL('./ownership-loader.mjs', import.meta.url), {
|
|
7
|
+
data: {
|
|
8
|
+
baselineDir: process.env.OWNERSHIP_BASELINE_DIR,
|
|
9
|
+
scene,
|
|
10
|
+
kits: new URL('../../', import.meta.url).href,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const { installSystem } = await import('../code/systems/multiplayer.js');
|
|
14
|
+
const Ownership = await import('../code/server/ownership.js');
|
|
15
|
+
const World = await import('../code/server/world.js');
|
|
16
|
+
const { connectSession } = await import('../../real-time/code/client/connection.js');
|
|
17
|
+
return { installSystem, Ownership, World, connectSession, sceneData: scene };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function fakeBody(point) {
|
|
21
|
+
let at = { ...point },
|
|
22
|
+
rotation = { x: 0, y: 0, z: 0, w: 1 };
|
|
23
|
+
let linear = { x: 0, y: 0, z: 0 },
|
|
24
|
+
angular = { x: 0, y: 0, z: 0 };
|
|
25
|
+
return {
|
|
26
|
+
translation: () => at,
|
|
27
|
+
rotation: () => rotation,
|
|
28
|
+
linvel: () => linear,
|
|
29
|
+
angvel: () => angular,
|
|
30
|
+
isSleeping: () => false,
|
|
31
|
+
setTranslation(v) {
|
|
32
|
+
at = { ...v };
|
|
33
|
+
},
|
|
34
|
+
setRotation(v) {
|
|
35
|
+
rotation = { ...v };
|
|
36
|
+
},
|
|
37
|
+
setNextKinematicTranslation(v) {
|
|
38
|
+
at = { ...v };
|
|
39
|
+
},
|
|
40
|
+
setNextKinematicRotation(v) {
|
|
41
|
+
rotation = { ...v };
|
|
42
|
+
},
|
|
43
|
+
setLinvel(v) {
|
|
44
|
+
linear = { ...v };
|
|
45
|
+
},
|
|
46
|
+
setAngvel(v) {
|
|
47
|
+
angular = { ...v };
|
|
48
|
+
},
|
|
49
|
+
setBodyType() {},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function setClock() {
|
|
54
|
+
let now = 0;
|
|
55
|
+
Object.defineProperty(globalThis, 'performance', {
|
|
56
|
+
configurable: true,
|
|
57
|
+
value: { now: () => now },
|
|
58
|
+
});
|
|
59
|
+
return (value) => {
|
|
60
|
+
now = value;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function makeClient(kit, id, actors, at, others = () => []) {
|
|
65
|
+
const packets = [],
|
|
66
|
+
inbox = [];
|
|
67
|
+
const connection = {
|
|
68
|
+
playerId: id,
|
|
69
|
+
state: 'connected',
|
|
70
|
+
isSolo: false,
|
|
71
|
+
send(data) {
|
|
72
|
+
packets.push(structuredClone(data));
|
|
73
|
+
},
|
|
74
|
+
onMessage() {},
|
|
75
|
+
onRoster() {},
|
|
76
|
+
onStateChange() {},
|
|
77
|
+
leave() {},
|
|
78
|
+
};
|
|
79
|
+
globalThis.__ownershipConnection = connection;
|
|
80
|
+
const system = kit.installSystem({ registerSystem() {} });
|
|
81
|
+
system.net = await kit.connectSession();
|
|
82
|
+
system.net.drain = () => inbox.splice(0);
|
|
83
|
+
system.otherPlaces = others;
|
|
84
|
+
const actorMap = new Map(actors.map((a) => [a.id, structuredClone(a)]));
|
|
85
|
+
const bodies = new Map([...actorMap].map(([key, a]) => [key, fakeBody(a.components.Transform)]));
|
|
86
|
+
const scene = {
|
|
87
|
+
data: kit.sceneData,
|
|
88
|
+
persistent: {},
|
|
89
|
+
getActor: (key) => actorMap.get(key),
|
|
90
|
+
physics3d: { bodyOf: (key) => bodies.get(key) },
|
|
91
|
+
};
|
|
92
|
+
const local = { components: { Transform: { ...at } } };
|
|
93
|
+
function receive(msg) {
|
|
94
|
+
inbox.push(msg);
|
|
95
|
+
system.receive(scene);
|
|
96
|
+
}
|
|
97
|
+
function report() {
|
|
98
|
+
system.report(scene, local);
|
|
99
|
+
return packets.at(-1);
|
|
100
|
+
}
|
|
101
|
+
return { id, system, scene, local, bodies, actorMap, packets, receive, report };
|
|
102
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
let settings;
|
|
3
|
+
export function initialize(data) {
|
|
4
|
+
settings = data;
|
|
5
|
+
}
|
|
6
|
+
const stubs = {
|
|
7
|
+
'../client/avatars.js':
|
|
8
|
+
'export const makeAvatars=()=>({actors:new Map(),tags:new Map(),leaving:new Map()}); export const showSelf=()=>{};',
|
|
9
|
+
'../client/steer.js': 'export const makeState=()=>({});',
|
|
10
|
+
'@imports/castle.real-time/code/client/gameHooks.js': 'export const game={};',
|
|
11
|
+
'@imports/castle.real-time/code/server/gameHooks.js':
|
|
12
|
+
'export const componentDefaults={}; export const game={};',
|
|
13
|
+
'castle-web-sdk': 'export const Multiplayer={join:async()=>globalThis.__ownershipConnection};',
|
|
14
|
+
};
|
|
15
|
+
export async function resolve(s, c, next) {
|
|
16
|
+
if (stubs[s])
|
|
17
|
+
return { url: 'data:text/javascript,' + encodeURIComponent(stubs[s]), shortCircuit: true };
|
|
18
|
+
if (s.startsWith('@imports/castle.real-time/'))
|
|
19
|
+
s = settings.kits + 'real-time/' + s.slice('@imports/castle.real-time/'.length);
|
|
20
|
+
return next(s, c);
|
|
21
|
+
}
|
|
22
|
+
export async function load(url, c, next) {
|
|
23
|
+
const relative = url.split('/multiplayer-3d/')[1];
|
|
24
|
+
const baseline =
|
|
25
|
+
settings.baselineDir &&
|
|
26
|
+
[
|
|
27
|
+
'code/systems/multiplayer.js',
|
|
28
|
+
'code/server/ownership.js',
|
|
29
|
+
'code/server/world.js',
|
|
30
|
+
'code/server/sceneBodies.js',
|
|
31
|
+
].includes(relative);
|
|
32
|
+
const globs = url.endsWith('/systems/multiplayer.js') || url.endsWith('/server/sceneBodies.js');
|
|
33
|
+
if (baseline || globs) {
|
|
34
|
+
let source = await readFile(
|
|
35
|
+
baseline ? new URL(relative, settings.baselineDir) : new URL(url),
|
|
36
|
+
'utf8',
|
|
37
|
+
);
|
|
38
|
+
source = source.replace(/import.meta.glob\([^)]*\)/g, (glob) => {
|
|
39
|
+
if (glob.includes('/scenes/'))
|
|
40
|
+
return JSON.stringify({ '/scenes/main.scene': JSON.stringify(settings.scene) });
|
|
41
|
+
return '({})';
|
|
42
|
+
});
|
|
43
|
+
return { format: 'module', source, shortCircuit: true };
|
|
44
|
+
}
|
|
45
|
+
return next(url, c);
|
|
46
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Separate module graphs let each config run as a fresh deck in one test process.
|
|
2
|
+
import { Worker } from 'node:worker_threads';
|
|
3
|
+
export function runWorker(url, argv = []) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const worker = new Worker(url, { argv, stdout: true });
|
|
6
|
+
let out = '';
|
|
7
|
+
worker.stdout.on('data', (chunk) => {
|
|
8
|
+
out += chunk;
|
|
9
|
+
});
|
|
10
|
+
worker.on('error', reject);
|
|
11
|
+
worker.on('exit', (code) =>
|
|
12
|
+
code === 0 ? resolve(out) : reject(new Error(`worker exited ${code}: ${out}`)),
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Deterministic session used to record the pre-option behaviour at 4290fc44005a5b53cdde1f0506504e40d9fa84e1.
|
|
2
|
+
// stdout is only the byte-comparable transcript; regenerating is an explicit action.
|
|
3
|
+
import { loadKit, makeClient, fakeBody, setClock } from './ownership-harness.mjs';
|
|
4
|
+
const config = process.argv[2] ? JSON.parse(process.argv[2]) : {};
|
|
5
|
+
const kit = await loadKit(config);
|
|
6
|
+
const clock = setClock();
|
|
7
|
+
const actors = [
|
|
8
|
+
{ id: 'dish', components: { Transform: { x: 1, y: 0, z: 0 }, Body: { type: 'dynamic' } } },
|
|
9
|
+
...Array.from({ length: 12 }, (_, i) => ({
|
|
10
|
+
id: `door-${i}`,
|
|
11
|
+
components: { Transform: { x: 0, y: 0, z: 0 }, Body: { type: 'kinematic' } },
|
|
12
|
+
})),
|
|
13
|
+
{ id: 'ball', components: { Transform: { x: 2, y: 0, z: 0 }, Body: { type: 'dynamic' } } },
|
|
14
|
+
];
|
|
15
|
+
const sim = {
|
|
16
|
+
eligibleClaims: config.multiplayer?.eligibleClaims === true,
|
|
17
|
+
timeMs: 0,
|
|
18
|
+
players: new Map([
|
|
19
|
+
['cook', { at: { x: 0, y: 0, z: 0 } }],
|
|
20
|
+
['guest', { at: { x: 4, y: 0, z: 0 } }],
|
|
21
|
+
]),
|
|
22
|
+
objects: new Map(
|
|
23
|
+
actors.map((a) => [
|
|
24
|
+
a.id,
|
|
25
|
+
{
|
|
26
|
+
body: fakeBody(a.components.Transform),
|
|
27
|
+
claimable: a.components.Body.type === 'dynamic',
|
|
28
|
+
owner: null,
|
|
29
|
+
epoch: 0,
|
|
30
|
+
reportedAt: 0,
|
|
31
|
+
claimedAt: 0,
|
|
32
|
+
},
|
|
33
|
+
]),
|
|
34
|
+
),
|
|
35
|
+
};
|
|
36
|
+
const client = await makeClient(kit, 'cook', actors, { x: 0, y: 0, z: 0 });
|
|
37
|
+
const transcript = [];
|
|
38
|
+
function state(own, k = 's') {
|
|
39
|
+
const msg = {
|
|
40
|
+
k,
|
|
41
|
+
t: sim.timeMs,
|
|
42
|
+
localMs: sim.timeMs,
|
|
43
|
+
ps: [],
|
|
44
|
+
os: kit.World.objectPoses(sim),
|
|
45
|
+
own,
|
|
46
|
+
};
|
|
47
|
+
transcript.push(['server', msg]);
|
|
48
|
+
client.receive(msg);
|
|
49
|
+
}
|
|
50
|
+
state(kit.Ownership.ownerships(sim), 'w');
|
|
51
|
+
for (const time of [120, 150, 240, 360, 480, 720, 840, 960, 1080, 1320, 1560, 1800]) {
|
|
52
|
+
sim.timeMs = time;
|
|
53
|
+
clock(time);
|
|
54
|
+
if (time === 360) client.local.components.Transform.x = 20;
|
|
55
|
+
if (time === 480) {
|
|
56
|
+
const entry = sim.objects.get('dish');
|
|
57
|
+
entry.owner = 'guest';
|
|
58
|
+
entry.claimedAt = time;
|
|
59
|
+
const rows = [];
|
|
60
|
+
kit.Ownership.release(sim, 'guest', ['dish'], rows);
|
|
61
|
+
state(rows);
|
|
62
|
+
}
|
|
63
|
+
if (time === 720) client.local.components.Transform.x = 20;
|
|
64
|
+
if (time === 960) client.local.components.Transform.x = 0;
|
|
65
|
+
if (time === 1080) client.scene.persistent.score = 1;
|
|
66
|
+
const before = client.packets.length;
|
|
67
|
+
client.report();
|
|
68
|
+
if (client.packets.length === before) {
|
|
69
|
+
transcript.push(['held', time]);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const msg = client.packets.at(-1);
|
|
73
|
+
transcript.push(['client', msg]);
|
|
74
|
+
const own = [];
|
|
75
|
+
kit.Ownership.setObjectPoses(sim, 'cook', msg.o, own);
|
|
76
|
+
kit.Ownership.release(sim, 'cook', msg.r, own);
|
|
77
|
+
kit.Ownership.claim(sim, 'cook', msg.c, own);
|
|
78
|
+
state(own);
|
|
79
|
+
}
|
|
80
|
+
// Contests: tie retains owner, hold protects owner, closer wins after hold,
|
|
81
|
+
// timeout wins even while the hold would otherwise protect the grant.
|
|
82
|
+
const contested = sim.objects.get('ball');
|
|
83
|
+
for (const [time, claimedAt, reportedAt, x] of [
|
|
84
|
+
[2000, 1900, 1900, 1],
|
|
85
|
+
[2200, 1000, 2200, 0],
|
|
86
|
+
[2400, 1000, 2400, 1],
|
|
87
|
+
[5000, 4900, 1000, 1],
|
|
88
|
+
]) {
|
|
89
|
+
sim.timeMs = time;
|
|
90
|
+
contested.owner = 'guest';
|
|
91
|
+
contested.claimedAt = claimedAt;
|
|
92
|
+
contested.reportedAt = reportedAt;
|
|
93
|
+
sim.players.get('cook').at.x = x;
|
|
94
|
+
const own = [];
|
|
95
|
+
kit.Ownership.claim(sim, 'cook', ['ball'], own);
|
|
96
|
+
transcript.push(['contest', own]);
|
|
97
|
+
}
|
|
98
|
+
process.stdout.write(JSON.stringify(transcript) + '\n');
|