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
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import { showBuildStamp } from '../client/build.js';
|
|
2
|
+
import { landscapeViewport } from '../client/landscapeLayout.js';
|
|
3
|
+
import { loadingCover } from '../client/loadingCover.js';
|
|
4
|
+
import { joinErrorText } from '../client/joinError.js';
|
|
5
|
+
import { kitBackNeeded } from '../client/backVisibility.js';
|
|
6
|
+
import { faceArrivalCamera } from '../client/arrivalCamera.js';
|
|
7
|
+
import { makeDoorErrors } from '../client/doorErrors.js';
|
|
8
|
+
import { makeVisibility } from '../client/visibility.js';
|
|
9
|
+
import { makeInvites } from '../client/invites.js';
|
|
10
|
+
import { makeSignIn } from '../client/signIn.js';
|
|
11
|
+
import { makeWeakestTier, readDistricts } from '../client/weakestTier.js';
|
|
12
|
+
import { makeHudRate } from '../client/hudRate.js';
|
|
13
|
+
import { allActors, capWorldLabels, lowQuality, noteQualityInteraction, qualityFor, qualityPlayers, qualitySpawnIds, restoreDecor } from '../client/quality.js';
|
|
14
|
+
import { makeActorBudget } from '../client/actorBudget.js';
|
|
1
15
|
// The hub system: the door, and everything a place draws that a game cannot.
|
|
2
16
|
// It runs after the engine's behaviors every frame and owns the trip between
|
|
3
17
|
// places -- the door animation, the scene swap and session switch under its
|
|
@@ -8,7 +22,8 @@
|
|
|
8
22
|
// the place's loose objects where it offers that (`client/grab.js`), and idle
|
|
9
23
|
// play -- emotes, seats and the place's sounds -- where it offers that
|
|
10
24
|
// (`client/idle.js`, `client/sound.js`), and, in a deck that asks for it, a
|
|
11
|
-
// cheaper picture on a slow device (`client/tiers.js`)
|
|
25
|
+
// cheaper picture on a slow device (`client/tiers.js`) and the sounds the kit
|
|
26
|
+
// makes itself (`client/soundscape.js`).
|
|
12
27
|
//
|
|
13
28
|
// One engine, one iframe (HUB.md decision 2): going through a door unloads this
|
|
14
29
|
// place's scene, loads the next one's (`scene.requestedScene`), and moves the
|
|
@@ -24,27 +39,58 @@
|
|
|
24
39
|
|
|
25
40
|
import * as castleSdk from 'castle-web-sdk';
|
|
26
41
|
import { attend, fadeNames, makeAttention } from '../client/attention.js';
|
|
42
|
+
import { chromeItem, goalAt, labelBox, near, nearCandidates, nearFor } from '../client/labelsNear.js';
|
|
43
|
+
import { mapWorldPoint, offsetWorldPoint, relevantLabels, worldLabelFocus } from '../client/worldLabels.js';
|
|
44
|
+
import { bodyBox, occupancyText, placeLabels } from '../client/padOccupancy.js';
|
|
45
|
+
import { padCuesEnabled } from '../client/padCues.js';
|
|
46
|
+
import { readPadArrival } from '../client/padCueArrival.js';
|
|
47
|
+
import { makePadReadability } from '../client/padReadability.js';
|
|
48
|
+
import { crowdNamesFor, layoutCrowdNames, readableSpriteBox, spriteBox } from '../client/crowdNames.js';
|
|
27
49
|
import { doorPoint } from '../client/doorFrame.js';
|
|
28
50
|
import * as Avatar from '../client/avatar.js';
|
|
51
|
+
import { pongJoin } from '../client/firstJoin.js';
|
|
52
|
+
import * as Rehello from '../client/rehello.js';
|
|
53
|
+
import * as AvatarCap from '../client/avatarCap.js';
|
|
54
|
+
import * as AvatarShare from '../client/avatarShare.js';
|
|
55
|
+
import { makeFarAvatars } from '../client/farAvatars.js';
|
|
56
|
+
import { makeYours } from '../client/yours.js';
|
|
57
|
+
import { askSlotKey, makeAskSlot, padsAt as askPadsAt } from '../client/askSlot.js';
|
|
29
58
|
import * as Cabinets from '../client/cabinets.js';
|
|
30
59
|
import { CHAT_BUBBLE_MS, makeChat } from '../client/chat.js';
|
|
60
|
+
import { chatModerationEnabled } from '../client/chatModeration.js';
|
|
31
61
|
import { makeChrome } from '../client/chrome.js';
|
|
32
62
|
import * as Packs from '../client/pack.js';
|
|
33
63
|
import * as Hub from '../client/state.js';
|
|
64
|
+
import { clearShot } from '../client/shot.js';
|
|
65
|
+
import { makeAct } from '../client/act.js';
|
|
34
66
|
import { makeGrab } from '../client/grab.js';
|
|
35
67
|
import { makeIdle } from '../client/idle.js';
|
|
68
|
+
import { makeDecor } from '../client/decor.js';
|
|
36
69
|
import { makeSay, REACTIONS } from '../client/say.js';
|
|
70
|
+
import { PLAY_NEAR_M } from '../shared/say.js';
|
|
71
|
+
import { cardFor, forget as forgetBallot, held as ballotHeld, makeBallot } from '../client/ballot.js';
|
|
37
72
|
import { makeSound } from '../client/sound.js';
|
|
73
|
+
import { makeSoundscape } from '../client/soundscape.js';
|
|
74
|
+
import { addSpinner, findSpinners, spinFrame } from '../client/spin.js';
|
|
75
|
+
import { makeStuck, resetStuck, STUCK_EVERY_MS, stuckDone, stuckFrame, stuckText, stuckWhere, walkInput } from '../client/stuck.js';
|
|
38
76
|
import { makeTalk } from '../client/talk.js';
|
|
77
|
+
import { makeInterestCap } from '../client/interestCap.js';
|
|
78
|
+
import { makeFpsTelemetry, fpsTelemetryFor } from '../client/fpsTelemetry.js';
|
|
79
|
+
import { loadTelemetryFor, reportLoadStage } from '../client/loadTelemetry.js';
|
|
80
|
+
import { LOAD_STAGES } from '../shared/loadStages.js';
|
|
39
81
|
import { makeTiers } from '../client/tiers.js';
|
|
40
|
-
import { makeTogether, pointerAt } from '../client/together.js';
|
|
41
|
-
import { makeWear } from '../client/wear.js';
|
|
82
|
+
import { goalPointers, goalText, makeTogether, pointerAt } from '../client/together.js';
|
|
83
|
+
import { makeEarned, makeWear } from '../client/wear.js';
|
|
84
|
+
import { makeCompanion } from '../client/companion.js';
|
|
85
|
+
import { makeDefaultEnvironment } from '../client/defaultEnvironment.js';
|
|
86
|
+
import { activeFallY, holdFallenPlayer } from '../client/fall.js';
|
|
42
87
|
|
|
43
88
|
// The door's three beats, in milliseconds: the door opens and the camera goes
|
|
44
89
|
// through it while the cover comes down; the swap and join happen under the
|
|
45
90
|
// cover; the cover lifts as the camera pulls back from the arrival.
|
|
46
91
|
const OPEN_MS = 650;
|
|
47
92
|
const REVEAL_MS = 700;
|
|
93
|
+
const LEAVING_MS = 2800;
|
|
48
94
|
const LOADING_LIMIT_MS = 15000;
|
|
49
95
|
// How long the cover waits for the place to say where it put this player
|
|
50
96
|
// after the session has placed them, before it lifts anyway.
|
|
@@ -130,7 +176,7 @@ const AWAY_JOIN = { mode: 'hub', handoff: null, away: true };
|
|
|
130
176
|
// Castle refuses a player it has barred from the hub at every door and at the
|
|
131
177
|
// town itself with this code; the kit says so plainly and does not ask again.
|
|
132
178
|
export const HUB_BANNED = 'CAULDRON_HUB_BANNED';
|
|
133
|
-
export
|
|
179
|
+
export { BANNED_TEXT } from '../client/joinError.js';
|
|
134
180
|
|
|
135
181
|
const ease = (t) => t * t * (3 - 2 * t);
|
|
136
182
|
const lerp = (a, b, t) => a + (b - a) * t;
|
|
@@ -186,16 +232,24 @@ class HubSystem {
|
|
|
186
232
|
this.trip = null;
|
|
187
233
|
this.pendingEnd = null;
|
|
188
234
|
this.endSession = null;
|
|
235
|
+
this.endLeaving = null;
|
|
189
236
|
this.helloNet = null;
|
|
190
237
|
this.helloAvatar = null;
|
|
238
|
+
this.signIn = makeSignIn({ api: castleSdk.Hub, signedIn: () => { this.helloNet = null; } });
|
|
191
239
|
this.scenePath = null;
|
|
192
240
|
this.sceneKey = null;
|
|
193
241
|
this.doorBase = new Map();
|
|
194
242
|
this.stash = new Map();
|
|
195
243
|
this.tinted = new Map();
|
|
196
244
|
this.spawnedHere = new Set();
|
|
245
|
+
// Turning displays (v1.55, `client/spin.js`): the scene data last looked
|
|
246
|
+
// through for `HubSpin`, and its turners -- null where nothing turns.
|
|
247
|
+
this.spinData = null;
|
|
248
|
+
this.spin = null;
|
|
197
249
|
this.wear = makeWear();
|
|
250
|
+
this.earned = makeEarned();
|
|
198
251
|
this.toast = { text: '', until: 0 };
|
|
252
|
+
this.leavingToast = null;
|
|
199
253
|
this.stats = statsWanted();
|
|
200
254
|
this.frames = 0;
|
|
201
255
|
this.fpsAt = 0;
|
|
@@ -209,6 +263,8 @@ class HubSystem {
|
|
|
209
263
|
// People list marks them and points the way to them).
|
|
210
264
|
this.friendsAll = null;
|
|
211
265
|
this.friendsAt = -Infinity;
|
|
266
|
+
this.friendsGameAt = -Infinity;
|
|
267
|
+
this.friendsGameWarm = false;
|
|
212
268
|
this.friendsAsking = false;
|
|
213
269
|
this.friendsOff = false;
|
|
214
270
|
// Whether this host runs the hub (it answered Hub.friends), so takes
|
|
@@ -227,6 +283,10 @@ class HubSystem {
|
|
|
227
283
|
this.wentAsk = null;
|
|
228
284
|
// Cues (v1.29): the game this player just came back from, offered again.
|
|
229
285
|
this.againAsk = null;
|
|
286
|
+
// v1.125: every card which reaches the town's shared ask slot gets one
|
|
287
|
+
// client lease from its first display. This survives a reconnect replay;
|
|
288
|
+
// a new place/session clears it below.
|
|
289
|
+
this.askSlot = makeAskSlot();
|
|
230
290
|
this.chat = makeChat();
|
|
231
291
|
this.namesTouched = new WeakMap();
|
|
232
292
|
// Cues (v1.23), all unused in a deck without `hub.cues`: when the host
|
|
@@ -244,54 +304,277 @@ class HubSystem {
|
|
|
244
304
|
this.partySettleUntil = 0;
|
|
245
305
|
this.partyCarryUntil = 0;
|
|
246
306
|
this.partyAccepted = null;
|
|
307
|
+
this.environment = makeDefaultEnvironment();
|
|
247
308
|
}
|
|
248
309
|
|
|
249
|
-
// Other players' names in a town: near ones only, and smaller
|
|
250
|
-
// (`attention.js`). After the multiplayer kit has placed them this frame.
|
|
310
|
+
// Other players' names in a town: near ones only, and smaller; never the
|
|
311
|
+
// player's own in a place (`attention.js`). After the multiplayer kit has placed them this frame.
|
|
251
312
|
fadeNames(scene) {
|
|
313
|
+
const hadCrowd = Object.hasOwn(this, 'crowdNamesHeld') || Object.hasOwn(this, 'crowdFrame') ||
|
|
314
|
+
Object.hasOwn(this, 'crowdHidden') || Object.hasOwn(this, 'crowdNameScales') || Object.hasOwn(this, 'crowdSprites');
|
|
315
|
+
this.restoreCrowdNameScales();
|
|
252
316
|
const place = Hub.hub.place;
|
|
253
317
|
const town = Boolean(place && !place.result && !this.trip);
|
|
254
|
-
|
|
318
|
+
const crowdNames = scene.data?.engine?.hubCrowdNames === true;
|
|
319
|
+
// Keep every sprite E owned hidden when current authorization/geometry is
|
|
320
|
+
// unavailable. In particular the SDK retains the net object and roster
|
|
321
|
+
// while reconnecting, and multiplayer itself may disappear for a frame.
|
|
322
|
+
if (crowdNames && !this.crowdNamesReady(scene)) {
|
|
323
|
+
fadeNames(scene.multiplayer, scene.actorWith('Player')?.components.Transform, town, this.namesTouched, Boolean(place));
|
|
324
|
+
this.invalidateCrowdNames(scene);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// Undo only E's previous-frame suppression before the ordinary name pass
|
|
328
|
+
// establishes this frame's baseline. This also restores game-place names
|
|
329
|
+
// and a live toggle OFF, where attention.js otherwise has no town touch.
|
|
330
|
+
if (this.crowdHidden) {
|
|
331
|
+
for (const sprite of this.crowdHidden) {sprite.visible = true;}
|
|
332
|
+
delete this.crowdHidden;
|
|
333
|
+
}
|
|
334
|
+
fadeNames(scene.multiplayer, scene.actorWith('Player')?.components.Transform, town, this.namesTouched, Boolean(place));
|
|
335
|
+
if (crowdNames) {
|
|
336
|
+
this.layoutCrowdNames(scene, performance.now());
|
|
337
|
+
} else {
|
|
338
|
+
// The baseline pass above restores every sprite E may have suppressed.
|
|
339
|
+
// Dropping the holder also removes visit-local ranks on a live toggle.
|
|
340
|
+
if (Object.hasOwn(this, 'crowdNamesHeld')) {delete this.crowdNamesHeld;}
|
|
341
|
+
if (Object.hasOwn(this, 'crowdFrame')) {delete this.crowdFrame;}
|
|
342
|
+
if (Object.hasOwn(this, 'crowdSprites')) {delete this.crowdSprites;}
|
|
343
|
+
if (hadCrowd) {this.chrome.setCrowdNameSummary?.(null);}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
crowdNamesReady(scene) {
|
|
348
|
+
const frame = this.crowdFrame;
|
|
349
|
+
const net = scene.multiplayer?.net;
|
|
350
|
+
const cam = scene.three?.camera;
|
|
351
|
+
return Boolean(frame && net && cam && frame.scene === scene && frame.data === scene.data && frame.net === net && frame.camera === cam &&
|
|
352
|
+
net?.status?.()?.state === 'connected');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
restoreCrowdNameScales() {
|
|
356
|
+
if (!this.crowdNameScales) {return;}
|
|
357
|
+
for (const [sprite, scale] of this.crowdNameScales) {
|
|
358
|
+
// Multiplayer may already have moved/resized or replaced this sprite.
|
|
359
|
+
// Restore only the exact E write, never a newer renderer decision.
|
|
360
|
+
if (sprite.scale.x === scale.scaledX && sprite.scale.y === scale.scaledY) {
|
|
361
|
+
sprite.scale.x = scale.x;
|
|
362
|
+
sprite.scale.y = scale.y;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
delete this.crowdNameScales;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
layoutCrowdNames(scene, now) {
|
|
369
|
+
const frame = this.crowdFrame;
|
|
370
|
+
const mp = scene.multiplayer;
|
|
371
|
+
const net = mp?.net;
|
|
372
|
+
const cam = scene.three?.camera;
|
|
373
|
+
if (!this.crowdNamesReady(scene)) {
|
|
374
|
+
this.invalidateCrowdNames(scene);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const roster = net.others?.() ?? new Map();
|
|
378
|
+
const friendIds = this.friendsAll === null ? null : new Set(this.friendsAll.map((friend) => String(friend.userId)));
|
|
379
|
+
const candidates = [];
|
|
380
|
+
const sprites = new Map();
|
|
381
|
+
const hidden = new Set();
|
|
382
|
+
const allSprites = new Set();
|
|
383
|
+
const tiny = frame.view.w <= 509 && frame.view.h <= 218;
|
|
384
|
+
for (const [playerId, tag] of mp.avatars?.tags ?? []) {
|
|
385
|
+
if (playerId === 'self') {continue;}
|
|
386
|
+
const sprite = tag?.sprite;
|
|
387
|
+
if (sprite) {allSprites.add(sprite);}
|
|
388
|
+
// A tag can survive one renderer frame after a roster/hook revocation.
|
|
389
|
+
// E intersects it with the current authorized roster before it can be
|
|
390
|
+
// named or counted.
|
|
391
|
+
if (!sprite || !roster.has(playerId) || roster.get(playerId) === null || AvatarCap.shown(playerId) === null) {
|
|
392
|
+
if (sprite) {
|
|
393
|
+
sprite.visible = false;
|
|
394
|
+
hidden.add(sprite);
|
|
395
|
+
}
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (!sprite.visible || !(sprite.material?.opacity > 0)) {continue;}
|
|
399
|
+
const actorId = mp.avatars?.actors?.get(playerId);
|
|
400
|
+
const at = actorId ? scene.getActor(actorId)?.components.Transform : null;
|
|
401
|
+
if (!at) {
|
|
402
|
+
sprite.visible = false;
|
|
403
|
+
hidden.add(sprite);
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
const userId = net.userId?.(playerId);
|
|
407
|
+
const geometry = tiny
|
|
408
|
+
? { box: spriteBox(sprite, cam, frame.view, project), resized: null }
|
|
409
|
+
: readableSpriteBox(sprite, cam, frame.view, project);
|
|
410
|
+
if (geometry.resized) {
|
|
411
|
+
(this.crowdNameScales ??= new Map()).set(sprite, geometry.resized);
|
|
412
|
+
}
|
|
413
|
+
candidates.push({
|
|
414
|
+
id: String(playerId),
|
|
415
|
+
friend: Boolean(friendIds && userId && friendIds.has(String(userId))),
|
|
416
|
+
distance: frame.local ? Math.hypot(at.x - frame.local.x, at.z - frame.local.z) : Infinity,
|
|
417
|
+
at,
|
|
418
|
+
box: geometry.box,
|
|
419
|
+
});
|
|
420
|
+
sprites.set(String(playerId), sprite);
|
|
421
|
+
}
|
|
422
|
+
const state = crowdNamesFor((this.crowdNamesHeld ??= {}), {
|
|
423
|
+
scene: sceneKeyOf(scene),
|
|
424
|
+
data: scene.data,
|
|
425
|
+
net,
|
|
426
|
+
place: Hub.hub.place,
|
|
427
|
+
visit: `${this.helloMark?.selfId ?? ''}:${this.helloMark?.again ?? ''}`,
|
|
428
|
+
});
|
|
429
|
+
const labelBoxes = this.chrome.crowdNameLabelBoxes?.() ?? [];
|
|
430
|
+
const obstacles = [...frame.controls, ...(frame.own ? [frame.own] : []), ...labelBoxes];
|
|
431
|
+
const result = layoutCrowdNames(state, candidates, { now, view: frame.view, obstacles });
|
|
432
|
+
for (const [playerId, sprite] of sprites) {
|
|
433
|
+
sprite.visible = result.visible.has(playerId);
|
|
434
|
+
if (!sprite.visible) {hidden.add(sprite);}
|
|
435
|
+
}
|
|
436
|
+
if (hidden.size) {this.crowdHidden = hidden;}
|
|
437
|
+
this.crowdSprites = allSprites;
|
|
438
|
+
let summary = [];
|
|
439
|
+
if (result.summary && this.chrome.measureLabel) {
|
|
440
|
+
const text = result.summary.tiny ? `${result.summary.count} people nearby` : `+${result.summary.count} more`;
|
|
441
|
+
const size = this.chrome.measureLabel(text, false, false, false);
|
|
442
|
+
const item = {
|
|
443
|
+
id: 'crowd:summary',
|
|
444
|
+
text,
|
|
445
|
+
x: result.summary.x,
|
|
446
|
+
y: result.summary.y,
|
|
447
|
+
box: {
|
|
448
|
+
left: result.summary.x - size.w / 2,
|
|
449
|
+
right: result.summary.x + size.w / 2,
|
|
450
|
+
top: result.summary.y - size.h,
|
|
451
|
+
bottom: result.summary.y,
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
const selected = candidates.filter((candidate) => result.visible.has(candidate.id) && candidate.box).map((candidate) => candidate.box);
|
|
455
|
+
summary = placeLabels([item], frame.own, [...frame.controls, ...labelBoxes, ...selected], frame.view, (...args) => this.chrome.measureLabel(...args));
|
|
456
|
+
}
|
|
457
|
+
// Ordinary labels have already completed HUD clearance. Updating only
|
|
458
|
+
// E's summary preserves those final DOM positions for this paint.
|
|
459
|
+
this.chrome.setCrowdNameSummary?.(summary[0] ?? null);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
invalidateCrowdNames(scene) {
|
|
463
|
+
// Without current geometry and authorization E cannot associate a name
|
|
464
|
+
// or count with an avatar. Remove all visit-local decisions and finish
|
|
465
|
+
// this paint with every current nonself tag hidden. Recovery begins from
|
|
466
|
+
// a new state once all prerequisites belong to this scene again.
|
|
467
|
+
if (Object.hasOwn(this, 'crowdNamesHeld')) {delete this.crowdNamesHeld;}
|
|
468
|
+
if (Object.hasOwn(this, 'crowdFrame')) {delete this.crowdFrame;}
|
|
469
|
+
this.chrome.setCrowdNameSummary?.(null);
|
|
470
|
+
let hidden = this.crowdHidden ?? null;
|
|
471
|
+
for (const sprite of this.crowdSprites ?? []) {
|
|
472
|
+
sprite.visible = false;
|
|
473
|
+
(hidden ??= new Set()).add(sprite);
|
|
474
|
+
}
|
|
475
|
+
for (const [playerId, tag] of scene.multiplayer?.avatars?.tags ?? []) {
|
|
476
|
+
const sprite = tag?.sprite;
|
|
477
|
+
if (playerId !== 'self' && sprite) {
|
|
478
|
+
sprite.visible = false;
|
|
479
|
+
(hidden ??= new Set()).add(sprite);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (hidden) {this.crowdHidden = hidden;}
|
|
483
|
+
if (Object.hasOwn(this, 'crowdSprites')) {delete this.crowdSprites;}
|
|
255
484
|
}
|
|
256
485
|
|
|
257
|
-
afterBehaviors(scene) {
|
|
486
|
+
afterBehaviors(scene, dt) {
|
|
487
|
+
// Snapshot layout before any of this frame's chrome setters write DOM.
|
|
488
|
+
const canvas = scene.three?.renderer?.domElement;
|
|
489
|
+
this.frameCanvas = this.chrome?.beginLayoutFrame?.(canvas) ?? canvas?.getBoundingClientRect?.();
|
|
490
|
+
this.act?.beginLayoutFrame?.();
|
|
491
|
+
// Late hub systems (crowd names, sound replies) still read the snapshot,
|
|
492
|
+
// so it ends once this synchronous frame has returned, not at a system.
|
|
493
|
+
if (!this.layoutEndQueued) {
|
|
494
|
+
this.layoutEndQueued = true;
|
|
495
|
+
queueMicrotask(() => {
|
|
496
|
+
this.layoutEndQueued = false;
|
|
497
|
+
this.endLayoutFrame();
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
loadingCover?.sync(scene);
|
|
258
501
|
const mp = scene.multiplayer;
|
|
259
502
|
if (!mp) {
|
|
503
|
+
this.endLayoutFrame();
|
|
260
504
|
return;
|
|
261
505
|
}
|
|
262
506
|
const now = performance.now();
|
|
263
|
-
this.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
507
|
+
if (Hub.hub.place?.result || this.doorErrors) {
|
|
508
|
+
this.doorErrors ??= makeDoorErrors();
|
|
509
|
+
this.doorErrors.sync(mp.net, Boolean(Hub.hub.place?.result) && !this.trip, now);
|
|
510
|
+
}
|
|
511
|
+
if (!this.chrome) {
|
|
512
|
+
this.chrome = makeChrome({
|
|
513
|
+
worldLabelsDefault: !Hub.deck.labels,
|
|
514
|
+
...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
|
|
515
|
+
onBack: () => this.backFromControl(scene),
|
|
516
|
+
onAvatar: (i) => Avatar.choose(scene, i),
|
|
517
|
+
onColor: (color) => Avatar.chooseColor(scene, color),
|
|
518
|
+
avatarCount: Avatar.AVATARS,
|
|
519
|
+
onPerson: (person, action) => this.join(this.scene, person, action),
|
|
520
|
+
onJumpDoor: (door) => this.goDoor(this.scene, door),
|
|
521
|
+
// A heart on the ask card is one of that card's actions, bound by its
|
|
522
|
+
// lease; a Doors list heart is not.
|
|
523
|
+
onHeart: (door, ask) => ask ? this.heartAsk(this.scene, ask, door) : this.yours?.toggle(door),
|
|
524
|
+
onAsk: (ask, yes) => this.answer(this.scene, ask, yes, true),
|
|
525
|
+
onLeaveParty: () => this.scene?.multiplayer?.net?.send({ k: 'hub-party', op: 'leave' }),
|
|
526
|
+
onReportChat: (line) => this.reportChat(line),
|
|
527
|
+
onBlockChat: (line) => this.blockChat(line),
|
|
528
|
+
onReport: (person) => this.report(person),
|
|
529
|
+
...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
|
|
530
|
+
});
|
|
531
|
+
// Initial chrome sources are new this frame; subsequent frames read
|
|
532
|
+
// them at the start above. The canvas already has its start-of-frame read.
|
|
533
|
+
this.chrome.beginLayoutFrame?.();
|
|
534
|
+
}
|
|
535
|
+
this.chrome.setWorldLabelFocus?.(worldLabelFocus(Hub.deck.labels, Boolean(Hub.hub.place?.result), scene.persistent.hubDepth > 0 || Boolean(scene.persistent.hubTickets?.length)));
|
|
536
|
+
this.chrome.beginWorldLabels?.();
|
|
537
|
+
// Shift lock belongs to the engine, including in places without Chirp.
|
|
538
|
+
this.chrome.layoutCompanion(scene.three?.renderer?.domElement?.parentElement);
|
|
539
|
+
const lock = scene.three?.renderer?.domElement?.parentElement?.querySelector?.('button[aria-label^="Shift lock"]');
|
|
540
|
+
this.chrome.safeSurface?.('engine-shift-lock', lock, 'control');
|
|
541
|
+
for (const name of ['score', 'look']) {
|
|
542
|
+
const node = scene.three?.renderer?.domElement?.parentElement?.querySelector?.(`[data-engine-hud="${name}"]`);
|
|
543
|
+
this.chrome.safeSurface?.(`engine-${name}`, node, 'text');
|
|
544
|
+
}
|
|
545
|
+
this.chrome.safeSurface?.('invite-dialog', this.invites?.surface?.());
|
|
274
546
|
Avatar.load(scene);
|
|
275
547
|
this.talk ??= makeTalk(this.chrome);
|
|
276
548
|
this.grab ??= makeGrab(this.chrome);
|
|
277
549
|
this.idle ??= makeIdle(this.chrome);
|
|
278
550
|
this.sound ??= makeSound();
|
|
551
|
+
if (Hub.deck.soundscape && !this.soundscape) {
|
|
552
|
+
this.hearPlace();
|
|
553
|
+
}
|
|
279
554
|
if (!this.sayHooked) {
|
|
280
555
|
this.sayHooked = true;
|
|
281
556
|
this.chrome.onSay?.((what) => this.saying(what));
|
|
282
557
|
}
|
|
283
558
|
this.scene = scene;
|
|
559
|
+
// The last place a manifest named: a Back after a close cleared it
|
|
560
|
+
// (`watchSession`) still knows whether it was leaving a game.
|
|
561
|
+
if (Hub.hub.place) {
|
|
562
|
+
this.knownPlace = Hub.hub.place;
|
|
563
|
+
}
|
|
284
564
|
// The host's Back control (a host that draws one, over a hub place) is
|
|
285
565
|
// answered the way the kit's own is: back through the door (contract §5).
|
|
286
566
|
if (!this.backHooked && typeof castleSdk.Hub?.onBack === 'function') {
|
|
287
567
|
this.backHooked = true;
|
|
288
|
-
castleSdk.Hub.onBack(() => this.
|
|
568
|
+
castleSdk.Hub.onBack(() => this.backFromControl(this.scene));
|
|
289
569
|
}
|
|
290
570
|
const per = (scene.persistent ??= {});
|
|
291
571
|
per.hubTickets ??= [];
|
|
292
572
|
this.keepResident(scene, per.hubTickets);
|
|
293
573
|
// A handle for test drivers and phone measurements.
|
|
294
|
-
|
|
574
|
+
const serverBuild = Hub.deck.build ? mp?.net?.serverBuild ?? null : null;
|
|
575
|
+
globalThis.__hub = { scene, system: this, state: Hub.hub, ...(Hub.deck.build ? { build: Hub.deck.build, serverBuild } : {}) };
|
|
576
|
+
showBuildStamp(Hub.deck.build ? { ...Hub.deck.build, server: serverBuild } : null);
|
|
577
|
+
Object.defineProperty(globalThis.__hub, 'avatarPlatform', { enumerable: true, get: Avatar.diagnostics });
|
|
295
578
|
globalThis.__hubPacks ??= () => Packs.cachedPacks().length;
|
|
296
579
|
|
|
297
580
|
if (sceneKeyOf(scene) !== this.sceneKey) {
|
|
@@ -302,8 +585,19 @@ class HubSystem {
|
|
|
302
585
|
this.applyTune(local);
|
|
303
586
|
this.watchSession(scene, mp);
|
|
304
587
|
this.sayHello(scene, mp);
|
|
588
|
+
if (Hub.hub.place?.push?.version === 1 && Hub.hub.arrivedFacing !== null && mp.net) {
|
|
589
|
+
this.pushVisit = reportPushVisit(mp.net, Hub.hub.place, Rehello.mark(mp, mp.net), this.pushVisit);
|
|
590
|
+
}
|
|
591
|
+
if (Hub.hub.place?.visibility === true || this.visibility) {
|
|
592
|
+
this.visibility ??= makeVisibility();
|
|
593
|
+
this.visibility.sync(mp.net, this.sceneKey, Hub.hub.place?.visibility === true && !this.trip);
|
|
594
|
+
}
|
|
595
|
+
const held = Hub.hub.held.has(mp.net?.selfId?.());
|
|
596
|
+
const fallY = activeFallY(Hub.hub.place?.fallY, held, Boolean(this.trip));
|
|
305
597
|
this.followPlace(scene);
|
|
306
|
-
this.holdFall(scene, local);
|
|
598
|
+
this.holdFall(scene, local, fallY);
|
|
599
|
+
this.environment.frame(scene, local, fallY, dt, Hub.deck.defaultEnvironment);
|
|
600
|
+
this.turnSpinners(scene, dt);
|
|
307
601
|
this.applySpawns(scene);
|
|
308
602
|
this.applyTints(scene);
|
|
309
603
|
// Visibility is applied once more after every other system: the
|
|
@@ -313,40 +607,231 @@ class HubSystem {
|
|
|
313
607
|
this.lateFor = scene;
|
|
314
608
|
this.registerLate(scene);
|
|
315
609
|
}
|
|
610
|
+
this.registerInterest(scene);
|
|
316
611
|
this.applyVisibility(scene);
|
|
317
|
-
this.applyWear(scene);
|
|
612
|
+
this.applyWear(scene, Hub.deck.weakestTier === true && this.weakestTier?.active && this.weakestTier.profile === 'weakest' ? local : undefined);
|
|
613
|
+
// Different characters draw from shared materials (`avatarShare.js`).
|
|
614
|
+
AvatarShare.share(scene, [local?.id, ...(mp?.avatars?.actors?.values() ?? [])]);
|
|
318
615
|
this.adoptLate(scene);
|
|
616
|
+
if (Hub.hub.place?.invite === true) {
|
|
617
|
+
this.invites ??= makeInvites(castleSdk.Hub, () => {},
|
|
618
|
+
(door) => { if (!this.trip && this.scene) {this.goHub(this.scene, { door, title: "Your friend's house" });} },
|
|
619
|
+
undefined, (text) => {this.toast = { text, until: performance.now() + TOAST_MS };}, () => Hub.deck.title,
|
|
620
|
+
(node) => this.chrome?.safeSurface?.('invite-dialog', node));
|
|
621
|
+
if (!this.trip) {this.invites.frame(mp.net);}
|
|
622
|
+
} else if (Hub.hub.place && this.invites) { this.invites.dispose(); this.invites = null; }
|
|
319
623
|
this.runCommands(scene, now);
|
|
320
624
|
this.askFriends(scene, mp, now);
|
|
321
625
|
this.together.frame(mp, this.friendsAll, !this.trip && this.pendingEnd === null, now, this.chrome.peopleOpen?.() === true);
|
|
322
626
|
|
|
627
|
+
if (!Hub.hub.place?.decor && this.decor) {
|
|
628
|
+
this.decor.dispose();
|
|
629
|
+
this.decor = null;
|
|
630
|
+
}
|
|
631
|
+
if (Hub.hub.place?.decor && !this.decor) {
|
|
632
|
+
this.decor = makeDecor(this.chrome);
|
|
633
|
+
}
|
|
634
|
+
this.decor?.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && this.chrome.pickerSheetOpen?.() !== true);
|
|
635
|
+
const decorating = this.decor?.opened() === true;
|
|
323
636
|
this.stepEnd(scene, mp, now);
|
|
324
|
-
|
|
637
|
+
// v1.68, rule B (`client/ballot.js`): the choice card runs only while
|
|
638
|
+
// its one gate holds a card (`ballotHeld`), which a place without
|
|
639
|
+
// `ballot` never does; when it lets go (another connection), the sheet
|
|
640
|
+
// goes, once. While a card is up it holds the bottom of the screen, and
|
|
641
|
+
// what it would cover (emotes, Sit, Say, the dock, the feed) waits.
|
|
642
|
+
// `cardFor` lets go of a card of another connection, so the gate is read
|
|
643
|
+
// again after it, before anything is made or drawn.
|
|
644
|
+
const card = ballotHeld ? cardFor(mp.net ?? null) : null;
|
|
645
|
+
if (ballotHeld) {
|
|
646
|
+
// A chip tap sounds as the chrome's do, only with UI cues.
|
|
647
|
+
this.ballot ??= makeBallot({
|
|
648
|
+
...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
|
|
649
|
+
send: (ids) => this.scene?.multiplayer?.net?.send({ k: 'hub-ballot', ...ids }),
|
|
650
|
+
...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
|
|
651
|
+
});
|
|
652
|
+
this.carded = card !== null && !this.trip;
|
|
653
|
+
} else if (this.ballot) {
|
|
654
|
+
this.ballot.dispose();
|
|
655
|
+
this.ballot = null;
|
|
656
|
+
this.carded = false;
|
|
657
|
+
}
|
|
658
|
+
// Resolve incoming conversations before a pending prompt can take focus.
|
|
659
|
+
// An already-open prompt yields as a cancel, before NPC chrome opens.
|
|
660
|
+
// NPC events belong to this client only, even for a shared body.
|
|
661
|
+
if (Hub.hub.place?.ask === true && this.askInput &&
|
|
662
|
+
(card !== null || this.talk.talking() || Hub.hub.npcEvents.some((msg) => msg.k === 'hub-npc' && msg.open))) {
|
|
663
|
+
this.chrome.cancelTextAsk();
|
|
664
|
+
}
|
|
665
|
+
if (this.menuInput && (card !== null || this.talk.talking() ||
|
|
666
|
+
(Hub.hub.place?.ask === true && this.chrome.textAskPending(Hub.hub.ask)) ||
|
|
667
|
+
Hub.hub.npcEvents.some((msg) => msg.k === 'hub-npc' && msg.open))) {
|
|
668
|
+
this.chrome.cancelMenu();
|
|
669
|
+
}
|
|
670
|
+
if (this.actionInput && (card !== null || this.talk.talking() || decorating || this.trip || this.pendingEnd !== null ||
|
|
671
|
+
(Hub.hub.place?.ask === true && this.chrome.textAskPending(Hub.hub.ask)) ||
|
|
672
|
+
(Hub.hub.place?.menu === true && Hub.hub.menu?.spec) ||
|
|
673
|
+
Hub.hub.npcEvents.some((msg) => msg.k === 'hub-npc' && msg.open))) {
|
|
674
|
+
this.chrome.cancelActionOverflow();
|
|
675
|
+
}
|
|
325
676
|
this.talk.frame(scene, mp, !this.trip && this.pendingEnd === null);
|
|
677
|
+
if (Hub.hub.place?.ask === true) {
|
|
678
|
+
this.askDrawn = true;
|
|
679
|
+
Hub.hub.askClose ??= () => this.clearTextAsk();
|
|
680
|
+
const canAsk = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking();
|
|
681
|
+
this.chrome.setTextAsk(canAsk ? Hub.hub.ask : null,
|
|
682
|
+
(id, n, text) => mp.net?.send({ k: 'hub-answer', id, n, text }),
|
|
683
|
+
(open) => {
|
|
684
|
+
if (open) {
|
|
685
|
+
this.askInput = holdAskInput(scene);
|
|
686
|
+
} else if (this.askInput) {
|
|
687
|
+
this.askInput.release();
|
|
688
|
+
delete this.askInput;
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
} else if (this.askDrawn) {
|
|
692
|
+
this.clearTextAsk();
|
|
693
|
+
}
|
|
694
|
+
if (Hub.hub.place?.menu === true) {
|
|
695
|
+
this.menuDrawn = true;
|
|
696
|
+
Hub.hub.menuClose ??= () => this.clearMenu();
|
|
697
|
+
const canMenu = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking() && !this.askInput;
|
|
698
|
+
this.chrome.setMenu(canMenu ? Hub.hub.menu : null,
|
|
699
|
+
(id, n) => mp.net?.send({ k: 'hub-menu-pick', id, n }),
|
|
700
|
+
(open) => {
|
|
701
|
+
if (open) {
|
|
702
|
+
this.menuInput = holdAskInput(scene);
|
|
703
|
+
} else if (this.menuInput) {
|
|
704
|
+
this.menuInput.release();
|
|
705
|
+
delete this.menuInput;
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
} else if (this.menuDrawn) {
|
|
709
|
+
this.clearMenu();
|
|
710
|
+
}
|
|
711
|
+
if (Hub.hub.menu?.spec?.face !== undefined && !held &&
|
|
712
|
+
!Object.hasOwn(Hub.hub.seated, mp.net?.selfId?.()) && scene.cameraControl === 'orbit') {
|
|
713
|
+
const face = this.chrome.menuFace();
|
|
714
|
+
if (Number.isFinite(face) && local?.components.Transform) {
|
|
715
|
+
// Player keeps radians; normal move reports pack the visible yaw from degrees.
|
|
716
|
+
local.runtime.facing = face * Math.PI / 180;
|
|
717
|
+
local.components.Transform.rotationY = face;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
326
720
|
// Idle play (v1.6): before input is locked, since a sitter's move is
|
|
327
721
|
// what gets them up (a seat is a hold).
|
|
328
|
-
this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking(), this.sceneKey);
|
|
722
|
+
this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.actionInput, this.sceneKey);
|
|
329
723
|
this.idle.draw(scene, local);
|
|
330
|
-
|
|
331
|
-
|
|
724
|
+
// The soundscape, only in a deck with `hub.soundscape`: its sound control
|
|
725
|
+
// also says how loud the place's own files play. Without the key the
|
|
726
|
+
// place's sounds are asked for exactly as they always were.
|
|
727
|
+
if (Hub.deck.soundscape) {
|
|
728
|
+
this.chrome.soundControl?.(!this.trip, this.soundscape.settings(), this.soundHandlers);
|
|
729
|
+
} else {
|
|
730
|
+
this.sound.frame(scene, local, !this.trip);
|
|
731
|
+
}
|
|
732
|
+
if (this.trip || held || this.talk.typing() || this.chrome.chatFocused?.() || decorating || this.askInput || this.menuInput || this.actionInput) {
|
|
332
733
|
lockInput(scene);
|
|
333
734
|
// Under the engine's orbit camera key the player's drags and wheel do
|
|
334
735
|
// not move the trip's camera, nor queue up for after it.
|
|
335
|
-
if (this.trip && scene.cameraControl === 'orbit') {
|
|
736
|
+
if ((this.trip || decorating || this.askInput || this.menuInput || this.actionInput) && scene.cameraControl === 'orbit') {
|
|
336
737
|
scene.lookInput?.lock?.();
|
|
337
738
|
}
|
|
338
739
|
}
|
|
339
740
|
// Grabbing and throwing (v1.3), in a place that offers it: after this
|
|
340
741
|
// frame's physics step, before the multiplayer kit reports what it owns.
|
|
341
|
-
this.grab.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking()
|
|
742
|
+
this.grab.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput,
|
|
743
|
+
Hub.deck.act === true && Boolean(this.actionInput) && !this.trip && this.pendingEnd === null);
|
|
744
|
+
if (Hub.deck.act === true) {
|
|
745
|
+
this.act ??= makeAct(this.chrome, this.grab, this.talk);
|
|
746
|
+
this.act.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput && !this.askInput && !this.menuInput && !this.carded);
|
|
747
|
+
}
|
|
342
748
|
if (this.trip) {
|
|
343
749
|
this.stepTrip(scene, mp, local, now);
|
|
344
750
|
} else if (!Hub.hub.faced) {
|
|
345
751
|
// A join that was not a trip (the first one) faces the arrival too.
|
|
346
752
|
this.faceArrival(scene);
|
|
347
753
|
}
|
|
754
|
+
if (Hub.hub.place?.companion === true) {
|
|
755
|
+
this.companion ??= makeCompanion({ idle: Hub.deck.companionIdle === true });
|
|
756
|
+
const cam = scene.three?.camera;
|
|
757
|
+
const view = { w: window.innerWidth, h: window.innerHeight };
|
|
758
|
+
const framing = cam ? {
|
|
759
|
+
camera: { position: cam.position, forward: cam.getWorldDirection(cam.position.clone()) },
|
|
760
|
+
panel: this.chrome.talkRect?.(), view,
|
|
761
|
+
project: (at) => project(cam, at.x, at.y, at.z, view),
|
|
762
|
+
} : null;
|
|
763
|
+
const chat = Hub.hub.place?.companionChat && this.talk.talkingToCompanion?.() ? framing ?? {} : null;
|
|
764
|
+
const activity = { ...framing, chatting: this.talk.talking() };
|
|
765
|
+
const busy = Boolean(this.talk.talkingWith()?.startsWith('companion:') || now < (this.companionTappedUntil ?? -Infinity));
|
|
766
|
+
this.companion.frame(scene, local, Hub.hub, dt, now, !this.trip && this.pendingEnd === null, chat, busy, activity);
|
|
767
|
+
} else if (this.companion) {
|
|
768
|
+
this.companion.dispose();
|
|
769
|
+
delete this.companion;
|
|
770
|
+
delete this.companionTappedUntil;
|
|
771
|
+
}
|
|
348
772
|
this.drawChrome(scene, local, now);
|
|
773
|
+
if (Hub.hub.place?.actions === true || Hub.hub.place?.anonymousEntry === true) {
|
|
774
|
+
this.actionsDrawn = true;
|
|
775
|
+
const hud = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
776
|
+
const items = this.signIn.items(Hub.hub.place, hud, Hub.hub.actions?.items ?? null);
|
|
777
|
+
this.chrome.setActions(items, (id, n) => {
|
|
778
|
+
if (id === 'signin' && Hub.hub.place?.anonymousEntry === true) {void this.signIn.press(hud?.text ?? 'Keep your progress');}
|
|
779
|
+
else {mp.net?.send({ k: 'hub-action', id, n });}
|
|
780
|
+
}, !this.signIn.pending() && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput,
|
|
781
|
+
Hub.hub.actions?.n, scene.data?.engine?.hubActionOverflow === true || !landscapeViewport(), (open) => {
|
|
782
|
+
if (open) {
|
|
783
|
+
this.actionInput = holdAskInput(scene);
|
|
784
|
+
} else if (this.actionInput) {
|
|
785
|
+
this.actionInput.release();
|
|
786
|
+
delete this.actionInput;
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
} else if (this.actionsDrawn) {
|
|
790
|
+
this.chrome.clearActions();
|
|
791
|
+
delete this.actionsDrawn;
|
|
792
|
+
}
|
|
793
|
+
// v1.68: the choice card, only where it was made above.
|
|
794
|
+
if (this.ballot) {
|
|
795
|
+
const box = this.carded ? this.chrome.hudClearBox?.() : null;
|
|
796
|
+
this.ballot.frame(this.carded ? cardFor(mp.net ?? null) : null, Hub.hub.place?.ballot?.lines ?? [], mp.net?.selfId?.() ?? null, Hub.simNow(), box ? box.bottom : 0);
|
|
797
|
+
}
|
|
798
|
+
this.chrome.safeSurface?.('ballot', this.ballot?.surface?.());
|
|
799
|
+
this.chrome.flushWorldLabels?.();
|
|
800
|
+
this.reportLoad(mp);
|
|
349
801
|
this.measure(scene, mp, now);
|
|
802
|
+
if (this.lateFor !== scene) {this.endLayoutFrame();}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// v1.138: an opted-in town hears once per transport that this browser's body
|
|
806
|
+
// is placed while it still waits for hub-arrived (shared/loadStages.js).
|
|
807
|
+
reportLoad(mp) {
|
|
808
|
+
const net = mp?.net;
|
|
809
|
+
if (loadTelemetryFor(net) && Hub.hub.arrivedFacing === null && mp.placed?.()) {reportLoadStage(net, LOAD_STAGES.placed);}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
endLayoutFrame() {
|
|
813
|
+
this.chrome?.endLayoutFrame?.();
|
|
814
|
+
this.act?.endLayoutFrame?.();
|
|
815
|
+
this.frameCanvas = null;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// The soundscape (`client/soundscape.js`), only in a deck whose castle.json
|
|
819
|
+
// asks (`hub.soundscape`): without it this is never called, and no context,
|
|
820
|
+
// listener, storage read or chrome of it is made. Made with the chrome, and
|
|
821
|
+
// put away with it (`dispose`): an NPC's line in the talk panel is heard as
|
|
822
|
+
// the panel is given it, by this player alone.
|
|
823
|
+
hearPlace() {
|
|
824
|
+
const soundscape = makeSoundscape(Hub.deck.soundscape, { onHide: () => this.sound?.hush(), isOn: () => !this.trip, loudestLoop: () => this.sound?.loudestLoop() ?? 0 });
|
|
825
|
+
this.soundscape = soundscape;
|
|
826
|
+
this.sound?.filterEvents?.(soundscape.live);
|
|
827
|
+
this.soundHandlers = { onVolume: (volume) => soundscape.setVolume(volume), onMuted: (muted) => soundscape.setMuted(muted) };
|
|
828
|
+
const talkLine = this.chrome.talkLine;
|
|
829
|
+
this.chrome.talkLine = (who, text, note) => {
|
|
830
|
+
talkLine(who, text, note);
|
|
831
|
+
if (who === 'them') {
|
|
832
|
+
soundscape.say(this.scene, this.talk?.talkingWith() ?? null, text, performance.now());
|
|
833
|
+
}
|
|
834
|
+
};
|
|
350
835
|
}
|
|
351
836
|
|
|
352
837
|
// Device tiers (`client/tiers.js`), only in a deck whose castle.json asks
|
|
@@ -360,20 +845,88 @@ class HubSystem {
|
|
|
360
845
|
return;
|
|
361
846
|
}
|
|
362
847
|
if (!this.tiers) {
|
|
363
|
-
this.tiers = makeTiers(
|
|
848
|
+
this.tiers = qualityFor(scene)?.tiers ?? makeTiers({ weakest: Hub.deck.weakestTier === true,
|
|
849
|
+
onLayout: (node) => this.chrome?.safeSurface?.('cells-debug', node, 'text') });
|
|
364
850
|
const pick = (mode) => {
|
|
365
851
|
this.tiers.set(mode);
|
|
366
|
-
this.chrome?.setGraphics?.(this.tiers.mode, pick);
|
|
852
|
+
this.chrome?.setGraphics?.(this.tiers.mode, pick, Hub.deck.weakestTier === true);
|
|
367
853
|
};
|
|
368
|
-
this.chrome?.setGraphics?.(this.tiers.mode, pick);
|
|
854
|
+
this.chrome?.setGraphics?.(this.tiers.mode, pick, Hub.deck.weakestTier === true);
|
|
369
855
|
}
|
|
370
856
|
const counts = !this.trip && this.pendingEnd === null && mp?.placed?.() === true;
|
|
371
857
|
this.tiers.frame(scene, counts, now);
|
|
858
|
+
const profile = Hub.deck.weakestTier === true
|
|
859
|
+
? (this.tiers.weakest() ? 'weakest' : this.tiers.middle?.() ? 'middle' : null)
|
|
860
|
+
: null;
|
|
861
|
+
if (profile && (this.weakestTier || readDistricts(scene.data?.weakestDistricts))) {
|
|
862
|
+
if (this.weakestTier && this.weakestTier.profile !== profile) {
|
|
863
|
+
this.weakestTier.restore();
|
|
864
|
+
this.weakestTier = null;
|
|
865
|
+
}
|
|
866
|
+
this.weakestTier ??= makeWeakestTier({ profile });
|
|
867
|
+
// Weakest protects only this player's guidance targets; Middle protects
|
|
868
|
+
// shared labels too. Sleeping targets remain available through getActor.
|
|
869
|
+
const pointerTargets = new Set([
|
|
870
|
+
...(profile === 'middle' ? Object.keys(Hub.hub.labels ?? {}) : []),
|
|
871
|
+
...Object.keys(Hub.hub.labelsMe ?? {}),
|
|
872
|
+
]);
|
|
873
|
+
this.weakestTier.frame(scene, true, now, Hub.deck.weakestLookBake === true, pointerTargets);
|
|
874
|
+
} else if (this.weakestTier?.active) {
|
|
875
|
+
this.weakestTier.restore();
|
|
876
|
+
}
|
|
877
|
+
const weakestActive = this.weakestTier?.active && this.weakestTier.profile === 'weakest';
|
|
878
|
+
if ((Hub.deck.mergeFarAvatars === true || weakestActive) && this.tiers?.current() === 'low' && !scene.content && scene.three?.staticActorsOff !== true) {
|
|
879
|
+
this.farAvatars ??= makeFarAvatars();
|
|
880
|
+
this.farAvatars.update(scene, mp?.avatars?.actors?.values() ?? [], scene.actorWith('Player')?.id, true, now, weakestActive ? 12 : Infinity);
|
|
881
|
+
} else {
|
|
882
|
+
this.farAvatars?.clear();
|
|
883
|
+
}
|
|
884
|
+
if (Hub.deck.lowActorBudget) {
|
|
885
|
+
this.actorBudget ??= makeActorBudget();
|
|
886
|
+
this.actorBudget(scene, this.tiers.current() === 'low' && !scene.content, now);
|
|
887
|
+
}
|
|
888
|
+
if (Hub.hub.place?.interest === 'cells') {
|
|
889
|
+
this.interestTier = this.tiers.current();
|
|
890
|
+
}
|
|
891
|
+
if (fpsTelemetryFor(mp?.net)) {this.fpsTier = this.tiers.weakest() ? 3 : this.tiers.current() === 'low' ? 1 : 2;}
|
|
892
|
+
if (Hub.deck.quality || Hub.deck.highOnly) {
|
|
893
|
+
const quality = qualityFor(scene);
|
|
894
|
+
if (quality) {
|
|
895
|
+
restoreDecor(scene, quality, quality.build);
|
|
896
|
+
if (Hub.deck.quality) {qualityPlayers(scene, quality, now);}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
372
899
|
globalThis.__hub.tier = this.tiers.handle;
|
|
373
900
|
}
|
|
374
901
|
|
|
902
|
+
interestFrame(scene, now) {
|
|
903
|
+
if (Hub.hub.place?.interest !== 'cells' || !scene.multiplayer?.net) {
|
|
904
|
+
this.interestCap = null;
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
if (!this.interestCap || this.interestPlace !== Hub.hub.place) {
|
|
908
|
+
this.interestCap = makeInterestCap(Hub.hub.place.nearestPlayers ?? 1000);
|
|
909
|
+
this.interestPlace = Hub.hub.place;
|
|
910
|
+
}
|
|
911
|
+
const counts = !this.trip && this.pendingEnd === null && scene.multiplayer.placed?.() === true;
|
|
912
|
+
const cap = this.interestCap.frame(now, this.interestTier ?? 'high', counts);
|
|
913
|
+
if (cap !== null) {
|
|
914
|
+
scene.multiplayer.net.send({ k: 'hub-cap', n: cap });
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
registerInterest(scene) {
|
|
919
|
+
if (Hub.hub.place?.interest !== 'cells' || typeof scene.registerSystem !== 'function' || this.interestScenes?.has(scene)) {
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
(this.interestScenes ??= new WeakSet()).add(scene);
|
|
923
|
+
scene.registerSystem({ afterBehaviors: (s) => this.interestFrame(s, performance.now()) });
|
|
924
|
+
}
|
|
925
|
+
|
|
375
926
|
// The systems that run after every other one, registered once per runtime.
|
|
376
927
|
registerLate(scene) {
|
|
928
|
+
if (this.lateScenes?.has(scene)) {return;}
|
|
929
|
+
(this.lateScenes ??= new WeakSet()).add(scene);
|
|
377
930
|
scene.registerSystem({
|
|
378
931
|
afterBehaviors: (s) => {
|
|
379
932
|
this.applyVisibility(s);
|
|
@@ -387,6 +940,28 @@ class HubSystem {
|
|
|
387
940
|
if (Hub.deck.tiers) {
|
|
388
941
|
scene.registerSystem({ afterBehaviors: (s) => this.deviceTier(s, s.multiplayer, performance.now()) });
|
|
389
942
|
}
|
|
943
|
+
// Complete sound recovery after every system, including the transport
|
|
944
|
+
// drain. A keyless deck registers no sound completion hook.
|
|
945
|
+
if (Hub.deck.soundscape) {
|
|
946
|
+
scene.registerSystem({ afterBehaviors: (s) => {
|
|
947
|
+
const local = s.actorWith('Player');
|
|
948
|
+
const now = performance.now();
|
|
949
|
+
// A drain after the hub frame can still hand the panel a reply. Do
|
|
950
|
+
// that before recovery completes, so a quiet reply cannot escape
|
|
951
|
+
// into the next live frame's panel queue.
|
|
952
|
+
if (Hub.hub.npcEvents.length) {
|
|
953
|
+
this.talk?.frame(s, s.multiplayer, !this.trip && this.pendingEnd === null);
|
|
954
|
+
}
|
|
955
|
+
if (this.soundscape) {
|
|
956
|
+
const level = this.soundscape.frame(s, s.multiplayer, local, !this.trip, this.talk?.talkingWith() ?? null, now);
|
|
957
|
+
if (Hub.hub.npcEvents.length) {
|
|
958
|
+
this.talk?.frame(s, s.multiplayer, !this.trip && this.pendingEnd === null);
|
|
959
|
+
}
|
|
960
|
+
this.sound.frame(s, local, !this.trip, level);
|
|
961
|
+
this.soundscape.completeFrame(s, s.multiplayer, local, !this.trip, this.talk?.talkingWith() ?? null, now);
|
|
962
|
+
}
|
|
963
|
+
} });
|
|
964
|
+
}
|
|
390
965
|
}
|
|
391
966
|
|
|
392
967
|
// The places this player will walk back into stay built while they are away
|
|
@@ -417,58 +992,113 @@ class HubSystem {
|
|
|
417
992
|
// stops just under it until the place puts them back: a pose past the
|
|
418
993
|
// world's floor is never read, so a client that kept falling would never be
|
|
419
994
|
// caught.
|
|
420
|
-
holdFall(scene, local) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
995
|
+
holdFall(scene, local, fallY) {
|
|
996
|
+
holdFallenPlayer(scene, local, fallY);
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
clearMenu() {
|
|
1000
|
+
if (this.menuDrawn) {
|
|
1001
|
+
this.chrome?.clearMenu();
|
|
1002
|
+
delete this.menuDrawn;
|
|
1003
|
+
}
|
|
1004
|
+
delete Hub.hub.menuClose;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
clearTextAsk() {
|
|
1008
|
+
if (this.askDrawn) {
|
|
1009
|
+
this.chrome?.clearTextAsk();
|
|
1010
|
+
delete this.askDrawn;
|
|
425
1011
|
}
|
|
426
|
-
|
|
427
|
-
scene.physics3d?.bodyOf?.(local)?.setTranslation({ x: t.x, y: t.y, z: t.z }, true);
|
|
428
|
-
scene.physics3d?.setVelocity?.(local, { x: 0, y: 0, z: 0 });
|
|
1012
|
+
delete Hub.hub.askClose;
|
|
429
1013
|
}
|
|
430
1014
|
|
|
431
1015
|
enterScene(scene) {
|
|
1016
|
+
this.clearPadReadability();
|
|
1017
|
+
if (this.actionInput) {
|
|
1018
|
+
this.chrome.cancelActionOverflow();
|
|
1019
|
+
}
|
|
1020
|
+
if (this.sceneKey !== null && this.sceneKey !== undefined && this.menuDrawn) {
|
|
1021
|
+
this.clearMenu();
|
|
1022
|
+
delete Hub.hub.menu;
|
|
1023
|
+
}
|
|
1024
|
+
if (this.sceneKey !== null && this.sceneKey !== undefined && this.askDrawn) {
|
|
1025
|
+
this.clearTextAsk();
|
|
1026
|
+
delete Hub.hub.ask;
|
|
1027
|
+
}
|
|
1028
|
+
clearShot();
|
|
432
1029
|
this.scenePath = scene.currentScenePath;
|
|
433
1030
|
this.sceneKey = sceneKeyOf(scene);
|
|
434
1031
|
this.doorBase.clear();
|
|
435
1032
|
this.stash.clear();
|
|
436
1033
|
this.tinted.clear();
|
|
437
1034
|
this.spawnedHere.clear();
|
|
1035
|
+
this.companion?.clear();
|
|
438
1036
|
this.wear.clear(scene);
|
|
1037
|
+
this.earned.clear();
|
|
439
1038
|
this.idle?.release();
|
|
1039
|
+
if (this.decor) {
|
|
1040
|
+
this.decor.dispose();
|
|
1041
|
+
this.decor = null;
|
|
1042
|
+
}
|
|
440
1043
|
// What was said in the place just left stays there.
|
|
441
1044
|
this.say.clear();
|
|
442
1045
|
this.together.clear();
|
|
443
1046
|
this.playAsk = null;
|
|
444
1047
|
this.wentAsk = null;
|
|
445
1048
|
this.againAsk = null;
|
|
1049
|
+
this.askSlot.clear();
|
|
446
1050
|
this.playAsked.clear();
|
|
1051
|
+
this.yours?.clear();
|
|
447
1052
|
}
|
|
448
1053
|
|
|
449
1054
|
// Every scene load, the same scene reloaded included: the actors are the
|
|
450
1055
|
// file's again, so what was dropped, painted or spawned in them is gone.
|
|
451
1056
|
reset(scene) {
|
|
1057
|
+
this.clearPadReadability();
|
|
1058
|
+
if (this.actionInput) {
|
|
1059
|
+
this.chrome.cancelActionOverflow();
|
|
1060
|
+
}
|
|
1061
|
+
this.weakestTier?.restore();
|
|
1062
|
+
this.environment.restore();
|
|
1063
|
+
this.farAvatars?.clear();
|
|
1064
|
+
if (this.menuDrawn) {
|
|
1065
|
+
this.clearMenu();
|
|
1066
|
+
delete Hub.hub.menu;
|
|
1067
|
+
}
|
|
1068
|
+
if (this.askDrawn) {
|
|
1069
|
+
this.clearTextAsk();
|
|
1070
|
+
delete Hub.hub.ask;
|
|
1071
|
+
}
|
|
1072
|
+
clearShot();
|
|
1073
|
+
this.companion?.clear();
|
|
1074
|
+
if (this.decor) {
|
|
1075
|
+
this.decor.dispose();
|
|
1076
|
+
this.decor = null;
|
|
1077
|
+
}
|
|
452
1078
|
this.stash.clear();
|
|
453
1079
|
this.tinted.clear();
|
|
454
1080
|
this.spawnedHere.clear();
|
|
455
1081
|
if (scene) {
|
|
456
1082
|
this.wear.clear(scene);
|
|
1083
|
+
this.earned.clear();
|
|
457
1084
|
} else {
|
|
458
1085
|
this.wear.forget();
|
|
1086
|
+
this.earned.forget();
|
|
459
1087
|
}
|
|
460
1088
|
}
|
|
461
1089
|
|
|
462
1090
|
// What players wear (`hub.wear`, v1.4), over each avatar and this player's
|
|
463
1091
|
// own body. Also after every other system, as visibility is: the
|
|
464
1092
|
// multiplayer kit moves the other avatars after this one runs.
|
|
465
|
-
applyWear(scene) {
|
|
1093
|
+
applyWear(scene, local) {
|
|
466
1094
|
const self = scene.multiplayer?.net?.selfId?.() ?? null;
|
|
467
1095
|
const style = Avatar.style();
|
|
468
|
-
|
|
1096
|
+
// Dressed as the avatar drawn: `known` for the others, or the stand-in
|
|
1097
|
+
// the cap draws (`avatarCap.js`), as the hook layer draws them.
|
|
1098
|
+
const indexOf = (playerId) => (playerId === self ? Avatar.current(scene) : AvatarCap.shown(playerId));
|
|
469
1099
|
this.wear.frame(
|
|
470
1100
|
scene,
|
|
471
|
-
scene.actorWith('Player'),
|
|
1101
|
+
local ?? scene.actorWith('Player'),
|
|
472
1102
|
Hub.hub.wearing,
|
|
473
1103
|
(playerId) => {
|
|
474
1104
|
const index = indexOf(playerId);
|
|
@@ -481,6 +1111,14 @@ class HubSystem {
|
|
|
481
1111
|
return Avatar.hatFit(index, Avatar.drawn(scene.files, index, style));
|
|
482
1112
|
},
|
|
483
1113
|
);
|
|
1114
|
+
// Earned items (v1.53): no work at all while nobody shows one and
|
|
1115
|
+
// nothing is drawn.
|
|
1116
|
+
if (Hub.hub.earned.size > 0 || this.earned.size > 0) {
|
|
1117
|
+
this.earned.frame(scene, local ?? scene.actorWith('Player'), Hub.hub.earned, (playerId) => {
|
|
1118
|
+
const index = indexOf(playerId);
|
|
1119
|
+
return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
484
1122
|
}
|
|
485
1123
|
|
|
486
1124
|
// The place's tuning of this player's own controller (`hub.tune`): the
|
|
@@ -514,7 +1152,7 @@ class HubSystem {
|
|
|
514
1152
|
if (!model) {
|
|
515
1153
|
return;
|
|
516
1154
|
}
|
|
517
|
-
const file = Avatar.model(scene.files, Avatar.current(scene));
|
|
1155
|
+
const file = Avatar.model(scene.files, Avatar.current(scene), Avatar.style(), Avatar.currentColor(scene));
|
|
518
1156
|
if (file && model.file !== file) {
|
|
519
1157
|
model.file = file;
|
|
520
1158
|
}
|
|
@@ -525,57 +1163,159 @@ class HubSystem {
|
|
|
525
1163
|
// out at once, so arrival never waits on the avatar; when the avatar
|
|
526
1164
|
// changes (the platform's answer, a pick) it says hello again and the place
|
|
527
1165
|
// redraws the body in the new one.
|
|
1166
|
+
//
|
|
1167
|
+
// A connection that comes back to a session that let it go (a phone's app
|
|
1168
|
+
// switch: the platform reported a leave and the place forgot the player) says
|
|
1169
|
+
// hello again, in every place but a game that did not opt in to `resume`
|
|
1170
|
+
// (`client/rehello.js` says how that is seen), without waiting for the place's own greet: a fresh hello, so the
|
|
1171
|
+
// place re-sends what it had sent, from a party of one and carrying nothing
|
|
1172
|
+
// (it has arrived once already), keeping this client's chat and start. A
|
|
1173
|
+
// place that still has the player arrived does not arrive them again.
|
|
528
1174
|
sayHello(scene, mp) {
|
|
529
1175
|
const net = mp.net;
|
|
530
1176
|
if (!net) {
|
|
531
1177
|
return;
|
|
532
1178
|
}
|
|
533
1179
|
const avatar = Avatar.current(scene);
|
|
534
|
-
|
|
1180
|
+
const color = Avatar.currentColor(scene);
|
|
1181
|
+
if (net === this.helloNet) {
|
|
1182
|
+
const back = Rehello.resumed(mp, net, this.helloMark);
|
|
1183
|
+
// (Another player id was reset for by `newIdentity`, already.) A game
|
|
1184
|
+
// (a place with `result`) back under the same id keeps the old way, as
|
|
1185
|
+
// its server does, unless its place says `resume: true` (v1.72); under a
|
|
1186
|
+
// new id it is a session that never arrived this player, which an
|
|
1187
|
+
// ordinary first hello does (`helloAfter`).
|
|
1188
|
+
const place = Hub.hub.place ?? this.identityPlace;
|
|
1189
|
+
const say = Rehello.helloAfter(back, Boolean(place?.result), place?.resume === true);
|
|
1190
|
+
if (say !== 'none') {
|
|
1191
|
+
console.log(`[hub] the connection came back (${back}): saying a ${say} hello`);
|
|
1192
|
+
this.sendHello(scene, mp, net, avatar, say === 'resume' ? { resume: true } : { solo: true });
|
|
1193
|
+
if (back === 'world') {
|
|
1194
|
+
this.talk?.resume();
|
|
1195
|
+
}
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
if (back) {
|
|
1199
|
+
this.helloMark = Rehello.mark(mp, net);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
if (net === this.helloNet && avatar === this.helloAvatar && color === (this.helloColor ?? 0)) {
|
|
535
1203
|
return;
|
|
536
1204
|
}
|
|
537
1205
|
// The same session again (the avatar changed): the place keeps what it
|
|
538
1206
|
// knows this client holds (a cabinet's card, v1.7).
|
|
539
1207
|
const again = net === this.helloNet;
|
|
1208
|
+
let inviteNear = null;
|
|
1209
|
+
if (!again && (Hub.hub.place?.invite === true || !Hub.hub.place && Hub.deck.invite)) {
|
|
1210
|
+
this.invites ??= makeInvites(castleSdk.Hub, () => {},
|
|
1211
|
+
(door) => { if (!this.trip && this.scene) { this.goHub(this.scene, { door, title: "Your friend's house" }); } },
|
|
1212
|
+
undefined, (text) => {this.toast = { text, until: performance.now() + TOAST_MS };}, () => Hub.deck.title,
|
|
1213
|
+
(node) => this.chrome?.safeSurface?.('invite-dialog', node));
|
|
1214
|
+
const arrival = this.invites.hello(net);
|
|
1215
|
+
if (!arrival.ready) {return;}
|
|
1216
|
+
inviteNear = arrival.near;
|
|
1217
|
+
}
|
|
540
1218
|
if (!again) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
1219
|
+
this.identityPlace = null;
|
|
1220
|
+
this.freshSession(scene);
|
|
1221
|
+
}
|
|
1222
|
+
this.sendHello(scene, mp, net, avatar, { again, inviteNear });
|
|
1223
|
+
if (!again) {this.invites?.landed();}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// The same connection under another player id is another session: what the
|
|
1227
|
+
// old one sent this player (its HUD, tune, decor, card, shot, labels, holds
|
|
1228
|
+
// and the snapshot's state) goes before the new one's packets are applied,
|
|
1229
|
+
// as on any switch of session, along with what this client kept of it.
|
|
1230
|
+
newIdentity() {
|
|
1231
|
+
this.pushVisit = null;
|
|
1232
|
+
console.log('[hub] the connection has a new player id: a new session');
|
|
1233
|
+
this.identityPlace = Hub.hub.place ?? this.identityPlace;
|
|
1234
|
+
Hub.clear();
|
|
1235
|
+
// The server forgets invitations with an old player identity. Hub.clear
|
|
1236
|
+
// resets that occurrence, while the shared slot retains other expired
|
|
1237
|
+
// client offers (notably Your games) through the reconnect.
|
|
1238
|
+
if (ballotHeld) {
|
|
1239
|
+
forgetBallot();
|
|
1240
|
+
}
|
|
1241
|
+
if (this.scene) {
|
|
1242
|
+
this.freshSession(this.scene, { keepAskSlot: true });
|
|
1243
|
+
}
|
|
1244
|
+
// A recovery, not a walk-in: no automatic start beside a friend.
|
|
1245
|
+
this.startNear = null;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
// What this client keeps of one session, cleared when it joins another.
|
|
1249
|
+
freshSession(scene, { keepAskSlot = false } = {}) {
|
|
1250
|
+
// A player who walks in (no door, no jump to a friend) starts beside a
|
|
1251
|
+
// friend or party member who is already here, once, if one turns up in
|
|
1252
|
+
// the first moments and the player has not walked off.
|
|
1253
|
+
const arrivingNow = scene.persistent?.hubArriving ?? null;
|
|
1254
|
+
this.startNear = !this.invites?.accepted() && !arrivingNow?.door && typeof arrivingNow?.near !== 'string' ? { until: performance.now() + START_NEAR_MS, at: null, asked: false } : null;
|
|
1255
|
+
this.friendsAt = -Infinity;
|
|
1256
|
+
this.friendsGameAt = -Infinity;
|
|
1257
|
+
this.friendsGameWarm = false;
|
|
1258
|
+
// Another session (a door, a layer): what was said in the last one stays there.
|
|
1259
|
+
this.companion?.clear();
|
|
1260
|
+
this.say.clear();
|
|
1261
|
+
this.together.clear();
|
|
1262
|
+
this.playAsk = null;
|
|
1263
|
+
this.wentAsk = null;
|
|
1264
|
+
this.againAsk = null;
|
|
1265
|
+
if (!keepAskSlot) {
|
|
1266
|
+
this.askSlot.clear();
|
|
1267
|
+
}
|
|
1268
|
+
this.playAsked.clear();
|
|
1269
|
+
this.chat.reset();
|
|
1270
|
+
this.talk?.reset();
|
|
1271
|
+
if (Hub.deck.cues) {
|
|
1272
|
+
this.hereCues = [];
|
|
1273
|
+
this.besideTold = null;
|
|
1274
|
+
this.rosterSeen = new Set();
|
|
1275
|
+
// The party this session is first told of is the one the player had.
|
|
1276
|
+
this.partyCarryUntil = this.partyLast?.members ? performance.now() + PARTY_CARRY_MS : 0;
|
|
1277
|
+
this.partyLast = null;
|
|
1278
|
+
this.partySettleUntil = performance.now() + PARTY_SETTLE_MS;
|
|
1279
|
+
this.partyAccepted = null;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
// `solo`: a party of one carrying nothing and naming no friend, as `resume`
|
|
1284
|
+
// is, without saying it resumes (a game's new session, `helloAfter`).
|
|
1285
|
+
sendHello(scene, mp, net, avatar, { again = false, resume = false, solo = resume, inviteNear = null } = {}) {
|
|
1286
|
+
if (resume && (this.menuDrawn || Object.hasOwn(Hub.hub, 'menu'))) {
|
|
1287
|
+
this.clearMenu();
|
|
1288
|
+
delete Hub.hub.menu;
|
|
1289
|
+
}
|
|
1290
|
+
if (resume && Object.hasOwn(Hub.hub, 'companion')) {
|
|
1291
|
+
delete Hub.hub.companion;
|
|
1292
|
+
this.companion?.clear();
|
|
1293
|
+
}
|
|
1294
|
+
if (resume && (this.askDrawn || Object.hasOwn(Hub.hub, 'ask'))) {
|
|
1295
|
+
this.clearTextAsk();
|
|
1296
|
+
delete Hub.hub.ask;
|
|
1297
|
+
}
|
|
1298
|
+
if (resume && Object.hasOwn(Hub.hub, 'actions')) {
|
|
1299
|
+
delete Hub.hub.actions;
|
|
565
1300
|
}
|
|
566
1301
|
this.helloNet = net;
|
|
567
1302
|
this.helloAvatar = avatar;
|
|
1303
|
+
this.helloColor = Avatar.currentColor(scene);
|
|
1304
|
+
this.helloMark = Rehello.mark(mp, net, () => this.newIdentity());
|
|
568
1305
|
const per = scene.persistent;
|
|
569
1306
|
const arriving = per.hubArriving ?? null;
|
|
570
1307
|
net.send({
|
|
571
1308
|
k: 'hub-hello',
|
|
572
1309
|
avatar,
|
|
1310
|
+
...(Number.isInteger(this.helloColor) && this.helloColor > 0 ? { color: this.helloColor } : {}),
|
|
573
1311
|
from: arriving?.door ?? null,
|
|
574
|
-
party: arriving?.party ?? 1,
|
|
575
|
-
carry: arriving?.returning && per.hubResult ? { result: per.hubResult } : null,
|
|
1312
|
+
party: solo ? 1 : arriving?.party ?? 1,
|
|
1313
|
+
carry: !solo && arriving?.returning && per.hubResult ? { result: per.hubResult } : null,
|
|
576
1314
|
// A jump to a friend: the place puts this player beside them.
|
|
577
|
-
...(typeof arriving?.near === 'string' ? { near: arriving.near } : {}),
|
|
1315
|
+
...(!solo && typeof (inviteNear ?? arriving?.near) === 'string' ? { near: inviteNear ?? arriving.near } : {}),
|
|
1316
|
+
...((Hub.hub.place?.invite === true || !Hub.hub.place && Hub.deck.invite) && this.invites?.accepted() ? { invited: true } : {}),
|
|
578
1317
|
...(again ? { again: true } : {}),
|
|
1318
|
+
...(resume ? { resume: true } : {}),
|
|
579
1319
|
});
|
|
580
1320
|
}
|
|
581
1321
|
|
|
@@ -586,11 +1326,14 @@ class HubSystem {
|
|
|
586
1326
|
// An actor the place moves (`hub.move`) has its pose written by the network
|
|
587
1327
|
// each frame it moves, which lifts it back up: it is dropped again, and
|
|
588
1328
|
// shown again by lifting it from wherever it is.
|
|
1329
|
+
// The engine is told before each write (`scene.touch`): a scene may hold
|
|
1330
|
+
// the actor still (physics-3d `"engine": { "staticActors": true }`).
|
|
589
1331
|
applyVisibility(scene) {
|
|
590
1332
|
for (const id of Hub.hub.hidden) {
|
|
591
1333
|
const t = scene.getActor(id)?.components.Transform;
|
|
592
1334
|
if (t && t.y > -HIDE_DROP_M / 2) {
|
|
593
1335
|
this.stash.set(id, true);
|
|
1336
|
+
scene.touch?.(id);
|
|
594
1337
|
t.y -= HIDE_DROP_M;
|
|
595
1338
|
}
|
|
596
1339
|
}
|
|
@@ -599,6 +1342,7 @@ class HubSystem {
|
|
|
599
1342
|
this.stash.delete(id);
|
|
600
1343
|
const t = scene.getActor(id)?.components.Transform;
|
|
601
1344
|
if (t && t.y < -HIDE_DROP_M / 2) {
|
|
1345
|
+
scene.touch?.(id);
|
|
602
1346
|
t.y += HIDE_DROP_M;
|
|
603
1347
|
}
|
|
604
1348
|
}
|
|
@@ -615,7 +1359,21 @@ class HubSystem {
|
|
|
615
1359
|
applySpawns(scene) {
|
|
616
1360
|
const want = Hub.hub.spawned;
|
|
617
1361
|
const mp = scene.multiplayer;
|
|
618
|
-
|
|
1362
|
+
const quality = Hub.deck.quality ? lowQuality(scene) : null;
|
|
1363
|
+
const allowed = quality ? qualitySpawnIds(want, Hub.hub.spawnTemplates, scene.actorWith('Player')?.components.Transform, quality.spawned) : null;
|
|
1364
|
+
if (allowed) {
|
|
1365
|
+
for (const id of this.spawnedHere) {
|
|
1366
|
+
if (Object.hasOwn(want, id) && !allowed.has(id) && Hub.hub.spawnTemplates[want[id].from]?.decor === true) {
|
|
1367
|
+
this.spawnedHere.delete(id);
|
|
1368
|
+
this.stash.delete(id); this.tinted.delete(id);
|
|
1369
|
+
mp?.avatars?.retired?.add(id);
|
|
1370
|
+
scene.despawnActor(id);
|
|
1371
|
+
mp?.forgetObject?.(id);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
const copies = allowed ? [...allowed].map((id) => [id, want[id]]) : Object.entries(want);
|
|
1376
|
+
for (const [id, copy] of copies) {
|
|
619
1377
|
if (this.spawnedHere.has(id) || scene.getActor(id) || mp?.gone?.has(id)) {
|
|
620
1378
|
continue;
|
|
621
1379
|
}
|
|
@@ -625,9 +1383,13 @@ class HubSystem {
|
|
|
625
1383
|
continue;
|
|
626
1384
|
}
|
|
627
1385
|
const components = JSON.parse(JSON.stringify(template));
|
|
1386
|
+
if (Hub.deck.quality) {delete components.decor;}
|
|
628
1387
|
components.Transform = { ...components.Transform, x: copy.x, y: copy.y, z: copy.z, rotationY: copy.rotationY };
|
|
629
1388
|
scene.spawnActor({ id, components });
|
|
630
1389
|
this.spawnedHere.add(id);
|
|
1390
|
+
if (components.HubSpin) {
|
|
1391
|
+
this.spin = addSpinner(this.spin, id, components);
|
|
1392
|
+
}
|
|
631
1393
|
}
|
|
632
1394
|
for (const id of this.spawnedHere) {
|
|
633
1395
|
if (!Object.hasOwn(want, id)) {
|
|
@@ -641,6 +1403,20 @@ class HubSystem {
|
|
|
641
1403
|
}
|
|
642
1404
|
}
|
|
643
1405
|
|
|
1406
|
+
// Turning displays (contract §10, v1.55): the scene's `HubSpin` actors are
|
|
1407
|
+
// found once per scene load, by the loaded data's identity, and copies as
|
|
1408
|
+
// they are spawned (`applySpawns`). A scene with none leaves `this.spin`
|
|
1409
|
+
// null and nothing is turned, touched or written.
|
|
1410
|
+
turnSpinners(scene, dt) {
|
|
1411
|
+
if (scene.data !== this.spinData) {
|
|
1412
|
+
this.spinData = scene.data;
|
|
1413
|
+
this.spin = findSpinners(scene.data?.actors);
|
|
1414
|
+
}
|
|
1415
|
+
if (this.spin) {
|
|
1416
|
+
spinFrame(this.spin, scene, dt, Hub.hub.hidden);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
644
1420
|
// Paint what the place painted, and put back what it stopped painting
|
|
645
1421
|
// (`hub.tint`, contract §10). A Shape that glows glows in its new colour.
|
|
646
1422
|
applyTints(scene) {
|
|
@@ -654,6 +1430,7 @@ class HubSystem {
|
|
|
654
1430
|
this.tinted.set(id, { color: shape.color, tint: shape.tint, emissive: shape.emissive });
|
|
655
1431
|
}
|
|
656
1432
|
// A textured face takes its colour from `tint`, a plain one from `color`.
|
|
1433
|
+
scene.touch?.(id);
|
|
657
1434
|
shape.color = color;
|
|
658
1435
|
shape.tint = color;
|
|
659
1436
|
if (glows(this.tinted.get(id).emissive)) {
|
|
@@ -665,6 +1442,7 @@ class HubSystem {
|
|
|
665
1442
|
this.tinted.delete(id);
|
|
666
1443
|
const shape = scene.getActor(id)?.components.Shape;
|
|
667
1444
|
if (shape) {
|
|
1445
|
+
scene.touch?.(id);
|
|
668
1446
|
shape.color = authored.color;
|
|
669
1447
|
shape.tint = authored.tint;
|
|
670
1448
|
shape.emissive = authored.emissive;
|
|
@@ -702,31 +1480,40 @@ class HubSystem {
|
|
|
702
1480
|
}
|
|
703
1481
|
this.lastNet = null;
|
|
704
1482
|
const inGame = Boolean(Hub.hub.place?.result);
|
|
705
|
-
const
|
|
1483
|
+
const refused = joinErrorText(last.closeError?.());
|
|
1484
|
+
// A player coming back from away is still under the multiplayer kit's
|
|
1485
|
+
// cover, and what the page holds is the place as it was before they left:
|
|
1486
|
+
// the way back starts under the trip's cover, with no door beat over it.
|
|
1487
|
+
const covered = mp.returning?.() === true;
|
|
706
1488
|
Hub.clear();
|
|
707
1489
|
if (inGame && scene.persistent.hubTickets.length) {
|
|
708
1490
|
this.toast = { text: 'The game ended', until: performance.now() + TOAST_MS };
|
|
709
|
-
this.back(scene);
|
|
710
|
-
} else if (!inGame && !
|
|
1491
|
+
this.back(scene, { covered });
|
|
1492
|
+
} else if (!inGame && !refused && mp.target?.mode === 'hub' && !(scene.persistent.hubDepth > 0)) {
|
|
711
1493
|
console.warn('[hub-door] this place ended under a hub join: joining it again');
|
|
712
|
-
mp.switchSession(scene, scene.persistent.hubRootJoin ?? { mode: 'public' });
|
|
1494
|
+
mp.switchSession(scene, pongJoin(scene.persistent.hubRootJoin ?? { mode: 'public' }, Hub.deck.pongTimeoutMs));
|
|
713
1495
|
this.helloNet = null;
|
|
714
1496
|
this.toast = { text: 'Reconnecting…', until: performance.now() + TOAST_MS };
|
|
715
|
-
} else if (!inGame && !
|
|
1497
|
+
} else if (!inGame && !refused && mp.target?.mode === 'hub') {
|
|
716
1498
|
console.warn('[hub-door] this place ended under a hub join behind a door: leaving by its way back');
|
|
717
1499
|
const title = scene.persistent.hubTickets.at(-1)?.title;
|
|
718
1500
|
this.toast = {
|
|
719
1501
|
text: title ? `This place was updated. Back to ${title}…` : 'This place was updated. Going back…',
|
|
720
1502
|
until: performance.now() + TOAST_MS,
|
|
721
1503
|
};
|
|
722
|
-
this.back(scene);
|
|
1504
|
+
this.back(scene, { covered });
|
|
723
1505
|
}
|
|
724
1506
|
}
|
|
725
1507
|
|
|
726
1508
|
runCommands(scene, now) {
|
|
727
1509
|
while (Hub.hub.commands.length && !this.trip) {
|
|
728
1510
|
const msg = Hub.hub.commands.shift();
|
|
729
|
-
if (msg.k === 'hub-
|
|
1511
|
+
if (msg.k === 'hub-invite' && Hub.hub.place?.invite === true) {
|
|
1512
|
+
this.invites?.open(msg.share === true);
|
|
1513
|
+
} else if (msg.k === 'hub-home-unlock') {
|
|
1514
|
+
// v1.77: a harbour boat deed names the Harbour; anything else is the house.
|
|
1515
|
+
this.toast = { text: msg.to === 'boat' ? 'Sent to your boat at the Harbour' : 'Sent to your house', until: now + TOAST_MS };
|
|
1516
|
+
} else if (msg.k === 'hub-go' && msg.classic) {
|
|
730
1517
|
// A cabinet: the host plays a classic deck; this place waits (v1.7).
|
|
731
1518
|
this.goClassic(scene, msg);
|
|
732
1519
|
} else if (msg.k === 'hub-go' && !msg.key) {
|
|
@@ -736,9 +1523,14 @@ class HubSystem {
|
|
|
736
1523
|
this.go(scene, msg);
|
|
737
1524
|
} else if (msg.k === 'hub-result') {
|
|
738
1525
|
scene.persistent.hubResult = { ...msg.result, at: Date.now() };
|
|
739
|
-
} else if (msg.k === 'hub-end') {
|
|
740
|
-
|
|
1526
|
+
} else if (msg.k === 'hub-end' && Rehello.takesEnd(msg, this.pendingEnd, this.endSession, sessionKey(scene))) {
|
|
1527
|
+
// An end that meets a player coming back from away (a game that ran
|
|
1528
|
+
// out meanwhile, a fresh admission it ends at once) is not paused on:
|
|
1529
|
+
// the way back starts now, under the trip's cover (`watchSession`).
|
|
1530
|
+
this.endCovered = scene.multiplayer?.returning?.() === true;
|
|
1531
|
+
this.pendingEnd = this.endCovered ? now : now + END_PAUSE_MS;
|
|
741
1532
|
this.endSession = sessionKey(scene);
|
|
1533
|
+
this.endLeaving = null;
|
|
742
1534
|
const r = scene.persistent.hubResult;
|
|
743
1535
|
this.toast = { text: r && Date.now() - r.at < 30000 ? resultLine(r) : 'Game over', until: now + END_PAUSE_MS + 200 };
|
|
744
1536
|
}
|
|
@@ -776,7 +1568,9 @@ class HubSystem {
|
|
|
776
1568
|
scene: null,
|
|
777
1569
|
content: undefined,
|
|
778
1570
|
deck: msg.title ?? msg.door,
|
|
779
|
-
|
|
1571
|
+
retryDoor: msg.door,
|
|
1572
|
+
retryOwner: msg.owner ?? null,
|
|
1573
|
+
pending: this.resolveHub(scene, () => hubGo(msg.door, msg.owner)),
|
|
780
1574
|
join: null,
|
|
781
1575
|
title: msg.title,
|
|
782
1576
|
exitDoor: doorActor(scene, msg.door),
|
|
@@ -838,6 +1632,7 @@ class HubSystem {
|
|
|
838
1632
|
// handoff (one from before cabinets), which is given back. In the chain
|
|
839
1633
|
// with every other acquisition and cancel (`resolveHub`).
|
|
840
1634
|
resolveClassic(acquire) {
|
|
1635
|
+
this.fpsTelemetry?.leave();
|
|
841
1636
|
const state = { done: false, error: null, code: null, abandoned: false, target: null };
|
|
842
1637
|
const run = async () => {
|
|
843
1638
|
let giveBack = false;
|
|
@@ -874,7 +1669,7 @@ class HubSystem {
|
|
|
874
1669
|
stepClassic(scene, trip, mp, now) {
|
|
875
1670
|
const pending = trip.target.pending;
|
|
876
1671
|
trip.marks.covered ??= now;
|
|
877
|
-
this.
|
|
1672
|
+
this.setTripCover(1, trip);
|
|
878
1673
|
if (!pending.done && now - trip.startedAt < CLASSIC_LIMIT_MS) {
|
|
879
1674
|
return;
|
|
880
1675
|
}
|
|
@@ -887,8 +1682,8 @@ class HubSystem {
|
|
|
887
1682
|
pending.abandoned = true;
|
|
888
1683
|
pending.target = trip.target;
|
|
889
1684
|
}
|
|
890
|
-
if (pending.code
|
|
891
|
-
trip.target.stuck =
|
|
1685
|
+
if (joinErrorText(pending.code)) {
|
|
1686
|
+
trip.target.stuck = joinErrorText(pending.code);
|
|
892
1687
|
}
|
|
893
1688
|
this.shutDoor(scene, trip, pending.error ?? 'it took too long', now);
|
|
894
1689
|
}
|
|
@@ -931,6 +1726,7 @@ class HubSystem {
|
|
|
931
1726
|
// retries no failed hub join, and `AWAY_JOIN` is one it could not make
|
|
932
1727
|
// anyway. The next `switchSession` (Back) clears that.
|
|
933
1728
|
leaveSession(scene, mp) {
|
|
1729
|
+
clearShot();
|
|
934
1730
|
mp.switchSession(scene, AWAY_JOIN, { quiet: true });
|
|
935
1731
|
mp.joinFailed = true;
|
|
936
1732
|
this.helloNet = null;
|
|
@@ -976,6 +1772,7 @@ class HubSystem {
|
|
|
976
1772
|
// none, so acquisitions and their cancels run one after another
|
|
977
1773
|
// (`hubChain`): a late cancel can never reach a newer trip's acquisition.
|
|
978
1774
|
resolveHub(scene, acquire, stay) {
|
|
1775
|
+
this.fpsTelemetry?.leave();
|
|
979
1776
|
const state = { done: false, content: null, error: null, join: null, stayed: false, abandoned: false };
|
|
980
1777
|
const keep = new Set(scene.persistent.hubTickets.map((t) => t.content?.sha256).filter(Boolean));
|
|
981
1778
|
if (scene.content) {
|
|
@@ -991,6 +1788,7 @@ class HubSystem {
|
|
|
991
1788
|
if (handoff?.status !== 'ok') {
|
|
992
1789
|
throw new Error(handoff?.status ?? 'unavailable');
|
|
993
1790
|
}
|
|
1791
|
+
state.acquiredAt = performance.now();
|
|
994
1792
|
state.join = { mode: 'hub', handoff };
|
|
995
1793
|
if (stay?.content && stay.content.sha256 === handoff.bundleHash) {
|
|
996
1794
|
// Held in the pack cache, unless it was evicted: then fetched again.
|
|
@@ -1116,16 +1914,16 @@ class HubSystem {
|
|
|
1116
1914
|
}
|
|
1117
1915
|
|
|
1118
1916
|
// Who of the player's friends is in another layer of this place, asked every
|
|
1119
|
-
// little while from a
|
|
1120
|
-
//
|
|
1121
|
-
// friends) stops asking for the life of the runtime; a failed ask is retried.
|
|
1917
|
+
// little while from a town; a requesting game asks at once, after 20 s,
|
|
1918
|
+
// then every 90 s. Dormant on a host that cannot say: `unavailable`
|
|
1919
|
+
// (no hub support) or a refusal (a host from before friends) stops asking for the life of the runtime; a failed ask is retried.
|
|
1122
1920
|
askFriends(scene, mp, now) {
|
|
1123
1921
|
if (this.friendsOff || this.friendsAsking || typeof castleSdk.Hub?.friends !== 'function') {
|
|
1124
1922
|
return;
|
|
1125
1923
|
}
|
|
1126
1924
|
const place = Hub.hub.place;
|
|
1127
1925
|
const idle = !this.trip && this.pendingEnd === null && (mp.joinState?.() ?? 'joined') === 'joined';
|
|
1128
|
-
if (!place || place.result || !idle) {
|
|
1926
|
+
if (!place || (place.result && !Hub.hub.friendsWanted) || !idle) {
|
|
1129
1927
|
return;
|
|
1130
1928
|
}
|
|
1131
1929
|
// Cues (v1.23): someone here is not named by the host as a friend, and
|
|
@@ -1136,8 +1934,11 @@ class HubSystem {
|
|
|
1136
1934
|
// 1 s of any ask.
|
|
1137
1935
|
// One that cannot be sent (a trip, a join still pending) reaches none of
|
|
1138
1936
|
// this and is simply tried again when it can be, owing nothing it missed.
|
|
1139
|
-
const
|
|
1937
|
+
const game = Boolean(place.result);
|
|
1938
|
+
const gameEvery = this.friendsGameWarm ? 20000 : 90000;
|
|
1939
|
+
const onTime = game ? now - this.friendsGameAt >= gameEvery : now - this.friendsAt >= FRIENDS_EVERY_MS;
|
|
1140
1940
|
const early =
|
|
1941
|
+
!game &&
|
|
1141
1942
|
!onTime &&
|
|
1142
1943
|
Hub.deck.cues &&
|
|
1143
1944
|
now - this.friendsEarlyAt >= FRIENDS_EARLY_PAIR_MS &&
|
|
@@ -1148,6 +1949,12 @@ class HubSystem {
|
|
|
1148
1949
|
return;
|
|
1149
1950
|
}
|
|
1150
1951
|
this.friendsAt = now;
|
|
1952
|
+
if (game) {
|
|
1953
|
+
// The first ask may precede the heartbeat roster. One warm-up ask
|
|
1954
|
+
// 20 s later writes the seen marker after the player reaches it.
|
|
1955
|
+
this.friendsGameWarm = this.friendsGameAt === -Infinity;
|
|
1956
|
+
this.friendsGameAt = now;
|
|
1957
|
+
}
|
|
1151
1958
|
this.friendsAsking = true;
|
|
1152
1959
|
if (Hub.deck.cues) {
|
|
1153
1960
|
// Sent: the bounds count from here, and the steps come due are spent.
|
|
@@ -1223,6 +2030,13 @@ class HubSystem {
|
|
|
1223
2030
|
say(`Invited ${person.username ?? 'them'} to your party`);
|
|
1224
2031
|
} else if (action === 'goto' && person.playerId) {
|
|
1225
2032
|
this.sendJump(net, { k: 'hub-goto', player: person.playerId });
|
|
2033
|
+
} else if (action === 'door' && person.door && person.owner) {
|
|
2034
|
+
// A friend at home: the place sends this player through their House
|
|
2035
|
+
// door with the owner (`hub-go` carrying `owner`), ending the visit here
|
|
2036
|
+
// as any door's trip does. A host that predates the owner acquires this
|
|
2037
|
+
// player's own House, as the pad would have.
|
|
2038
|
+
this.sendJump(net, { k: 'hub-house-visit', door: person.door, owner: person.owner });
|
|
2039
|
+
say(`Going to ${person.username ?? 'your friend'}'s House`);
|
|
1226
2040
|
} else if (action === 'door' && person.door) {
|
|
1227
2041
|
this.sendJump(net, { k: 'hub-door-jump', door: person.door });
|
|
1228
2042
|
// A friend inside the game is said to be; someone standing at the door
|
|
@@ -1236,6 +2050,68 @@ class HubSystem {
|
|
|
1236
2050
|
}
|
|
1237
2051
|
}
|
|
1238
2052
|
|
|
2053
|
+
// "Stuck?" (v1.33, `client/stuck.js`), only in a deck whose castle.json asks
|
|
2054
|
+
// (`hub.stuck`): without it this is never called and nothing of it is made.
|
|
2055
|
+
// A chip is offered to a player who has walked for a few seconds and got
|
|
2056
|
+
// nowhere; nothing moves them but their own tap. Only in a town that says
|
|
2057
|
+
// it takes it (`hubStuck`), and never to a player the place holds.
|
|
2058
|
+
offerUnstick(scene, local, town, now) {
|
|
2059
|
+
const offer = town ? Hub.hub.stuck : null;
|
|
2060
|
+
const t = local?.components.Transform;
|
|
2061
|
+
const selfId = scene.multiplayer?.net?.selfId?.();
|
|
2062
|
+
if (!offer || !t || Hub.hub.held.has(selfId)) {
|
|
2063
|
+
if (this.stuck) {
|
|
2064
|
+
resetStuck(this.stuck);
|
|
2065
|
+
this.stuckShown = false;
|
|
2066
|
+
this.chrome.stuckPrompt?.(null);
|
|
2067
|
+
}
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
this.stuck ??= makeStuck();
|
|
2071
|
+
const walking = walkInput(scene.keys, scene.moveInput, scene.cameraControl === 'orbit');
|
|
2072
|
+
const hidden = globalThis.document?.visibilityState === 'hidden';
|
|
2073
|
+
const shown = stuckFrame(this.stuck, { key: `${this.sceneKey}|${Hub.hub.place.id}`, x: t.x, z: t.z, walking, hidden }, now);
|
|
2074
|
+
let text = shown ? stuckText(offer.to) : null;
|
|
2075
|
+
if (offer.hook) {
|
|
2076
|
+
// v1.39, a place that picks the spot itself: asked, as the chip comes
|
|
2077
|
+
// up, what a tap would do from here; until it answers the words name
|
|
2078
|
+
// nowhere. And what it did, once the player has tapped.
|
|
2079
|
+
if (shown && !this.stuckShown) {
|
|
2080
|
+
Hub.hub.stuckTo = null;
|
|
2081
|
+
scene.multiplayer?.net?.send({ k: 'hub-unstick', ask: true });
|
|
2082
|
+
}
|
|
2083
|
+
const says = Hub.hub.stuckTo;
|
|
2084
|
+
text = shown ? (says ? stuckText(says.to, says.spot) : stuckText(null, true)) : null;
|
|
2085
|
+
const done = Hub.hub.unstuck;
|
|
2086
|
+
if (done) {
|
|
2087
|
+
Hub.hub.unstuck = null;
|
|
2088
|
+
this.toast = { text: stuckDone(done.to, done.spot), until: now + TOAST_MS };
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
this.stuckShown = shown;
|
|
2092
|
+
this.chrome.stuckPrompt?.(text, () => this.unstick(this.scene));
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
// A tap on the chip or the Doors row: the place is asked to put this player
|
|
2096
|
+
// back at its arrival (`hub-unstick`), at most as often as it would answer.
|
|
2097
|
+
unstick(scene) {
|
|
2098
|
+
const net = scene?.multiplayer?.net;
|
|
2099
|
+
const now = performance.now();
|
|
2100
|
+
const offer = Hub.hub.stuck;
|
|
2101
|
+
if (!Hub.deck.stuck || !net || this.trip || !offer || now - (this.unstuckAt ?? -Infinity) < STUCK_EVERY_MS) {
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2104
|
+
this.unstuckAt = now;
|
|
2105
|
+
if (this.stuck) {
|
|
2106
|
+
resetStuck(this.stuck);
|
|
2107
|
+
}
|
|
2108
|
+
this.sendJump(net, { k: 'hub-unstick' });
|
|
2109
|
+
// A place that picks the spot says where it was (`hub-jumped`), and is quoted then.
|
|
2110
|
+
if (!offer.hook) {
|
|
2111
|
+
this.toast = { text: stuckWhere(offer.to), until: now + TOAST_MS };
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
|
|
1239
2115
|
// Go, from the Doors list: onto that door's pad. In a party the door is
|
|
1240
2116
|
// proposed to the party too, and each member who says yes lands on the pad.
|
|
1241
2117
|
goDoor(scene, door) {
|
|
@@ -1342,6 +2218,18 @@ class HubSystem {
|
|
|
1342
2218
|
});
|
|
1343
2219
|
}
|
|
1344
2220
|
|
|
2221
|
+
blockChat(line) {
|
|
2222
|
+
if (!chatModerationEnabled(this.scene)) {
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
this.chat.reportAndBlock(line?.id, line?.userId, (ok) => {
|
|
2226
|
+
if (ok) {
|
|
2227
|
+
this.say.hideUser(line.userId);
|
|
2228
|
+
}
|
|
2229
|
+
this.toast = { text: ok ? 'Reported and blocked.' : "The block wasn't confirmed. Try again.", until: performance.now() + TOAST_MS };
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
|
|
1345
2233
|
reportChat(line) {
|
|
1346
2234
|
this.chat.report(line?.id, (ok) => {
|
|
1347
2235
|
this.toast = { text: ok ? 'Reported. Thanks.' : "That report didn't go through.", until: performance.now() + TOAST_MS };
|
|
@@ -1350,7 +2238,7 @@ class HubSystem {
|
|
|
1350
2238
|
|
|
1351
2239
|
// The question the chrome puts to the player, from the place's word on
|
|
1352
2240
|
// their party: a door their party proposed, else an invitation.
|
|
1353
|
-
ask() {
|
|
2241
|
+
ask(now = performance.now()) {
|
|
1354
2242
|
const { invite, proposal } = Hub.hub.party;
|
|
1355
2243
|
if (proposal?.asked) {
|
|
1356
2244
|
const title = Hub.hub.doors.find((d) => d.id === proposal.door)?.title ?? 'a game';
|
|
@@ -1358,7 +2246,8 @@ class HubSystem {
|
|
|
1358
2246
|
}
|
|
1359
2247
|
// Someone here said "Let's play <door>": Go takes this player to its pad.
|
|
1360
2248
|
const play = this.playAsk;
|
|
1361
|
-
|
|
2249
|
+
const playCard = play ? { key: `play:${play.from}:${play.door}:${play.until}`, kind: 'play' } : null;
|
|
2250
|
+
if (play && (now < play.until || this.askSlot.known(playCard)) && Hub.hub.doors.some((d) => d.id === play.door) && !invite) {
|
|
1362
2251
|
const title = Hub.hub.doors.find((d) => d.id === play.door)?.title ?? 'a game';
|
|
1363
2252
|
// A game that takes no late joiners cannot be followed into: the player
|
|
1364
2253
|
// is told where their friend is, and that they will be back.
|
|
@@ -1370,12 +2259,24 @@ class HubSystem {
|
|
|
1370
2259
|
return { key: `play:${play.from}:${play.door}:${play.until}`, kind: 'play', door: play.door, text, yes: play.went ? 'Follow' : 'Go', no: 'Not now' };
|
|
1371
2260
|
}
|
|
1372
2261
|
if (invite) {
|
|
1373
|
-
|
|
2262
|
+
const occurrence = Hub.invitationOccurrence(invite);
|
|
2263
|
+
return { key: `invite:${invite.from}:${occurrence.n}`, kind: 'invite', from: invite.from, text: `${invite.username ?? 'Someone'} invited you to their party`, yes: 'Join party', no: 'No thanks' };
|
|
1374
2264
|
}
|
|
1375
2265
|
// Cues (v1.29): back from a game with nothing else asked -- the same game
|
|
1376
2266
|
// again, with the party when there is one (the Doors list's own Go).
|
|
1377
|
-
|
|
1378
|
-
|
|
2267
|
+
if (Hub.deck.yourGames && !proposal) {
|
|
2268
|
+
const ask = this.yours?.ask(Hub.hub.yours, Hub.hub.doors, Hub.hub.party.members, now) ?? null;
|
|
2269
|
+
// A returned offer begins only after the server's arrival pose has been
|
|
2270
|
+
// applied. Once displayed, its slot lease remains the authority through
|
|
2271
|
+
// reconnects even while the next placement receipt is still pending.
|
|
2272
|
+
if (ask?.requiresArrivalPlacement && !this.askSlot.known(ask) && !Hub.hub.arrivalPlaced) {
|
|
2273
|
+
return null;
|
|
2274
|
+
}
|
|
2275
|
+
return ask;
|
|
2276
|
+
}
|
|
2277
|
+
const again = Hub.deck.cues && !Hub.deck.yourGames ? this.againAsk : null;
|
|
2278
|
+
const againCard = again ? { key: `again:${again.door}:${again.until}`, kind: 'again' } : null;
|
|
2279
|
+
const door = again && (now < again.until || this.askSlot.known(againCard)) ? Hub.hub.doors.find((d) => d.id === again.door) : null;
|
|
1379
2280
|
if (door) {
|
|
1380
2281
|
const together = Hub.hub.party.members?.length && !door.solo;
|
|
1381
2282
|
return { key: `again:${again.door}:${again.until}`, kind: 'again', door: door.id, text: `Play ${door.title ?? 'that'} again${together ? ' together' : ''}?`, yes: together ? 'Go together' : 'Play again', no: 'Not now' };
|
|
@@ -1383,16 +2284,43 @@ class HubSystem {
|
|
|
1383
2284
|
return null;
|
|
1384
2285
|
}
|
|
1385
2286
|
|
|
1386
|
-
answer(scene, ask, yes) {
|
|
2287
|
+
answer(scene, ask, yes, fromChrome = false) {
|
|
1387
2288
|
const net = scene?.multiplayer?.net;
|
|
1388
2289
|
if (!net || !ask) {
|
|
1389
2290
|
return;
|
|
1390
2291
|
}
|
|
2292
|
+
if (fromChrome) {
|
|
2293
|
+
const current = this.liveAsk(scene, ask);
|
|
2294
|
+
if (!current) {
|
|
2295
|
+
this.chrome?.setAsk?.(null);
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
// The same occurrence redrawn (hearts or arrival data changed between
|
|
2299
|
+
// render and tap): the tap answered words no longer up, so it does
|
|
2300
|
+
// nothing and keeps the lease; the next frame shows the current card.
|
|
2301
|
+
if (current.key !== ask.key || current.door !== ask.door) {
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
// The server may take a frame to clear an accepted/declined offer. It
|
|
2305
|
+
// cannot reopen after the local action which consumed this display.
|
|
2306
|
+
this.askSlot.retire(ask);
|
|
2307
|
+
}
|
|
2308
|
+
if (ask.kind === 'yours') {
|
|
2309
|
+
const current = this.ask();
|
|
2310
|
+
if (!Hub.deck.yourGames || current?.key !== ask.key || current?.door !== ask.door || this.trip || Hub.hub.place?.result) {
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
this.yours.dismiss();
|
|
2314
|
+
if (yes) {
|
|
2315
|
+
this.goDoor(scene, Hub.hub.doors.find((d) => d.id === ask.door));
|
|
2316
|
+
}
|
|
2317
|
+
return;
|
|
2318
|
+
}
|
|
1391
2319
|
if (ask.kind === 'again') {
|
|
1392
2320
|
// Only the offer that is up: one whose time ran out, or that a later
|
|
1393
2321
|
// return replaced, is answered by nothing.
|
|
1394
2322
|
const again = this.againAsk;
|
|
1395
|
-
if (!Hub.deck.cues || !again || ask.key !== `again:${again.door}:${again.until}`
|
|
2323
|
+
if (!Hub.deck.cues || !again || ask.key !== `again:${again.door}:${again.until}`) {
|
|
1396
2324
|
return;
|
|
1397
2325
|
}
|
|
1398
2326
|
this.againAsk = null;
|
|
@@ -1424,6 +2352,47 @@ class HubSystem {
|
|
|
1424
2352
|
}
|
|
1425
2353
|
}
|
|
1426
2354
|
|
|
2355
|
+
// The card up now, when `ask` (as the chrome drew it) is that occurrence
|
|
2356
|
+
// and its lease still takes a tap; null otherwise.
|
|
2357
|
+
liveAsk(scene, ask) {
|
|
2358
|
+
const now = performance.now();
|
|
2359
|
+
const at = scene?.actorWith?.('Player')?.components?.Transform ?? null;
|
|
2360
|
+
const pads = askPadsAt(scene, at, Hub.hub.hidden);
|
|
2361
|
+
const place = Hub.hub.place;
|
|
2362
|
+
const eligible = !this.trip && place && !place.result && this.pendingEnd === null && !this.talk?.talking?.() && !this.carded &&
|
|
2363
|
+
!this.askInput && !this.menuInput && !this.actionInput && this.decor?.opened() !== true;
|
|
2364
|
+
const current = eligible ? this.ask(now) : null;
|
|
2365
|
+
return askSlotKey(current) === askSlotKey(ask) && this.askSlot.accepts(ask, at, pads, now) ? current : null;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
// The heart on a Your games card: toggled only while that card's lease
|
|
2369
|
+
// takes a tap, and only for the presentation it was drawn with. It leaves
|
|
2370
|
+
// the lease running: Go and Not now stay available until the boundary.
|
|
2371
|
+
heartAsk(scene, ask, door) {
|
|
2372
|
+
const current = this.liveAsk(scene, ask);
|
|
2373
|
+
if (!current) {
|
|
2374
|
+
this.chrome?.setAsk?.(null);
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2377
|
+
if (current.kind !== 'yours' || current.key !== ask.key || current.door !== door) {
|
|
2378
|
+
return;
|
|
2379
|
+
}
|
|
2380
|
+
this.yours?.toggle(door);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
retireExpiredAsk(ask) {
|
|
2384
|
+
if (!ask || !this.askSlot.expired(ask)) {
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
if (ask.kind === 'play' && this.playAsk && ask.key === `play:${this.playAsk.from}:${this.playAsk.door}:${this.playAsk.until}`) {
|
|
2388
|
+
this.playAsk = null;
|
|
2389
|
+
} else if (ask.kind === 'again' && this.againAsk && ask.key === `again:${this.againAsk.door}:${this.againAsk.until}`) {
|
|
2390
|
+
this.againAsk = null;
|
|
2391
|
+
} else if (ask.kind === 'yours') {
|
|
2392
|
+
this.yours?.dismiss();
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
|
|
1427
2396
|
// Cues (v1.23): the friends found already in this layer are told to the
|
|
1428
2397
|
// player ("amy is here") and pointed to, one at a time and never over
|
|
1429
2398
|
// another toast -- the result line of a game just left, or "You're next to
|
|
@@ -1511,9 +2480,23 @@ class HubSystem {
|
|
|
1511
2480
|
});
|
|
1512
2481
|
}
|
|
1513
2482
|
|
|
2483
|
+
// A user Back first dismisses transient chrome; automatic travel still uses back.
|
|
2484
|
+
backFromControl(scene) {
|
|
2485
|
+
if (this.chrome?.actionOverflowOpen?.()) {
|
|
2486
|
+
this.chrome.cancelActionOverflow();
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
if (this.chrome?.menuOpen?.()) {
|
|
2490
|
+
this.chrome.cancelMenu();
|
|
2491
|
+
return;
|
|
2492
|
+
}
|
|
2493
|
+
if (Hub.hub.place?.result) {scene.multiplayer?.net?.send({ k: 'hub-door-quit' });}
|
|
2494
|
+
this.back(scene);
|
|
2495
|
+
}
|
|
2496
|
+
|
|
1514
2497
|
// Back through the door this player came in by (contract §5). With no ticket
|
|
1515
2498
|
// -- a game played on its own -- it is a fresh instance of the same place.
|
|
1516
|
-
back(scene, { covered = false, attempt = 0, lost = 0, away = null } = {}) {
|
|
2499
|
+
back(scene, { covered = false, attempt = 0, lost = 0, away = null, previousTrip = null } = {}) {
|
|
1517
2500
|
// Away in a classic deck (v1.7): Back is the way out, cover already down.
|
|
1518
2501
|
if (this.trip?.phase === 'away') {
|
|
1519
2502
|
away = this.trip.target;
|
|
@@ -1554,7 +2537,7 @@ class HubSystem {
|
|
|
1554
2537
|
attempt,
|
|
1555
2538
|
lost,
|
|
1556
2539
|
away,
|
|
1557
|
-
});
|
|
2540
|
+
}, previousTrip);
|
|
1558
2541
|
if (covered && this.trip) {
|
|
1559
2542
|
this.trip.startedAt -= OPEN_MS;
|
|
1560
2543
|
}
|
|
@@ -1564,14 +2547,37 @@ class HubSystem {
|
|
|
1564
2547
|
const place = Hub.hub.place?.id ?? 'main';
|
|
1565
2548
|
// Another deck's place runs that deck's server: its key keeps the prefix.
|
|
1566
2549
|
const prefix = scene.content?.sessionKeyPrefix ?? '';
|
|
2550
|
+
// A fresh instance is a game's Again, and how the dev serve keys its
|
|
2551
|
+
// places. A town joined publicly or through a door is not left for one:
|
|
2552
|
+
// ghost opens no door from a private instance (no hub pin, no public
|
|
2553
|
+
// shard), so a player sent there was alone with every door shut until a
|
|
2554
|
+
// reload (a QA runner's Back at the town root did it twice). It rejoins
|
|
2555
|
+
// the join this runtime began with, and says who sent it.
|
|
2556
|
+
// The visit a town ended (`hub.end`, a longest visit) is settled here:
|
|
2557
|
+
// the rejoin can be the same session, which `settleEnd` would never
|
|
2558
|
+
// count as leaving it, and the end would send the player Back again.
|
|
2559
|
+
let join;
|
|
2560
|
+
const known = Hub.hub.place ?? this.knownPlace ?? null;
|
|
2561
|
+
if (!known?.result && scene.multiplayer?.target?.mode !== 'named') {
|
|
2562
|
+
console.warn('[hub-door] Back at a town root without a ticket: rejoining the root join', new Error().stack?.split('\n').slice(0, 7).join('\n'));
|
|
2563
|
+
join = per.hubRootJoin ?? { mode: 'public' };
|
|
2564
|
+
this.pendingEnd = null;
|
|
2565
|
+
this.endSession = null;
|
|
2566
|
+
this.endLeaving = null;
|
|
2567
|
+
} else {
|
|
2568
|
+
join = { mode: 'named', key: `${prefix}hub.${place}.${Math.random().toString(36).slice(2, 10)}` };
|
|
2569
|
+
}
|
|
1567
2570
|
this.startTrip(scene, {
|
|
1568
2571
|
scene: this.scenePath,
|
|
1569
|
-
join
|
|
2572
|
+
join,
|
|
1570
2573
|
title: Hub.hub.place?.title ?? '',
|
|
1571
2574
|
exitDoor: null,
|
|
1572
2575
|
arrive: { door: null, party: 1, returning: false },
|
|
1573
2576
|
lost,
|
|
1574
|
-
});
|
|
2577
|
+
}, previousTrip);
|
|
2578
|
+
if (covered && this.trip) {
|
|
2579
|
+
this.trip.startedAt -= OPEN_MS;
|
|
2580
|
+
}
|
|
1575
2581
|
return;
|
|
1576
2582
|
}
|
|
1577
2583
|
this.startTrip(scene, {
|
|
@@ -1587,32 +2593,74 @@ class HubSystem {
|
|
|
1587
2593
|
arrive: { door: ticket.door, party: ticket.party ?? 1, returning: true },
|
|
1588
2594
|
ticket,
|
|
1589
2595
|
lost,
|
|
1590
|
-
});
|
|
2596
|
+
}, previousTrip);
|
|
1591
2597
|
if (covered && this.trip) {
|
|
1592
2598
|
// Straight to the swap: the door already closed over the player.
|
|
1593
2599
|
this.trip.startedAt -= OPEN_MS;
|
|
1594
2600
|
}
|
|
1595
2601
|
}
|
|
1596
2602
|
|
|
1597
|
-
startTrip(scene, target) {
|
|
2603
|
+
startTrip(scene, target, previousTrip = null) {
|
|
1598
2604
|
if (this.trip) {
|
|
1599
2605
|
return;
|
|
1600
2606
|
}
|
|
2607
|
+
this.fpsTelemetry?.leave();
|
|
2608
|
+
clearShot();
|
|
2609
|
+
if (Hub.deck.soundscape?.ui === true && target.exitDoor) {
|
|
2610
|
+
this.soundscape?.cue('door', performance.now());
|
|
2611
|
+
}
|
|
1601
2612
|
const cam = scene.three?.camera;
|
|
2613
|
+
const startedAt = performance.now();
|
|
2614
|
+
// Local screenshot fixture, like hubFriends: never on a hosted page.
|
|
2615
|
+
const { hostname, search } = globalThis.location ?? {};
|
|
2616
|
+
const devLine = hostname === 'localhost' || hostname === '127.0.0.1'
|
|
2617
|
+
? new URLSearchParams(search ?? '').get('hubLeaving')?.trim().slice(0, 120)
|
|
2618
|
+
: null;
|
|
2619
|
+
previousTrip ??= this.pendingEnd !== null ? this.endLeaving : null;
|
|
2620
|
+
const leaving = previousTrip ? previousTrip.leaving : target.classic || target.away ? null : Hub.hub.leaving ?? (devLine || null);
|
|
2621
|
+
const leavingUntil = previousTrip ? previousTrip.leavingUntil : startedAt + LEAVING_MS;
|
|
2622
|
+
// The toast as the trip began: one set after this (feedback during the trip) wins over the line.
|
|
2623
|
+
const toastAtStart = previousTrip?.toastAtStart ?? this.toast;
|
|
2624
|
+
this.leavingToast = null;
|
|
1602
2625
|
this.tripCount += 1;
|
|
1603
2626
|
this.trip = {
|
|
1604
2627
|
n: this.tripCount,
|
|
1605
2628
|
target,
|
|
1606
2629
|
phase: 'opening',
|
|
1607
2630
|
from: this.scenePath,
|
|
1608
|
-
startedAt
|
|
2631
|
+
startedAt,
|
|
2632
|
+
leaving,
|
|
2633
|
+
leavingUntil,
|
|
2634
|
+
toastAtStart,
|
|
1609
2635
|
cam0: cam ? { x: cam.position.x, y: cam.position.y, z: cam.position.z } : null,
|
|
1610
2636
|
heapBefore: heapMB(),
|
|
1611
2637
|
marks: {},
|
|
1612
2638
|
};
|
|
2639
|
+
if (this.pendingEnd !== null) {
|
|
2640
|
+
this.endLeaving ??= { leaving, leavingUntil, toastAtStart };
|
|
2641
|
+
}
|
|
1613
2642
|
scene.persistent.hubArriving = target.arrive;
|
|
1614
2643
|
}
|
|
1615
2644
|
|
|
2645
|
+
setTripCover(alpha, trip) {
|
|
2646
|
+
if (trip.leaving && !trip.shut) {
|
|
2647
|
+
this.chrome.setCover(alpha, trip.target.title, trip.leaving);
|
|
2648
|
+
} else {
|
|
2649
|
+
this.chrome.setCover(alpha, trip.target.title);
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
showLeaving(scene, trip, now) {
|
|
2654
|
+
if (!trip.leaving || trip.shut || trip.lost || trip.timedOut || now >= trip.leavingUntil) {
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
const r = scene.persistent.hubResult;
|
|
2658
|
+
const back = trip.target.arrive?.returning && r ? `Back from ${resultLine(r)}` : '';
|
|
2659
|
+
// Capture once: later feedback must stay ahead, even on another reveal frame.
|
|
2660
|
+
this.leavingToast ??= { previousToast: trip.toastAtStart ?? this.toast, until: trip.leavingUntil };
|
|
2661
|
+
this.leavingToast.text = back ? `${back.slice(0, 80)} · ${trip.leaving}` : trip.leaving;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
1616
2664
|
stepTrip(scene, mp, local, now) {
|
|
1617
2665
|
const trip = this.trip;
|
|
1618
2666
|
const elapsed = now - trip.startedAt;
|
|
@@ -1621,7 +2669,7 @@ class HubSystem {
|
|
|
1621
2669
|
const t = clamp01(elapsed / OPEN_MS);
|
|
1622
2670
|
const door = trip.target.exitDoor ? scene.getActor(trip.target.exitDoor) : null;
|
|
1623
2671
|
if (door) {
|
|
1624
|
-
this.swingDoor(door, ease(t));
|
|
2672
|
+
this.swingDoor(door, ease(t), scene);
|
|
1625
2673
|
}
|
|
1626
2674
|
if (cam && trip.cam0) {
|
|
1627
2675
|
const e = ease(t);
|
|
@@ -1647,7 +2695,7 @@ class HubSystem {
|
|
|
1647
2695
|
cam.lookAt(lt.x, lt.y + 0.8, lt.z);
|
|
1648
2696
|
}
|
|
1649
2697
|
}
|
|
1650
|
-
this.
|
|
2698
|
+
this.setTripCover(clamp01((t - 0.4) / 0.6), trip);
|
|
1651
2699
|
if (t >= 1 && trip.target.classic) {
|
|
1652
2700
|
this.stepClassic(scene, trip, mp, now);
|
|
1653
2701
|
return;
|
|
@@ -1661,7 +2709,7 @@ class HubSystem {
|
|
|
1661
2709
|
const hubJoin = trip.target.join?.mode === 'hub' && typeof mp.joinState === 'function';
|
|
1662
2710
|
// A hub join's messages wait for its scene: the destination's WORLD
|
|
1663
2711
|
// must place this player in the destination, not the place it left.
|
|
1664
|
-
mp.switchSession(scene, trip.target.join, { quiet: true, hold: hubJoin });
|
|
2712
|
+
mp.switchSession(scene, pongJoin(trip.target.join, Hub.deck.pongTimeoutMs), { quiet: true, hold: hubJoin });
|
|
1665
2713
|
this.helloNet = null;
|
|
1666
2714
|
// A hub join is the host's trip: nothing of the destination is
|
|
1667
2715
|
// mounted until the host has committed it, so a refused join leaves
|
|
@@ -1675,11 +2723,27 @@ class HubSystem {
|
|
|
1675
2723
|
return;
|
|
1676
2724
|
}
|
|
1677
2725
|
if (trip.phase === 'away') {
|
|
1678
|
-
this.
|
|
2726
|
+
this.setTripCover(1, trip);
|
|
2727
|
+
return;
|
|
2728
|
+
}
|
|
2729
|
+
if (trip.phase === 'retrying-door') {
|
|
2730
|
+
this.setTripCover(1, trip);
|
|
2731
|
+
if (now < trip.retryDoorAt) {return;}
|
|
2732
|
+
if (!trip.target.pending) {
|
|
2733
|
+
// The refused nonce is spent. Give it back before acquiring again;
|
|
2734
|
+
// never replay it or add another ticket/depth to this same trip.
|
|
2735
|
+
this.cancelHub();
|
|
2736
|
+
trip.target.pending = this.resolveHub(scene, () => hubGo(trip.target.retryDoor, trip.target.retryOwner));
|
|
2737
|
+
trip.target.pendingFrom = now;
|
|
2738
|
+
}
|
|
2739
|
+
if (!this.contentReady(scene, trip, now)) {return;}
|
|
2740
|
+
mp.switchSession(scene, pongJoin(trip.target.join, Hub.deck.pongTimeoutMs), { quiet: true, hold: true });
|
|
2741
|
+
this.helloNet = null;
|
|
2742
|
+
trip.phase = 'committing';
|
|
1679
2743
|
return;
|
|
1680
2744
|
}
|
|
1681
2745
|
if (trip.phase === 'committing') {
|
|
1682
|
-
this.
|
|
2746
|
+
this.setTripCover(1, trip);
|
|
1683
2747
|
const state = mp.joinState();
|
|
1684
2748
|
// 'lost' was committed too: the loading phase recovers from it.
|
|
1685
2749
|
if (state === 'joined' || state === 'lost') {
|
|
@@ -1688,12 +2752,21 @@ class HubSystem {
|
|
|
1688
2752
|
per.hubDepth = Math.max(0, (per.hubDepth ?? 0) + (trip.target.hubStep ?? 0));
|
|
1689
2753
|
this.mount(scene, trip, now);
|
|
1690
2754
|
} else if (state === 'failed') {
|
|
2755
|
+
const age = now - trip.target.acquiredAt;
|
|
2756
|
+
if (trip.target.retryDoor && !trip.doorRetried && mp.joinFailure?.closeCode === 4404 &&
|
|
2757
|
+
mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <= 5000) {
|
|
2758
|
+
trip.doorRetried = true;
|
|
2759
|
+
trip.retryDoorAt = now + 2500;
|
|
2760
|
+
trip.phase = 'retrying-door';
|
|
2761
|
+
console.log(`[hub-door-retry] ${JSON.stringify({ door: trip.target.retryDoor, reason: 'not_running', attempt: 1, acquiredMs: Math.round(age), delayMs: 2500 })}`);
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
1691
2764
|
this.uncommitted(scene, trip, now);
|
|
1692
2765
|
}
|
|
1693
2766
|
return;
|
|
1694
2767
|
}
|
|
1695
2768
|
if (trip.phase === 'loading') {
|
|
1696
|
-
this.
|
|
2769
|
+
this.setTripCover(1, trip);
|
|
1697
2770
|
if (scene.mountError) {
|
|
1698
2771
|
this.mountFailed(scene, trip, now);
|
|
1699
2772
|
return;
|
|
@@ -1732,7 +2805,7 @@ class HubSystem {
|
|
|
1732
2805
|
this.faceArrival(scene);
|
|
1733
2806
|
const door = trip.target.arriveDoor ? scene.getActor(doorActor(scene, trip.target.arriveDoor)) : null;
|
|
1734
2807
|
if (door) {
|
|
1735
|
-
this.swingDoor(door, 1);
|
|
2808
|
+
this.swingDoor(door, 1, scene);
|
|
1736
2809
|
}
|
|
1737
2810
|
const lt = local?.components.Transform;
|
|
1738
2811
|
const base = door ? (this.doorBase.get(door.id) ?? door.components.Transform) : null;
|
|
@@ -1744,10 +2817,14 @@ class HubSystem {
|
|
|
1744
2817
|
// player came through, and the door swings shut behind them.
|
|
1745
2818
|
const t = clamp01((now - trip.revealAt) / REVEAL_MS);
|
|
1746
2819
|
trip.marks.firstFrame ??= now;
|
|
1747
|
-
|
|
2820
|
+
const cover = 1 - clamp01(t / 0.6);
|
|
2821
|
+
this.setTripCover(cover, trip);
|
|
2822
|
+
if (cover <= 0.05) {
|
|
2823
|
+
this.showLeaving(scene, trip, now);
|
|
2824
|
+
}
|
|
1748
2825
|
const door = trip.target.arriveDoor ? scene.getActor(doorActor(scene, trip.target.arriveDoor)) : null;
|
|
1749
2826
|
if (door) {
|
|
1750
|
-
this.swingDoor(door, 1 - ease(clamp01((t - 0.35) / 0.65)));
|
|
2827
|
+
this.swingDoor(door, 1 - ease(clamp01((t - 0.35) / 0.65)), scene);
|
|
1751
2828
|
}
|
|
1752
2829
|
const lt = local?.components.Transform;
|
|
1753
2830
|
const follow = local && cam ? followCamera(scene, local) : null;
|
|
@@ -1772,7 +2849,7 @@ class HubSystem {
|
|
|
1772
2849
|
return true;
|
|
1773
2850
|
}
|
|
1774
2851
|
trip.marks.covered ??= now;
|
|
1775
|
-
this.
|
|
2852
|
+
this.setTripCover(1, trip);
|
|
1776
2853
|
// A retried way back has its own deadline, from when it was asked again.
|
|
1777
2854
|
if (!pending.done && now - (trip.target.pendingFrom ?? trip.startedAt) < LOADING_LIMIT_MS) {
|
|
1778
2855
|
return false;
|
|
@@ -1781,8 +2858,8 @@ class HubSystem {
|
|
|
1781
2858
|
// back refused as unavailable is asked once more under the cover: ghost
|
|
1782
2859
|
// refuses one while the place's session is between pins, which passes in
|
|
1783
2860
|
// moments. Only then does the door stay shut.
|
|
1784
|
-
if (pending.done && pending.code
|
|
1785
|
-
trip.target.stuck =
|
|
2861
|
+
if (pending.done && joinErrorText(pending.code)) {
|
|
2862
|
+
trip.target.stuck = joinErrorText(pending.code);
|
|
1786
2863
|
} else if (pending.done && pending.error === 'unavailable' && trip.target.retryBack && (trip.target.attempt ?? 0) < 1) {
|
|
1787
2864
|
trip.target.attempt = (trip.target.attempt ?? 0) + 1;
|
|
1788
2865
|
trip.target.pending = trip.target.retryBack();
|
|
@@ -1818,11 +2895,13 @@ class HubSystem {
|
|
|
1818
2895
|
// Acquired and loaded, and still not taken.
|
|
1819
2896
|
this.cancelHub();
|
|
1820
2897
|
}
|
|
1821
|
-
this.
|
|
2898
|
+
if (trip.phase === 'retrying-door') {this.uncommitted(scene, trip, now);}
|
|
2899
|
+
else {this.shutDoor(scene, trip, error, now);}
|
|
1822
2900
|
return false;
|
|
1823
2901
|
}
|
|
1824
2902
|
trip.marks.resolved = now;
|
|
1825
2903
|
if (pending.join) {
|
|
2904
|
+
trip.target.acquiredAt = pending.acquiredAt;
|
|
1826
2905
|
trip.target.join = pending.join;
|
|
1827
2906
|
}
|
|
1828
2907
|
if (pending.stayed) {
|
|
@@ -1883,7 +2962,7 @@ class HubSystem {
|
|
|
1883
2962
|
scene.mountError = null;
|
|
1884
2963
|
this.trip = null;
|
|
1885
2964
|
this.toast = { text: 'That door is stuck', until: now + TOAST_MS };
|
|
1886
|
-
this.back(scene, { covered: true });
|
|
2965
|
+
this.back(scene, { covered: true, previousTrip: trip });
|
|
1887
2966
|
}
|
|
1888
2967
|
|
|
1889
2968
|
// The host committed this hub trip, and the session it led to closed before
|
|
@@ -1900,7 +2979,7 @@ class HubSystem {
|
|
|
1900
2979
|
lostJoin(scene, trip, mp, now) {
|
|
1901
2980
|
const tries = trip.target.lost ?? 0;
|
|
1902
2981
|
console.warn(`[hub-door] the session ${trip.target.deck ?? trip.target.scene} led to closed before placing this player`);
|
|
1903
|
-
if (tries >= LOST_TRIES_MAX || mp.joinError
|
|
2982
|
+
if (tries >= LOST_TRIES_MAX || joinErrorText(mp.joinError)) {
|
|
1904
2983
|
trip.lost = 'the session closed before placing this player';
|
|
1905
2984
|
return false;
|
|
1906
2985
|
}
|
|
@@ -1911,7 +2990,7 @@ class HubSystem {
|
|
|
1911
2990
|
trip.target.join = rejoin;
|
|
1912
2991
|
Hub.clear();
|
|
1913
2992
|
// Held, as the hub join was, until the destination's scene is in.
|
|
1914
|
-
mp.switchSession(scene, rejoin, { quiet: true, hold: trip.marks.sceneLoaded === undefined });
|
|
2993
|
+
mp.switchSession(scene, pongJoin(rejoin, Hub.deck.pongTimeoutMs), { quiet: true, hold: trip.marks.sceneLoaded === undefined });
|
|
1915
2994
|
this.helloNet = null;
|
|
1916
2995
|
trip.loadingFrom = now;
|
|
1917
2996
|
if (trip.target.stuck) {
|
|
@@ -1923,7 +3002,7 @@ class HubSystem {
|
|
|
1923
3002
|
this.toast = { text: trip.target.stuck ?? 'That door is stuck', until: now + TOAST_MS };
|
|
1924
3003
|
// Both counts ride along, so a way that alternates between a lost join
|
|
1925
3004
|
// and an uncommitted one still runs out.
|
|
1926
|
-
this.back(scene, { covered: true, attempt: trip.target.attempt ?? 0, lost: tries + 1 });
|
|
3005
|
+
this.back(scene, { covered: true, attempt: trip.target.attempt ?? 0, lost: tries + 1, previousTrip: trip });
|
|
1927
3006
|
if (!this.trip) {
|
|
1928
3007
|
this.chrome.setCover(0);
|
|
1929
3008
|
}
|
|
@@ -1970,13 +3049,13 @@ class HubSystem {
|
|
|
1970
3049
|
title: '',
|
|
1971
3050
|
exitDoor: null,
|
|
1972
3051
|
arrive: { door: null, party: 1, returning: false },
|
|
1973
|
-
});
|
|
3052
|
+
}, trip);
|
|
1974
3053
|
if (this.trip) {
|
|
1975
3054
|
this.trip.startedAt -= OPEN_MS;
|
|
1976
3055
|
}
|
|
1977
3056
|
return;
|
|
1978
3057
|
}
|
|
1979
|
-
this.back(scene, { covered: true });
|
|
3058
|
+
this.back(scene, { covered: true, previousTrip: trip });
|
|
1980
3059
|
return;
|
|
1981
3060
|
}
|
|
1982
3061
|
if (trip.target.pushedTicket) {
|
|
@@ -1995,20 +3074,20 @@ class HubSystem {
|
|
|
1995
3074
|
exitDoor: null,
|
|
1996
3075
|
arriveDoor: ticket.door,
|
|
1997
3076
|
arrive: { door: ticket.door, party: ticket.party ?? 1, returning: true },
|
|
1998
|
-
});
|
|
3077
|
+
}, trip);
|
|
1999
3078
|
if (this.trip) {
|
|
2000
3079
|
this.trip.startedAt -= OPEN_MS;
|
|
2001
3080
|
}
|
|
2002
3081
|
return;
|
|
2003
3082
|
}
|
|
2004
|
-
this.back(scene, { covered: true });
|
|
3083
|
+
this.back(scene, { covered: true, previousTrip: trip });
|
|
2005
3084
|
return;
|
|
2006
3085
|
}
|
|
2007
3086
|
if (trip.target.ticket) {
|
|
2008
3087
|
per.hubTickets.push(trip.target.ticket);
|
|
2009
3088
|
}
|
|
2010
3089
|
if ((trip.target.attempt ?? 0) < 1) {
|
|
2011
|
-
this.back(scene, { covered: true, attempt: (trip.target.attempt ?? 0) + 1, lost: trip.target.lost ?? 0, away: trip.target.away ?? null });
|
|
3090
|
+
this.back(scene, { covered: true, attempt: (trip.target.attempt ?? 0) + 1, lost: trip.target.lost ?? 0, away: trip.target.away ?? null, previousTrip: trip });
|
|
2012
3091
|
}
|
|
2013
3092
|
if (!this.trip && trip.target.away) {
|
|
2014
3093
|
// The way back from a classic deck did not commit: still away.
|
|
@@ -2034,7 +3113,7 @@ class HubSystem {
|
|
|
2034
3113
|
// Armed until the player is out of the ended session (settleEnd): a
|
|
2035
3114
|
// way back that fails is tried again a pause later.
|
|
2036
3115
|
this.pendingEnd = now + END_PAUSE_MS;
|
|
2037
|
-
this.back(scene);
|
|
3116
|
+
this.back(scene, { covered: this.endCovered === true });
|
|
2038
3117
|
}
|
|
2039
3118
|
}
|
|
2040
3119
|
|
|
@@ -2047,6 +3126,7 @@ class HubSystem {
|
|
|
2047
3126
|
settleEnd(scene) {
|
|
2048
3127
|
if (this.pendingEnd !== null && sessionKey(scene) !== this.endSession) {
|
|
2049
3128
|
this.pendingEnd = null;
|
|
3129
|
+
this.endLeaving = null;
|
|
2050
3130
|
}
|
|
2051
3131
|
}
|
|
2052
3132
|
|
|
@@ -2055,7 +3135,10 @@ class HubSystem {
|
|
|
2055
3135
|
// PI - camAngle.
|
|
2056
3136
|
faceArrival(scene) {
|
|
2057
3137
|
if (Hub.hub.arrivedFacing !== null) {
|
|
2058
|
-
|
|
3138
|
+
if (Hub.deck.soundscape?.ui === true && !this.trip && !Hub.hub.faced) {
|
|
3139
|
+
this.soundscape?.uiArrival(performance.now());
|
|
3140
|
+
}
|
|
3141
|
+
faceArrivalCamera(scene, Hub.hub.arrivedFacing);
|
|
2059
3142
|
// Under the engine's orbit camera key the character's facing is not
|
|
2060
3143
|
// PI - camAngle: it is asked for.
|
|
2061
3144
|
if (scene.cameraControl === 'orbit') {
|
|
@@ -2067,11 +3150,17 @@ class HubSystem {
|
|
|
2067
3150
|
|
|
2068
3151
|
finishTrip(scene, trip) {
|
|
2069
3152
|
this.trip = null;
|
|
3153
|
+
if (Hub.deck.soundscape?.ui === true && !trip.shut && !trip.lost && !trip.timedOut && Hub.hub.arrivedFacing !== null) {
|
|
3154
|
+
this.soundscape?.uiArrival(performance.now());
|
|
3155
|
+
}
|
|
2070
3156
|
this.chrome.setCover(0);
|
|
3157
|
+
this.showLeaving(scene, trip, performance.now());
|
|
2071
3158
|
// A new place or layer: ask again who is elsewhere.
|
|
2072
3159
|
this.friends = null;
|
|
2073
3160
|
this.friendsAll = null;
|
|
2074
3161
|
this.friendsAt = -Infinity;
|
|
3162
|
+
this.friendsGameAt = -Infinity;
|
|
3163
|
+
this.friendsGameWarm = false;
|
|
2075
3164
|
const m = trip.marks;
|
|
2076
3165
|
const start = trip.startedAt;
|
|
2077
3166
|
const record = {
|
|
@@ -2106,22 +3195,37 @@ class HubSystem {
|
|
|
2106
3195
|
(globalThis.__hubTrips ??= []).push(record);
|
|
2107
3196
|
console.log(`[hub-trip] ${JSON.stringify(record)}`);
|
|
2108
3197
|
const r = scene.persistent.hubResult;
|
|
2109
|
-
if (trip.target.arrive?.returning && r) {
|
|
3198
|
+
if (trip.target.arrive?.returning && r && (!this.leavingToast || this.toast === this.leavingToast.previousToast)) {
|
|
2110
3199
|
this.toast = { text: `Back from ${resultLine(r)}`, until: performance.now() + TOAST_MS };
|
|
3200
|
+
// The arrival result is already part of the leaving toast, not new feedback.
|
|
3201
|
+
if (this.leavingToast) {
|
|
3202
|
+
this.leavingToast.previousToast = this.toast;
|
|
3203
|
+
}
|
|
2111
3204
|
}
|
|
2112
|
-
if (Hub.deck.
|
|
3205
|
+
if (Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
3206
|
+
this.yourGames().returned(trip.target.arrive.door, r);
|
|
3207
|
+
}
|
|
3208
|
+
if (Hub.deck.cues && !Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
2113
3209
|
// Cues: a next step, put once the player is back in the town, whether
|
|
2114
3210
|
// or not the game had a result to tell.
|
|
2115
3211
|
this.againAsk = { door: trip.target.arrive.door, until: performance.now() + AGAIN_ASK_MS };
|
|
2116
3212
|
}
|
|
2117
3213
|
}
|
|
2118
3214
|
|
|
3215
|
+
yourGames() {
|
|
3216
|
+
this.yours ??= makeYours(castleSdk.Hub, castleSdk.User, (text) => {
|
|
3217
|
+
this.toast = { text, until: performance.now() + TOAST_MS };
|
|
3218
|
+
});
|
|
3219
|
+
return this.yours;
|
|
3220
|
+
}
|
|
3221
|
+
|
|
2119
3222
|
// Swing a door leaf open by `amount` (0 shut, 1 open) about its left edge,
|
|
2120
3223
|
// in the door's own frame, so a door turned to face any way opens the same.
|
|
2121
|
-
swingDoor(door, amount) {
|
|
3224
|
+
swingDoor(door, amount, scene) {
|
|
2122
3225
|
if (isCabinet(door)) {
|
|
2123
3226
|
return;
|
|
2124
3227
|
}
|
|
3228
|
+
scene?.touch?.(door.id);
|
|
2125
3229
|
const t = door.components.Transform;
|
|
2126
3230
|
if (!this.doorBase.has(door.id)) {
|
|
2127
3231
|
this.doorBase.set(door.id, { x: t.x, z: t.z, rotationY: t.rotationY ?? 0 });
|
|
@@ -2135,6 +3239,37 @@ class HubSystem {
|
|
|
2135
3239
|
t.rotationY = base.rotationY + amount * DOOR_SWING_DEG;
|
|
2136
3240
|
}
|
|
2137
3241
|
|
|
3242
|
+
// A phrase still draws its bubble/feed even when it cannot offer a card.
|
|
3243
|
+
offerPlay(scene, local, now, playerId, name, door) {
|
|
3244
|
+
let stranger = false;
|
|
3245
|
+
if (Hub.deck.playCards) {
|
|
3246
|
+
const userId = scene.multiplayer?.net?.userId?.(playerId);
|
|
3247
|
+
const friend = userId && this.friendsAll?.some((f) => String(f.userId) === String(userId));
|
|
3248
|
+
stranger = !friend && !Hub.hub.party.members?.includes(playerId);
|
|
3249
|
+
if (stranger) {
|
|
3250
|
+
// Displayed avatars deliberately lag; use the newest received pose.
|
|
3251
|
+
const pose = scene.multiplayer?.players?.get(playerId)?.samples?.at(-1)?.pose;
|
|
3252
|
+
const lt = local?.components.Transform;
|
|
3253
|
+
if (!pose || !lt || !(Math.hypot(pose[0] - lt.x, pose[2] - lt.z) <= PLAY_NEAR_M)) {
|
|
3254
|
+
return;
|
|
3255
|
+
}
|
|
3256
|
+
// Never replace another live stranger card, including later events
|
|
3257
|
+
// in this frame. Suppressed events spend no cooldown.
|
|
3258
|
+
const current = this.playAsk;
|
|
3259
|
+
const currentCard = current ? { key: `play:${current.from}:${current.door}:${current.until}`, kind: 'play' } : null;
|
|
3260
|
+
if (current?.stranger && (now < current.until || this.askSlot.known(currentCard))) {
|
|
3261
|
+
return;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
const key = Hub.deck.playCards && stranger ? playerId : `${playerId}:${door}`;
|
|
3266
|
+
if ((this.playAsked.get(key) ?? -Infinity) > now - PLAY_ASK_AGAIN_MS) {
|
|
3267
|
+
return;
|
|
3268
|
+
}
|
|
3269
|
+
this.playAsked.set(key, now);
|
|
3270
|
+
this.playAsk = { from: playerId, name, door, until: now + PLAY_ASK_MS, ...(Hub.deck.playCards ? { stranger } : {}) };
|
|
3271
|
+
}
|
|
3272
|
+
|
|
2138
3273
|
drawChrome(scene, local, now) {
|
|
2139
3274
|
const chrome = this.chrome;
|
|
2140
3275
|
const place = Hub.hub.place;
|
|
@@ -2146,18 +3281,29 @@ class HubSystem {
|
|
|
2146
3281
|
const inGame = Boolean(place?.result);
|
|
2147
3282
|
// Away in a classic deck, the cover is down and Back is the only control.
|
|
2148
3283
|
const away = this.trip?.phase === 'away';
|
|
3284
|
+
const hostTrail = scene.persistent.hubDepth > 0;
|
|
2149
3285
|
chrome.showBack(
|
|
2150
|
-
//
|
|
2151
|
-
//
|
|
2152
|
-
(away || (idle && this.pendingEnd === null)) &&
|
|
2153
|
-
ticket?.title ?? 'Again',
|
|
3286
|
+
// Old Android landscape hosts draw Exit deck, so keep a way back into
|
|
3287
|
+
// town. Hosts advertising their landscape Back retain sole ownership.
|
|
3288
|
+
(away || (idle && this.pendingEnd === null)) && (hostTrail ? place !== null && kitBackNeeded() : inGame || Boolean(ticket)),
|
|
3289
|
+
ticket?.title ?? (hostTrail && kitBackNeeded() ? 'Back' : 'Again'),
|
|
2154
3290
|
);
|
|
2155
|
-
|
|
2156
|
-
const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking();
|
|
3291
|
+
const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking() && !this.carded;
|
|
2157
3292
|
const town = free && !inGame;
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
3293
|
+
const weakest = this.weakestTier?.active && this.weakestTier.profile === 'weakest';
|
|
3294
|
+
if (!weakest) {this.drawPanelControls(scene, now, place, idle, inGame, free, town);}
|
|
3295
|
+
else if (Hub.deck.yourGames) {this.yourGames().frame(town, Hub.hub.yours, now);}
|
|
3296
|
+
const askAt = local?.components?.Transform ?? null;
|
|
3297
|
+
const askPads = askPadsAt(scene, askAt, Hub.hub.hidden);
|
|
3298
|
+
this.askSlot.frame(askAt, askPads, now);
|
|
3299
|
+
// Prompt and editor shields sit above the shared question card, and a
|
|
3300
|
+
// hidden or suspended page draws none. Do not start a lease behind
|
|
3301
|
+
// either, but keep aging a lease that was already shown.
|
|
3302
|
+
const askVisible = town && !this.askInput && !this.menuInput && !this.actionInput && this.decor?.opened() !== true &&
|
|
3303
|
+
chrome.askShowable?.() !== false;
|
|
3304
|
+
const ask = askVisible ? this.ask(now) : null;
|
|
3305
|
+
chrome.setAsk?.(askVisible ? this.askSlot.display(ask, askAt, askPads, now) : null);
|
|
3306
|
+
this.retireExpiredAsk(ask);
|
|
2161
3307
|
this.startBeside(scene, local, town, now);
|
|
2162
3308
|
// A friend or party member went through a door: say so, and offer to follow.
|
|
2163
3309
|
// Kept until the question can be put (not while talking to an NPC): the
|
|
@@ -2200,17 +3346,7 @@ class HubSystem {
|
|
|
2200
3346
|
selfId,
|
|
2201
3347
|
(playerId) => net?.others?.().get(playerId) ?? null,
|
|
2202
3348
|
(playerId) => this.together.ping(playerId, now),
|
|
2203
|
-
|
|
2204
|
-
// Once from a player for a door: saying it again neither keeps the
|
|
2205
|
-
// card up nor brings it back after Not now, until the pause has passed.
|
|
2206
|
-
(playerId, name, door) => {
|
|
2207
|
-
const key = `${playerId}:${door}`;
|
|
2208
|
-
if ((this.playAsked.get(key) ?? -Infinity) > now - PLAY_ASK_AGAIN_MS) {
|
|
2209
|
-
return;
|
|
2210
|
-
}
|
|
2211
|
-
this.playAsked.set(key, now);
|
|
2212
|
-
this.playAsk = { from: playerId, name, door, until: now + PLAY_ASK_MS };
|
|
2213
|
-
},
|
|
3349
|
+
(playerId, name, door) => this.offerPlay(scene, local, now, playerId, name, door),
|
|
2214
3350
|
);
|
|
2215
3351
|
// Cues: someone new in the roster may be one this player can chat with,
|
|
2216
3352
|
// so the host is asked soon, not at the end of its idle wait. In a town
|
|
@@ -2246,6 +3382,7 @@ class HubSystem {
|
|
|
2246
3382
|
continue;
|
|
2247
3383
|
}
|
|
2248
3384
|
const from = message.mine ? { playerId: selfId, username: 'You' } : byUser.get(String(message.fromUserId));
|
|
3385
|
+
if (Hub.deck.quality && !message.mine && from?.playerId) {noteQualityInteraction(scene, from.playerId, now);}
|
|
2249
3386
|
this.say.chat(now, from?.playerId ?? null, from?.username ?? message.fromUsername ?? 'Someone', message, CHAT_BUBBLE_MS);
|
|
2250
3387
|
}
|
|
2251
3388
|
const reach = (this.chat.peers ?? []).map((userId) => byUser.get(userId)?.username).filter(Boolean);
|
|
@@ -2270,42 +3407,74 @@ class HubSystem {
|
|
|
2270
3407
|
chatPart.placeholder = chatPart.input ? CHAT_HINT.on : CHAT_HINT.off;
|
|
2271
3408
|
chatPart.label = chatPart.input ? CHAT_HINT.label : CHAT_HINT.why;
|
|
2272
3409
|
}
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
3410
|
+
let panels = true;
|
|
3411
|
+
if (weakest) {
|
|
3412
|
+
// Prompts settle before the decision; panels still precede world placement.
|
|
3413
|
+
this.drawNearPrompt(scene, local, town);
|
|
3414
|
+
this.hudRate ??= makeHudRate();
|
|
3415
|
+
// A new door offer must replace its Go buttons at once: a stale one
|
|
3416
|
+
// still jumps. HUD and toast copy can confirm an earlier input, so their
|
|
3417
|
+
// text wakes the pass too; only the timer's ticking waits.
|
|
3418
|
+
if (this.hudDoors !== Hub.hub.doors) {
|
|
3419
|
+
this.hudDoors = Hub.hub.doors;
|
|
3420
|
+
this.hudDoorsSeen = (this.hudDoorsSeen ?? 0) + 1;
|
|
3421
|
+
}
|
|
3422
|
+
const spec = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
3423
|
+
const leaving = this.leavingToast && now < this.leavingToast.until && this.toast === this.leavingToast.previousToast;
|
|
3424
|
+
const toastText = leaving ? this.leavingToast.text : now < this.toast.until ? this.toast.text : '';
|
|
3425
|
+
panels = this.hudRate.frame(true, JSON.stringify([chrome.hudPromptSignature?.(), Hub.hub.prompts,
|
|
3426
|
+
place?.id, this.trip?.phase, this.pendingEnd !== null, this.carded, this.decor?.opened() === true,
|
|
3427
|
+
Boolean(this.askInput), Boolean(this.menuInput), Boolean(this.actionInput),
|
|
3428
|
+
this.hudDoorsSeen, Hub.hub.party.members?.length ?? 0, spec ? { ...spec, timer: undefined } : null,
|
|
3429
|
+
toastText, joinErrorText(scene.multiplayer?.joinError)]));
|
|
3430
|
+
if (panels) {this.drawPanelControls(scene, now, place, idle, inGame, free, town, false);}
|
|
3431
|
+
} else {
|
|
3432
|
+
this.hudRate?.frame(false);
|
|
2289
3433
|
}
|
|
2290
|
-
|
|
2291
|
-
const
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
}
|
|
2296
|
-
|
|
3434
|
+
if (panels) {chrome.setSay?.(free ? { reactions: REACTIONS, phrases: this.say.phrases(), chat: chatPart } : null);}
|
|
3435
|
+
const moderation = chatModerationEnabled(scene);
|
|
3436
|
+
if (moderation !== (this.chatModeration === true)) {
|
|
3437
|
+
chrome.setChatModeration?.(moderation);
|
|
3438
|
+
this.chatModeration = moderation;
|
|
3439
|
+
}
|
|
3440
|
+
if (panels) {chrome.setFeed?.(idle && place !== null && !this.carded ? this.say.feed() : []);}
|
|
3441
|
+
if (!weakest) {this.drawNearPrompt(scene, local, town);}
|
|
3442
|
+
const joinText = joinErrorText(scene.multiplayer?.joinError);
|
|
3443
|
+
if (joinText) {
|
|
3444
|
+
this.toast = { text: joinText, until: now + TOAST_MS };
|
|
2297
3445
|
}
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
3446
|
+
|
|
3447
|
+
if (panels) {
|
|
3448
|
+
const spec = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
3449
|
+
let timer = null;
|
|
3450
|
+
if (spec?.timer?.since !== undefined) {
|
|
3451
|
+
timer = Math.max(0, (Hub.simNow() - spec.timer.since) / 1000);
|
|
3452
|
+
} else if (spec?.timer?.until !== undefined) {
|
|
3453
|
+
timer = Math.max(0, (spec.timer.until - Hub.simNow()) / 1000);
|
|
3454
|
+
}
|
|
3455
|
+
// A place that asks (`hud.clear`, v1.26) has its HUD kept short and its
|
|
3456
|
+
// labels kept out from under it; any other is drawn as it always was.
|
|
3457
|
+
if (place?.hud?.clear === true || this.hudClear) {
|
|
3458
|
+
this.hudClear = place?.hud?.clear === true;
|
|
3459
|
+
chrome.setHudClear?.(this.hudClear);
|
|
3460
|
+
}
|
|
3461
|
+
chrome.setHud(idle || this.trip?.phase === 'revealing' ? spec : null, timer);
|
|
2303
3462
|
}
|
|
2304
|
-
chrome.setHud(idle || this.trip?.phase === 'revealing' ? spec : null, timer);
|
|
2305
3463
|
|
|
2306
3464
|
const cam = scene.three?.camera;
|
|
2307
3465
|
const view = { w: window.innerWidth, h: window.innerHeight };
|
|
3466
|
+
if (worldLabelFocus(Hub.deck.labels, inGame, hostTrail || Boolean(ticket))) {
|
|
3467
|
+
const canvas = this.frameCanvas ?? scene.three?.renderer?.domElement?.getBoundingClientRect?.();
|
|
3468
|
+
if (canvas?.width > 0 && canvas.height > 0) {view.world = canvas;}
|
|
3469
|
+
}
|
|
3470
|
+
chrome.setWorldViewport?.(view.world ?? null);
|
|
2308
3471
|
const labels = [];
|
|
3472
|
+
const padOccupancy = scene.data?.engine?.hubPadOccupancy === true;
|
|
3473
|
+
const crowdNames = scene.data?.engine?.hubCrowdNames === true;
|
|
3474
|
+
if (crowdNames && cam?.parent === null && cam.matrixWorldAutoUpdate === true) {
|
|
3475
|
+
cam.updateMatrixWorld();
|
|
3476
|
+
}
|
|
3477
|
+
let worldLabelCount = 0;
|
|
2309
3478
|
// This player's goals: scene actors a `goal` label points at.
|
|
2310
3479
|
const goals = [];
|
|
2311
3480
|
if (cam && idle) {
|
|
@@ -2316,10 +3485,10 @@ class HubSystem {
|
|
|
2316
3485
|
if (id === talkingWith && label.style === 'speech') {
|
|
2317
3486
|
continue;
|
|
2318
3487
|
}
|
|
2319
|
-
const at = scene.getActor(id)?.components.Transform;
|
|
3488
|
+
const at = goalAt(label, scene.getActor(id)?.components.Transform);
|
|
2320
3489
|
if (at && label.style === 'goal') {
|
|
2321
3490
|
// Where the place is sending this player (v1.13): a pointer, not a label.
|
|
2322
|
-
goals.push({ id, at,
|
|
3491
|
+
goals.push({ id, at, label });
|
|
2323
3492
|
} else if (at) {
|
|
2324
3493
|
// A sign is drawn at any distance in a town: a street's name, or a
|
|
2325
3494
|
// word the player must see from where they stand.
|
|
@@ -2329,39 +3498,105 @@ class HubSystem {
|
|
|
2329
3498
|
}
|
|
2330
3499
|
// In a town only what the player stands by is labelled (`attention.js`).
|
|
2331
3500
|
const lt = local?.components.Transform;
|
|
3501
|
+
let activePad = null;
|
|
3502
|
+
if (padOccupancy) {
|
|
3503
|
+
const active = placed.find(({ id, label }) => Object.hasOwn(Hub.hub.labelsMe, id) && scene.getActor(id)?.components.HubPad && occupancyText(label.text));
|
|
3504
|
+
if (active) {
|
|
3505
|
+
activePad = active.id;
|
|
3506
|
+
this.attention.plate = active.id;
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
2332
3509
|
const shown = place && !inGame && lt
|
|
2333
3510
|
? attend(
|
|
2334
3511
|
this.attention,
|
|
2335
3512
|
placed
|
|
2336
3513
|
.filter(({ always }) => !always)
|
|
2337
|
-
.map(({ id, at, label }) => ({ id, d: Math.hypot(at.x - lt.x, at.z - lt.z), speech: label.style === 'speech' })),
|
|
3514
|
+
.map(({ id, at, label }) => ({ id, d: id === activePad ? 0 : Math.hypot(at.x - lt.x, at.z - lt.z), speech: label.style === 'speech' })),
|
|
2338
3515
|
now,
|
|
2339
3516
|
)
|
|
2340
3517
|
: null;
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
3518
|
+
if (lt && worldLabelFocus(Hub.deck.labels, inGame, hostTrail || Boolean(ticket)) && chrome.measureLabel) {
|
|
3519
|
+
labels.push(...this.nearLabels(scene, placed, lt, cam, view, now, padOccupancy, true));
|
|
3520
|
+
} else if (shown && (Hub.deck.labels || padOccupancy) && chrome.measureLabel) {
|
|
3521
|
+
// `hub.labels: "near"` (v1.43): signs near the player only, no two
|
|
3522
|
+
// world labels overlapping, three at most (`labelsNear.js`).
|
|
3523
|
+
labels.push(...this.nearLabels(scene, placed, lt, cam, view, now, padOccupancy));
|
|
3524
|
+
} else {
|
|
3525
|
+
for (const { id, at, label, always } of placed) {
|
|
3526
|
+
const opacity = shown && !always ? shown.get(id) : 1;
|
|
3527
|
+
const screen = opacity ? project(cam, at.x, at.y + 1.6, at.z, view) : null;
|
|
3528
|
+
if (screen) {
|
|
3529
|
+
if (padOccupancy && chrome.measureLabel) {
|
|
3530
|
+
const speech = label.style === 'speech';
|
|
3531
|
+
const npc = label.npc === true;
|
|
3532
|
+
const pad = Boolean(scene.getActor(id)?.components.HubPad);
|
|
3533
|
+
const box = labelBox(screen.x, screen.y, chrome.measureLabel(label.text, speech, npc, pad), npc, view, chrome.hudClearBox?.() ?? null, chrome.hudPromptBox?.() ?? null);
|
|
3534
|
+
if (!box) {continue;}
|
|
3535
|
+
const item = chromeItem(id, label.text, speech, npc, box, opacity);
|
|
3536
|
+
if (Hub.deck.quality) {item.actorId = id;}
|
|
3537
|
+
if (pad) {item.padOccupancy = true;}
|
|
3538
|
+
labels.push(item);
|
|
3539
|
+
} else {
|
|
3540
|
+
labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity });
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
if (Hub.deck.quality) {
|
|
3546
|
+
const quality = lowQuality(scene);
|
|
3547
|
+
if (quality && lt) {
|
|
3548
|
+
const party = new Set((Hub.hub.party.members ?? []).map((id) => scene.multiplayer?.avatars?.actors?.get(id)));
|
|
3549
|
+
// Party world labels bypass numerical caps, including the ordinary
|
|
3550
|
+
// near-label slots. Door labels still go through their 12/14 m rule.
|
|
3551
|
+
for (const { id, at, label } of placed) {
|
|
3552
|
+
if (!party.has(id) || labels.some((item) => (item.actorId ?? item.id) === id)) {continue;}
|
|
3553
|
+
const screen = project(cam, at.x, at.y + 1.6, at.z, view);
|
|
3554
|
+
if (screen) {labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity: 1 });}
|
|
3555
|
+
}
|
|
3556
|
+
const capped = capWorldLabels(labels, placed, lt, quality.labels, party);
|
|
3557
|
+
labels.splice(0, labels.length, ...capped);
|
|
2346
3558
|
}
|
|
2347
3559
|
}
|
|
3560
|
+
worldLabelCount = labels.length;
|
|
2348
3561
|
}
|
|
2349
|
-
const
|
|
3562
|
+
const pointerView = view.world ? { w: view.world.width, h: view.world.height } : view;
|
|
3563
|
+
const pointers = cam && idle && place && !inGame && this.pendingEnd === null ? this.together.pointers(scene, local, cam, pointerView) : [];
|
|
2350
3564
|
const me = local?.components.Transform;
|
|
2351
3565
|
if (cam && me && this.pendingEnd === null) {
|
|
2352
|
-
// The nearest goals, each with how far it is.
|
|
2353
|
-
const near = goals.map((g) => ({ ...g, d: Math.hypot(g.at.x - me.x, g.at.z - me.z) }))
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
}
|
|
2358
|
-
|
|
3566
|
+
// The nearest drawable goals, each with how far it is.
|
|
3567
|
+
const near = goals.map((g) => ({ ...g, d: Math.hypot(g.at.x - me.x, g.at.z - me.z) }));
|
|
3568
|
+
pointers.push(...goalPointers(near, GOALS_MAX, (g) =>
|
|
3569
|
+
pointerAt(cam, pointerView, { x: g.at.x, y: g.at.y + 1.6, z: g.at.z }, `goal:${g.id}`, goalText(g.label, g.d, GOAL_NEAR_M)),
|
|
3570
|
+
));
|
|
3571
|
+
}
|
|
3572
|
+
const invitePointer = cam && idle && place?.invite === true && !inGame && this.pendingEnd === null ? this.invites?.pointer(scene) : null;
|
|
3573
|
+
if (invitePointer) {
|
|
3574
|
+
const { id, at } = invitePointer;
|
|
3575
|
+
pointers.unshift(pointerAt(cam, pointerView, { x: at.x, y: at.y + 1.9, z: at.z }, `invite:${id}`, 'Your friend'));
|
|
3576
|
+
}
|
|
3577
|
+
chrome.setPointers?.(pointers.map((point) => offsetWorldPoint(point, view)));
|
|
2359
3578
|
if (cam && idle) {
|
|
2360
3579
|
labels.push(...this.markItems(scene, local, cam, view));
|
|
2361
3580
|
labels.push(...this.idle.labels(scene, local, cam, view, project));
|
|
2362
3581
|
labels.push(...this.say.labels(scene, local, cam, view, project, scene.multiplayer?.net?.selfId?.() ?? null));
|
|
2363
3582
|
}
|
|
2364
|
-
|
|
3583
|
+
if (Hub.hub.place?.companion === true && cam && idle) {
|
|
3584
|
+
labels.push(...(this.companion?.labels(cam, view, project, now) ?? []));
|
|
3585
|
+
}
|
|
3586
|
+
if (!padOccupancy && !crowdNames) {chrome.setLabels(labels);}
|
|
3587
|
+
if (place?.companionChat) {
|
|
3588
|
+
const canTalk = cam && idle && this.pendingEnd === null && !this.talk.talking() && this.decor?.opened() !== true && !this.carded;
|
|
3589
|
+
chrome.setCompanionBadge?.(Boolean(canTalk && Hub.hub.companion?.c && place.companion === true && local), place.companionChat.name, () => this.talk.openCompanion(scene));
|
|
3590
|
+
this.companionTalkDrawn = true;
|
|
3591
|
+
chrome.setCompanionTalk?.(canTalk ? this.companion?.screen(cam, view, project) : null, place.companionChat.name, () => {
|
|
3592
|
+
this.companionTappedUntil = now + 3000;
|
|
3593
|
+
this.talk.openCompanion(scene);
|
|
3594
|
+
});
|
|
3595
|
+
} else if (this.companionTalkDrawn) {
|
|
3596
|
+
chrome.setCompanionBadge?.(false);
|
|
3597
|
+
chrome.setCompanionTalk(null);
|
|
3598
|
+
delete this.companionTalkDrawn;
|
|
3599
|
+
}
|
|
2365
3600
|
|
|
2366
3601
|
const lt = local?.components.Transform;
|
|
2367
3602
|
// The card of the cabinet this player stands nearest (v1.7).
|
|
@@ -2369,12 +3604,199 @@ class HubSystem {
|
|
|
2369
3604
|
const r = scene.persistent.hubResult;
|
|
2370
3605
|
const showRibbon = !inGame && idle && r && Date.now() - r.at < RIBBON_MS && lt && cam;
|
|
2371
3606
|
chrome.setRibbon(showRibbon ? project(cam, lt.x, lt.y + 1.7, lt.z, view) : null, r ? `🏅 ${resultLine(r)}` : '');
|
|
2372
|
-
|
|
3607
|
+
if (panels) {
|
|
3608
|
+
const leaving = this.leavingToast && now < this.leavingToast.until && this.toast === this.leavingToast.previousToast;
|
|
3609
|
+
const toast = leaving ? this.leavingToast : this.toast;
|
|
3610
|
+
if (leaving) {
|
|
3611
|
+
chrome.setToast(toast.text, { wrap: true });
|
|
3612
|
+
} else {
|
|
3613
|
+
chrome.setToast(now < toast.until ? toast.text : '');
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
const index = Avatar.current(scene);
|
|
3617
|
+
const model = local?.components.Model;
|
|
3618
|
+
const scale = Math.abs(model?.scale ?? 1);
|
|
3619
|
+
const height = Avatar.top(index, Avatar.drawn(scene.files, index, Avatar.style())) * scale + 0.5;
|
|
3620
|
+
// The avatar rig is drawn at Model.yOffset relative to the collider
|
|
3621
|
+
// centre (the stock rig uses -0.7), not with its feet at Transform.y.
|
|
3622
|
+
const yOffset = model ? model.yOffset ?? 0 : -(local?.components.Shape?.height ?? 1.4) / 2;
|
|
3623
|
+
const own = cam && lt ? bodyBox(lt, height, Math.max(0.65 * scale, local?.components.Player?.radius ?? 0.35), (x, y, z) => project(cam, x, y, z, view), yOffset) : null;
|
|
3624
|
+
chrome.setWorldAvatar?.(own);
|
|
3625
|
+
if (padOccupancy || crowdNames) {
|
|
3626
|
+
// Cabinet/ribbon/pointers must already occupy their final HUD-cleared
|
|
3627
|
+
// boxes before the pad pass reserves them. Boxed labels move no later.
|
|
3628
|
+
if (this.hudClear) {chrome.flushHudClear?.();}
|
|
3629
|
+
const controls = chrome.padOccupancyControls?.() ?? [];
|
|
3630
|
+
controls.push({ left: 0, right: 64, top: 0, bottom: 56 });
|
|
3631
|
+
const lock = scene.three?.renderer?.domElement?.parentElement?.querySelector?.('button[aria-label^="Shift lock"]');
|
|
3632
|
+
if (lock && lock.style.display !== 'none') {
|
|
3633
|
+
const rect = chrome.layoutGeometry?.()?.rect?.(lock);
|
|
3634
|
+
if (rect?.width && rect.height) {controls.push(rect);}
|
|
3635
|
+
}
|
|
3636
|
+
const world = padOccupancy
|
|
3637
|
+
? own ? placeLabels(labels.slice(0, worldLabelCount), own, controls, view, (...args) => chrome.measureLabel(...args), now - Hub.hub.lastTAt > 2000) : []
|
|
3638
|
+
: labels.slice(0, worldLabelCount);
|
|
3639
|
+
const finalLabels = [...world, ...labels.slice(worldLabelCount)];
|
|
3640
|
+
// Keep E's one summary node for its late update. Its setter removes the
|
|
3641
|
+
// node in the same frame when no summary remains; OFF takes the legacy
|
|
3642
|
+
// one-argument path and removes it here.
|
|
3643
|
+
chrome.setLabels(finalLabels, crowdNames);
|
|
3644
|
+
if (crowdNames) {
|
|
3645
|
+
// The late system runs after multiplayer has put every tag at its
|
|
3646
|
+
// final pose. It reuses this one own-body/control pass and the final
|
|
3647
|
+
// DOM label boxes; it never projects the local body a second time.
|
|
3648
|
+
this.crowdFrame = { scene, data: scene.data, net: scene.multiplayer?.net, camera: cam, local: lt, own, controls, view, labels: finalLabels };
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
2373
3651
|
// A clear HUD (v1.26): everything drawn above is measured, then moved
|
|
2374
3652
|
// out from under it, once for the frame. Never said in any other place.
|
|
2375
3653
|
if (this.hudClear) {
|
|
2376
3654
|
chrome.flushHudClear?.();
|
|
2377
3655
|
}
|
|
3656
|
+
// "Stuck?" (v1.33), last of all: the chip is measured after every other
|
|
3657
|
+
// chrome element has its final rect for this frame -- after every setter
|
|
3658
|
+
// above, and after a clear HUD's flush has moved labels, pointers, a
|
|
3659
|
+
// cabinet's card and the ribbon out from under the HUD. Nothing above
|
|
3660
|
+
// knows of the chip or makes way for it: the chip is the one that yields,
|
|
3661
|
+
// and is not drawn where a card or the ribbon now lies; labels and
|
|
3662
|
+
// pointers pass under it (`chrome.stuckPrompt`).
|
|
3663
|
+
if (Hub.deck.stuck) {
|
|
3664
|
+
this.offerUnstick(scene, local, town, now);
|
|
3665
|
+
}
|
|
3666
|
+
// Optional pad readability, after the chip: nothing above makes way for
|
|
3667
|
+
// the caption, which takes every final rect this frame (the chip's too).
|
|
3668
|
+
if (padCuesEnabled(scene.data?.engine) || this.padReadability) {
|
|
3669
|
+
this.drawPadReadability(scene, local);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
|
|
3673
|
+
drawPanelControls(scene, now, place, idle, inGame, free, town, frameYours = true) {
|
|
3674
|
+
const chrome = this.chrome;
|
|
3675
|
+
const inviteNet = scene.multiplayer?.net;
|
|
3676
|
+
// A guest is an over-13 player like any other: the host's canInvite
|
|
3677
|
+
// answer alone decides the rail.
|
|
3678
|
+
const inviteRail = scene.data?.engine?.hubInviteRail === true && !inGame && place?.invite === true &&
|
|
3679
|
+
this.invites?.canInvite(inviteNet, castleSdk.User) === true;
|
|
3680
|
+
const pickerFree = idle && place !== null && !this.talk.talking() && !this.carded;
|
|
3681
|
+
chrome.showPicker(pickerFree && !inGame, Avatar.current(scene), { available: Avatar.colorsAvailable(), style: Avatar.style(), color: Avatar.currentColor(scene), files: scene.files, model: Avatar.colorsAvailable() && Avatar.style() === 'toon' ? Avatar.model(scene.files, Avatar.current(scene), 'toon') : null }, ...(inviteRail ? [{
|
|
3682
|
+
onPick: () => {
|
|
3683
|
+
// A stale menu cannot mint after a scene/connection change or a trip.
|
|
3684
|
+
if (this.scene !== scene || scene.multiplayer?.net !== inviteNet || this.trip || this.pendingEnd !== null ||
|
|
3685
|
+
scene.data?.engine?.hubInviteRail !== true || Hub.hub.place !== place || Boolean(place.result) || this.talk.talking() || this.carded ||
|
|
3686
|
+
this.invites?.canInvite(inviteNet, castleSdk.User) !== true) {return;}
|
|
3687
|
+
this.invites?.open(true);
|
|
3688
|
+
},
|
|
3689
|
+
}] : []));
|
|
3690
|
+
// "Stuck?" (v1.33), only in a deck with `hub.stuck`, and there only in a
|
|
3691
|
+
// place that says it takes it (a town): a row over the Doors list.
|
|
3692
|
+
const stuckRow = Hub.deck.stuck && town && Hub.hub.stuck ? { where: Hub.hub.stuck.hook ? stuckWhere(null, true) : stuckWhere(Hub.hub.stuck.to), onPick: () => this.unstick(this.scene) } : null;
|
|
3693
|
+
let yours = null;
|
|
3694
|
+
if (Hub.deck.yourGames) {
|
|
3695
|
+
const controller = this.yourGames();
|
|
3696
|
+
if (frameYours) {controller.frame(town, Hub.hub.yours, now);}
|
|
3697
|
+
yours = { rows: controller.rows(Hub.hub.yours, Hub.hub.doors), ...controller.controls() };
|
|
3698
|
+
}
|
|
3699
|
+
chrome.setDoors?.(town ? Hub.hub.doors : null, Hub.hub.party.members?.length ? 'Go together' : 'Go', stuckRow, yours);
|
|
3700
|
+
chrome.setPeople?.(free ? this.people(scene, inGame) : null, town ? this.together.partyLine() : null);
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3703
|
+
drawNearPrompt(scene, local, town) {
|
|
3704
|
+
const chrome = this.chrome;
|
|
3705
|
+
// Standing still beside someone: a small button invites them.
|
|
3706
|
+
const beside = town && !Hub.hub.party.invite && local ? this.together.beside(scene, local) : null;
|
|
3707
|
+
chrome.nearPrompt?.(
|
|
3708
|
+
beside ? `${beside.sent ? 'Invited' : '+ Party'} · ${beside.username ?? 'this player'}` : null,
|
|
3709
|
+
() => {
|
|
3710
|
+
if (!beside.sent) {
|
|
3711
|
+
this.together.invited(beside.playerId);
|
|
3712
|
+
this.join(scene, beside, 'invite');
|
|
3713
|
+
}
|
|
3714
|
+
},
|
|
3715
|
+
);
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
clearPadReadability() {
|
|
3719
|
+
this.padReadability?.dispose();
|
|
3720
|
+
delete this.padReadability;
|
|
3721
|
+
delete this.padReadabilityScope;
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
drawPadReadability(scene, local) {
|
|
3725
|
+
const engine = scene.data?.engine;
|
|
3726
|
+
if (!padCuesEnabled(engine) || !Hub.hub.place || !scene.three?.scene) {
|
|
3727
|
+
this.clearPadReadability();
|
|
3728
|
+
return;
|
|
3729
|
+
}
|
|
3730
|
+
const scope = this.padReadabilityScope;
|
|
3731
|
+
if (!scope || scope.data !== scene.data || scope.place !== Hub.hub.place.id ||
|
|
3732
|
+
scope.context !== engine.hubPadContext || scope.ring !== engine.hubPadRing || scope.spawn !== engine.hubSpawnRing) {
|
|
3733
|
+
this.clearPadReadability();
|
|
3734
|
+
this.padReadability = makePadReadability(engine, {
|
|
3735
|
+
world: scene.three.scene, chrome: this.chrome,
|
|
3736
|
+
arrival: engine.hubSpawnRing === true ? readPadArrival(scene, Hub.hub.place, Hub.localArrival.for(Hub.hub.place.id)) : null,
|
|
3737
|
+
});
|
|
3738
|
+
this.padReadabilityScope = { data: scene.data, place: Hub.hub.place.id,
|
|
3739
|
+
context: engine.hubPadContext, ring: engine.hubPadRing, spawn: engine.hubSpawnRing };
|
|
3740
|
+
}
|
|
3741
|
+
this.padReadability.frame(scene.actors, Hub.hub.hidden, local?.components.Transform, Boolean(this.trip),
|
|
3742
|
+
this.carded || this.decor?.opened() === true);
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3745
|
+
// A town's world labels under `hub.labels: "near"` (v1.43): the plate and
|
|
3746
|
+
// the line the attention rule picked this frame (`attend` has just run) and
|
|
3747
|
+
// every sign, each with where its label would lie, handed to `near`.
|
|
3748
|
+
//
|
|
3749
|
+
// The rule's state is one visit's (`nearFor`): another scene, the scene
|
|
3750
|
+
// loaded again, another connection or the hub's state cleared, and it
|
|
3751
|
+
// starts again.
|
|
3752
|
+
//
|
|
3753
|
+
// Label boxes are final when the rule judges them, because the chrome draws
|
|
3754
|
+
// from them: `labelBox` is the one place a world label's box is worked out
|
|
3755
|
+
// (its size for these words, kept on the screen, moved from under a clear
|
|
3756
|
+
// HUD -- `setHud` has run, so the HUD's box is this frame's), the rule is
|
|
3757
|
+
// given that box, and the same box goes to `setLabels`, which puts the
|
|
3758
|
+
// label exactly there and moves it no more. A label whose style changes
|
|
3759
|
+
// gets a node of its own (the chrome styles a node once), so the node drawn
|
|
3760
|
+
// is always one measured as it is styled.
|
|
3761
|
+
nearLabels(scene, placed, lt, cam, view, now, padOccupancy = false, defaults = false) {
|
|
3762
|
+
const chrome = this.chrome;
|
|
3763
|
+
const mine = Hub.hub.labelsMe;
|
|
3764
|
+
const state = nearFor((this.nearHeld ??= {}), { scene: sceneKeyOf(scene), data: scene.data, net: scene.multiplayer?.net ?? null, place: Hub.hub.place });
|
|
3765
|
+
const hud = chrome.hudClearBox?.() ?? null;
|
|
3766
|
+
const prompt = chrome.hudPromptBox?.() ?? null;
|
|
3767
|
+
const candidates = nearCandidates((this.nearCandidates ??= {}), placed, lt, now, state, defaults);
|
|
3768
|
+
const items = [];
|
|
3769
|
+
const drawn = new Map();
|
|
3770
|
+
for (const { id, at, label, always } of placed) {
|
|
3771
|
+
const speech = label.style === 'speech';
|
|
3772
|
+
const kind = always ? 'sign' : speech ? 'speech' : 'plate';
|
|
3773
|
+
const pick = !always && id === (speech ? this.attention.speech : this.attention.plate);
|
|
3774
|
+
// A plate or a line the attention rule passed over: only one still fading.
|
|
3775
|
+
if (!defaults && !always && !pick && !state.alpha.has(id)) {
|
|
3776
|
+
continue;
|
|
3777
|
+
}
|
|
3778
|
+
const npc = label.npc === true;
|
|
3779
|
+
const pad = padOccupancy && Boolean(scene.getActor(id)?.components.HubPad);
|
|
3780
|
+
const screen = candidates.has(id) ? project(cam, at.x, at.y + 1.6, at.z, view) : null;
|
|
3781
|
+
const box = screen ? labelBox(screen.x, screen.y, chrome.measureLabel(label.text, speech, npc, pad), npc, view, hud, prompt) : null;
|
|
3782
|
+
items.push({ id, kind, pick, d: candidates.has(id) ? Math.hypot(at.x - lt.x, at.z - lt.z) : Infinity, mine: Object.hasOwn(mine, id), box });
|
|
3783
|
+
drawn.set(id, { text: label.text, speech, npc, box, pad });
|
|
3784
|
+
}
|
|
3785
|
+
const out = [];
|
|
3786
|
+
for (const [id, opacity] of (defaults ? relevantLabels(state, items, view, now) : near(state, items, view, now))) {
|
|
3787
|
+
const d = drawn.get(id);
|
|
3788
|
+
if (!d?.box) {continue;}
|
|
3789
|
+
const item = chromeItem(id, d.text, d.speech, d.npc, d.box, opacity);
|
|
3790
|
+
if (Hub.deck.quality) {
|
|
3791
|
+
item.actorId = id;
|
|
3792
|
+
// Admission by the near-label rule grants the exemption, regardless
|
|
3793
|
+
// of whether a door, pad or linked actor carries the caption.
|
|
3794
|
+
item.qualityNear = true;
|
|
3795
|
+
}
|
|
3796
|
+
if (d.pad) {item.padOccupancy = true;}
|
|
3797
|
+
out.push(item);
|
|
3798
|
+
}
|
|
3799
|
+
return out;
|
|
2378
3800
|
}
|
|
2379
3801
|
|
|
2380
3802
|
// The People list's rows. In a town: everyone here and the player's
|
|
@@ -2443,6 +3865,23 @@ class HubSystem {
|
|
|
2443
3865
|
}
|
|
2444
3866
|
|
|
2445
3867
|
measure(scene, mp, now) {
|
|
3868
|
+
const net = mp?.net;
|
|
3869
|
+
const config = fpsTelemetryFor(net);
|
|
3870
|
+
if (this.fpsTelemetry && (this.fpsNet !== net || !config)) {
|
|
3871
|
+
this.fpsTelemetry.dispose();
|
|
3872
|
+
this.fpsTelemetry = null;
|
|
3873
|
+
this.fpsNet = null;
|
|
3874
|
+
}
|
|
3875
|
+
if (config && !this.trip && this.scenePath === config.scene) {
|
|
3876
|
+
if (!this.fpsTelemetry) {
|
|
3877
|
+
// Bind departures to their original transport even after a scene swap.
|
|
3878
|
+
this.fpsNet = net;
|
|
3879
|
+
this.fpsTelemetry = makeFpsTelemetry({ send: (data) => net.send(data) });
|
|
3880
|
+
}
|
|
3881
|
+
const tier = this.fpsTier ?? 0;
|
|
3882
|
+
this.fpsTelemetry.frame(now, { scene: this.scenePath, tier, avatars: Math.min(255, (mp.avatars?.actors?.size ?? 0) + 1) });
|
|
3883
|
+
}
|
|
3884
|
+
else {this.fpsTelemetry?.pause();}
|
|
2446
3885
|
if (!this.stats) {
|
|
2447
3886
|
return;
|
|
2448
3887
|
}
|
|
@@ -2455,7 +3894,11 @@ class HubSystem {
|
|
|
2455
3894
|
}
|
|
2456
3895
|
const avatars = (mp.avatars?.actors?.size ?? 0) + 1;
|
|
2457
3896
|
const heap = heapMB();
|
|
2458
|
-
|
|
3897
|
+
const build = Hub.deck.build;
|
|
3898
|
+
const stamp = build ? `\n${build.sha.slice(0, 12)} · ${build.savedAt}${build.hubGameBuiltinVersion ? ` · hub-game ${build.hubGameBuiltinVersion}` : ''}` : '';
|
|
3899
|
+
const server = globalThis.__hub?.serverBuild;
|
|
3900
|
+
const serverLine = server ? `\nserver ${server.bundleId ?? server.bundleSha256?.slice(0, 12)}` : '';
|
|
3901
|
+
this.chrome.setStats(`${Math.round(this.fps)} fps · ${avatars} avatars${heap !== null ? ` · ${heap} MB` : ''}${stamp}${serverLine}`);
|
|
2459
3902
|
if (now - this.statsAt >= STATS_EVERY_MS) {
|
|
2460
3903
|
this.statsAt = now;
|
|
2461
3904
|
const record = { scene: this.scenePath, fps: Math.round(this.fps * 10) / 10, avatars, heapMB: heap, trips: this.tripCount, ...gpuCounts(scene), ...this.lastFrame };
|
|
@@ -2465,8 +3908,37 @@ class HubSystem {
|
|
|
2465
3908
|
}
|
|
2466
3909
|
|
|
2467
3910
|
dispose() {
|
|
3911
|
+
this.clearPadReadability();
|
|
3912
|
+
this.hudRate?.dispose();
|
|
3913
|
+
this.hudRate = null;
|
|
3914
|
+
this.fpsTelemetry?.dispose();
|
|
3915
|
+
this.fpsTelemetry = null;
|
|
3916
|
+
this.fpsNet = null;
|
|
3917
|
+
|
|
3918
|
+
this.doorErrors?.dispose();
|
|
3919
|
+
loadingCover?.detach();
|
|
3920
|
+
this.invites?.dispose();
|
|
3921
|
+
this.invites = null;
|
|
3922
|
+
this.weakestTier?.restore();
|
|
3923
|
+
this.environment.restore();
|
|
3924
|
+
this.farAvatars?.clear();
|
|
3925
|
+
this.visibility?.sync(null, null, false);
|
|
3926
|
+
this.visibility = null;
|
|
3927
|
+
if (this.menuDrawn) {this.clearMenu();}
|
|
3928
|
+
if (this.askDrawn) {
|
|
3929
|
+
this.clearTextAsk();
|
|
3930
|
+
}
|
|
3931
|
+
clearShot();
|
|
3932
|
+
if (this.decor) {
|
|
3933
|
+
this.decor.dispose();
|
|
3934
|
+
this.decor = null;
|
|
3935
|
+
}
|
|
3936
|
+
this.act?.dispose();
|
|
3937
|
+
this.act = null;
|
|
2468
3938
|
this.chrome?.dispose();
|
|
2469
3939
|
this.chrome = null;
|
|
3940
|
+
this.actionInput?.release();
|
|
3941
|
+
delete this.actionInput;
|
|
2470
3942
|
this.talk = null;
|
|
2471
3943
|
this.grab?.dispose();
|
|
2472
3944
|
this.grab = null;
|
|
@@ -2474,6 +3946,17 @@ class HubSystem {
|
|
|
2474
3946
|
this.idle = null;
|
|
2475
3947
|
this.sound?.dispose();
|
|
2476
3948
|
this.sound = null;
|
|
3949
|
+
this.soundscape?.dispose();
|
|
3950
|
+
this.soundscape = null;
|
|
3951
|
+
if (this.ballot) {
|
|
3952
|
+
this.ballot.dispose();
|
|
3953
|
+
this.ballot = null;
|
|
3954
|
+
}
|
|
3955
|
+
// What players wear hangs on the avatars' nodes and holds shares of the
|
|
3956
|
+
// hat builds: given back with the runtime.
|
|
3957
|
+
this.companion?.dispose();
|
|
3958
|
+
this.wear?.clear();
|
|
3959
|
+
this.earned?.clear();
|
|
2477
3960
|
}
|
|
2478
3961
|
}
|
|
2479
3962
|
|
|
@@ -2525,7 +4008,7 @@ function doorActor(scene, door) {
|
|
|
2525
4008
|
if (!door) {
|
|
2526
4009
|
return null;
|
|
2527
4010
|
}
|
|
2528
|
-
for (const actor of scene
|
|
4011
|
+
for (const actor of allActors(scene)) {
|
|
2529
4012
|
if (actor.components?.HubDoor?.id === door) {
|
|
2530
4013
|
return actor.id;
|
|
2531
4014
|
}
|
|
@@ -2533,6 +4016,67 @@ function doorActor(scene, door) {
|
|
|
2533
4016
|
return null;
|
|
2534
4017
|
}
|
|
2535
4018
|
|
|
4019
|
+
// SceneRuntime has no before-behavior system hook. While this card alone is
|
|
4020
|
+
// open, clear inputs at the entry to the same update that Player runs in,
|
|
4021
|
+
// including capped frames' lent presses; restore the method on every close.
|
|
4022
|
+
function holdAskInput(scene) {
|
|
4023
|
+
const active = scene.moveInput?.active;
|
|
4024
|
+
const ownUpdate = Object.getOwnPropertyDescriptor(scene, 'update');
|
|
4025
|
+
const update = scene.update;
|
|
4026
|
+
const hold = () => {
|
|
4027
|
+
lockInput(scene);
|
|
4028
|
+
scene.moveInput?.consumeJump?.();
|
|
4029
|
+
const player = scene.actorWith?.('Player');
|
|
4030
|
+
if (player?.runtime) {
|
|
4031
|
+
player.runtime.jumpBuffer = 0;
|
|
4032
|
+
}
|
|
4033
|
+
if (scene.cameraControl === 'orbit') {
|
|
4034
|
+
scene.lookInput?.lock?.();
|
|
4035
|
+
}
|
|
4036
|
+
};
|
|
4037
|
+
// Captured/locked canvas pointers can bypass the DOM shield. Block their
|
|
4038
|
+
// new drags too, while still letting pointerup clean up an older gesture.
|
|
4039
|
+
const listeners = new AbortController();
|
|
4040
|
+
for (const type of ['pointerdown', 'pointermove', 'mousedown', 'wheel']) {
|
|
4041
|
+
globalThis.addEventListener?.(type, (event) => {
|
|
4042
|
+
if (event.target?.tagName === 'CANVAS') {
|
|
4043
|
+
event.stopImmediatePropagation();
|
|
4044
|
+
event.preventDefault();
|
|
4045
|
+
}
|
|
4046
|
+
}, { capture: true, passive: false, signal: listeners.signal });
|
|
4047
|
+
}
|
|
4048
|
+
// Drop any drag already held when the prompt took the screen.
|
|
4049
|
+
scene.lookInput?.cancel?.();
|
|
4050
|
+
// A desktop mouse lock would keep the cursor in the canvas, out of reach of
|
|
4051
|
+
// the card: let it go (the orbit input hears the change and drops its own).
|
|
4052
|
+
if (globalThis.document?.pointerLockElement) {
|
|
4053
|
+
globalThis.document.exitPointerLock?.();
|
|
4054
|
+
}
|
|
4055
|
+
hold();
|
|
4056
|
+
const guardedUpdate = function (...args) {
|
|
4057
|
+
hold();
|
|
4058
|
+
return update.apply(this, args);
|
|
4059
|
+
};
|
|
4060
|
+
if (typeof update === 'function') {
|
|
4061
|
+
scene.update = guardedUpdate;
|
|
4062
|
+
}
|
|
4063
|
+
return {
|
|
4064
|
+
release() {
|
|
4065
|
+
listeners.abort();
|
|
4066
|
+
if (scene.update === guardedUpdate) {
|
|
4067
|
+
if (ownUpdate) {
|
|
4068
|
+
Object.defineProperty(scene, 'update', ownUpdate);
|
|
4069
|
+
} else {
|
|
4070
|
+
delete scene.update;
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
if (scene.moveInput) {
|
|
4074
|
+
scene.moveInput.active = active;
|
|
4075
|
+
}
|
|
4076
|
+
},
|
|
4077
|
+
};
|
|
4078
|
+
}
|
|
4079
|
+
|
|
2536
4080
|
function lockInput(scene) {
|
|
2537
4081
|
scene.keys?.clear?.();
|
|
2538
4082
|
if (scene.moveInput) {
|
|
@@ -2553,12 +4097,18 @@ function followCamera(scene, local) {
|
|
|
2553
4097
|
return { x: t.x - distance * Math.sin(angle), y: t.y + height, z: t.z + distance * Math.cos(angle) };
|
|
2554
4098
|
}
|
|
2555
4099
|
|
|
4100
|
+
// Hub.go through a door; with an owner (a friend at home), into that owner's
|
|
4101
|
+
// House. Without one the call is the door alone, as it always was.
|
|
4102
|
+
function hubGo(door, owner) {
|
|
4103
|
+
return owner ? castleSdk.Hub.go(door, { ownerUserId: owner }) : castleSdk.Hub.go(door);
|
|
4104
|
+
}
|
|
4105
|
+
|
|
2556
4106
|
function project(cam, x, y, z, view) {
|
|
2557
4107
|
const v = cam.position.clone().set(x, y, z).project(cam);
|
|
2558
4108
|
if (v.z > 1 || v.z < -1) {
|
|
2559
4109
|
return null;
|
|
2560
4110
|
}
|
|
2561
|
-
return { x: ((v.x + 1) / 2) * view.w, y: ((1 - v.y) / 2) * view.h };
|
|
4111
|
+
return mapWorldPoint({ x: ((v.x + 1) / 2) * view.w, y: ((1 - v.y) / 2) * view.h }, view);
|
|
2562
4112
|
}
|
|
2563
4113
|
|
|
2564
4114
|
function statsWanted() {
|
|
@@ -2593,3 +4143,4 @@ function frameCounts(scene) {
|
|
|
2593
4143
|
info.reset();
|
|
2594
4144
|
return counts;
|
|
2595
4145
|
}
|
|
4146
|
+
import { reportPushVisit } from '../client/pushVisit.js';
|