castle-web-cli 0.4.232 → 0.4.234
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/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +18 -2
- package/dist/castle-host/host.js +844 -39
- package/dist/castleJson.d.ts +23 -2
- package/dist/castleJson.js +46 -2
- package/dist/check.d.ts +3 -1
- package/dist/check.js +20 -3
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +50 -2
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- 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 +11 -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 +25 -1
- package/dist/save-deck.js +178 -9
- package/dist/serve.js +32 -11
- package/dist/shell/assets/{index-D2tWM896.js → index-DulbYIJm.js} +97 -97
- 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/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +339 -5
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +176 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +37 -6
- package/kits/base/sdk/hub.js +63 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +148 -32
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +81 -7
- package/kits/base/sdk/server/hub.d.ts +117 -0
- package/kits/base/sdk/server/hub.js +119 -2
- package/kits/base/sdk/server/platformHandle.d.ts +43 -1
- package/kits/base/sdk/server/storage.d.ts +17 -0
- package/kits/base/sdk/server/storage.js +65 -3
- package/kits/base/sdk/server/wrapper.d.ts +43 -6
- package/kits/base/sdk/server/wrapper.js +93 -9
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +451 -13
- package/kits/hub-game/README.md +63 -0
- 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/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +311 -35
- 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 +253 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +472 -0
- package/kits/hub-game/code/client/build.js +38 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +2144 -160
- 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/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +515 -0
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -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/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +368 -29
- package/kits/hub-game/code/client/hookLayer.js +385 -20
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +177 -24
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +234 -0
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -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/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +146 -0
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -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 +162 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +714 -59
- package/kits/hub-game/code/client/tiers.js +543 -52
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +39 -2
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +200 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +138 -0
- package/kits/hub-game/code/server/actors.js +11 -2
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- 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 +107 -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/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +478 -0
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +272 -0
- package/kits/hub-game/code/server/history.js +7 -0
- package/kits/hub-game/code/server/hub.js +2510 -95
- package/kits/hub-game/code/server/idle.js +60 -12
- package/kits/hub-game/code/server/index.js +28 -6
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +36 -2
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +586 -7
- package/kits/hub-game/code/server/menu.js +161 -0
- package/kits/hub-game/code/server/npcs.js +1025 -113
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +30 -0
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +123 -0
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +175 -0
- package/kits/hub-game/code/server/wear.js +12 -0
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +53 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1753 -202
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +3475 -77
- package/kits/hub-game/docs/home-pieces.md +71 -0
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -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 +10 -1
- package/kits/hub-game/package.json +6 -2
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +117 -16
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +132 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +26 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +123 -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/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +853 -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 +38 -23
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -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 +792 -0
- package/kits/hub-game/scripts/test-avatar.mjs +584 -7
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +1008 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +49 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +863 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +216 -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-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +344 -0
- package/kits/hub-game/scripts/test-decor.mjs +464 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1224 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +961 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +758 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1594 -12
- package/kits/hub-game/scripts/test-hud-clear.mjs +484 -57
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +427 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +513 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +664 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +472 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +585 -0
- package/kits/hub-game/scripts/test-menu.mjs +319 -0
- package/kits/hub-game/scripts/test-npcs.mjs +2528 -13
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +541 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1733 -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-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +901 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5437 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +449 -0
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1904 -0
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +412 -0
- package/kits/hub-game/scripts/test-tiers.mjs +476 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- package/kits/hub-game/scripts/test-vis.mjs +770 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +210 -0
- package/kits/hub-game/scripts/test-yours.mjs +403 -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/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- 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 +443 -34
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +3 -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-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +19 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +337 -3
- 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/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +42 -529
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +661 -87
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +9 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -277
- package/kits/physics-3d/engine3d/actornode.js +87 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -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 +99 -0
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +126 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +514 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +106 -21
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +522 -10
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +890 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- 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 +1253 -76
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +10 -2
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2613 -82
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +2 -2
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +438 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -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 +5 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +2001 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +582 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +657 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -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-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +10 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2174 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +7 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +419 -9
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +102 -22
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -8,12 +8,16 @@
|
|
|
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';
|
|
17
|
+
import * as ResumeGate from '../client/resumeGate.js';
|
|
18
|
+
import { joinPlaceName, showJoinFailure } from '../client/joinFailure.js';
|
|
16
19
|
import * as Steer from '../client/steer.js';
|
|
20
|
+
import { eligibleClaims } from '../options.js';
|
|
17
21
|
import { connectSession } from '@imports/castle.real-time/code/client/connection.js';
|
|
18
22
|
import { showSoloBadge, updateSoloBadge } from '@imports/castle.real-time/code/client/soloBadge.js';
|
|
19
23
|
import { showJoinOverlay } from '@imports/castle.real-time/code/client/joinOverlay.js';
|
|
@@ -21,6 +25,8 @@ import { GONE, SCENE, STATE, WORLD } from '@imports/castle.real-time/code/client
|
|
|
21
25
|
|
|
22
26
|
// How long the joining overlay may hold the card before giving up.
|
|
23
27
|
const JOIN_WAIT_MS = 10000;
|
|
28
|
+
const JOIN_WATCHDOG_MS = 20000;
|
|
29
|
+
const JOIN_FAILURE_LIMIT = 3;
|
|
24
30
|
import { game } from '@imports/castle.real-time/code/client/gameHooks.js';
|
|
25
31
|
|
|
26
32
|
// Apply this fraction of a server player correction per frame. Corrections over
|
|
@@ -43,6 +49,8 @@ const WRITTEN_SLACK = 0.005;
|
|
|
43
49
|
const JOIN_BACK_MS = 250;
|
|
44
50
|
// Castle refuses a player barred from the hub every hub join with this code.
|
|
45
51
|
const HUB_BANNED = 'CAULDRON_HUB_BANNED';
|
|
52
|
+
const finalJoinError = (code) => code === HUB_BANNED ||
|
|
53
|
+
(typeof code === 'string' && code.startsWith('CAULDRON_HUB_INVITE_') && code !== 'CAULDRON_HUB_INVITE_NOT_IN_SESSION') ? code : null;
|
|
46
54
|
|
|
47
55
|
// A deck may provide its own multiplayer system. The engine registry permits
|
|
48
56
|
// duplicate systems, which would create duplicate session connections, so these
|
|
@@ -53,6 +61,13 @@ const deckSystem = {
|
|
|
53
61
|
...import.meta.glob('/code/systems/multiplayer.js'),
|
|
54
62
|
};
|
|
55
63
|
|
|
64
|
+
// Read only in this browser system; the track helpers are also imported by
|
|
65
|
+
// Node probes. No gait-module dependency on the deck's physics-3d version.
|
|
66
|
+
const castleJson = Object.values(import.meta.glob('/castle.json', { eager: true, import: 'default' }))[0] ?? {};
|
|
67
|
+
export function gaitModel() {
|
|
68
|
+
return castleJson.gait === 'model';
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
// The engine system owns connection-wide state and runtime actor lifecycles. The
|
|
57
72
|
// system registry calls `installSystem` once for each created engine runtime.
|
|
58
73
|
// Install one multiplayer system into an engine runtime. Return null when a
|
|
@@ -81,13 +96,13 @@ class MultiplayerSystem {
|
|
|
81
96
|
this.joined = false;
|
|
82
97
|
this.joinStartedAt = 0;
|
|
83
98
|
|
|
84
|
-
// `starting`
|
|
99
|
+
// `starting` spans connection acquisition through placement, not only the promise.
|
|
85
100
|
this.starting = false;
|
|
86
101
|
|
|
87
102
|
// What `Multiplayer.join` is asked for, and whether the kit's join overlay
|
|
88
103
|
// stays down while it happens (the caller covers the join itself, as a
|
|
89
|
-
// hub's door animation does). `generation`
|
|
90
|
-
//
|
|
104
|
+
// hub's door animation does). `generation` invalidates pending joins when
|
|
105
|
+
// switching sessions, abandoning a join, or disposing the runtime.
|
|
91
106
|
// A client hook may name the first join instead (`firstJoin`, a hub place
|
|
92
107
|
// that joins its world through a destination route).
|
|
93
108
|
this.target = game.firstJoin?.() ?? { mode: 'public' };
|
|
@@ -97,8 +112,16 @@ class MultiplayerSystem {
|
|
|
97
112
|
// refused, or its connection closes for good, it is not tried again. The
|
|
98
113
|
// caller that switched to it reads `joinState()` and decides where to go.
|
|
99
114
|
this.joinFailed = false;
|
|
100
|
-
|
|
115
|
+
this.joinFailures = 0;
|
|
116
|
+
this.joinRetryAt = 0;
|
|
117
|
+
this.joinAttempt = null;
|
|
118
|
+
this.joinFrameAt = null;
|
|
119
|
+
this.joinScene = null;
|
|
120
|
+
this.joinAttemptNumber = 0;
|
|
121
|
+
this.removeJoinFailure = null;
|
|
122
|
+
// The CastleError code of a join refused for good, else null.
|
|
101
123
|
this.joinError = null;
|
|
124
|
+
this.joinFailure = null;
|
|
102
125
|
// Whether the join `switchSession` asked for has resolved (for a hub join,
|
|
103
126
|
// the host committed the trip), kept apart from whether its connection is
|
|
104
127
|
// still open. `holding` keeps a new connection's messages queued, nothing
|
|
@@ -175,6 +198,21 @@ class MultiplayerSystem {
|
|
|
175
198
|
// The JSON of the last state block sent, so a block goes out only when it
|
|
176
199
|
// changes.
|
|
177
200
|
this.sentState = '';
|
|
201
|
+
|
|
202
|
+
// A placed player who went away (the page hidden, its frames stopped, or
|
|
203
|
+
// the connection dropped) is kept behind the cover until a current
|
|
204
|
+
// snapshot arrives (`client/resumeGate.js`). `frameAt` is the page time of
|
|
205
|
+
// the last network frame, where an away begins; `wasAway` says the cover
|
|
206
|
+
// is for a return, not a join, until the next session. `gaveUp` keeps a
|
|
207
|
+
// gate that timed out from arming again before the connection is back.
|
|
208
|
+
// `outAt` is the page time the player last came out from behind it, by a
|
|
209
|
+
// snapshot, by giving up, or by the session closing under it (`returning`).
|
|
210
|
+
this.resume = ResumeGate.makeGate();
|
|
211
|
+
this.frameAt = 0;
|
|
212
|
+
this.wasAway = false;
|
|
213
|
+
this.gaveUp = false;
|
|
214
|
+
this.outAt = null;
|
|
215
|
+
this.onVisibility = null;
|
|
178
216
|
}
|
|
179
217
|
|
|
180
218
|
// Run the network frame after engine behaviors and local physics. Connection,
|
|
@@ -183,7 +221,9 @@ class MultiplayerSystem {
|
|
|
183
221
|
// Connecting on the first stepped frame keeps editor-only runtimes out of
|
|
184
222
|
// multiplayer sessions because the scene editor constructs but never steps them.
|
|
185
223
|
if (!this.net) {
|
|
186
|
-
|
|
224
|
+
this.stepJoin(scene);
|
|
225
|
+
this.watchJoin(scene);
|
|
226
|
+
showJoinOverlay(this.joiningOverlayWanted(), this.coverText());
|
|
187
227
|
return void this.start(scene);
|
|
188
228
|
}
|
|
189
229
|
|
|
@@ -191,35 +231,66 @@ class MultiplayerSystem {
|
|
|
191
231
|
// platform closed it). Everything drawn from it goes, and the next frame
|
|
192
232
|
// joins afresh behind the overlay.
|
|
193
233
|
if (this.net.closed()) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
234
|
+
this.generation += 1;
|
|
235
|
+
this.joinError = finalJoinError(this.net.closeError?.());
|
|
236
|
+
if (this.resume.armed) {
|
|
237
|
+
this.outAt = performance.now();
|
|
238
|
+
}
|
|
197
239
|
if (this.target?.mode === 'hub' && this.joinCommitted && !this.joined) {
|
|
198
240
|
this.joinLost = true;
|
|
199
241
|
}
|
|
200
|
-
this.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.
|
|
204
|
-
this.joinFailed = this.target?.mode === 'hub' || this.joinError !== null;
|
|
205
|
-
this.holding = false;
|
|
206
|
-
this.net = null;
|
|
207
|
-
this.joined = false;
|
|
208
|
-
this.joinStartedAt = 0;
|
|
209
|
-
this.starting = false;
|
|
210
|
-
this.sentState = '';
|
|
242
|
+
if (!this.joined) {
|
|
243
|
+
this.failedJoin(scene, this.net.closeError?.() ?? 'CLOSED', null);
|
|
244
|
+
}
|
|
245
|
+
this.clearConnection(scene);
|
|
211
246
|
return;
|
|
212
247
|
}
|
|
248
|
+
const now = performance.now();
|
|
249
|
+
const last = this.frameAt;
|
|
250
|
+
this.frameAt = now;
|
|
213
251
|
if (this.holding) {
|
|
214
252
|
return;
|
|
215
253
|
}
|
|
254
|
+
|
|
255
|
+
// Frames that stopped for a while, or a connection no longer connected,
|
|
256
|
+
// mean the room drawn is no longer current. The page being hidden arms the
|
|
257
|
+
// same gate from its event (`start`), before the page goes.
|
|
258
|
+
if (last && now - last > ResumeGate.STALL_MS) {
|
|
259
|
+
this.away(last);
|
|
260
|
+
}
|
|
261
|
+
const connected = this.net.status().state === 'connected';
|
|
262
|
+
if (connected) {
|
|
263
|
+
this.joinStage('connected');
|
|
264
|
+
this.gaveUp = false;
|
|
265
|
+
} else {
|
|
266
|
+
this.away(last || now);
|
|
267
|
+
}
|
|
268
|
+
ResumeGate.noteConnection(this.resume, connected, now);
|
|
269
|
+
if (gaitModel()) {
|
|
270
|
+
this.walkTimeHint = walkFrameTime((this.walkFrame ??= {}));
|
|
271
|
+
}
|
|
216
272
|
const local = scene.actorWith('Player');
|
|
217
273
|
if (this.settleFrames > 0) {
|
|
218
274
|
this.settleFrames -= 1;
|
|
219
275
|
}
|
|
220
276
|
|
|
221
277
|
// Drain all queued messages before choosing the render time for this frame.
|
|
278
|
+
// A current snapshot releases the resume gate inside `receive`; one that
|
|
279
|
+
// never comes releases it after RESUME_WAIT_MS of visible time.
|
|
222
280
|
this.receive(scene);
|
|
281
|
+
// An assigned connection may already hold its WORLD, even after a parked
|
|
282
|
+
// frame or while reconnecting. Drain placement before any join recovery.
|
|
283
|
+
this.stepJoin(scene);
|
|
284
|
+
if (!this.net) { return; }
|
|
285
|
+
// Drain first: a placement queued for this frame wins over the timeout.
|
|
286
|
+
if (this.watchJoin(scene)) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (ResumeGate.waited(this.resume, now, !pageHidden())) {
|
|
290
|
+
console.warn('[multiplayer] no current snapshot since coming back; showing the room as it is');
|
|
291
|
+
this.resumed();
|
|
292
|
+
this.gaveUp = true;
|
|
293
|
+
}
|
|
223
294
|
this.applyGone(scene);
|
|
224
295
|
this.reportGone(scene);
|
|
225
296
|
|
|
@@ -260,56 +331,203 @@ class MultiplayerSystem {
|
|
|
260
331
|
}
|
|
261
332
|
this.publish(scene, local);
|
|
262
333
|
updateSoloBadge(this.net.status(), game);
|
|
263
|
-
showJoinOverlay(this.joiningOverlayWanted());
|
|
334
|
+
showJoinOverlay(this.joiningOverlayWanted(), this.coverText());
|
|
264
335
|
}
|
|
265
336
|
|
|
266
337
|
// Join the session `target` names (the public one unless `switchSession`
|
|
267
338
|
// said otherwise) and retain the transport across scene loads.
|
|
268
339
|
async start(scene) {
|
|
269
|
-
if (this.starting || this.joinFailed) {
|
|
340
|
+
if (this.net || this.starting || this.joinFailed || performance.now() < this.joinRetryAt) {
|
|
270
341
|
return;
|
|
271
342
|
}
|
|
272
343
|
this.starting = true;
|
|
273
344
|
this.joinStartedAt ||= performance.now();
|
|
345
|
+
const now = performance.now();
|
|
346
|
+
this.joinAttempt = { number: ++this.joinAttemptNumber, at: now, stepAt: now,
|
|
347
|
+
visibleMs: 0, hidden: pageHidden(), stages: new Set() };
|
|
348
|
+
this.joinStage('attempt start', { mode: this.target?.mode ?? (this.target?.destination ? 'destination' : 'public') });
|
|
274
349
|
const generation = this.generation;
|
|
350
|
+
|
|
351
|
+
// The cover has to be up before the page goes, so the first frame shown
|
|
352
|
+
// when it comes back is the cover and not the scene it last drew.
|
|
353
|
+
if (!this.onVisibility && typeof document !== 'undefined') {
|
|
354
|
+
this.onVisibility = () => {
|
|
355
|
+
if (pageHidden()) {
|
|
356
|
+
if (this.joinAttempt) { this.joinAttempt.hidden = true; }
|
|
357
|
+
this.away(this.frameAt || performance.now());
|
|
358
|
+
} else {
|
|
359
|
+
this.visibleJoin(this.joinScene ?? scene, this.joinAttempt?.hidden === true);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
document.addEventListener('visibilitychange', this.onVisibility);
|
|
363
|
+
}
|
|
275
364
|
try {
|
|
276
365
|
const net = await connectSession({
|
|
277
366
|
join: this.target,
|
|
367
|
+
isCurrent: () => generation === this.generation,
|
|
368
|
+
...(game.unpack ? { unpack: game.unpack } : {}),
|
|
278
369
|
onLog: (text) => console.log(`[multiplayer] ${text}`),
|
|
279
370
|
|
|
280
371
|
// A deck message can be handled on arrival through the `arrive` hook,
|
|
281
372
|
// which still runs in a hidden tab. State messages always wait for a frame.
|
|
282
|
-
onArrival: (msg) => msg.k !== STATE && msg.k !== WORLD && game.arrive?.(msg, this) === true,
|
|
373
|
+
onArrival: (msg) => generation === this.generation && msg.k !== STATE && msg.k !== WORLD && game.arrive?.(msg, this) === true,
|
|
283
374
|
|
|
284
375
|
// A reconnect may reach a restarted server process, which builds its
|
|
285
376
|
// world from scratch: it is named the scene again.
|
|
286
377
|
onConnected: () => {
|
|
287
378
|
if (generation === this.generation) {
|
|
379
|
+
this.joinStage('connected');
|
|
288
380
|
this.nameScene(scene);
|
|
381
|
+
this.reconnected();
|
|
289
382
|
}
|
|
290
383
|
},
|
|
291
384
|
});
|
|
292
385
|
if (generation !== this.generation) {
|
|
293
|
-
//
|
|
386
|
+
// Switched, abandoned or disposed while pending: this net is not wanted.
|
|
294
387
|
net.close();
|
|
295
388
|
return;
|
|
296
389
|
}
|
|
297
390
|
this.net = net;
|
|
298
391
|
this.joinCommitted = true;
|
|
392
|
+
if (net.status().state === 'connected') { this.joinStage('connected'); }
|
|
393
|
+
this.joinRetryAt = 0;
|
|
299
394
|
|
|
300
395
|
this.nameScene(scene);
|
|
301
396
|
} catch (err) {
|
|
302
397
|
console.log(`[multiplayer] could not join: ${err?.message ?? err}`);
|
|
303
398
|
if (generation === this.generation) {
|
|
304
399
|
this.starting = false;
|
|
305
|
-
|
|
306
|
-
// the town's own included: asking again changes nothing.
|
|
307
|
-
this.joinError = err?.code === HUB_BANNED ? HUB_BANNED : null;
|
|
308
|
-
this.joinFailed = this.target?.mode === 'hub' || this.joinError !== null;
|
|
400
|
+
this.failedJoin(scene, err?.code ?? null, err?.extensions?.closeCode ?? null);
|
|
309
401
|
}
|
|
310
402
|
}
|
|
311
403
|
}
|
|
312
404
|
|
|
405
|
+
// Join-stage diagnostics are emitted once even if a socket reconnects or a
|
|
406
|
+
// visibility event repeats. Durations are wall time; the budget below is not.
|
|
407
|
+
joinStage(stage, detail = {}) {
|
|
408
|
+
const attempt = this.joinAttempt;
|
|
409
|
+
if (!attempt || attempt.stages.has(stage)) { return; }
|
|
410
|
+
attempt.stages.add(stage);
|
|
411
|
+
console.warn(`[multiplayer] join ${stage}`, {
|
|
412
|
+
attempt: attempt.number, ms: Math.round(performance.now() - attempt.at), ...detail,
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Only adjacent visible steps spend the budget. A suspended WebView can
|
|
417
|
+
// miss visibilitychange entirely, including while getSession is pending.
|
|
418
|
+
stepJoin(scene) {
|
|
419
|
+
this.joinScene = scene;
|
|
420
|
+
const now = performance.now();
|
|
421
|
+
const last = this.joinFrameAt;
|
|
422
|
+
this.joinFrameAt = now;
|
|
423
|
+
if (this.joined || this.target?.mode === 'hub' || this.joinFailed || this.net?.status().solo) { return; }
|
|
424
|
+
const attempt = this.joinAttempt;
|
|
425
|
+
const gap = attempt ? now - attempt.stepAt : 0;
|
|
426
|
+
const stalled = this.starting ? gap > ResumeGate.STALL_MS : last !== null && now - last > ResumeGate.STALL_MS;
|
|
427
|
+
if (!pageHidden() && (attempt?.hidden || stalled)) {
|
|
428
|
+
this.visibleJoin(scene, true, true);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (!this.starting || !attempt) { return; }
|
|
432
|
+
if (!pageHidden()) { attempt.visibleMs += gap; }
|
|
433
|
+
attempt.stepAt = now;
|
|
434
|
+
attempt.hidden ||= pageHidden();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// A visibility event never abandons an assigned net: its next frame must
|
|
438
|
+
// drain first. Connected nets keep waiting for placement under the watchdog.
|
|
439
|
+
visibleJoin(scene, stale, drained = false) {
|
|
440
|
+
if (this.joined || this.target?.mode === 'hub' || this.joinFailed || this.net?.status().solo) { return; }
|
|
441
|
+
this.joinRetryAt = 0;
|
|
442
|
+
if (this.net && !drained) {
|
|
443
|
+
if (this.joinAttempt && stale) { this.joinAttempt.hidden = true; }
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (this.joinAttempt) {
|
|
447
|
+
this.joinAttempt.hidden = false;
|
|
448
|
+
if (stale) { this.joinAttempt.stepAt = performance.now(); }
|
|
449
|
+
}
|
|
450
|
+
if (this.starting && stale && (!this.net || this.net.status().state !== 'connected')) {
|
|
451
|
+
this.joinStage('visible rejoin');
|
|
452
|
+
this.abandonJoin(scene, 'VISIBLE_REJOIN');
|
|
453
|
+
// A return retries now rather than waiting through the normal backoff.
|
|
454
|
+
this.joinRetryAt = 0;
|
|
455
|
+
void this.start(scene);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
watchJoin(scene) {
|
|
460
|
+
if (this.target?.mode === 'hub' || this.joined || this.net?.status().solo || !this.starting ||
|
|
461
|
+
!(this.joinAttempt?.visibleMs > JOIN_WATCHDOG_MS)) { return false; }
|
|
462
|
+
this.joinStage('watchdog abort', { visibleMs: Math.round(this.joinAttempt.visibleMs) });
|
|
463
|
+
this.abandonJoin(scene, 'JOIN_TIMEOUT');
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
abandonJoin(scene, code) {
|
|
468
|
+
// Invalidate before closing: callbacks and a late promise belong to the
|
|
469
|
+
// abandoned attempt and must never reach this scene or replace its net.
|
|
470
|
+
this.generation += 1;
|
|
471
|
+
this.net?.close();
|
|
472
|
+
this.failedJoin(scene, code, null);
|
|
473
|
+
this.clearConnection(scene);
|
|
474
|
+
this.joinCommitted = false;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// The same scene/transport cleanup for an ended socket and an abandoned join.
|
|
478
|
+
clearConnection(scene) {
|
|
479
|
+
this.reset(scene);
|
|
480
|
+
this.shortIds.clear();
|
|
481
|
+
this.rowInterval = 0;
|
|
482
|
+
this.rowLagShown = 0;
|
|
483
|
+
this.joinFailed ||= this.target?.mode === 'hub' || this.joinError !== null;
|
|
484
|
+
this.holding = false;
|
|
485
|
+
this.net = null;
|
|
486
|
+
this.joined = false;
|
|
487
|
+
this.joinStartedAt = 0;
|
|
488
|
+
this.starting = false;
|
|
489
|
+
this.sentState = '';
|
|
490
|
+
this.endAway();
|
|
491
|
+
this.clock = Clock.makeClock();
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
failedJoin(scene, code, closeCode) {
|
|
495
|
+
if (this.net?.status().solo) { return; }
|
|
496
|
+
this.joinStage('failure', { code, closeCode });
|
|
497
|
+
this.joinFailure = { code, closeCode };
|
|
498
|
+
this.joinError = finalJoinError(code);
|
|
499
|
+
this.joinFailed = this.target?.mode === 'hub' || this.joinError !== null;
|
|
500
|
+
if (this.target?.mode === 'hub') { return; }
|
|
501
|
+
this.joinFailures += 1;
|
|
502
|
+
// Permanent refusals keep the deck's existing ban/invite failure surface.
|
|
503
|
+
if (this.joinError !== null) { return; }
|
|
504
|
+
this.joinFailed ||= this.joinFailures >= JOIN_FAILURE_LIMIT;
|
|
505
|
+
if (this.joinFailed) {
|
|
506
|
+
this.joinStage('gave up');
|
|
507
|
+
showJoinOverlay(false);
|
|
508
|
+
this.removeJoinFailure ??= showJoinFailure(this.joinName(), () => {
|
|
509
|
+
if (!this.joinFailed) { return; }
|
|
510
|
+
this.joinStage('retry tapped');
|
|
511
|
+
this.removeJoinFailure?.();
|
|
512
|
+
this.removeJoinFailure = null;
|
|
513
|
+
this.joinFailures = 0;
|
|
514
|
+
this.joinFailed = false;
|
|
515
|
+
this.joinError = null;
|
|
516
|
+
this.joinFailure = null;
|
|
517
|
+
this.joinRetryAt = 0;
|
|
518
|
+
this.joinStartedAt = 0;
|
|
519
|
+
void this.start(this.joinScene ?? scene);
|
|
520
|
+
showJoinOverlay(this.joiningOverlayWanted(), this.coverText());
|
|
521
|
+
});
|
|
522
|
+
} else {
|
|
523
|
+
this.joinRetryAt = performance.now() + Math.min(30_000, 1_000 * 2 ** Math.min(this.joinFailures - 1, 5));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
joinName() {
|
|
528
|
+
return joinPlaceName(castleJson.hub?.title);
|
|
529
|
+
}
|
|
530
|
+
|
|
313
531
|
// A deck whose server takes its scene from the client names the scene this
|
|
314
532
|
// runtime is playing, before anything else is sent. A server that already
|
|
315
533
|
// has one ignores it.
|
|
@@ -327,6 +545,10 @@ class MultiplayerSystem {
|
|
|
327
545
|
// A scene swap requested in the same frame is applied before the next one,
|
|
328
546
|
// so the new session is named the new scene.
|
|
329
547
|
switchSession(scene, join, { quiet = false, hold = false } = {}) {
|
|
548
|
+
this.removeJoinFailure?.();
|
|
549
|
+
this.removeJoinFailure = null;
|
|
550
|
+
this.joinAttempt = null;
|
|
551
|
+
this.joinFrameAt = null;
|
|
330
552
|
this.generation += 1;
|
|
331
553
|
this.reset(scene);
|
|
332
554
|
this.net?.close();
|
|
@@ -336,11 +558,16 @@ class MultiplayerSystem {
|
|
|
336
558
|
this.joinWarned = false;
|
|
337
559
|
this.starting = false;
|
|
338
560
|
this.joinFailed = false;
|
|
561
|
+
this.joinFailures = 0;
|
|
562
|
+
this.joinRetryAt = 0;
|
|
339
563
|
this.joinError = null;
|
|
564
|
+
this.joinFailure = null;
|
|
340
565
|
this.joinCommitted = false;
|
|
341
566
|
this.joinLost = false;
|
|
342
567
|
this.holding = hold;
|
|
343
568
|
this.sentState = '';
|
|
569
|
+
this.endAway();
|
|
570
|
+
this.outAt = null;
|
|
344
571
|
this.gone.clear();
|
|
345
572
|
// The new session numbers its rows afresh.
|
|
346
573
|
this.shortIds.clear();
|
|
@@ -350,7 +577,7 @@ class MultiplayerSystem {
|
|
|
350
577
|
this.clock = Clock.makeClock();
|
|
351
578
|
this.target = join;
|
|
352
579
|
this.quiet = quiet;
|
|
353
|
-
showJoinOverlay(this.joiningOverlayWanted());
|
|
580
|
+
showJoinOverlay(this.joiningOverlayWanted(), this.coverText());
|
|
354
581
|
}
|
|
355
582
|
|
|
356
583
|
// Where the join `switchSession` asked for stands: 'joining', 'joined' (it
|
|
@@ -371,14 +598,107 @@ class MultiplayerSystem {
|
|
|
371
598
|
|
|
372
599
|
// Whether the session has placed this player and the body and camera have
|
|
373
600
|
// caught up with it, which is when a caller covering the join can uncover.
|
|
601
|
+
// A player kept behind the resume gate is not placed until it releases.
|
|
374
602
|
placed() {
|
|
375
|
-
return Boolean(this.net) && this.joined && !this.placedTo && this.settleFrames === 0;
|
|
603
|
+
return Boolean(this.net) && this.joined && !this.placedTo && this.settleFrames === 0 && !this.resume.armed;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// The room stopped being current at page time `since`. A placed player is
|
|
607
|
+
// kept behind the cover from now until a current snapshot (`receive`). The
|
|
608
|
+
// cover goes up at once, because this runs from the page's hidden event.
|
|
609
|
+
away(since) {
|
|
610
|
+
if (!this.net || !this.joined || this.gaveUp || this.net.status().solo || this.joinError) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const serverAt = Clock.ready(this.clock) ? since - this.clock.offset : null;
|
|
614
|
+
if (ResumeGate.arm(this.resume, since, serverAt)) {
|
|
615
|
+
console.log('[multiplayer] away; holding the room until a current snapshot');
|
|
616
|
+
this.wasAway = true;
|
|
617
|
+
showJoinOverlay(this.joiningOverlayWanted(), this.coverText());
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// The connection came back after dropping, perhaps while the page was hidden
|
|
622
|
+
// and no frame saw it go: whatever changed meanwhile was not seen here.
|
|
623
|
+
reconnected() {
|
|
624
|
+
const now = performance.now();
|
|
625
|
+
this.gaveUp = false;
|
|
626
|
+
this.away(this.frameAt || now);
|
|
627
|
+
ResumeGate.noteConnection(this.resume, false, now);
|
|
628
|
+
ResumeGate.noteConnection(this.resume, true, now);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// A current snapshot arrived after an away. Every displayed pose is
|
|
632
|
+
// forgotten, so this frame draws each object and player at its current pose
|
|
633
|
+
// rather than smoothing from the one shown before the away, and each live
|
|
634
|
+
// object this client does not hold is placed afresh at the network's
|
|
635
|
+
// present rather than steered there from where its body was left.
|
|
636
|
+
//
|
|
637
|
+
// Each history also loses the samples from before the away that a later
|
|
638
|
+
// one follows: interpolating between the two would draw a glide across the
|
|
639
|
+
// whole absence. A history with nothing newer keeps its newest pose, which
|
|
640
|
+
// is still where that object is.
|
|
641
|
+
//
|
|
642
|
+
// A live body is placed on its rapier body, which its Transform follows
|
|
643
|
+
// only at the next physics step, so the cover stays up one more frame.
|
|
644
|
+
resumed() {
|
|
645
|
+
const from = this.resume.serverAt;
|
|
646
|
+
ResumeGate.clear(this.resume);
|
|
647
|
+
this.outAt = performance.now();
|
|
648
|
+
this.shown = Smoothing.makeSmoothing();
|
|
649
|
+
if (from !== null) {
|
|
650
|
+
for (const track of [...this.objects.values(), ...this.players.values()]) {
|
|
651
|
+
// A sample at `from` itself arrived by the last frame before the away.
|
|
652
|
+
const first = track.samples.findIndex((s) => s.simMs > from);
|
|
653
|
+
if (first > 0) {
|
|
654
|
+
track.samples.splice(0, first);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
for (const id of [...this.live.keys()]) {
|
|
659
|
+
if (!this.own.mine.has(id)) {
|
|
660
|
+
this.live.delete(id);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
if (gaitModel()) {
|
|
664
|
+
this.playerWalkSpeeds?.clear();
|
|
665
|
+
this.objectWalkSpeeds?.clear();
|
|
666
|
+
}
|
|
667
|
+
this.settleFrames = Math.max(this.settleFrames, 1);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// Whether this player is behind the resume cover, or came out from behind
|
|
671
|
+
// it within `RETURN_MS`. A session that ends now most likely ended over the
|
|
672
|
+
// absence (a game that ran out while the player was away), and what the
|
|
673
|
+
// page still draws of it is the room as it was: a caller leaving the place
|
|
674
|
+
// goes straight under its own cover rather than playing a beat over it.
|
|
675
|
+
returning() {
|
|
676
|
+
return this.resume.armed || (this.outAt !== null && performance.now() - this.outAt < ResumeGate.RETURN_MS);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Leave the resume gate without a snapshot: the session it waited on has
|
|
680
|
+
// gone, and the join overlay covers the next one.
|
|
681
|
+
endAway() {
|
|
682
|
+
ResumeGate.clear(this.resume);
|
|
683
|
+
this.wasAway = false;
|
|
684
|
+
this.gaveUp = false;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// What the cover says.
|
|
688
|
+
coverText() {
|
|
689
|
+
const name = this.joinName();
|
|
690
|
+
return this.wasAway ? 'Reconnecting…' : name ? `Joining ${name}…` : 'Joining…';
|
|
376
691
|
}
|
|
377
692
|
|
|
378
693
|
// Drain queued transport messages. State messages update clock, ownership, pose
|
|
379
694
|
// histories, and deck state in that order; other message kinds go to the deck.
|
|
380
695
|
receive(scene) {
|
|
381
696
|
const selfId = this.net.selfId();
|
|
697
|
+
|
|
698
|
+
// A snapshot releases the resume gate only once the page is shown and
|
|
699
|
+
// connected again; the whole drain is applied before it does.
|
|
700
|
+
const resuming = this.resume.armed && !pageHidden() && this.net.status().state === 'connected';
|
|
701
|
+
let fresh = false;
|
|
382
702
|
for (const msg of this.net.drain()) {
|
|
383
703
|
if (msg.k !== STATE && msg.k !== WORLD) {
|
|
384
704
|
game.message?.(scene, msg, this);
|
|
@@ -402,9 +722,13 @@ class MultiplayerSystem {
|
|
|
402
722
|
|
|
403
723
|
// Pair simulation time with the page arrival time before filing samples.
|
|
404
724
|
Clock.noteArrival(this.clock, msg.t, msg.localMs);
|
|
725
|
+
fresh ||= resuming && ResumeGate.current(this.resume, msg);
|
|
405
726
|
if (!this.joined && (msg.k === WORLD || (msg.ps ?? []).some((pose) => pose[0] === selfId))) {
|
|
406
727
|
this.joined = true;
|
|
728
|
+
this.starting = false;
|
|
729
|
+
this.joinFailures = 0;
|
|
407
730
|
console.log('[multiplayer] placed by the session');
|
|
731
|
+
this.joinStage('placed');
|
|
408
732
|
}
|
|
409
733
|
for (const id of msg.gone ?? []) {
|
|
410
734
|
this.gone.add(id);
|
|
@@ -454,6 +778,25 @@ class MultiplayerSystem {
|
|
|
454
778
|
this.clampedTo = { x, y, z };
|
|
455
779
|
}
|
|
456
780
|
}
|
|
781
|
+
// A re-entering object starts at its current pose, without sliding from
|
|
782
|
+
// the last pose this client saw before it left the interest set.
|
|
783
|
+
// An entry row under an older epoch than the last handover seen is a
|
|
784
|
+
// new object reusing the id: nothing this client kept about the old one
|
|
785
|
+
// (its handover, or holding it) applies.
|
|
786
|
+
const entryRows = msg.oin?.length ? new Map((msg.os ?? []).map(([id, ...row]) => [id, row])) : null;
|
|
787
|
+
for (const id of msg.oin ?? []) {
|
|
788
|
+
if (entryRows.get(id)?.[7] < this.handed.get(id)?.epoch) {
|
|
789
|
+
this.forgetObject(id);
|
|
790
|
+
this.own.mine.delete(id);
|
|
791
|
+
this.own.asked.delete(id);
|
|
792
|
+
this.own.released.delete(id);
|
|
793
|
+
}
|
|
794
|
+
this.objects.delete(id);
|
|
795
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
796
|
+
Smoothing.forget(this.shown, id);
|
|
797
|
+
this.written.delete(id);
|
|
798
|
+
this.live.delete(id);
|
|
799
|
+
}
|
|
457
800
|
for (const [id, ...row] of msg.os ?? []) {
|
|
458
801
|
this.sampleObject(msg, id, row);
|
|
459
802
|
}
|
|
@@ -465,6 +808,9 @@ class MultiplayerSystem {
|
|
|
465
808
|
// available through the system state.
|
|
466
809
|
game.state?.(scene, msg, this);
|
|
467
810
|
}
|
|
811
|
+
if (fresh) {
|
|
812
|
+
this.resumed();
|
|
813
|
+
}
|
|
468
814
|
this.placeGrants(scene);
|
|
469
815
|
}
|
|
470
816
|
|
|
@@ -558,6 +904,11 @@ class MultiplayerSystem {
|
|
|
558
904
|
|
|
559
905
|
// The Transform follows the body at the next physics step. It is moved
|
|
560
906
|
// now so this frame's reach checks and report read the seed as well.
|
|
907
|
+
// The engine is told first (`touch`): a scene may hold an actor still
|
|
908
|
+
// (physics-3d `"engine": { "staticActors": true }`). Only actors with
|
|
909
|
+
// a dynamic or kinematic Body are objects here (server world.js), and
|
|
910
|
+
// those are never still; the touch costs nothing then.
|
|
911
|
+
scene.touch?.(id);
|
|
561
912
|
Poses.applyPose(transform, seed);
|
|
562
913
|
}
|
|
563
914
|
const [vx, vy, vz, wx, wy, wz] = velocity;
|
|
@@ -594,6 +945,7 @@ class MultiplayerSystem {
|
|
|
594
945
|
// An owned object is simulated here, and is live once it is let go.
|
|
595
946
|
// Writing the older network pose over it would undo a local push.
|
|
596
947
|
if (this.own.mine.has(id)) {
|
|
948
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
597
949
|
if (dynamic) {
|
|
598
950
|
this.live.set(id, Steer.makeState());
|
|
599
951
|
}
|
|
@@ -610,9 +962,13 @@ class MultiplayerSystem {
|
|
|
610
962
|
)
|
|
611
963
|
: null;
|
|
612
964
|
if (network && this.isLive(id, network, body, transform, me)) {
|
|
965
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
613
966
|
Steer.steer(body, network, this.live.get(id), dt, now, world, player);
|
|
614
967
|
} else if (!this.live.has(id)) {
|
|
615
|
-
|
|
968
|
+
scene.touch?.(id);
|
|
969
|
+
this.drawInterpolated(id, track, actor, body, at, dt, scene, now);
|
|
970
|
+
} else if (gaitModel()) {
|
|
971
|
+
this.objectWalkSpeeds?.delete(id);
|
|
616
972
|
}
|
|
617
973
|
}
|
|
618
974
|
}
|
|
@@ -649,7 +1005,7 @@ class MultiplayerSystem {
|
|
|
649
1005
|
// Draw an object from its track at the render time `at`, on both its Transform
|
|
650
1006
|
// and its rapier body. A pose already written, with the body still there, is
|
|
651
1007
|
// not written again, so a body at rest can sleep.
|
|
652
|
-
drawInterpolated(id, track, actor, body, at, dt) {
|
|
1008
|
+
drawInterpolated(id, track, actor, body, at, dt, scene, wall) {
|
|
653
1009
|
const sampled = Interpolate.sampleAt(track, at, Poses.blend);
|
|
654
1010
|
if (!sampled) {
|
|
655
1011
|
return;
|
|
@@ -657,6 +1013,15 @@ class MultiplayerSystem {
|
|
|
657
1013
|
|
|
658
1014
|
// Smooth the sampled target to absorb small steps from uneven delivery.
|
|
659
1015
|
const pose = Smoothing.smooth(this.shown, id, sampled, dt, Poses);
|
|
1016
|
+
if (gaitModel()) {
|
|
1017
|
+
const speed = easeWalkSpeed((this.objectWalkSpeeds ??= new Map()), id, track, at, dt, wall);
|
|
1018
|
+
const node = scene.three?.nodes?.get(actor.id)?.node;
|
|
1019
|
+
if (node) {
|
|
1020
|
+
node.userData.walkSpeedHint = speed;
|
|
1021
|
+
node.userData.walkTimeHint = this.walkTimeHint;
|
|
1022
|
+
node.userData.walkHintAt = wall;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
660
1025
|
const written = this.written.get(id);
|
|
661
1026
|
if (written && Poses.same(written, pose) && bodyAt(body, pose)) {
|
|
662
1027
|
return;
|
|
@@ -673,6 +1038,7 @@ class MultiplayerSystem {
|
|
|
673
1038
|
// Apply each other player's pose, spawning its avatar and name tag when needed.
|
|
674
1039
|
applyPlayerPoses(scene, at, dt) {
|
|
675
1040
|
const others = this.net.others();
|
|
1041
|
+
const wall = gaitModel() ? performance.now() : undefined;
|
|
676
1042
|
for (const [playerId, username] of others) {
|
|
677
1043
|
const track = this.players.get(playerId);
|
|
678
1044
|
const sampled = track && Interpolate.sampleAt(track, at, Poses.blend);
|
|
@@ -687,10 +1053,19 @@ class MultiplayerSystem {
|
|
|
687
1053
|
if (!look) {
|
|
688
1054
|
continue;
|
|
689
1055
|
}
|
|
690
|
-
Avatars.showPlayer(this.avatars, scene, playerId, look.username ?? null, pose, {
|
|
1056
|
+
const actor = Avatars.showPlayer(this.avatars, scene, playerId, look.username ?? null, pose, {
|
|
691
1057
|
blueprint: look.blueprint,
|
|
692
1058
|
userId: this.net.userId(playerId),
|
|
693
1059
|
});
|
|
1060
|
+
if (gaitModel()) {
|
|
1061
|
+
const speed = easeWalkSpeed((this.playerWalkSpeeds ??= new Map()), playerId, track, at, dt, wall);
|
|
1062
|
+
const node = scene.three?.nodes?.get(actor.id)?.node;
|
|
1063
|
+
if (node) {
|
|
1064
|
+
node.userData.walkSpeedHint = speed;
|
|
1065
|
+
node.userData.walkTimeHint = this.walkTimeHint;
|
|
1066
|
+
node.userData.walkHintAt = wall;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
694
1069
|
}
|
|
695
1070
|
Avatars.dropMissing(this.avatars, scene, others);
|
|
696
1071
|
Avatars.animate(this.avatars, scene, dt);
|
|
@@ -720,6 +1095,7 @@ class MultiplayerSystem {
|
|
|
720
1095
|
// Remove history and smoothing state after a player leaves the SDK roster.
|
|
721
1096
|
dropPlayer(playerId) {
|
|
722
1097
|
this.players.delete(playerId);
|
|
1098
|
+
if (gaitModel()) {this.playerWalkSpeeds?.delete(playerId);}
|
|
723
1099
|
Smoothing.forget(this.shown, playerId);
|
|
724
1100
|
}
|
|
725
1101
|
|
|
@@ -782,7 +1158,9 @@ class MultiplayerSystem {
|
|
|
782
1158
|
const objects = game.claimable?.(scene, this) ?? this.claimable(scene);
|
|
783
1159
|
const claims = Ownership.toClaim(
|
|
784
1160
|
this.own,
|
|
785
|
-
|
|
1161
|
+
eligibleClaims(scene.data)
|
|
1162
|
+
? objects.filter(([id]) => scene.getActor(id)?.components.Body?.type === 'dynamic')
|
|
1163
|
+
: objects,
|
|
786
1164
|
me,
|
|
787
1165
|
this.otherPlaces(now),
|
|
788
1166
|
now,
|
|
@@ -929,6 +1307,12 @@ class MultiplayerSystem {
|
|
|
929
1307
|
game.reset?.(scene, this);
|
|
930
1308
|
Avatars.clearAvatars(this.avatars, scene);
|
|
931
1309
|
this.players.clear();
|
|
1310
|
+
if (gaitModel()) {
|
|
1311
|
+
this.playerWalkSpeeds?.clear();
|
|
1312
|
+
this.objectWalkSpeeds?.clear();
|
|
1313
|
+
delete this.walkFrame;
|
|
1314
|
+
delete this.walkTimeHint;
|
|
1315
|
+
}
|
|
932
1316
|
this.objects.clear();
|
|
933
1317
|
this.own = Ownership.makeOwnership();
|
|
934
1318
|
this.granted.clear();
|
|
@@ -954,6 +1338,7 @@ class MultiplayerSystem {
|
|
|
954
1338
|
// starts afresh.
|
|
955
1339
|
forgetObject(id) {
|
|
956
1340
|
this.objects.delete(id);
|
|
1341
|
+
if (gaitModel()) {this.objectWalkSpeeds?.delete(id);}
|
|
957
1342
|
this.live.delete(id);
|
|
958
1343
|
this.written.delete(id);
|
|
959
1344
|
this.handed.delete(id);
|
|
@@ -993,7 +1378,17 @@ class MultiplayerSystem {
|
|
|
993
1378
|
// yet placed. A session that never answers releases it after JOIN_WAIT_MS so
|
|
994
1379
|
// the deck is not stuck behind it.
|
|
995
1380
|
joiningOverlayWanted() {
|
|
996
|
-
if (this.
|
|
1381
|
+
if (this.net?.status().solo || this.joinError || (this.joinFailed && this.target?.mode !== 'hub')) {
|
|
1382
|
+
return false;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
// A player behind the resume gate is covered even when the join was quiet:
|
|
1386
|
+
// the caller covered the join, not the return. So is the frame a returning
|
|
1387
|
+
// snapshot's placement takes the camera to follow.
|
|
1388
|
+
if (this.resume.armed || (this.wasAway && this.joined && (this.placedTo || this.settleFrames > 0))) {
|
|
1389
|
+
return true;
|
|
1390
|
+
}
|
|
1391
|
+
if (this.quiet) {
|
|
997
1392
|
return false;
|
|
998
1393
|
}
|
|
999
1394
|
|
|
@@ -1017,12 +1412,21 @@ class MultiplayerSystem {
|
|
|
1017
1412
|
|
|
1018
1413
|
// Release scene resources and leave the session when the engine runtime ends.
|
|
1019
1414
|
dispose(scene) {
|
|
1415
|
+
this.generation += 1;
|
|
1416
|
+
this.starting = false;
|
|
1417
|
+
this.removeJoinFailure?.();
|
|
1418
|
+
this.removeJoinFailure = null;
|
|
1020
1419
|
game.dispose?.(scene, this);
|
|
1021
1420
|
this.reset(scene);
|
|
1022
1421
|
this.net?.close();
|
|
1023
1422
|
this.net = null;
|
|
1024
1423
|
this.joined = false;
|
|
1025
1424
|
this.joinStartedAt = 0;
|
|
1425
|
+
this.endAway();
|
|
1426
|
+
if (this.onVisibility) {
|
|
1427
|
+
document.removeEventListener('visibilitychange', this.onVisibility);
|
|
1428
|
+
this.onVisibility = null;
|
|
1429
|
+
}
|
|
1026
1430
|
showJoinOverlay(false);
|
|
1027
1431
|
// The badge is a fixed element outside the scene, so a disposed runtime
|
|
1028
1432
|
// (an editor preview closing, say) has to take it down explicitly.
|
|
@@ -1030,6 +1434,11 @@ class MultiplayerSystem {
|
|
|
1030
1434
|
}
|
|
1031
1435
|
}
|
|
1032
1436
|
|
|
1437
|
+
// Whether the page is hidden. False outside a browser.
|
|
1438
|
+
function pageHidden() {
|
|
1439
|
+
return typeof document !== 'undefined' && document.hidden === true;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1033
1442
|
// File one player or object pose under the message's simulation timestamp.
|
|
1034
1443
|
function sample(tracks, msg, id, pose) {
|
|
1035
1444
|
// A WORLD message represents complete current state. Replace an existing track
|