castle-web-cli 0.4.231 → 0.4.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +51 -3
- package/dist/castleJson.d.ts +4 -2
- package/dist/castleJson.js +2 -0
- package/dist/check.d.ts +3 -1
- package/dist/check.js +11 -1
- package/dist/devSessionStorage.js +47 -1
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +5 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +5 -0
- package/dist/save-deck.js +37 -4
- package/dist/serve.js +3 -0
- package/dist/serverBundle.js +5 -3
- package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +79 -2
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +1 -1
- package/kits/base/sdk/commands.d.ts +14 -0
- package/kits/base/sdk/hub.d.ts +6 -2
- package/kits/base/sdk/hub.js +13 -0
- package/kits/base/sdk/multiplayer.js +17 -1
- package/kits/base/sdk/save.js +2 -1
- package/kits/base/sdk/server/hub.d.ts +87 -0
- package/kits/base/sdk/server/hub.js +70 -0
- package/kits/base/sdk/server/platformHandle.d.ts +31 -1
- package/kits/base/sdk/server/storage.d.ts +13 -0
- package/kits/base/sdk/server/storage.js +46 -0
- package/kits/base/sdk/server/wrapper.d.ts +36 -5
- package/kits/base/sdk/server/wrapper.js +83 -8
- package/kits/hub-game/CLAUDE.md +352 -12
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +345 -32
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +251 -0
- package/kits/hub-game/code/client/ballot.js +467 -0
- package/kits/hub-game/code/client/build.js +22 -0
- package/kits/hub-game/code/client/chat.js +12 -0
- package/kits/hub-game/code/client/chrome.js +1334 -50
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/decor.js +509 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/grab.js +363 -20
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +328 -15
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/idle.js +163 -22
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +205 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/shot.js +92 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +131 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +538 -47
- package/kits/hub-game/code/client/tiers.js +541 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +98 -1
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +470 -97
- package/kits/hub-game/code/client/yours.js +199 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/actions.js +133 -0
- package/kits/hub-game/code/server/actors.js +14 -1
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +82 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/earned.js +461 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +232 -0
- package/kits/hub-game/code/server/grab.js +296 -11
- package/kits/hub-game/code/server/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1317 -52
- package/kits/hub-game/code/server/idle.js +30 -11
- package/kits/hub-game/code/server/index.js +2 -2
- package/kits/hub-game/code/server/labels.js +28 -2
- package/kits/hub-game/code/server/manifest.js +424 -8
- package/kits/hub-game/code/server/menu.js +133 -0
- package/kits/hub-game/code/server/npcs.js +830 -80
- package/kits/hub-game/code/server/party.js +13 -2
- package/kits/hub-game/code/server/players.js +22 -0
- package/kits/hub-game/code/server/say.js +8 -2
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +124 -0
- package/kits/hub-game/code/server/vis.js +113 -0
- package/kits/hub-game/code/server/wear.js +128 -11
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/shot.js +19 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1083 -85
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2440 -61
- package/kits/hub-game/docs/home-pieces.md +64 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +2 -0
- package/kits/hub-game/package.json +2 -1
- package/kits/hub-game/scripts/check.mjs +78 -11
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -17
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
- package/kits/hub-game/scripts/test-avatar.mjs +540 -7
- package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
- package/kits/hub-game/scripts/test-build.mjs +31 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +694 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
- package/kits/hub-game/scripts/test-decor.mjs +457 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1194 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +186 -3
- package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +864 -3
- package/kits/hub-game/scripts/test-hats.mjs +483 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1228 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +1000 -0
- package/kits/hub-game/scripts/test-idle.mjs +361 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +596 -0
- package/kits/hub-game/scripts/test-manifest.mjs +282 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
- package/kits/hub-game/scripts/test-menu.mjs +296 -0
- package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-party.mjs +22 -1
- package/kits/hub-game/scripts/test-picker.mjs +314 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-shot.mjs +756 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +416 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
- package/kits/hub-game/scripts/test-tiers.mjs +666 -3
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/hub-game/scripts/test-vis.mjs +343 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
- package/kits/hub-game/scripts/test-yours.mjs +372 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/physics-2d/CLAUDE.md +9 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +288 -1
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +370 -1
- package/kits/physics-3d/CLAUDE.md +1391 -0
- package/kits/physics-3d/behaviors/Player.jsx +921 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +12 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +98 -10
- package/kits/physics-3d/engine3d/actornode.js +86 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +96 -0
- package/kits/physics-3d/engine3d/gait.js +118 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +507 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +37 -19
- package/kits/physics-3d/engine3d/optimize.js +58 -5
- package/kits/physics-3d/engine3d/orbitinput.js +755 -0
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/shadowfade.js +882 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +870 -87
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
- package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +12 -2
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +4588 -0
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +13 -1
- package/kits/physics-3d/scripts/test-static-passes.mjs +1 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +635 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +474 -12
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +97 -19
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { makeVisibility } from '../client/visibility.js';
|
|
2
|
+
import { makeActorBudget } from '../client/actorBudget.js';
|
|
1
3
|
// The hub system: the door, and everything a place draws that a game cannot.
|
|
2
4
|
// It runs after the engine's behaviors every frame and owns the trip between
|
|
3
5
|
// places -- the door animation, the scene swap and session switch under its
|
|
@@ -8,7 +10,8 @@
|
|
|
8
10
|
// the place's loose objects where it offers that (`client/grab.js`), and idle
|
|
9
11
|
// play -- emotes, seats and the place's sounds -- where it offers that
|
|
10
12
|
// (`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`)
|
|
13
|
+
// cheaper picture on a slow device (`client/tiers.js`) and the sounds the kit
|
|
14
|
+
// makes itself (`client/soundscape.js`).
|
|
12
15
|
//
|
|
13
16
|
// One engine, one iframe (HUB.md decision 2): going through a door unloads this
|
|
14
17
|
// place's scene, loads the next one's (`scene.requestedScene`), and moves the
|
|
@@ -24,27 +27,41 @@
|
|
|
24
27
|
|
|
25
28
|
import * as castleSdk from 'castle-web-sdk';
|
|
26
29
|
import { attend, fadeNames, makeAttention } from '../client/attention.js';
|
|
30
|
+
import { chromeItem, labelBox, near, nearFor } from '../client/labelsNear.js';
|
|
27
31
|
import { doorPoint } from '../client/doorFrame.js';
|
|
28
32
|
import * as Avatar from '../client/avatar.js';
|
|
33
|
+
import * as Rehello from '../client/rehello.js';
|
|
34
|
+
import * as AvatarCap from '../client/avatarCap.js';
|
|
35
|
+
import * as AvatarShare from '../client/avatarShare.js';
|
|
36
|
+
import { makeYours } from '../client/yours.js';
|
|
29
37
|
import * as Cabinets from '../client/cabinets.js';
|
|
30
38
|
import { CHAT_BUBBLE_MS, makeChat } from '../client/chat.js';
|
|
31
39
|
import { makeChrome } from '../client/chrome.js';
|
|
32
40
|
import * as Packs from '../client/pack.js';
|
|
33
41
|
import * as Hub from '../client/state.js';
|
|
42
|
+
import { clearShot } from '../client/shot.js';
|
|
34
43
|
import { makeGrab } from '../client/grab.js';
|
|
35
44
|
import { makeIdle } from '../client/idle.js';
|
|
45
|
+
import { makeDecor } from '../client/decor.js';
|
|
36
46
|
import { makeSay, REACTIONS } from '../client/say.js';
|
|
47
|
+
import { cardFor, forget as forgetBallot, held as ballotHeld, makeBallot } from '../client/ballot.js';
|
|
37
48
|
import { makeSound } from '../client/sound.js';
|
|
49
|
+
import { makeSoundscape } from '../client/soundscape.js';
|
|
50
|
+
import { addSpinner, findSpinners, spinFrame } from '../client/spin.js';
|
|
51
|
+
import { makeStuck, resetStuck, STUCK_EVERY_MS, stuckDone, stuckFrame, stuckText, stuckWhere, walkInput } from '../client/stuck.js';
|
|
38
52
|
import { makeTalk } from '../client/talk.js';
|
|
53
|
+
import { makeInterestCap } from '../client/interestCap.js';
|
|
39
54
|
import { makeTiers } from '../client/tiers.js';
|
|
40
|
-
import { makeTogether, pointerAt } from '../client/together.js';
|
|
41
|
-
import { makeWear } from '../client/wear.js';
|
|
55
|
+
import { goalPointers, goalText, makeTogether, pointerAt } from '../client/together.js';
|
|
56
|
+
import { makeEarned, makeWear } from '../client/wear.js';
|
|
57
|
+
import { makeCompanion } from '../client/companion.js';
|
|
42
58
|
|
|
43
59
|
// The door's three beats, in milliseconds: the door opens and the camera goes
|
|
44
60
|
// through it while the cover comes down; the swap and join happen under the
|
|
45
61
|
// cover; the cover lifts as the camera pulls back from the arrival.
|
|
46
62
|
const OPEN_MS = 650;
|
|
47
63
|
const REVEAL_MS = 700;
|
|
64
|
+
const LEAVING_MS = 2800;
|
|
48
65
|
const LOADING_LIMIT_MS = 15000;
|
|
49
66
|
// How long the cover waits for the place to say where it put this player
|
|
50
67
|
// after the session has placed them, before it lifts anyway.
|
|
@@ -73,6 +90,38 @@ const TICKETS_MAX = 4;
|
|
|
73
90
|
// How often a place asks the host who of the player's friends is in its other
|
|
74
91
|
// layers, while the player is there and idle.
|
|
75
92
|
const FRIENDS_EVERY_MS = 20000;
|
|
93
|
+
// Cues (v1.23): while someone here is not named by the host as a friend, the
|
|
94
|
+
// host is asked again a few times (`together.due`) -- one such ask in this
|
|
95
|
+
// long at most on average, however many come in: 15 a minute (16 in the
|
|
96
|
+
// worst-placed one), never a 2 s poll. v1.32: counted as two in any twice this long, this far apart at
|
|
97
|
+
// least, so an ask the host answered a moment too soon (it knows a join
|
|
98
|
+
// within a few seconds) is put again while it matters.
|
|
99
|
+
const FRIENDS_EARLY_MS = 4000;
|
|
100
|
+
const FRIENDS_EARLY_PAIR_MS = 2000;
|
|
101
|
+
// ...and never this soon after any ask, the cadence's own included (v1.31:
|
|
102
|
+
// 1 s, with the first extra ask 1 s after someone is seen; were 2 s).
|
|
103
|
+
const FRIENDS_EARLY_AFTER_MS = 1000;
|
|
104
|
+
// Cues: a friend found already here is told to the player when no other
|
|
105
|
+
// toast is up, and not at all once this long has passed.
|
|
106
|
+
const HERE_CUE_MS = 15000;
|
|
107
|
+
// Cues: the party the place first tells a session about is the one the player
|
|
108
|
+
// already had; only a change after this long is a join worth a toast.
|
|
109
|
+
const PARTY_SETTLE_MS = 5000;
|
|
110
|
+
const PARTY_CARRY_MS = 30000;
|
|
111
|
+
// Cues: an accepted invitation is this player's own join for this long.
|
|
112
|
+
const PARTY_ACCEPT_MS = 10000;
|
|
113
|
+
// Cues: the chat field's own words. The field is about 20 characters wide,
|
|
114
|
+
// so the whole sentence is its accessible label and the note above it.
|
|
115
|
+
const CHAT_HINT = {
|
|
116
|
+
on: 'To your follows…',
|
|
117
|
+
// v1.29: one field and one sentence for every reason it cannot be used, so
|
|
118
|
+
// neither says which reason it is (never a player's age).
|
|
119
|
+
off: 'Friends only',
|
|
120
|
+
why: 'Typed chat is for friends who follow each other. Emotes work with everyone.',
|
|
121
|
+
label: 'Message · only players you follow each other with',
|
|
122
|
+
};
|
|
123
|
+
// Cues (v1.29): how long a player back from a game is offered it again.
|
|
124
|
+
const AGAIN_ASK_MS = 20000;
|
|
76
125
|
// Starting next to a friend: how long after walking in a friend found here
|
|
77
126
|
// still moves the player beside them, and how far the player may have walked.
|
|
78
127
|
const START_NEAR_MS = 12000;
|
|
@@ -154,6 +203,7 @@ class HubSystem {
|
|
|
154
203
|
this.trip = null;
|
|
155
204
|
this.pendingEnd = null;
|
|
156
205
|
this.endSession = null;
|
|
206
|
+
this.endLeaving = null;
|
|
157
207
|
this.helloNet = null;
|
|
158
208
|
this.helloAvatar = null;
|
|
159
209
|
this.scenePath = null;
|
|
@@ -162,8 +212,14 @@ class HubSystem {
|
|
|
162
212
|
this.stash = new Map();
|
|
163
213
|
this.tinted = new Map();
|
|
164
214
|
this.spawnedHere = new Set();
|
|
215
|
+
// Turning displays (v1.55, `client/spin.js`): the scene data last looked
|
|
216
|
+
// through for `HubSpin`, and its turners -- null where nothing turns.
|
|
217
|
+
this.spinData = null;
|
|
218
|
+
this.spin = null;
|
|
165
219
|
this.wear = makeWear();
|
|
220
|
+
this.earned = makeEarned();
|
|
166
221
|
this.toast = { text: '', until: 0 };
|
|
222
|
+
this.leavingToast = null;
|
|
167
223
|
this.stats = statsWanted();
|
|
168
224
|
this.frames = 0;
|
|
169
225
|
this.fpsAt = 0;
|
|
@@ -177,6 +233,8 @@ class HubSystem {
|
|
|
177
233
|
// People list marks them and points the way to them).
|
|
178
234
|
this.friendsAll = null;
|
|
179
235
|
this.friendsAt = -Infinity;
|
|
236
|
+
this.friendsGameAt = -Infinity;
|
|
237
|
+
this.friendsGameWarm = false;
|
|
180
238
|
this.friendsAsking = false;
|
|
181
239
|
this.friendsOff = false;
|
|
182
240
|
// Whether this host runs the hub (it answered Hub.friends), so takes
|
|
@@ -193,40 +251,63 @@ class HubSystem {
|
|
|
193
251
|
this.playAsked = new Map();
|
|
194
252
|
// A friend who went through a door while the question could not be put.
|
|
195
253
|
this.wentAsk = null;
|
|
254
|
+
// Cues (v1.29): the game this player just came back from, offered again.
|
|
255
|
+
this.againAsk = null;
|
|
196
256
|
this.chat = makeChat();
|
|
197
257
|
this.namesTouched = new WeakMap();
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
258
|
+
// Cues (v1.23), all unused in a deck without `hub.cues`: when the host
|
|
259
|
+
// was last asked early for the friends; friends found already here, not
|
|
260
|
+
// yet told; the friend the player was just put beside; the roster as of
|
|
261
|
+
// the last frame; and the party as of the last frame, with what tells a
|
|
262
|
+
// party the player already had from one they just joined.
|
|
263
|
+
this.friendsEarlyAt = -Infinity;
|
|
264
|
+
this.friendsEarlyBeforeAt = -Infinity;
|
|
265
|
+
this.friendsSentAt = -Infinity;
|
|
266
|
+
this.hereCues = [];
|
|
267
|
+
this.besideTold = null;
|
|
268
|
+
this.rosterSeen = new Set();
|
|
269
|
+
this.partyLast = null;
|
|
270
|
+
this.partySettleUntil = 0;
|
|
271
|
+
this.partyCarryUntil = 0;
|
|
272
|
+
this.partyAccepted = null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Other players' names in a town: near ones only, and smaller; never the
|
|
276
|
+
// player's own in a place (`attention.js`). After the multiplayer kit has placed them this frame.
|
|
202
277
|
fadeNames(scene) {
|
|
203
278
|
const place = Hub.hub.place;
|
|
204
279
|
const town = Boolean(place && !place.result && !this.trip);
|
|
205
|
-
fadeNames(scene.multiplayer, scene.actorWith('Player')?.components.Transform, town, this.namesTouched);
|
|
280
|
+
fadeNames(scene.multiplayer, scene.actorWith('Player')?.components.Transform, town, this.namesTouched, Boolean(place));
|
|
206
281
|
}
|
|
207
282
|
|
|
208
|
-
afterBehaviors(scene) {
|
|
283
|
+
afterBehaviors(scene, dt) {
|
|
209
284
|
const mp = scene.multiplayer;
|
|
210
285
|
if (!mp) {
|
|
211
286
|
return;
|
|
212
287
|
}
|
|
213
288
|
const now = performance.now();
|
|
214
289
|
this.chrome ??= makeChrome({
|
|
215
|
-
onBack: () => this.
|
|
290
|
+
onBack: () => this.backFromControl(scene),
|
|
216
291
|
onAvatar: (i) => Avatar.choose(scene, i),
|
|
292
|
+
onColor: (color) => Avatar.chooseColor(scene, color),
|
|
217
293
|
avatarCount: Avatar.AVATARS,
|
|
218
294
|
onPerson: (person, action) => this.join(this.scene, person, action),
|
|
219
295
|
onJumpDoor: (door) => this.goDoor(this.scene, door),
|
|
296
|
+
onHeart: (door) => this.yours?.toggle(door),
|
|
220
297
|
onAsk: (ask, yes) => this.answer(this.scene, ask, yes),
|
|
221
298
|
onLeaveParty: () => this.scene?.multiplayer?.net?.send({ k: 'hub-party', op: 'leave' }),
|
|
222
299
|
onReportChat: (line) => this.reportChat(line),
|
|
223
300
|
onReport: (person) => this.report(person),
|
|
301
|
+
...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
|
|
224
302
|
});
|
|
225
303
|
Avatar.load(scene);
|
|
226
304
|
this.talk ??= makeTalk(this.chrome);
|
|
227
305
|
this.grab ??= makeGrab(this.chrome);
|
|
228
306
|
this.idle ??= makeIdle(this.chrome);
|
|
229
307
|
this.sound ??= makeSound();
|
|
308
|
+
if (Hub.deck.soundscape && !this.soundscape) {
|
|
309
|
+
this.hearPlace();
|
|
310
|
+
}
|
|
230
311
|
if (!this.sayHooked) {
|
|
231
312
|
this.sayHooked = true;
|
|
232
313
|
this.chrome.onSay?.((what) => this.saying(what));
|
|
@@ -236,13 +317,14 @@ class HubSystem {
|
|
|
236
317
|
// answered the way the kit's own is: back through the door (contract §5).
|
|
237
318
|
if (!this.backHooked && typeof castleSdk.Hub?.onBack === 'function') {
|
|
238
319
|
this.backHooked = true;
|
|
239
|
-
castleSdk.Hub.onBack(() => this.
|
|
320
|
+
castleSdk.Hub.onBack(() => this.backFromControl(this.scene));
|
|
240
321
|
}
|
|
241
322
|
const per = (scene.persistent ??= {});
|
|
242
323
|
per.hubTickets ??= [];
|
|
243
324
|
this.keepResident(scene, per.hubTickets);
|
|
244
325
|
// A handle for test drivers and phone measurements.
|
|
245
|
-
globalThis.__hub = { scene, system: this, state: Hub.hub };
|
|
326
|
+
globalThis.__hub = { scene, system: this, state: Hub.hub, ...(Hub.deck.build ? { build: Hub.deck.build } : {}) };
|
|
327
|
+
Object.defineProperty(globalThis.__hub, 'avatarPlatform', { enumerable: true, get: Avatar.diagnostics });
|
|
246
328
|
globalThis.__hubPacks ??= () => Packs.cachedPacks().length;
|
|
247
329
|
|
|
248
330
|
if (sceneKeyOf(scene) !== this.sceneKey) {
|
|
@@ -253,8 +335,13 @@ class HubSystem {
|
|
|
253
335
|
this.applyTune(local);
|
|
254
336
|
this.watchSession(scene, mp);
|
|
255
337
|
this.sayHello(scene, mp);
|
|
338
|
+
if (Hub.hub.place?.visibility === true || this.visibility) {
|
|
339
|
+
this.visibility ??= makeVisibility();
|
|
340
|
+
this.visibility.sync(mp.net, this.sceneKey, Hub.hub.place?.visibility === true && !this.trip);
|
|
341
|
+
}
|
|
256
342
|
this.followPlace(scene);
|
|
257
343
|
this.holdFall(scene, local);
|
|
344
|
+
this.turnSpinners(scene, dt);
|
|
258
345
|
this.applySpawns(scene);
|
|
259
346
|
this.applyTints(scene);
|
|
260
347
|
// Visibility is applied once more after every other system: the
|
|
@@ -264,37 +351,185 @@ class HubSystem {
|
|
|
264
351
|
this.lateFor = scene;
|
|
265
352
|
this.registerLate(scene);
|
|
266
353
|
}
|
|
354
|
+
this.registerInterest(scene);
|
|
267
355
|
this.applyVisibility(scene);
|
|
268
356
|
this.applyWear(scene);
|
|
357
|
+
// Different characters draw from shared materials (`avatarShare.js`).
|
|
358
|
+
AvatarShare.share(scene, [local?.id, ...(mp?.avatars?.actors?.values() ?? [])]);
|
|
269
359
|
this.adoptLate(scene);
|
|
270
360
|
this.runCommands(scene, now);
|
|
271
361
|
this.askFriends(scene, mp, now);
|
|
272
362
|
this.together.frame(mp, this.friendsAll, !this.trip && this.pendingEnd === null, now, this.chrome.peopleOpen?.() === true);
|
|
273
363
|
|
|
364
|
+
if (!Hub.hub.place?.decor && this.decor) {
|
|
365
|
+
this.decor.dispose();
|
|
366
|
+
this.decor = null;
|
|
367
|
+
}
|
|
368
|
+
if (Hub.hub.place?.decor && !this.decor) {
|
|
369
|
+
this.decor = makeDecor(this.chrome);
|
|
370
|
+
}
|
|
371
|
+
this.decor?.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking());
|
|
372
|
+
const decorating = this.decor?.opened() === true;
|
|
274
373
|
this.stepEnd(scene, mp, now);
|
|
275
374
|
const held = Hub.hub.held.has(mp.net?.selfId?.());
|
|
375
|
+
// v1.68, rule B (`client/ballot.js`): the choice card runs only while
|
|
376
|
+
// its one gate holds a card (`ballotHeld`), which a place without
|
|
377
|
+
// `ballot` never does; when it lets go (another connection), the sheet
|
|
378
|
+
// goes, once. While a card is up it holds the bottom of the screen, and
|
|
379
|
+
// what it would cover (emotes, Sit, Say, the dock, the feed) waits.
|
|
380
|
+
// `cardFor` lets go of a card of another connection, so the gate is read
|
|
381
|
+
// again after it, before anything is made or drawn.
|
|
382
|
+
const card = ballotHeld ? cardFor(mp.net ?? null) : null;
|
|
383
|
+
if (ballotHeld) {
|
|
384
|
+
// A chip tap sounds as the chrome's do, only with UI cues.
|
|
385
|
+
this.ballot ??= makeBallot({
|
|
386
|
+
send: (ids) => this.scene?.multiplayer?.net?.send({ k: 'hub-ballot', ...ids }),
|
|
387
|
+
...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
|
|
388
|
+
});
|
|
389
|
+
this.carded = card !== null && !this.trip;
|
|
390
|
+
} else if (this.ballot) {
|
|
391
|
+
this.ballot.dispose();
|
|
392
|
+
this.ballot = null;
|
|
393
|
+
this.carded = false;
|
|
394
|
+
}
|
|
395
|
+
// Resolve incoming conversations before a pending prompt can take focus.
|
|
396
|
+
// An already-open prompt yields as a cancel, before NPC chrome opens.
|
|
397
|
+
// NPC events belong to this client only, even for a shared body.
|
|
398
|
+
if (Hub.hub.place?.ask === true && this.askInput &&
|
|
399
|
+
(card !== null || this.talk.talking() || Hub.hub.npcEvents.some((msg) => msg.k === 'hub-npc' && msg.open))) {
|
|
400
|
+
this.chrome.cancelTextAsk();
|
|
401
|
+
}
|
|
402
|
+
if (this.menuInput && (card !== null || this.talk.talking() ||
|
|
403
|
+
(Hub.hub.place?.ask === true && this.chrome.textAskPending(Hub.hub.ask)) ||
|
|
404
|
+
Hub.hub.npcEvents.some((msg) => msg.k === 'hub-npc' && msg.open))) {
|
|
405
|
+
this.chrome.cancelMenu();
|
|
406
|
+
}
|
|
276
407
|
this.talk.frame(scene, mp, !this.trip && this.pendingEnd === null);
|
|
408
|
+
if (Hub.hub.place?.ask === true) {
|
|
409
|
+
this.askDrawn = true;
|
|
410
|
+
Hub.hub.askClose ??= () => this.clearTextAsk();
|
|
411
|
+
const canAsk = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking();
|
|
412
|
+
this.chrome.setTextAsk(canAsk ? Hub.hub.ask : null,
|
|
413
|
+
(id, n, text) => mp.net?.send({ k: 'hub-answer', id, n, text }),
|
|
414
|
+
(open) => {
|
|
415
|
+
if (open) {
|
|
416
|
+
this.askInput = holdAskInput(scene);
|
|
417
|
+
} else if (this.askInput) {
|
|
418
|
+
this.askInput.release();
|
|
419
|
+
delete this.askInput;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
} else if (this.askDrawn) {
|
|
423
|
+
this.clearTextAsk();
|
|
424
|
+
}
|
|
425
|
+
if (Hub.hub.place?.menu === true) {
|
|
426
|
+
this.menuDrawn = true;
|
|
427
|
+
Hub.hub.menuClose ??= () => this.clearMenu();
|
|
428
|
+
const canMenu = !this.trip && this.pendingEnd === null && !decorating && card === null && !this.talk.talking() && !this.askInput;
|
|
429
|
+
this.chrome.setMenu(canMenu ? Hub.hub.menu : null,
|
|
430
|
+
(id, n) => mp.net?.send({ k: 'hub-menu-pick', id, n }),
|
|
431
|
+
(open) => {
|
|
432
|
+
if (open) {
|
|
433
|
+
this.menuInput = holdAskInput(scene);
|
|
434
|
+
} else if (this.menuInput) {
|
|
435
|
+
this.menuInput.release();
|
|
436
|
+
delete this.menuInput;
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
} else if (this.menuDrawn) {
|
|
440
|
+
this.clearMenu();
|
|
441
|
+
}
|
|
442
|
+
if (Hub.hub.menu?.spec?.face !== undefined && !held &&
|
|
443
|
+
!Object.hasOwn(Hub.hub.seated, mp.net?.selfId?.()) && scene.cameraControl === 'orbit') {
|
|
444
|
+
const face = this.chrome.menuFace();
|
|
445
|
+
if (Number.isFinite(face) && local?.components.Transform) {
|
|
446
|
+
// Player keeps radians; normal move reports pack the visible yaw from degrees.
|
|
447
|
+
local.runtime.facing = face * Math.PI / 180;
|
|
448
|
+
local.components.Transform.rotationY = face;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
277
451
|
// Idle play (v1.6): before input is locked, since a sitter's move is
|
|
278
452
|
// what gets them up (a seat is a hold).
|
|
279
|
-
this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking(), this.sceneKey);
|
|
453
|
+
this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded, this.sceneKey);
|
|
280
454
|
this.idle.draw(scene, local);
|
|
281
|
-
|
|
282
|
-
|
|
455
|
+
// The soundscape, only in a deck with `hub.soundscape`: its sound control
|
|
456
|
+
// also says how loud the place's own files play. Without the key the
|
|
457
|
+
// place's sounds are asked for exactly as they always were.
|
|
458
|
+
if (Hub.deck.soundscape) {
|
|
459
|
+
this.chrome.soundControl?.(!this.trip, this.soundscape.settings(), this.soundHandlers);
|
|
460
|
+
} else {
|
|
461
|
+
this.sound.frame(scene, local, !this.trip);
|
|
462
|
+
}
|
|
463
|
+
if (this.trip || held || this.talk.typing() || this.chrome.chatFocused?.() || decorating || this.askInput || this.menuInput) {
|
|
283
464
|
lockInput(scene);
|
|
465
|
+
// Under the engine's orbit camera key the player's drags and wheel do
|
|
466
|
+
// not move the trip's camera, nor queue up for after it.
|
|
467
|
+
if ((this.trip || decorating || this.askInput || this.menuInput) && scene.cameraControl === 'orbit') {
|
|
468
|
+
scene.lookInput?.lock?.();
|
|
469
|
+
}
|
|
284
470
|
}
|
|
285
471
|
// Grabbing and throwing (v1.3), in a place that offers it: after this
|
|
286
472
|
// frame's physics step, before the multiplayer kit reports what it owns.
|
|
287
|
-
this.grab.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking());
|
|
473
|
+
this.grab.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating);
|
|
288
474
|
if (this.trip) {
|
|
289
475
|
this.stepTrip(scene, mp, local, now);
|
|
290
476
|
} else if (!Hub.hub.faced) {
|
|
291
477
|
// A join that was not a trip (the first one) faces the arrival too.
|
|
292
478
|
this.faceArrival(scene);
|
|
293
479
|
}
|
|
480
|
+
if (Hub.hub.place?.companion === true) {
|
|
481
|
+
this.companion ??= makeCompanion({ idle: Hub.deck.companionIdle === true });
|
|
482
|
+
const cam = scene.three?.camera;
|
|
483
|
+
const view = { w: window.innerWidth, h: window.innerHeight };
|
|
484
|
+
const framing = cam ? {
|
|
485
|
+
camera: { position: cam.position, forward: cam.getWorldDirection(cam.position.clone()) },
|
|
486
|
+
panel: this.chrome.talkRect?.(), view,
|
|
487
|
+
project: (at) => project(cam, at.x, at.y, at.z, view),
|
|
488
|
+
} : null;
|
|
489
|
+
const chat = Hub.hub.place?.companionChat && this.talk.talkingToCompanion?.() ? framing ?? {} : null;
|
|
490
|
+
const activity = { ...framing, chatting: this.talk.talking() };
|
|
491
|
+
const busy = Boolean(this.talk.talkingWith()?.startsWith('companion:') || now < (this.companionTappedUntil ?? -Infinity));
|
|
492
|
+
this.companion.frame(scene, local, Hub.hub, dt, now, !this.trip && this.pendingEnd === null, chat, busy, activity);
|
|
493
|
+
} else if (this.companion) {
|
|
494
|
+
this.companion.dispose();
|
|
495
|
+
delete this.companion;
|
|
496
|
+
delete this.companionTappedUntil;
|
|
497
|
+
}
|
|
294
498
|
this.drawChrome(scene, local, now);
|
|
499
|
+
if (Hub.hub.place?.actions === true) {
|
|
500
|
+
this.actionsDrawn = true;
|
|
501
|
+
this.chrome.setActions(Hub.hub.actions?.items ?? null, (id, n) => mp.net?.send({ k: 'hub-action', id, n }), !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput, Hub.hub.actions?.n);
|
|
502
|
+
} else if (this.actionsDrawn) {
|
|
503
|
+
this.chrome.clearActions();
|
|
504
|
+
delete this.actionsDrawn;
|
|
505
|
+
}
|
|
506
|
+
// v1.68: the choice card, only where it was made above.
|
|
507
|
+
if (this.ballot) {
|
|
508
|
+
const box = this.carded ? this.chrome.hudClearBox?.() : null;
|
|
509
|
+
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);
|
|
510
|
+
}
|
|
295
511
|
this.measure(scene, mp, now);
|
|
296
512
|
}
|
|
297
513
|
|
|
514
|
+
// The soundscape (`client/soundscape.js`), only in a deck whose castle.json
|
|
515
|
+
// asks (`hub.soundscape`): without it this is never called, and no context,
|
|
516
|
+
// listener, storage read or chrome of it is made. Made with the chrome, and
|
|
517
|
+
// put away with it (`dispose`): an NPC's line in the talk panel is heard as
|
|
518
|
+
// the panel is given it, by this player alone.
|
|
519
|
+
hearPlace() {
|
|
520
|
+
const soundscape = makeSoundscape(Hub.deck.soundscape, { onHide: () => this.sound?.hush(), isOn: () => !this.trip, loudestLoop: () => this.sound?.loudestLoop() ?? 0 });
|
|
521
|
+
this.soundscape = soundscape;
|
|
522
|
+
this.sound?.filterEvents?.(soundscape.live);
|
|
523
|
+
this.soundHandlers = { onVolume: (volume) => soundscape.setVolume(volume), onMuted: (muted) => soundscape.setMuted(muted) };
|
|
524
|
+
const talkLine = this.chrome.talkLine;
|
|
525
|
+
this.chrome.talkLine = (who, text, note) => {
|
|
526
|
+
talkLine(who, text, note);
|
|
527
|
+
if (who === 'them') {
|
|
528
|
+
soundscape.say(this.scene, this.talk?.talkingWith() ?? null, text, performance.now());
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
298
533
|
// Device tiers (`client/tiers.js`), only in a deck whose castle.json asks
|
|
299
534
|
// (`hub.tiers`): without it this is never called, nothing of theirs is made
|
|
300
535
|
// or run, and the place is drawn and behaves exactly as it did. A frame
|
|
@@ -315,9 +550,40 @@ class HubSystem {
|
|
|
315
550
|
}
|
|
316
551
|
const counts = !this.trip && this.pendingEnd === null && mp?.placed?.() === true;
|
|
317
552
|
this.tiers.frame(scene, counts, now);
|
|
553
|
+
if (Hub.deck.lowActorBudget) {
|
|
554
|
+
this.actorBudget ??= makeActorBudget();
|
|
555
|
+
this.actorBudget(scene, this.tiers.current() === 'low' && !scene.content, now);
|
|
556
|
+
}
|
|
557
|
+
if (Hub.hub.place?.interest === 'cells') {
|
|
558
|
+
this.interestTier = this.tiers.current();
|
|
559
|
+
}
|
|
318
560
|
globalThis.__hub.tier = this.tiers.handle;
|
|
319
561
|
}
|
|
320
562
|
|
|
563
|
+
interestFrame(scene, now) {
|
|
564
|
+
if (Hub.hub.place?.interest !== 'cells' || !scene.multiplayer?.net) {
|
|
565
|
+
this.interestCap = null;
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (!this.interestCap || this.interestPlace !== Hub.hub.place) {
|
|
569
|
+
this.interestCap = makeInterestCap(Hub.hub.place.nearestPlayers ?? 1000);
|
|
570
|
+
this.interestPlace = Hub.hub.place;
|
|
571
|
+
}
|
|
572
|
+
const counts = !this.trip && this.pendingEnd === null && scene.multiplayer.placed?.() === true;
|
|
573
|
+
const cap = this.interestCap.frame(now, this.interestTier ?? 'high', counts);
|
|
574
|
+
if (cap !== null) {
|
|
575
|
+
scene.multiplayer.net.send({ k: 'hub-cap', n: cap });
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
registerInterest(scene) {
|
|
580
|
+
if (Hub.hub.place?.interest !== 'cells' || typeof scene.registerSystem !== 'function' || this.interestScenes?.has(scene)) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
(this.interestScenes ??= new WeakSet()).add(scene);
|
|
584
|
+
scene.registerSystem({ afterBehaviors: (s) => this.interestFrame(s, performance.now()) });
|
|
585
|
+
}
|
|
586
|
+
|
|
321
587
|
// The systems that run after every other one, registered once per runtime.
|
|
322
588
|
registerLate(scene) {
|
|
323
589
|
scene.registerSystem({
|
|
@@ -333,6 +599,34 @@ class HubSystem {
|
|
|
333
599
|
if (Hub.deck.tiers) {
|
|
334
600
|
scene.registerSystem({ afterBehaviors: (s) => this.deviceTier(s, s.multiplayer, performance.now()) });
|
|
335
601
|
}
|
|
602
|
+
// Complete sound recovery after every system, including the transport
|
|
603
|
+
// drain. A keyless deck registers no sound completion hook.
|
|
604
|
+
if (Hub.deck.soundscape) {
|
|
605
|
+
// Resident scenes can be entered again. Their existing hook already
|
|
606
|
+
// refers to this system; registering twice would count one frame twice.
|
|
607
|
+
if (this.soundScenes?.has(scene)) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
(this.soundScenes ??= new WeakSet()).add(scene);
|
|
611
|
+
scene.registerSystem({ afterBehaviors: (s) => {
|
|
612
|
+
const local = s.actorWith('Player');
|
|
613
|
+
const now = performance.now();
|
|
614
|
+
// A drain after the hub frame can still hand the panel a reply. Do
|
|
615
|
+
// that before recovery completes, so a quiet reply cannot escape
|
|
616
|
+
// into the next live frame's panel queue.
|
|
617
|
+
if (Hub.hub.npcEvents.length) {
|
|
618
|
+
this.talk?.frame(s, s.multiplayer, !this.trip && this.pendingEnd === null);
|
|
619
|
+
}
|
|
620
|
+
if (this.soundscape) {
|
|
621
|
+
const level = this.soundscape.frame(s, s.multiplayer, local, !this.trip, this.talk?.talkingWith() ?? null, now);
|
|
622
|
+
if (Hub.hub.npcEvents.length) {
|
|
623
|
+
this.talk?.frame(s, s.multiplayer, !this.trip && this.pendingEnd === null);
|
|
624
|
+
}
|
|
625
|
+
this.sound.frame(s, local, !this.trip, level);
|
|
626
|
+
this.soundscape.completeFrame(s, s.multiplayer, local, !this.trip, this.talk?.talkingWith() ?? null, now);
|
|
627
|
+
}
|
|
628
|
+
} });
|
|
629
|
+
}
|
|
336
630
|
}
|
|
337
631
|
|
|
338
632
|
// The places this player will walk back into stay built while they are away
|
|
@@ -374,33 +668,82 @@ class HubSystem {
|
|
|
374
668
|
scene.physics3d?.setVelocity?.(local, { x: 0, y: 0, z: 0 });
|
|
375
669
|
}
|
|
376
670
|
|
|
671
|
+
clearMenu() {
|
|
672
|
+
if (this.menuDrawn) {
|
|
673
|
+
this.chrome?.clearMenu();
|
|
674
|
+
delete this.menuDrawn;
|
|
675
|
+
}
|
|
676
|
+
delete Hub.hub.menuClose;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
clearTextAsk() {
|
|
680
|
+
if (this.askDrawn) {
|
|
681
|
+
this.chrome?.clearTextAsk();
|
|
682
|
+
delete this.askDrawn;
|
|
683
|
+
}
|
|
684
|
+
delete Hub.hub.askClose;
|
|
685
|
+
}
|
|
686
|
+
|
|
377
687
|
enterScene(scene) {
|
|
688
|
+
if (this.sceneKey !== null && this.sceneKey !== undefined && this.menuDrawn) {
|
|
689
|
+
this.clearMenu();
|
|
690
|
+
delete Hub.hub.menu;
|
|
691
|
+
}
|
|
692
|
+
if (this.sceneKey !== null && this.sceneKey !== undefined && this.askDrawn) {
|
|
693
|
+
this.clearTextAsk();
|
|
694
|
+
delete Hub.hub.ask;
|
|
695
|
+
}
|
|
696
|
+
clearShot();
|
|
378
697
|
this.scenePath = scene.currentScenePath;
|
|
379
698
|
this.sceneKey = sceneKeyOf(scene);
|
|
380
699
|
this.doorBase.clear();
|
|
381
700
|
this.stash.clear();
|
|
382
701
|
this.tinted.clear();
|
|
383
702
|
this.spawnedHere.clear();
|
|
703
|
+
this.companion?.clear();
|
|
384
704
|
this.wear.clear(scene);
|
|
705
|
+
this.earned.clear();
|
|
385
706
|
this.idle?.release();
|
|
707
|
+
if (this.decor) {
|
|
708
|
+
this.decor.dispose();
|
|
709
|
+
this.decor = null;
|
|
710
|
+
}
|
|
386
711
|
// What was said in the place just left stays there.
|
|
387
712
|
this.say.clear();
|
|
388
713
|
this.together.clear();
|
|
389
714
|
this.playAsk = null;
|
|
390
715
|
this.wentAsk = null;
|
|
716
|
+
this.againAsk = null;
|
|
391
717
|
this.playAsked.clear();
|
|
718
|
+
this.yours?.clear();
|
|
392
719
|
}
|
|
393
720
|
|
|
394
721
|
// Every scene load, the same scene reloaded included: the actors are the
|
|
395
722
|
// file's again, so what was dropped, painted or spawned in them is gone.
|
|
396
723
|
reset(scene) {
|
|
724
|
+
if (this.menuDrawn) {
|
|
725
|
+
this.clearMenu();
|
|
726
|
+
delete Hub.hub.menu;
|
|
727
|
+
}
|
|
728
|
+
if (this.askDrawn) {
|
|
729
|
+
this.clearTextAsk();
|
|
730
|
+
delete Hub.hub.ask;
|
|
731
|
+
}
|
|
732
|
+
clearShot();
|
|
733
|
+
this.companion?.clear();
|
|
734
|
+
if (this.decor) {
|
|
735
|
+
this.decor.dispose();
|
|
736
|
+
this.decor = null;
|
|
737
|
+
}
|
|
397
738
|
this.stash.clear();
|
|
398
739
|
this.tinted.clear();
|
|
399
740
|
this.spawnedHere.clear();
|
|
400
741
|
if (scene) {
|
|
401
742
|
this.wear.clear(scene);
|
|
743
|
+
this.earned.clear();
|
|
402
744
|
} else {
|
|
403
745
|
this.wear.forget();
|
|
746
|
+
this.earned.forget();
|
|
404
747
|
}
|
|
405
748
|
}
|
|
406
749
|
|
|
@@ -410,10 +753,32 @@ class HubSystem {
|
|
|
410
753
|
applyWear(scene) {
|
|
411
754
|
const self = scene.multiplayer?.net?.selfId?.() ?? null;
|
|
412
755
|
const style = Avatar.style();
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
756
|
+
// Dressed as the avatar drawn: `known` for the others, or the stand-in
|
|
757
|
+
// the cap draws (`avatarCap.js`), as the hook layer draws them.
|
|
758
|
+
const indexOf = (playerId) => (playerId === self ? Avatar.current(scene) : AvatarCap.shown(playerId));
|
|
759
|
+
this.wear.frame(
|
|
760
|
+
scene,
|
|
761
|
+
scene.actorWith('Player'),
|
|
762
|
+
Hub.hub.wearing,
|
|
763
|
+
(playerId) => {
|
|
764
|
+
const index = indexOf(playerId);
|
|
765
|
+
return Avatar.top(index, Avatar.drawn(scene.files, index, style));
|
|
766
|
+
},
|
|
767
|
+
undefined,
|
|
768
|
+
// Asked only for a player wearing a hat.
|
|
769
|
+
(playerId) => {
|
|
770
|
+
const index = indexOf(playerId);
|
|
771
|
+
return Avatar.hatFit(index, Avatar.drawn(scene.files, index, style));
|
|
772
|
+
},
|
|
773
|
+
);
|
|
774
|
+
// Earned items (v1.53): no work at all while nobody shows one and
|
|
775
|
+
// nothing is drawn.
|
|
776
|
+
if (Hub.hub.earned.size > 0 || this.earned.size > 0) {
|
|
777
|
+
this.earned.frame(scene, scene.actorWith('Player'), Hub.hub.earned, (playerId) => {
|
|
778
|
+
const index = indexOf(playerId);
|
|
779
|
+
return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
|
|
780
|
+
});
|
|
781
|
+
}
|
|
417
782
|
}
|
|
418
783
|
|
|
419
784
|
// The place's tuning of this player's own controller (`hub.tune`): the
|
|
@@ -447,7 +812,7 @@ class HubSystem {
|
|
|
447
812
|
if (!model) {
|
|
448
813
|
return;
|
|
449
814
|
}
|
|
450
|
-
const file = Avatar.model(scene.files, Avatar.current(scene));
|
|
815
|
+
const file = Avatar.model(scene.files, Avatar.current(scene), Avatar.style(), Avatar.currentColor(scene));
|
|
451
816
|
if (file && model.file !== file) {
|
|
452
817
|
model.file = file;
|
|
453
818
|
}
|
|
@@ -458,46 +823,140 @@ class HubSystem {
|
|
|
458
823
|
// out at once, so arrival never waits on the avatar; when the avatar
|
|
459
824
|
// changes (the platform's answer, a pick) it says hello again and the place
|
|
460
825
|
// redraws the body in the new one.
|
|
826
|
+
//
|
|
827
|
+
// A connection that comes back to a session that let it go (a phone's app
|
|
828
|
+
// switch: the platform reported a leave and the place forgot the player) says
|
|
829
|
+
// hello again, in every place but a game that did not opt in to `resume`
|
|
830
|
+
// (`client/rehello.js` says how that is seen), without waiting for the place's own greet: a fresh hello, so the
|
|
831
|
+
// place re-sends what it had sent, from a party of one and carrying nothing
|
|
832
|
+
// (it has arrived once already), keeping this client's chat and start. A
|
|
833
|
+
// place that still has the player arrived does not arrive them again.
|
|
461
834
|
sayHello(scene, mp) {
|
|
462
835
|
const net = mp.net;
|
|
463
836
|
if (!net) {
|
|
464
837
|
return;
|
|
465
838
|
}
|
|
466
839
|
const avatar = Avatar.current(scene);
|
|
467
|
-
|
|
840
|
+
const color = Avatar.currentColor(scene);
|
|
841
|
+
if (net === this.helloNet) {
|
|
842
|
+
const back = Rehello.resumed(mp, net, this.helloMark);
|
|
843
|
+
// (Another player id was reset for by `newIdentity`, already.) A game
|
|
844
|
+
// (a place with `result`) back under the same id keeps the old way, as
|
|
845
|
+
// its server does, unless its place says `resume: true` (v1.72); under a
|
|
846
|
+
// new id it is a session that never arrived this player, which an
|
|
847
|
+
// ordinary first hello does (`helloAfter`).
|
|
848
|
+
const place = Hub.hub.place ?? this.identityPlace;
|
|
849
|
+
const say = Rehello.helloAfter(back, Boolean(place?.result), place?.resume === true);
|
|
850
|
+
if (say !== 'none') {
|
|
851
|
+
console.log(`[hub] the connection came back (${back}): saying a ${say} hello`);
|
|
852
|
+
this.sendHello(scene, mp, net, avatar, say === 'resume' ? { resume: true } : { solo: true });
|
|
853
|
+
if (back === 'world') {
|
|
854
|
+
this.talk?.resume();
|
|
855
|
+
}
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if (back) {
|
|
859
|
+
this.helloMark = Rehello.mark(mp, net);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
if (net === this.helloNet && avatar === this.helloAvatar && color === (this.helloColor ?? 0)) {
|
|
468
863
|
return;
|
|
469
864
|
}
|
|
470
865
|
// The same session again (the avatar changed): the place keeps what it
|
|
471
866
|
// knows this client holds (a cabinet's card, v1.7).
|
|
472
867
|
const again = net === this.helloNet;
|
|
473
868
|
if (!again) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
869
|
+
this.identityPlace = null;
|
|
870
|
+
this.freshSession(scene);
|
|
871
|
+
}
|
|
872
|
+
this.sendHello(scene, mp, net, avatar, { again });
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// The same connection under another player id is another session: what the
|
|
876
|
+
// old one sent this player (its HUD, tune, decor, card, shot, labels, holds
|
|
877
|
+
// and the snapshot's state) goes before the new one's packets are applied,
|
|
878
|
+
// as on any switch of session, along with what this client kept of it.
|
|
879
|
+
newIdentity() {
|
|
880
|
+
console.log('[hub] the connection has a new player id: a new session');
|
|
881
|
+
this.identityPlace = Hub.hub.place ?? this.identityPlace;
|
|
882
|
+
Hub.clear();
|
|
883
|
+
if (ballotHeld) {
|
|
884
|
+
forgetBallot();
|
|
885
|
+
}
|
|
886
|
+
if (this.scene) {
|
|
887
|
+
this.freshSession(this.scene);
|
|
888
|
+
}
|
|
889
|
+
// A recovery, not a walk-in: no automatic start beside a friend.
|
|
890
|
+
this.startNear = null;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// What this client keeps of one session, cleared when it joins another.
|
|
894
|
+
freshSession(scene) {
|
|
895
|
+
// A player who walks in (no door, no jump to a friend) starts beside a
|
|
896
|
+
// friend or party member who is already here, once, if one turns up in
|
|
897
|
+
// the first moments and the player has not walked off.
|
|
898
|
+
const arrivingNow = scene.persistent?.hubArriving ?? null;
|
|
899
|
+
this.startNear = !arrivingNow?.door && typeof arrivingNow?.near !== 'string' ? { until: performance.now() + START_NEAR_MS, at: null, asked: false } : null;
|
|
900
|
+
this.friendsAt = -Infinity;
|
|
901
|
+
this.friendsGameAt = -Infinity;
|
|
902
|
+
this.friendsGameWarm = false;
|
|
903
|
+
// Another session (a door, a layer): what was said in the last one stays there.
|
|
904
|
+
this.companion?.clear();
|
|
905
|
+
this.say.clear();
|
|
906
|
+
this.together.clear();
|
|
907
|
+
this.playAsk = null;
|
|
908
|
+
this.wentAsk = null;
|
|
909
|
+
this.againAsk = null;
|
|
910
|
+
this.playAsked.clear();
|
|
911
|
+
this.chat.reset();
|
|
912
|
+
this.talk?.reset();
|
|
913
|
+
if (Hub.deck.cues) {
|
|
914
|
+
this.hereCues = [];
|
|
915
|
+
this.besideTold = null;
|
|
916
|
+
this.rosterSeen = new Set();
|
|
917
|
+
// The party this session is first told of is the one the player had.
|
|
918
|
+
this.partyCarryUntil = this.partyLast?.members ? performance.now() + PARTY_CARRY_MS : 0;
|
|
919
|
+
this.partyLast = null;
|
|
920
|
+
this.partySettleUntil = performance.now() + PARTY_SETTLE_MS;
|
|
921
|
+
this.partyAccepted = null;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// `solo`: a party of one carrying nothing and naming no friend, as `resume`
|
|
926
|
+
// is, without saying it resumes (a game's new session, `helloAfter`).
|
|
927
|
+
sendHello(scene, mp, net, avatar, { again = false, resume = false, solo = resume } = {}) {
|
|
928
|
+
if (resume && (this.menuDrawn || Object.hasOwn(Hub.hub, 'menu'))) {
|
|
929
|
+
this.clearMenu();
|
|
930
|
+
delete Hub.hub.menu;
|
|
931
|
+
}
|
|
932
|
+
if (resume && Object.hasOwn(Hub.hub, 'companion')) {
|
|
933
|
+
delete Hub.hub.companion;
|
|
934
|
+
this.companion?.clear();
|
|
935
|
+
}
|
|
936
|
+
if (resume && (this.askDrawn || Object.hasOwn(Hub.hub, 'ask'))) {
|
|
937
|
+
this.clearTextAsk();
|
|
938
|
+
delete Hub.hub.ask;
|
|
939
|
+
}
|
|
940
|
+
if (resume && Object.hasOwn(Hub.hub, 'actions')) {
|
|
941
|
+
delete Hub.hub.actions;
|
|
487
942
|
}
|
|
488
943
|
this.helloNet = net;
|
|
489
944
|
this.helloAvatar = avatar;
|
|
945
|
+
this.helloColor = Avatar.currentColor(scene);
|
|
946
|
+
this.helloMark = Rehello.mark(mp, net, () => this.newIdentity());
|
|
490
947
|
const per = scene.persistent;
|
|
491
948
|
const arriving = per.hubArriving ?? null;
|
|
492
949
|
net.send({
|
|
493
950
|
k: 'hub-hello',
|
|
494
951
|
avatar,
|
|
952
|
+
...(Number.isInteger(this.helloColor) && this.helloColor > 0 ? { color: this.helloColor } : {}),
|
|
495
953
|
from: arriving?.door ?? null,
|
|
496
|
-
party: arriving?.party ?? 1,
|
|
497
|
-
carry: arriving?.returning && per.hubResult ? { result: per.hubResult } : null,
|
|
954
|
+
party: solo ? 1 : arriving?.party ?? 1,
|
|
955
|
+
carry: !solo && arriving?.returning && per.hubResult ? { result: per.hubResult } : null,
|
|
498
956
|
// A jump to a friend: the place puts this player beside them.
|
|
499
|
-
...(typeof arriving?.near === 'string' ? { near: arriving.near } : {}),
|
|
957
|
+
...(!solo && typeof arriving?.near === 'string' ? { near: arriving.near } : {}),
|
|
500
958
|
...(again ? { again: true } : {}),
|
|
959
|
+
...(resume ? { resume: true } : {}),
|
|
501
960
|
});
|
|
502
961
|
}
|
|
503
962
|
|
|
@@ -508,11 +967,14 @@ class HubSystem {
|
|
|
508
967
|
// An actor the place moves (`hub.move`) has its pose written by the network
|
|
509
968
|
// each frame it moves, which lifts it back up: it is dropped again, and
|
|
510
969
|
// shown again by lifting it from wherever it is.
|
|
970
|
+
// The engine is told before each write (`scene.touch`): a scene may hold
|
|
971
|
+
// the actor still (physics-3d `"engine": { "staticActors": true }`).
|
|
511
972
|
applyVisibility(scene) {
|
|
512
973
|
for (const id of Hub.hub.hidden) {
|
|
513
974
|
const t = scene.getActor(id)?.components.Transform;
|
|
514
975
|
if (t && t.y > -HIDE_DROP_M / 2) {
|
|
515
976
|
this.stash.set(id, true);
|
|
977
|
+
scene.touch?.(id);
|
|
516
978
|
t.y -= HIDE_DROP_M;
|
|
517
979
|
}
|
|
518
980
|
}
|
|
@@ -521,6 +983,7 @@ class HubSystem {
|
|
|
521
983
|
this.stash.delete(id);
|
|
522
984
|
const t = scene.getActor(id)?.components.Transform;
|
|
523
985
|
if (t && t.y < -HIDE_DROP_M / 2) {
|
|
986
|
+
scene.touch?.(id);
|
|
524
987
|
t.y += HIDE_DROP_M;
|
|
525
988
|
}
|
|
526
989
|
}
|
|
@@ -550,6 +1013,9 @@ class HubSystem {
|
|
|
550
1013
|
components.Transform = { ...components.Transform, x: copy.x, y: copy.y, z: copy.z, rotationY: copy.rotationY };
|
|
551
1014
|
scene.spawnActor({ id, components });
|
|
552
1015
|
this.spawnedHere.add(id);
|
|
1016
|
+
if (components.HubSpin) {
|
|
1017
|
+
this.spin = addSpinner(this.spin, id, components);
|
|
1018
|
+
}
|
|
553
1019
|
}
|
|
554
1020
|
for (const id of this.spawnedHere) {
|
|
555
1021
|
if (!Object.hasOwn(want, id)) {
|
|
@@ -563,6 +1029,20 @@ class HubSystem {
|
|
|
563
1029
|
}
|
|
564
1030
|
}
|
|
565
1031
|
|
|
1032
|
+
// Turning displays (contract §10, v1.55): the scene's `HubSpin` actors are
|
|
1033
|
+
// found once per scene load, by the loaded data's identity, and copies as
|
|
1034
|
+
// they are spawned (`applySpawns`). A scene with none leaves `this.spin`
|
|
1035
|
+
// null and nothing is turned, touched or written.
|
|
1036
|
+
turnSpinners(scene, dt) {
|
|
1037
|
+
if (scene.data !== this.spinData) {
|
|
1038
|
+
this.spinData = scene.data;
|
|
1039
|
+
this.spin = findSpinners(scene.data?.actors);
|
|
1040
|
+
}
|
|
1041
|
+
if (this.spin) {
|
|
1042
|
+
spinFrame(this.spin, scene, dt, Hub.hub.hidden);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
566
1046
|
// Paint what the place painted, and put back what it stopped painting
|
|
567
1047
|
// (`hub.tint`, contract §10). A Shape that glows glows in its new colour.
|
|
568
1048
|
applyTints(scene) {
|
|
@@ -576,6 +1056,7 @@ class HubSystem {
|
|
|
576
1056
|
this.tinted.set(id, { color: shape.color, tint: shape.tint, emissive: shape.emissive });
|
|
577
1057
|
}
|
|
578
1058
|
// A textured face takes its colour from `tint`, a plain one from `color`.
|
|
1059
|
+
scene.touch?.(id);
|
|
579
1060
|
shape.color = color;
|
|
580
1061
|
shape.tint = color;
|
|
581
1062
|
if (glows(this.tinted.get(id).emissive)) {
|
|
@@ -587,6 +1068,7 @@ class HubSystem {
|
|
|
587
1068
|
this.tinted.delete(id);
|
|
588
1069
|
const shape = scene.getActor(id)?.components.Shape;
|
|
589
1070
|
if (shape) {
|
|
1071
|
+
scene.touch?.(id);
|
|
590
1072
|
shape.color = authored.color;
|
|
591
1073
|
shape.tint = authored.tint;
|
|
592
1074
|
shape.emissive = authored.emissive;
|
|
@@ -648,7 +1130,10 @@ class HubSystem {
|
|
|
648
1130
|
runCommands(scene, now) {
|
|
649
1131
|
while (Hub.hub.commands.length && !this.trip) {
|
|
650
1132
|
const msg = Hub.hub.commands.shift();
|
|
651
|
-
if (msg.k === 'hub-
|
|
1133
|
+
if (msg.k === 'hub-home-unlock') {
|
|
1134
|
+
// v1.77: a harbour boat deed names the Harbour; anything else is the house.
|
|
1135
|
+
this.toast = { text: msg.to === 'boat' ? 'Sent to your boat at the Harbour' : 'Sent to your house', until: now + TOAST_MS };
|
|
1136
|
+
} else if (msg.k === 'hub-go' && msg.classic) {
|
|
652
1137
|
// A cabinet: the host plays a classic deck; this place waits (v1.7).
|
|
653
1138
|
this.goClassic(scene, msg);
|
|
654
1139
|
} else if (msg.k === 'hub-go' && !msg.key) {
|
|
@@ -658,9 +1143,10 @@ class HubSystem {
|
|
|
658
1143
|
this.go(scene, msg);
|
|
659
1144
|
} else if (msg.k === 'hub-result') {
|
|
660
1145
|
scene.persistent.hubResult = { ...msg.result, at: Date.now() };
|
|
661
|
-
} else if (msg.k === 'hub-end') {
|
|
1146
|
+
} else if (msg.k === 'hub-end' && Rehello.takesEnd(msg, this.pendingEnd, this.endSession, sessionKey(scene))) {
|
|
662
1147
|
this.pendingEnd = now + END_PAUSE_MS;
|
|
663
1148
|
this.endSession = sessionKey(scene);
|
|
1149
|
+
this.endLeaving = null;
|
|
664
1150
|
const r = scene.persistent.hubResult;
|
|
665
1151
|
this.toast = { text: r && Date.now() - r.at < 30000 ? resultLine(r) : 'Game over', until: now + END_PAUSE_MS + 200 };
|
|
666
1152
|
}
|
|
@@ -796,7 +1282,7 @@ class HubSystem {
|
|
|
796
1282
|
stepClassic(scene, trip, mp, now) {
|
|
797
1283
|
const pending = trip.target.pending;
|
|
798
1284
|
trip.marks.covered ??= now;
|
|
799
|
-
this.
|
|
1285
|
+
this.setTripCover(1, trip);
|
|
800
1286
|
if (!pending.done && now - trip.startedAt < CLASSIC_LIMIT_MS) {
|
|
801
1287
|
return;
|
|
802
1288
|
}
|
|
@@ -853,6 +1339,7 @@ class HubSystem {
|
|
|
853
1339
|
// retries no failed hub join, and `AWAY_JOIN` is one it could not make
|
|
854
1340
|
// anyway. The next `switchSession` (Back) clears that.
|
|
855
1341
|
leaveSession(scene, mp) {
|
|
1342
|
+
clearShot();
|
|
856
1343
|
mp.switchSession(scene, AWAY_JOIN, { quiet: true });
|
|
857
1344
|
mp.joinFailed = true;
|
|
858
1345
|
this.helloNet = null;
|
|
@@ -1038,20 +1525,57 @@ class HubSystem {
|
|
|
1038
1525
|
}
|
|
1039
1526
|
|
|
1040
1527
|
// Who of the player's friends is in another layer of this place, asked every
|
|
1041
|
-
// little while from a
|
|
1042
|
-
//
|
|
1043
|
-
// friends) stops asking for the life of the runtime; a failed ask is retried.
|
|
1528
|
+
// little while from a town; a requesting game asks at once, after 20 s,
|
|
1529
|
+
// then every 90 s. Dormant on a host that cannot say: `unavailable`
|
|
1530
|
+
// (no hub support) or a refusal (a host from before friends) stops asking for the life of the runtime; a failed ask is retried.
|
|
1044
1531
|
askFriends(scene, mp, now) {
|
|
1045
1532
|
if (this.friendsOff || this.friendsAsking || typeof castleSdk.Hub?.friends !== 'function') {
|
|
1046
1533
|
return;
|
|
1047
1534
|
}
|
|
1048
1535
|
const place = Hub.hub.place;
|
|
1049
1536
|
const idle = !this.trip && this.pendingEnd === null && (mp.joinState?.() ?? 'joined') === 'joined';
|
|
1050
|
-
if (!place || place.result
|
|
1537
|
+
if (!place || (place.result && !Hub.hub.friendsWanted) || !idle) {
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
// Cues (v1.23): someone here is not named by the host as a friend, and
|
|
1541
|
+
// may be one it has not heard is here yet (it learns presence on a
|
|
1542
|
+
// heartbeat), so the host is asked again when `together.due` says, not
|
|
1543
|
+
// at the end of its 20 s. Every bound is measured from asks that were
|
|
1544
|
+
// really sent: at most two such asks in any 8 s, 2 s apart, none within
|
|
1545
|
+
// 1 s of any ask.
|
|
1546
|
+
// One that cannot be sent (a trip, a join still pending) reaches none of
|
|
1547
|
+
// this and is simply tried again when it can be, owing nothing it missed.
|
|
1548
|
+
const game = Boolean(place.result);
|
|
1549
|
+
const gameEvery = this.friendsGameWarm ? 20000 : 90000;
|
|
1550
|
+
const onTime = game ? now - this.friendsGameAt >= gameEvery : now - this.friendsAt >= FRIENDS_EVERY_MS;
|
|
1551
|
+
const early =
|
|
1552
|
+
!game &&
|
|
1553
|
+
!onTime &&
|
|
1554
|
+
Hub.deck.cues &&
|
|
1555
|
+
now - this.friendsEarlyAt >= FRIENDS_EARLY_PAIR_MS &&
|
|
1556
|
+
now - this.friendsEarlyBeforeAt >= 2 * FRIENDS_EARLY_MS &&
|
|
1557
|
+
now - this.friendsSentAt >= FRIENDS_EARLY_AFTER_MS &&
|
|
1558
|
+
this.together.due(this.friendsAll, now);
|
|
1559
|
+
if (!onTime && !early) {
|
|
1051
1560
|
return;
|
|
1052
1561
|
}
|
|
1053
1562
|
this.friendsAt = now;
|
|
1563
|
+
if (game) {
|
|
1564
|
+
// The first ask may precede the heartbeat roster. One warm-up ask
|
|
1565
|
+
// 20 s later writes the seen marker after the player reaches it.
|
|
1566
|
+
this.friendsGameWarm = this.friendsGameAt === -Infinity;
|
|
1567
|
+
this.friendsGameAt = now;
|
|
1568
|
+
}
|
|
1054
1569
|
this.friendsAsking = true;
|
|
1570
|
+
if (Hub.deck.cues) {
|
|
1571
|
+
// Sent: the bounds count from here, and the steps come due are spent.
|
|
1572
|
+
this.friendsSentAt = now;
|
|
1573
|
+
if (early) {
|
|
1574
|
+
this.friendsEarlyBeforeAt = this.friendsEarlyAt;
|
|
1575
|
+
this.friendsEarlyAt = now;
|
|
1576
|
+
}
|
|
1577
|
+
this.together.asked(now);
|
|
1578
|
+
}
|
|
1055
1579
|
const key = this.sceneKey;
|
|
1056
1580
|
Promise.resolve(castleSdk.Hub.friends())
|
|
1057
1581
|
.then((answer) => {
|
|
@@ -1130,6 +1654,68 @@ class HubSystem {
|
|
|
1130
1654
|
}
|
|
1131
1655
|
}
|
|
1132
1656
|
|
|
1657
|
+
// "Stuck?" (v1.33, `client/stuck.js`), only in a deck whose castle.json asks
|
|
1658
|
+
// (`hub.stuck`): without it this is never called and nothing of it is made.
|
|
1659
|
+
// A chip is offered to a player who has walked for a few seconds and got
|
|
1660
|
+
// nowhere; nothing moves them but their own tap. Only in a town that says
|
|
1661
|
+
// it takes it (`hubStuck`), and never to a player the place holds.
|
|
1662
|
+
offerUnstick(scene, local, town, now) {
|
|
1663
|
+
const offer = town ? Hub.hub.stuck : null;
|
|
1664
|
+
const t = local?.components.Transform;
|
|
1665
|
+
const selfId = scene.multiplayer?.net?.selfId?.();
|
|
1666
|
+
if (!offer || !t || Hub.hub.held.has(selfId)) {
|
|
1667
|
+
if (this.stuck) {
|
|
1668
|
+
resetStuck(this.stuck);
|
|
1669
|
+
this.stuckShown = false;
|
|
1670
|
+
this.chrome.stuckPrompt?.(null);
|
|
1671
|
+
}
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
this.stuck ??= makeStuck();
|
|
1675
|
+
const walking = walkInput(scene.keys, scene.moveInput, scene.cameraControl === 'orbit');
|
|
1676
|
+
const hidden = globalThis.document?.visibilityState === 'hidden';
|
|
1677
|
+
const shown = stuckFrame(this.stuck, { key: `${this.sceneKey}|${Hub.hub.place.id}`, x: t.x, z: t.z, walking, hidden }, now);
|
|
1678
|
+
let text = shown ? stuckText(offer.to) : null;
|
|
1679
|
+
if (offer.hook) {
|
|
1680
|
+
// v1.39, a place that picks the spot itself: asked, as the chip comes
|
|
1681
|
+
// up, what a tap would do from here; until it answers the words name
|
|
1682
|
+
// nowhere. And what it did, once the player has tapped.
|
|
1683
|
+
if (shown && !this.stuckShown) {
|
|
1684
|
+
Hub.hub.stuckTo = null;
|
|
1685
|
+
scene.multiplayer?.net?.send({ k: 'hub-unstick', ask: true });
|
|
1686
|
+
}
|
|
1687
|
+
const says = Hub.hub.stuckTo;
|
|
1688
|
+
text = shown ? (says ? stuckText(says.to, says.spot) : stuckText(null, true)) : null;
|
|
1689
|
+
const done = Hub.hub.unstuck;
|
|
1690
|
+
if (done) {
|
|
1691
|
+
Hub.hub.unstuck = null;
|
|
1692
|
+
this.toast = { text: stuckDone(done.to, done.spot), until: now + TOAST_MS };
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
this.stuckShown = shown;
|
|
1696
|
+
this.chrome.stuckPrompt?.(text, () => this.unstick(this.scene));
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
// A tap on the chip or the Doors row: the place is asked to put this player
|
|
1700
|
+
// back at its arrival (`hub-unstick`), at most as often as it would answer.
|
|
1701
|
+
unstick(scene) {
|
|
1702
|
+
const net = scene?.multiplayer?.net;
|
|
1703
|
+
const now = performance.now();
|
|
1704
|
+
const offer = Hub.hub.stuck;
|
|
1705
|
+
if (!Hub.deck.stuck || !net || this.trip || !offer || now - (this.unstuckAt ?? -Infinity) < STUCK_EVERY_MS) {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
this.unstuckAt = now;
|
|
1709
|
+
if (this.stuck) {
|
|
1710
|
+
resetStuck(this.stuck);
|
|
1711
|
+
}
|
|
1712
|
+
this.sendJump(net, { k: 'hub-unstick' });
|
|
1713
|
+
// A place that picks the spot says where it was (`hub-jumped`), and is quoted then.
|
|
1714
|
+
if (!offer.hook) {
|
|
1715
|
+
this.toast = { text: stuckWhere(offer.to), until: now + TOAST_MS };
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1133
1719
|
// Go, from the Doors list: onto that door's pad. In a party the door is
|
|
1134
1720
|
// proposed to the party too, and each member who says yes lands on the pad.
|
|
1135
1721
|
goDoor(scene, door) {
|
|
@@ -1172,6 +1758,8 @@ class HubSystem {
|
|
|
1172
1758
|
this.startNear = null;
|
|
1173
1759
|
if (name) {
|
|
1174
1760
|
this.toast = { text: `You're next to ${name}`, until: now + TOAST_MS };
|
|
1761
|
+
// Cues: this friend has been told; "is here" would say it twice.
|
|
1762
|
+
this.besideTold = start.asked;
|
|
1175
1763
|
}
|
|
1176
1764
|
return;
|
|
1177
1765
|
}
|
|
@@ -1264,6 +1852,17 @@ class HubSystem {
|
|
|
1264
1852
|
if (invite) {
|
|
1265
1853
|
return { key: `invite:${invite.from}`, kind: 'invite', from: invite.from, text: `${invite.username ?? 'Someone'} invited you to their party`, yes: 'Join party', no: 'No thanks' };
|
|
1266
1854
|
}
|
|
1855
|
+
// Cues (v1.29): back from a game with nothing else asked -- the same game
|
|
1856
|
+
// again, with the party when there is one (the Doors list's own Go).
|
|
1857
|
+
if (Hub.deck.yourGames && !proposal) {
|
|
1858
|
+
return this.yours?.ask(Hub.hub.yours, Hub.hub.doors, Hub.hub.party.members, performance.now()) ?? null;
|
|
1859
|
+
}
|
|
1860
|
+
const again = Hub.deck.cues && !Hub.deck.yourGames ? this.againAsk : null;
|
|
1861
|
+
const door = again && performance.now() < again.until ? Hub.hub.doors.find((d) => d.id === again.door) : null;
|
|
1862
|
+
if (door) {
|
|
1863
|
+
const together = Hub.hub.party.members?.length && !door.solo;
|
|
1864
|
+
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' };
|
|
1865
|
+
}
|
|
1267
1866
|
return null;
|
|
1268
1867
|
}
|
|
1269
1868
|
|
|
@@ -1272,6 +1871,30 @@ class HubSystem {
|
|
|
1272
1871
|
if (!net || !ask) {
|
|
1273
1872
|
return;
|
|
1274
1873
|
}
|
|
1874
|
+
if (ask.kind === 'yours') {
|
|
1875
|
+
const current = this.ask();
|
|
1876
|
+
if (!Hub.deck.yourGames || current?.key !== ask.key || this.trip || Hub.hub.place?.result) {
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
this.yours.dismiss();
|
|
1880
|
+
if (yes) {
|
|
1881
|
+
this.goDoor(scene, Hub.hub.doors.find((d) => d.id === ask.door));
|
|
1882
|
+
}
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
if (ask.kind === 'again') {
|
|
1886
|
+
// Only the offer that is up: one whose time ran out, or that a later
|
|
1887
|
+
// return replaced, is answered by nothing.
|
|
1888
|
+
const again = this.againAsk;
|
|
1889
|
+
if (!Hub.deck.cues || !again || ask.key !== `again:${again.door}:${again.until}` || performance.now() >= again.until) {
|
|
1890
|
+
return;
|
|
1891
|
+
}
|
|
1892
|
+
this.againAsk = null;
|
|
1893
|
+
if (yes) {
|
|
1894
|
+
this.goDoor(scene, Hub.hub.doors.find((d) => d.id === again.door));
|
|
1895
|
+
}
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1275
1898
|
if (ask.kind === 'play') {
|
|
1276
1899
|
// "Back soon" (no door on the question): OK stays, the other button
|
|
1277
1900
|
// goes to wait at the door.
|
|
@@ -1288,6 +1911,67 @@ class HubSystem {
|
|
|
1288
1911
|
net.send({ k: 'hub-party', op: yes ? 'go-yes' : 'go-no', id: ask.id });
|
|
1289
1912
|
} else {
|
|
1290
1913
|
net.send({ k: 'hub-party', op: yes ? 'accept' : 'decline', from: ask.from });
|
|
1914
|
+
if (Hub.deck.cues && yes) {
|
|
1915
|
+
// Cues: the party that comes of this is one the player joined.
|
|
1916
|
+
this.partyAccepted = { from: ask.from, username: Hub.hub.party.invite?.username ?? null, until: performance.now() + PARTY_ACCEPT_MS };
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
// Cues (v1.23): the friends found already in this layer are told to the
|
|
1922
|
+
// player ("amy is here") and pointed to, one at a time and never over
|
|
1923
|
+
// another toast -- the result line of a game just left, or "You're next to
|
|
1924
|
+
// amy", which says it already.
|
|
1925
|
+
cueHere(now) {
|
|
1926
|
+
const waiting = [];
|
|
1927
|
+
for (const who of this.hereCues) {
|
|
1928
|
+
// Gone, or no longer a friend the player can see, since it was queued:
|
|
1929
|
+
// nothing is said of someone who is not here.
|
|
1930
|
+
if (this.besideTold === who.playerId || now > who.until || !this.together.close(who.playerId)) {
|
|
1931
|
+
continue;
|
|
1932
|
+
}
|
|
1933
|
+
// A start beside a friend still to be asked for, or asked for this one:
|
|
1934
|
+
// its own toast may be about to say it.
|
|
1935
|
+
if ((this.startNear && (!this.startNear.asked || this.startNear.asked === who.playerId)) || now < this.toast.until) {
|
|
1936
|
+
waiting.push(who);
|
|
1937
|
+
continue;
|
|
1938
|
+
}
|
|
1939
|
+
this.toast = { text: `${who.username ?? 'A friend'} is here · People to join`, until: now + TOAST_MS };
|
|
1940
|
+
this.together.ping(who.playerId, now, true);
|
|
1941
|
+
}
|
|
1942
|
+
this.hereCues = waiting;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
// Cues (v1.23): a party that gained someone says so -- "You joined amy's
|
|
1946
|
+
// party" to the one who accepted, "bo joined your party" to the rest. Not
|
|
1947
|
+
// the party a session is first told of (the player had it already), and
|
|
1948
|
+
// not a member back from a game (one fewer is away).
|
|
1949
|
+
cueParty(net, now) {
|
|
1950
|
+
if (this.trip) {
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
const cur = Hub.hub.party;
|
|
1954
|
+
const prev = this.partyLast;
|
|
1955
|
+
this.partyLast = { members: cur.members ? [...cur.members] : null, away: cur.away };
|
|
1956
|
+
if (!prev || now < this.partySettleUntil) {
|
|
1957
|
+
return;
|
|
1958
|
+
}
|
|
1959
|
+
const gained = (cur.members ?? []).filter((id) => !prev.members?.includes(id));
|
|
1960
|
+
if (!gained.length || cur.away < prev.away) {
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
if (!prev.members && now < this.partyCarryUntil) {
|
|
1964
|
+
this.partyCarryUntil = 0;
|
|
1965
|
+
return;
|
|
1966
|
+
}
|
|
1967
|
+
const accepted = this.partyAccepted;
|
|
1968
|
+
this.partyAccepted = null;
|
|
1969
|
+
const nameOf = (playerId) => net?.others?.().get(playerId) || null;
|
|
1970
|
+
if (accepted && now < accepted.until && cur.members.includes(accepted.from)) {
|
|
1971
|
+
const name = accepted.username ?? nameOf(accepted.from);
|
|
1972
|
+
this.toast = { text: name ? `You joined ${name}'s party` : 'You joined the party', until: now + TOAST_MS };
|
|
1973
|
+
} else {
|
|
1974
|
+
this.toast = { text: `${nameOf(gained[0]) ?? 'Someone'} joined your party`, until: now + TOAST_MS };
|
|
1291
1975
|
}
|
|
1292
1976
|
}
|
|
1293
1977
|
|
|
@@ -1321,9 +2005,18 @@ class HubSystem {
|
|
|
1321
2005
|
});
|
|
1322
2006
|
}
|
|
1323
2007
|
|
|
2008
|
+
// A user Back first dismisses the menu; automatic travel still uses back.
|
|
2009
|
+
backFromControl(scene) {
|
|
2010
|
+
if (this.chrome?.menuOpen?.()) {
|
|
2011
|
+
this.chrome.cancelMenu();
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
this.back(scene);
|
|
2015
|
+
}
|
|
2016
|
+
|
|
1324
2017
|
// Back through the door this player came in by (contract §5). With no ticket
|
|
1325
2018
|
// -- a game played on its own -- it is a fresh instance of the same place.
|
|
1326
|
-
back(scene, { covered = false, attempt = 0, lost = 0, away = null } = {}) {
|
|
2019
|
+
back(scene, { covered = false, attempt = 0, lost = 0, away = null, previousTrip = null } = {}) {
|
|
1327
2020
|
// Away in a classic deck (v1.7): Back is the way out, cover already down.
|
|
1328
2021
|
if (this.trip?.phase === 'away') {
|
|
1329
2022
|
away = this.trip.target;
|
|
@@ -1364,7 +2057,7 @@ class HubSystem {
|
|
|
1364
2057
|
attempt,
|
|
1365
2058
|
lost,
|
|
1366
2059
|
away,
|
|
1367
|
-
});
|
|
2060
|
+
}, previousTrip);
|
|
1368
2061
|
if (covered && this.trip) {
|
|
1369
2062
|
this.trip.startedAt -= OPEN_MS;
|
|
1370
2063
|
}
|
|
@@ -1381,7 +2074,7 @@ class HubSystem {
|
|
|
1381
2074
|
exitDoor: null,
|
|
1382
2075
|
arrive: { door: null, party: 1, returning: false },
|
|
1383
2076
|
lost,
|
|
1384
|
-
});
|
|
2077
|
+
}, previousTrip);
|
|
1385
2078
|
return;
|
|
1386
2079
|
}
|
|
1387
2080
|
this.startTrip(scene, {
|
|
@@ -1397,32 +2090,73 @@ class HubSystem {
|
|
|
1397
2090
|
arrive: { door: ticket.door, party: ticket.party ?? 1, returning: true },
|
|
1398
2091
|
ticket,
|
|
1399
2092
|
lost,
|
|
1400
|
-
});
|
|
2093
|
+
}, previousTrip);
|
|
1401
2094
|
if (covered && this.trip) {
|
|
1402
2095
|
// Straight to the swap: the door already closed over the player.
|
|
1403
2096
|
this.trip.startedAt -= OPEN_MS;
|
|
1404
2097
|
}
|
|
1405
2098
|
}
|
|
1406
2099
|
|
|
1407
|
-
startTrip(scene, target) {
|
|
2100
|
+
startTrip(scene, target, previousTrip = null) {
|
|
1408
2101
|
if (this.trip) {
|
|
1409
2102
|
return;
|
|
1410
2103
|
}
|
|
2104
|
+
clearShot();
|
|
2105
|
+
if (Hub.deck.soundscape?.ui === true && target.exitDoor) {
|
|
2106
|
+
this.soundscape?.cue('door', performance.now());
|
|
2107
|
+
}
|
|
1411
2108
|
const cam = scene.three?.camera;
|
|
2109
|
+
const startedAt = performance.now();
|
|
2110
|
+
// Local screenshot fixture, like hubFriends: never on a hosted page.
|
|
2111
|
+
const { hostname, search } = globalThis.location ?? {};
|
|
2112
|
+
const devLine = hostname === 'localhost' || hostname === '127.0.0.1'
|
|
2113
|
+
? new URLSearchParams(search ?? '').get('hubLeaving')?.trim().slice(0, 120)
|
|
2114
|
+
: null;
|
|
2115
|
+
previousTrip ??= this.pendingEnd !== null ? this.endLeaving : null;
|
|
2116
|
+
const leaving = previousTrip ? previousTrip.leaving : target.classic || target.away ? null : Hub.hub.leaving ?? (devLine || null);
|
|
2117
|
+
const leavingUntil = previousTrip ? previousTrip.leavingUntil : startedAt + LEAVING_MS;
|
|
2118
|
+
// The toast as the trip began: one set after this (feedback during the trip) wins over the line.
|
|
2119
|
+
const toastAtStart = previousTrip?.toastAtStart ?? this.toast;
|
|
2120
|
+
this.leavingToast = null;
|
|
1412
2121
|
this.tripCount += 1;
|
|
1413
2122
|
this.trip = {
|
|
1414
2123
|
n: this.tripCount,
|
|
1415
2124
|
target,
|
|
1416
2125
|
phase: 'opening',
|
|
1417
2126
|
from: this.scenePath,
|
|
1418
|
-
startedAt
|
|
2127
|
+
startedAt,
|
|
2128
|
+
leaving,
|
|
2129
|
+
leavingUntil,
|
|
2130
|
+
toastAtStart,
|
|
1419
2131
|
cam0: cam ? { x: cam.position.x, y: cam.position.y, z: cam.position.z } : null,
|
|
1420
2132
|
heapBefore: heapMB(),
|
|
1421
2133
|
marks: {},
|
|
1422
2134
|
};
|
|
2135
|
+
if (this.pendingEnd !== null) {
|
|
2136
|
+
this.endLeaving ??= { leaving, leavingUntil, toastAtStart };
|
|
2137
|
+
}
|
|
1423
2138
|
scene.persistent.hubArriving = target.arrive;
|
|
1424
2139
|
}
|
|
1425
2140
|
|
|
2141
|
+
setTripCover(alpha, trip) {
|
|
2142
|
+
if (trip.leaving && !trip.shut) {
|
|
2143
|
+
this.chrome.setCover(alpha, trip.target.title, trip.leaving);
|
|
2144
|
+
} else {
|
|
2145
|
+
this.chrome.setCover(alpha, trip.target.title);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
showLeaving(scene, trip, now) {
|
|
2150
|
+
if (!trip.leaving || trip.shut || trip.lost || trip.timedOut || now >= trip.leavingUntil) {
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
const r = scene.persistent.hubResult;
|
|
2154
|
+
const back = trip.target.arrive?.returning && r ? `Back from ${resultLine(r)}` : '';
|
|
2155
|
+
// Capture once: later feedback must stay ahead, even on another reveal frame.
|
|
2156
|
+
this.leavingToast ??= { previousToast: trip.toastAtStart ?? this.toast, until: trip.leavingUntil };
|
|
2157
|
+
this.leavingToast.text = back ? `${back.slice(0, 80)} · ${trip.leaving}` : trip.leaving;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
1426
2160
|
stepTrip(scene, mp, local, now) {
|
|
1427
2161
|
const trip = this.trip;
|
|
1428
2162
|
const elapsed = now - trip.startedAt;
|
|
@@ -1431,7 +2165,7 @@ class HubSystem {
|
|
|
1431
2165
|
const t = clamp01(elapsed / OPEN_MS);
|
|
1432
2166
|
const door = trip.target.exitDoor ? scene.getActor(trip.target.exitDoor) : null;
|
|
1433
2167
|
if (door) {
|
|
1434
|
-
this.swingDoor(door, ease(t));
|
|
2168
|
+
this.swingDoor(door, ease(t), scene);
|
|
1435
2169
|
}
|
|
1436
2170
|
if (cam && trip.cam0) {
|
|
1437
2171
|
const e = ease(t);
|
|
@@ -1457,7 +2191,7 @@ class HubSystem {
|
|
|
1457
2191
|
cam.lookAt(lt.x, lt.y + 0.8, lt.z);
|
|
1458
2192
|
}
|
|
1459
2193
|
}
|
|
1460
|
-
this.
|
|
2194
|
+
this.setTripCover(clamp01((t - 0.4) / 0.6), trip);
|
|
1461
2195
|
if (t >= 1 && trip.target.classic) {
|
|
1462
2196
|
this.stepClassic(scene, trip, mp, now);
|
|
1463
2197
|
return;
|
|
@@ -1485,11 +2219,11 @@ class HubSystem {
|
|
|
1485
2219
|
return;
|
|
1486
2220
|
}
|
|
1487
2221
|
if (trip.phase === 'away') {
|
|
1488
|
-
this.
|
|
2222
|
+
this.setTripCover(1, trip);
|
|
1489
2223
|
return;
|
|
1490
2224
|
}
|
|
1491
2225
|
if (trip.phase === 'committing') {
|
|
1492
|
-
this.
|
|
2226
|
+
this.setTripCover(1, trip);
|
|
1493
2227
|
const state = mp.joinState();
|
|
1494
2228
|
// 'lost' was committed too: the loading phase recovers from it.
|
|
1495
2229
|
if (state === 'joined' || state === 'lost') {
|
|
@@ -1503,7 +2237,7 @@ class HubSystem {
|
|
|
1503
2237
|
return;
|
|
1504
2238
|
}
|
|
1505
2239
|
if (trip.phase === 'loading') {
|
|
1506
|
-
this.
|
|
2240
|
+
this.setTripCover(1, trip);
|
|
1507
2241
|
if (scene.mountError) {
|
|
1508
2242
|
this.mountFailed(scene, trip, now);
|
|
1509
2243
|
return;
|
|
@@ -1542,7 +2276,7 @@ class HubSystem {
|
|
|
1542
2276
|
this.faceArrival(scene);
|
|
1543
2277
|
const door = trip.target.arriveDoor ? scene.getActor(doorActor(scene, trip.target.arriveDoor)) : null;
|
|
1544
2278
|
if (door) {
|
|
1545
|
-
this.swingDoor(door, 1);
|
|
2279
|
+
this.swingDoor(door, 1, scene);
|
|
1546
2280
|
}
|
|
1547
2281
|
const lt = local?.components.Transform;
|
|
1548
2282
|
const base = door ? (this.doorBase.get(door.id) ?? door.components.Transform) : null;
|
|
@@ -1554,10 +2288,14 @@ class HubSystem {
|
|
|
1554
2288
|
// player came through, and the door swings shut behind them.
|
|
1555
2289
|
const t = clamp01((now - trip.revealAt) / REVEAL_MS);
|
|
1556
2290
|
trip.marks.firstFrame ??= now;
|
|
1557
|
-
|
|
2291
|
+
const cover = 1 - clamp01(t / 0.6);
|
|
2292
|
+
this.setTripCover(cover, trip);
|
|
2293
|
+
if (cover <= 0.05) {
|
|
2294
|
+
this.showLeaving(scene, trip, now);
|
|
2295
|
+
}
|
|
1558
2296
|
const door = trip.target.arriveDoor ? scene.getActor(doorActor(scene, trip.target.arriveDoor)) : null;
|
|
1559
2297
|
if (door) {
|
|
1560
|
-
this.swingDoor(door, 1 - ease(clamp01((t - 0.35) / 0.65)));
|
|
2298
|
+
this.swingDoor(door, 1 - ease(clamp01((t - 0.35) / 0.65)), scene);
|
|
1561
2299
|
}
|
|
1562
2300
|
const lt = local?.components.Transform;
|
|
1563
2301
|
const follow = local && cam ? followCamera(scene, local) : null;
|
|
@@ -1582,7 +2320,7 @@ class HubSystem {
|
|
|
1582
2320
|
return true;
|
|
1583
2321
|
}
|
|
1584
2322
|
trip.marks.covered ??= now;
|
|
1585
|
-
this.
|
|
2323
|
+
this.setTripCover(1, trip);
|
|
1586
2324
|
// A retried way back has its own deadline, from when it was asked again.
|
|
1587
2325
|
if (!pending.done && now - (trip.target.pendingFrom ?? trip.startedAt) < LOADING_LIMIT_MS) {
|
|
1588
2326
|
return false;
|
|
@@ -1693,7 +2431,7 @@ class HubSystem {
|
|
|
1693
2431
|
scene.mountError = null;
|
|
1694
2432
|
this.trip = null;
|
|
1695
2433
|
this.toast = { text: 'That door is stuck', until: now + TOAST_MS };
|
|
1696
|
-
this.back(scene, { covered: true });
|
|
2434
|
+
this.back(scene, { covered: true, previousTrip: trip });
|
|
1697
2435
|
}
|
|
1698
2436
|
|
|
1699
2437
|
// The host committed this hub trip, and the session it led to closed before
|
|
@@ -1733,7 +2471,7 @@ class HubSystem {
|
|
|
1733
2471
|
this.toast = { text: trip.target.stuck ?? 'That door is stuck', until: now + TOAST_MS };
|
|
1734
2472
|
// Both counts ride along, so a way that alternates between a lost join
|
|
1735
2473
|
// and an uncommitted one still runs out.
|
|
1736
|
-
this.back(scene, { covered: true, attempt: trip.target.attempt ?? 0, lost: tries + 1 });
|
|
2474
|
+
this.back(scene, { covered: true, attempt: trip.target.attempt ?? 0, lost: tries + 1, previousTrip: trip });
|
|
1737
2475
|
if (!this.trip) {
|
|
1738
2476
|
this.chrome.setCover(0);
|
|
1739
2477
|
}
|
|
@@ -1780,13 +2518,13 @@ class HubSystem {
|
|
|
1780
2518
|
title: '',
|
|
1781
2519
|
exitDoor: null,
|
|
1782
2520
|
arrive: { door: null, party: 1, returning: false },
|
|
1783
|
-
});
|
|
2521
|
+
}, trip);
|
|
1784
2522
|
if (this.trip) {
|
|
1785
2523
|
this.trip.startedAt -= OPEN_MS;
|
|
1786
2524
|
}
|
|
1787
2525
|
return;
|
|
1788
2526
|
}
|
|
1789
|
-
this.back(scene, { covered: true });
|
|
2527
|
+
this.back(scene, { covered: true, previousTrip: trip });
|
|
1790
2528
|
return;
|
|
1791
2529
|
}
|
|
1792
2530
|
if (trip.target.pushedTicket) {
|
|
@@ -1805,20 +2543,20 @@ class HubSystem {
|
|
|
1805
2543
|
exitDoor: null,
|
|
1806
2544
|
arriveDoor: ticket.door,
|
|
1807
2545
|
arrive: { door: ticket.door, party: ticket.party ?? 1, returning: true },
|
|
1808
|
-
});
|
|
2546
|
+
}, trip);
|
|
1809
2547
|
if (this.trip) {
|
|
1810
2548
|
this.trip.startedAt -= OPEN_MS;
|
|
1811
2549
|
}
|
|
1812
2550
|
return;
|
|
1813
2551
|
}
|
|
1814
|
-
this.back(scene, { covered: true });
|
|
2552
|
+
this.back(scene, { covered: true, previousTrip: trip });
|
|
1815
2553
|
return;
|
|
1816
2554
|
}
|
|
1817
2555
|
if (trip.target.ticket) {
|
|
1818
2556
|
per.hubTickets.push(trip.target.ticket);
|
|
1819
2557
|
}
|
|
1820
2558
|
if ((trip.target.attempt ?? 0) < 1) {
|
|
1821
|
-
this.back(scene, { covered: true, attempt: (trip.target.attempt ?? 0) + 1, lost: trip.target.lost ?? 0, away: trip.target.away ?? null });
|
|
2559
|
+
this.back(scene, { covered: true, attempt: (trip.target.attempt ?? 0) + 1, lost: trip.target.lost ?? 0, away: trip.target.away ?? null, previousTrip: trip });
|
|
1822
2560
|
}
|
|
1823
2561
|
if (!this.trip && trip.target.away) {
|
|
1824
2562
|
// The way back from a classic deck did not commit: still away.
|
|
@@ -1857,6 +2595,7 @@ class HubSystem {
|
|
|
1857
2595
|
settleEnd(scene) {
|
|
1858
2596
|
if (this.pendingEnd !== null && sessionKey(scene) !== this.endSession) {
|
|
1859
2597
|
this.pendingEnd = null;
|
|
2598
|
+
this.endLeaving = null;
|
|
1860
2599
|
}
|
|
1861
2600
|
}
|
|
1862
2601
|
|
|
@@ -1865,18 +2604,32 @@ class HubSystem {
|
|
|
1865
2604
|
// PI - camAngle.
|
|
1866
2605
|
faceArrival(scene) {
|
|
1867
2606
|
if (Hub.hub.arrivedFacing !== null) {
|
|
2607
|
+
if (Hub.deck.soundscape?.ui === true && !this.trip && !Hub.hub.faced) {
|
|
2608
|
+
this.soundscape?.uiArrival(performance.now());
|
|
2609
|
+
}
|
|
1868
2610
|
scene.persistent.camAngle = Math.PI - Hub.hub.arrivedFacing;
|
|
2611
|
+
// Under the engine's orbit camera key the character's facing is not
|
|
2612
|
+
// PI - camAngle: it is asked for.
|
|
2613
|
+
if (scene.cameraControl === 'orbit') {
|
|
2614
|
+
scene.faceRequest = Hub.hub.arrivedFacing;
|
|
2615
|
+
}
|
|
1869
2616
|
Hub.hub.faced = true;
|
|
1870
2617
|
}
|
|
1871
2618
|
}
|
|
1872
2619
|
|
|
1873
2620
|
finishTrip(scene, trip) {
|
|
1874
2621
|
this.trip = null;
|
|
2622
|
+
if (Hub.deck.soundscape?.ui === true && !trip.shut && !trip.lost && !trip.timedOut && Hub.hub.arrivedFacing !== null) {
|
|
2623
|
+
this.soundscape?.uiArrival(performance.now());
|
|
2624
|
+
}
|
|
1875
2625
|
this.chrome.setCover(0);
|
|
2626
|
+
this.showLeaving(scene, trip, performance.now());
|
|
1876
2627
|
// A new place or layer: ask again who is elsewhere.
|
|
1877
2628
|
this.friends = null;
|
|
1878
2629
|
this.friendsAll = null;
|
|
1879
2630
|
this.friendsAt = -Infinity;
|
|
2631
|
+
this.friendsGameAt = -Infinity;
|
|
2632
|
+
this.friendsGameWarm = false;
|
|
1880
2633
|
const m = trip.marks;
|
|
1881
2634
|
const start = trip.startedAt;
|
|
1882
2635
|
const record = {
|
|
@@ -1911,17 +2664,37 @@ class HubSystem {
|
|
|
1911
2664
|
(globalThis.__hubTrips ??= []).push(record);
|
|
1912
2665
|
console.log(`[hub-trip] ${JSON.stringify(record)}`);
|
|
1913
2666
|
const r = scene.persistent.hubResult;
|
|
1914
|
-
if (trip.target.arrive?.returning && r) {
|
|
2667
|
+
if (trip.target.arrive?.returning && r && (!this.leavingToast || this.toast === this.leavingToast.previousToast)) {
|
|
1915
2668
|
this.toast = { text: `Back from ${resultLine(r)}`, until: performance.now() + TOAST_MS };
|
|
2669
|
+
// The arrival result is already part of the leaving toast, not new feedback.
|
|
2670
|
+
if (this.leavingToast) {
|
|
2671
|
+
this.leavingToast.previousToast = this.toast;
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
if (Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
2675
|
+
this.yourGames().returned(trip.target.arrive.door, r);
|
|
1916
2676
|
}
|
|
2677
|
+
if (Hub.deck.cues && !Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
2678
|
+
// Cues: a next step, put once the player is back in the town, whether
|
|
2679
|
+
// or not the game had a result to tell.
|
|
2680
|
+
this.againAsk = { door: trip.target.arrive.door, until: performance.now() + AGAIN_ASK_MS };
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
yourGames() {
|
|
2685
|
+
this.yours ??= makeYours(castleSdk.Hub, castleSdk.User, (text) => {
|
|
2686
|
+
this.toast = { text, until: performance.now() + TOAST_MS };
|
|
2687
|
+
});
|
|
2688
|
+
return this.yours;
|
|
1917
2689
|
}
|
|
1918
2690
|
|
|
1919
2691
|
// Swing a door leaf open by `amount` (0 shut, 1 open) about its left edge,
|
|
1920
2692
|
// in the door's own frame, so a door turned to face any way opens the same.
|
|
1921
|
-
swingDoor(door, amount) {
|
|
2693
|
+
swingDoor(door, amount, scene) {
|
|
1922
2694
|
if (isCabinet(door)) {
|
|
1923
2695
|
return;
|
|
1924
2696
|
}
|
|
2697
|
+
scene?.touch?.(door.id);
|
|
1925
2698
|
const t = door.components.Transform;
|
|
1926
2699
|
if (!this.doorBase.has(door.id)) {
|
|
1927
2700
|
this.doorBase.set(door.id, { x: t.x, z: t.z, rotationY: t.rotationY ?? 0 });
|
|
@@ -1952,10 +2725,19 @@ class HubSystem {
|
|
|
1952
2725
|
(away || (idle && this.pendingEnd === null)) && !(scene.persistent.hubDepth > 0) && (inGame || Boolean(ticket)),
|
|
1953
2726
|
ticket?.title ?? 'Again',
|
|
1954
2727
|
);
|
|
1955
|
-
chrome.showPicker(idle && place !== null && !inGame && !this.talk.talking(), Avatar.current(scene));
|
|
1956
|
-
const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking();
|
|
2728
|
+
chrome.showPicker(idle && place !== null && !inGame && !this.talk.talking() && !this.carded, 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 });
|
|
2729
|
+
const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking() && !this.carded;
|
|
1957
2730
|
const town = free && !inGame;
|
|
1958
|
-
|
|
2731
|
+
// "Stuck?" (v1.33), only in a deck with `hub.stuck`, and there only in a
|
|
2732
|
+
// place that says it takes it (a town): a row over the Doors list.
|
|
2733
|
+
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;
|
|
2734
|
+
let yours = null;
|
|
2735
|
+
if (Hub.deck.yourGames) {
|
|
2736
|
+
const controller = this.yourGames();
|
|
2737
|
+
controller.frame(town, Hub.hub.yours, now);
|
|
2738
|
+
yours = { rows: controller.rows(Hub.hub.yours, Hub.hub.doors), ...controller.controls() };
|
|
2739
|
+
}
|
|
2740
|
+
chrome.setDoors?.(town ? Hub.hub.doors : null, Hub.hub.party.members?.length ? 'Go together' : 'Go', stuckRow, yours);
|
|
1959
2741
|
chrome.setPeople?.(free ? this.people(scene, inGame) : null, town ? this.together.partyLine() : null);
|
|
1960
2742
|
chrome.setAsk?.(town ? this.ask() : null);
|
|
1961
2743
|
this.startBeside(scene, local, town, now);
|
|
@@ -1976,9 +2758,21 @@ class HubSystem {
|
|
|
1976
2758
|
}
|
|
1977
2759
|
// A friend or party member who just came in: say so, and point to them.
|
|
1978
2760
|
for (const who of town ? this.together.arrivals() : []) {
|
|
2761
|
+
// Cues: one who was here already (`here`, never set without cues)
|
|
2762
|
+
// waits its turn in `cueHere`.
|
|
2763
|
+
if (who.here) {
|
|
2764
|
+
this.hereCues.push({ ...who, until: now + HERE_CUE_MS });
|
|
2765
|
+
continue;
|
|
2766
|
+
}
|
|
1979
2767
|
this.toast = { text: `${who.username ?? 'A friend'} is here · People to join`, until: now + TOAST_MS };
|
|
1980
2768
|
this.together.ping(who.playerId, now, true);
|
|
1981
2769
|
}
|
|
2770
|
+
if (Hub.deck.cues && town) {
|
|
2771
|
+
this.cueHere(now);
|
|
2772
|
+
}
|
|
2773
|
+
if (Hub.deck.cues && place !== null && !inGame) {
|
|
2774
|
+
this.cueParty(scene.multiplayer?.net, now);
|
|
2775
|
+
}
|
|
1982
2776
|
// Quick reactions and phrases, in every place; what was said, as bubbles
|
|
1983
2777
|
// (below, with the labels) and a short feed.
|
|
1984
2778
|
const net = scene.multiplayer?.net;
|
|
@@ -2000,6 +2794,22 @@ class HubSystem {
|
|
|
2000
2794
|
this.playAsk = { from: playerId, name, door, until: now + PLAY_ASK_MS };
|
|
2001
2795
|
},
|
|
2002
2796
|
);
|
|
2797
|
+
// Cues: someone new in the roster may be one this player can chat with,
|
|
2798
|
+
// so the host is asked soon, not at the end of its idle wait. In a town
|
|
2799
|
+
// only, like every cue: a game behind one of its doors is drawn by this
|
|
2800
|
+
// client too, and is left exactly as it was.
|
|
2801
|
+
const cuesHere = Hub.deck.cues && place !== null && !inGame;
|
|
2802
|
+
if (cuesHere) {
|
|
2803
|
+
const here = new Set(net?.others?.().keys() ?? []);
|
|
2804
|
+
let fresh = false;
|
|
2805
|
+
for (const playerId of here) {
|
|
2806
|
+
fresh ||= !this.rosterSeen.has(playerId);
|
|
2807
|
+
}
|
|
2808
|
+
this.rosterSeen = here;
|
|
2809
|
+
if (fresh) {
|
|
2810
|
+
this.chat.soon(now);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2003
2813
|
// Free-text chat, where the host has it: ghost says whom this player may
|
|
2004
2814
|
// chat with (they follow each other and both are over 13); the kit only
|
|
2005
2815
|
// shows what it is handed.
|
|
@@ -2033,8 +2843,17 @@ class HubSystem {
|
|
|
2033
2843
|
const chatPart = this.chat.available() && this.chat.peers !== null
|
|
2034
2844
|
? { input: this.chat.canChat && reach.length > 0, note: chatNote }
|
|
2035
2845
|
: null;
|
|
2846
|
+
// Cues: the field itself says who reads a line, or in a few words why it
|
|
2847
|
+
// cannot be used (the note has the long form).
|
|
2848
|
+
if (chatPart && cuesHere) {
|
|
2849
|
+
if (!chatPart.input) {
|
|
2850
|
+
chatPart.note = CHAT_HINT.why;
|
|
2851
|
+
}
|
|
2852
|
+
chatPart.placeholder = chatPart.input ? CHAT_HINT.on : CHAT_HINT.off;
|
|
2853
|
+
chatPart.label = chatPart.input ? CHAT_HINT.label : CHAT_HINT.why;
|
|
2854
|
+
}
|
|
2036
2855
|
chrome.setSay?.(free ? { reactions: REACTIONS, phrases: this.say.phrases(), chat: chatPart } : null);
|
|
2037
|
-
chrome.setFeed?.(idle && place !== null ? this.say.feed() : []);
|
|
2856
|
+
chrome.setFeed?.(idle && place !== null && !this.carded ? this.say.feed() : []);
|
|
2038
2857
|
// Standing still beside someone: a small button invites them.
|
|
2039
2858
|
const beside = town && !Hub.hub.party.invite && local ? this.together.beside(scene, local) : null;
|
|
2040
2859
|
chrome.nearPrompt?.(
|
|
@@ -2058,6 +2877,12 @@ class HubSystem {
|
|
|
2058
2877
|
} else if (spec?.timer?.until !== undefined) {
|
|
2059
2878
|
timer = Math.max(0, (spec.timer.until - Hub.simNow()) / 1000);
|
|
2060
2879
|
}
|
|
2880
|
+
// A place that asks (`hud.clear`, v1.26) has its HUD kept short and its
|
|
2881
|
+
// labels kept out from under it; any other is drawn as it always was.
|
|
2882
|
+
if (place?.hud?.clear === true || this.hudClear) {
|
|
2883
|
+
this.hudClear = place?.hud?.clear === true;
|
|
2884
|
+
chrome.setHudClear?.(this.hudClear);
|
|
2885
|
+
}
|
|
2061
2886
|
chrome.setHud(idle || this.trip?.phase === 'revealing' ? spec : null, timer);
|
|
2062
2887
|
|
|
2063
2888
|
const cam = scene.three?.camera;
|
|
@@ -2076,7 +2901,7 @@ class HubSystem {
|
|
|
2076
2901
|
const at = scene.getActor(id)?.components.Transform;
|
|
2077
2902
|
if (at && label.style === 'goal') {
|
|
2078
2903
|
// Where the place is sending this player (v1.13): a pointer, not a label.
|
|
2079
|
-
goals.push({ id, at,
|
|
2904
|
+
goals.push({ id, at, label });
|
|
2080
2905
|
} else if (at) {
|
|
2081
2906
|
// A sign is drawn at any distance in a town: a street's name, or a
|
|
2082
2907
|
// word the player must see from where they stand.
|
|
@@ -2095,22 +2920,28 @@ class HubSystem {
|
|
|
2095
2920
|
now,
|
|
2096
2921
|
)
|
|
2097
2922
|
: null;
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2923
|
+
if (shown && Hub.deck.labels && chrome.measureLabel) {
|
|
2924
|
+
// `hub.labels: "near"` (v1.43): signs near the player only, no two
|
|
2925
|
+
// world labels overlapping, three at most (`labelsNear.js`).
|
|
2926
|
+
labels.push(...this.nearLabels(scene, placed, lt, cam, view, now));
|
|
2927
|
+
} else {
|
|
2928
|
+
for (const { id, at, label, always } of placed) {
|
|
2929
|
+
const opacity = shown && !always ? shown.get(id) : 1;
|
|
2930
|
+
const screen = opacity ? project(cam, at.x, at.y + 1.6, at.z, view) : null;
|
|
2931
|
+
if (screen) {
|
|
2932
|
+
labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity });
|
|
2933
|
+
}
|
|
2103
2934
|
}
|
|
2104
2935
|
}
|
|
2105
2936
|
}
|
|
2106
2937
|
const pointers = cam && idle && place && !inGame && this.pendingEnd === null ? this.together.pointers(scene, local, cam, view) : [];
|
|
2107
2938
|
const me = local?.components.Transform;
|
|
2108
2939
|
if (cam && me && this.pendingEnd === null) {
|
|
2109
|
-
// The nearest goals, each with how far it is.
|
|
2110
|
-
const near = goals.map((g) => ({ ...g, d: Math.hypot(g.at.x - me.x, g.at.z - me.z) }))
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2940
|
+
// The nearest drawable goals, each with how far it is.
|
|
2941
|
+
const near = goals.map((g) => ({ ...g, d: Math.hypot(g.at.x - me.x, g.at.z - me.z) }));
|
|
2942
|
+
pointers.push(...goalPointers(near, GOALS_MAX, (g) =>
|
|
2943
|
+
pointerAt(cam, view, { 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)),
|
|
2944
|
+
));
|
|
2114
2945
|
}
|
|
2115
2946
|
chrome.setPointers?.(pointers);
|
|
2116
2947
|
if (cam && idle) {
|
|
@@ -2118,7 +2949,25 @@ class HubSystem {
|
|
|
2118
2949
|
labels.push(...this.idle.labels(scene, local, cam, view, project));
|
|
2119
2950
|
labels.push(...this.say.labels(scene, local, cam, view, project, scene.multiplayer?.net?.selfId?.() ?? null));
|
|
2120
2951
|
}
|
|
2952
|
+
if (Hub.hub.place?.companion === true && cam && idle) {
|
|
2953
|
+
labels.push(...(this.companion?.labels(cam, view, project, now) ?? []));
|
|
2954
|
+
}
|
|
2121
2955
|
chrome.setLabels(labels);
|
|
2956
|
+
if (place?.companionChat) {
|
|
2957
|
+
const canTalk = cam && idle && this.pendingEnd === null && !this.talk.talking() && this.decor?.opened() !== true && !this.carded;
|
|
2958
|
+
chrome.layoutCompanion?.(scene.three?.renderer?.domElement?.parentElement);
|
|
2959
|
+
chrome.setCompanionBadge?.(Boolean(canTalk && Hub.hub.companion?.c && place.companion === true && local), place.companionChat.name, () => this.talk.openCompanion(scene));
|
|
2960
|
+
this.companionTalkDrawn = true;
|
|
2961
|
+
chrome.setCompanionTalk?.(canTalk ? this.companion?.screen(cam, view, project) : null, place.companionChat.name, () => {
|
|
2962
|
+
this.companionTappedUntil = now + 3000;
|
|
2963
|
+
this.talk.openCompanion(scene);
|
|
2964
|
+
});
|
|
2965
|
+
} else if (this.companionTalkDrawn) {
|
|
2966
|
+
chrome.setCompanionBadge?.(false);
|
|
2967
|
+
chrome.layoutCompanion?.(null);
|
|
2968
|
+
chrome.setCompanionTalk(null);
|
|
2969
|
+
delete this.companionTalkDrawn;
|
|
2970
|
+
}
|
|
2122
2971
|
|
|
2123
2972
|
const lt = local?.components.Transform;
|
|
2124
2973
|
// The card of the cabinet this player stands nearest (v1.7).
|
|
@@ -2126,7 +2975,73 @@ class HubSystem {
|
|
|
2126
2975
|
const r = scene.persistent.hubResult;
|
|
2127
2976
|
const showRibbon = !inGame && idle && r && Date.now() - r.at < RIBBON_MS && lt && cam;
|
|
2128
2977
|
chrome.setRibbon(showRibbon ? project(cam, lt.x, lt.y + 1.7, lt.z, view) : null, r ? `🏅 ${resultLine(r)}` : '');
|
|
2129
|
-
|
|
2978
|
+
const leaving = this.leavingToast && now < this.leavingToast.until && this.toast === this.leavingToast.previousToast;
|
|
2979
|
+
const toast = leaving ? this.leavingToast : this.toast;
|
|
2980
|
+
if (leaving) {
|
|
2981
|
+
chrome.setToast(toast.text, { wrap: true });
|
|
2982
|
+
} else {
|
|
2983
|
+
chrome.setToast(now < toast.until ? toast.text : '');
|
|
2984
|
+
}
|
|
2985
|
+
// A clear HUD (v1.26): everything drawn above is measured, then moved
|
|
2986
|
+
// out from under it, once for the frame. Never said in any other place.
|
|
2987
|
+
if (this.hudClear) {
|
|
2988
|
+
chrome.flushHudClear?.();
|
|
2989
|
+
}
|
|
2990
|
+
// "Stuck?" (v1.33), last of all: the chip is measured after every other
|
|
2991
|
+
// chrome element has its final rect for this frame -- after every setter
|
|
2992
|
+
// above, and after a clear HUD's flush has moved labels, pointers, a
|
|
2993
|
+
// cabinet's card and the ribbon out from under the HUD. Nothing above
|
|
2994
|
+
// knows of the chip or makes way for it: the chip is the one that yields,
|
|
2995
|
+
// and is not drawn where a card or the ribbon now lies; labels and
|
|
2996
|
+
// pointers pass under it (`chrome.stuckPrompt`).
|
|
2997
|
+
if (Hub.deck.stuck) {
|
|
2998
|
+
this.offerUnstick(scene, local, town, now);
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
// A town's world labels under `hub.labels: "near"` (v1.43): the plate and
|
|
3003
|
+
// the line the attention rule picked this frame (`attend` has just run) and
|
|
3004
|
+
// every sign, each with where its label would lie, handed to `near`.
|
|
3005
|
+
//
|
|
3006
|
+
// The rule's state is one visit's (`nearFor`): another scene, the scene
|
|
3007
|
+
// loaded again, another connection or the hub's state cleared, and it
|
|
3008
|
+
// starts again.
|
|
3009
|
+
//
|
|
3010
|
+
// Label boxes are final when the rule judges them, because the chrome draws
|
|
3011
|
+
// from them: `labelBox` is the one place a world label's box is worked out
|
|
3012
|
+
// (its size for these words, kept on the screen, moved from under a clear
|
|
3013
|
+
// HUD -- `setHud` has run, so the HUD's box is this frame's), the rule is
|
|
3014
|
+
// given that box, and the same box goes to `setLabels`, which puts the
|
|
3015
|
+
// label exactly there and moves it no more. A label whose style changes
|
|
3016
|
+
// gets a node of its own (the chrome styles a node once), so the node drawn
|
|
3017
|
+
// is always one measured as it is styled.
|
|
3018
|
+
nearLabels(scene, placed, lt, cam, view, now) {
|
|
3019
|
+
const chrome = this.chrome;
|
|
3020
|
+
const mine = Hub.hub.labelsMe;
|
|
3021
|
+
const state = nearFor((this.nearHeld ??= {}), { scene: sceneKeyOf(scene), data: scene.data, net: scene.multiplayer?.net ?? null, place: Hub.hub.place });
|
|
3022
|
+
const hud = chrome.hudClearBox?.() ?? null;
|
|
3023
|
+
const items = [];
|
|
3024
|
+
const drawn = new Map();
|
|
3025
|
+
for (const { id, at, label, always } of placed) {
|
|
3026
|
+
const speech = label.style === 'speech';
|
|
3027
|
+
const kind = always ? 'sign' : speech ? 'speech' : 'plate';
|
|
3028
|
+
const pick = !always && id === (speech ? this.attention.speech : this.attention.plate);
|
|
3029
|
+
// A plate or a line the attention rule passed over: only one still fading.
|
|
3030
|
+
if (!always && !pick && !state.alpha.has(id)) {
|
|
3031
|
+
continue;
|
|
3032
|
+
}
|
|
3033
|
+
const npc = label.npc === true;
|
|
3034
|
+
const screen = project(cam, at.x, at.y + 1.6, at.z, view);
|
|
3035
|
+
const box = screen ? labelBox(screen.x, screen.y, chrome.measureLabel(label.text, speech, npc), npc, view, hud) : null;
|
|
3036
|
+
items.push({ id, kind, pick, d: Math.hypot(at.x - lt.x, at.z - lt.z), mine: Object.hasOwn(mine, id), box });
|
|
3037
|
+
drawn.set(id, { text: label.text, speech, npc, box });
|
|
3038
|
+
}
|
|
3039
|
+
const out = [];
|
|
3040
|
+
for (const [id, opacity] of near(state, items, view, now)) {
|
|
3041
|
+
const d = drawn.get(id);
|
|
3042
|
+
out.push(chromeItem(id, d.text, d.speech, d.npc, d.box, opacity));
|
|
3043
|
+
}
|
|
3044
|
+
return out;
|
|
2130
3045
|
}
|
|
2131
3046
|
|
|
2132
3047
|
// The People list's rows. In a town: everyone here and the player's
|
|
@@ -2217,6 +3132,17 @@ class HubSystem {
|
|
|
2217
3132
|
}
|
|
2218
3133
|
|
|
2219
3134
|
dispose() {
|
|
3135
|
+
this.visibility?.sync(null, null, false);
|
|
3136
|
+
this.visibility = null;
|
|
3137
|
+
if (this.menuDrawn) {this.clearMenu();}
|
|
3138
|
+
if (this.askDrawn) {
|
|
3139
|
+
this.clearTextAsk();
|
|
3140
|
+
}
|
|
3141
|
+
clearShot();
|
|
3142
|
+
if (this.decor) {
|
|
3143
|
+
this.decor.dispose();
|
|
3144
|
+
this.decor = null;
|
|
3145
|
+
}
|
|
2220
3146
|
this.chrome?.dispose();
|
|
2221
3147
|
this.chrome = null;
|
|
2222
3148
|
this.talk = null;
|
|
@@ -2226,6 +3152,17 @@ class HubSystem {
|
|
|
2226
3152
|
this.idle = null;
|
|
2227
3153
|
this.sound?.dispose();
|
|
2228
3154
|
this.sound = null;
|
|
3155
|
+
this.soundscape?.dispose();
|
|
3156
|
+
this.soundscape = null;
|
|
3157
|
+
if (this.ballot) {
|
|
3158
|
+
this.ballot.dispose();
|
|
3159
|
+
this.ballot = null;
|
|
3160
|
+
}
|
|
3161
|
+
// What players wear hangs on the avatars' nodes and holds shares of the
|
|
3162
|
+
// hat builds: given back with the runtime.
|
|
3163
|
+
this.companion?.dispose();
|
|
3164
|
+
this.wear?.clear();
|
|
3165
|
+
this.earned?.clear();
|
|
2229
3166
|
}
|
|
2230
3167
|
}
|
|
2231
3168
|
|
|
@@ -2285,6 +3222,67 @@ function doorActor(scene, door) {
|
|
|
2285
3222
|
return null;
|
|
2286
3223
|
}
|
|
2287
3224
|
|
|
3225
|
+
// SceneRuntime has no before-behavior system hook. While this card alone is
|
|
3226
|
+
// open, clear inputs at the entry to the same update that Player runs in,
|
|
3227
|
+
// including capped frames' lent presses; restore the method on every close.
|
|
3228
|
+
function holdAskInput(scene) {
|
|
3229
|
+
const active = scene.moveInput?.active;
|
|
3230
|
+
const ownUpdate = Object.getOwnPropertyDescriptor(scene, 'update');
|
|
3231
|
+
const update = scene.update;
|
|
3232
|
+
const hold = () => {
|
|
3233
|
+
lockInput(scene);
|
|
3234
|
+
scene.moveInput?.consumeJump?.();
|
|
3235
|
+
const player = scene.actorWith?.('Player');
|
|
3236
|
+
if (player?.runtime) {
|
|
3237
|
+
player.runtime.jumpBuffer = 0;
|
|
3238
|
+
}
|
|
3239
|
+
if (scene.cameraControl === 'orbit') {
|
|
3240
|
+
scene.lookInput?.lock?.();
|
|
3241
|
+
}
|
|
3242
|
+
};
|
|
3243
|
+
// Captured/locked canvas pointers can bypass the DOM shield. Block their
|
|
3244
|
+
// new drags too, while still letting pointerup clean up an older gesture.
|
|
3245
|
+
const listeners = new AbortController();
|
|
3246
|
+
for (const type of ['pointerdown', 'pointermove', 'mousedown', 'wheel']) {
|
|
3247
|
+
globalThis.addEventListener?.(type, (event) => {
|
|
3248
|
+
if (event.target?.tagName === 'CANVAS') {
|
|
3249
|
+
event.stopImmediatePropagation();
|
|
3250
|
+
event.preventDefault();
|
|
3251
|
+
}
|
|
3252
|
+
}, { capture: true, passive: false, signal: listeners.signal });
|
|
3253
|
+
}
|
|
3254
|
+
// Drop any drag already held when the prompt took the screen.
|
|
3255
|
+
scene.lookInput?.cancel?.();
|
|
3256
|
+
// A desktop mouse lock would keep the cursor in the canvas, out of reach of
|
|
3257
|
+
// the card: let it go (the orbit input hears the change and drops its own).
|
|
3258
|
+
if (globalThis.document?.pointerLockElement) {
|
|
3259
|
+
globalThis.document.exitPointerLock?.();
|
|
3260
|
+
}
|
|
3261
|
+
hold();
|
|
3262
|
+
const guardedUpdate = function (...args) {
|
|
3263
|
+
hold();
|
|
3264
|
+
return update.apply(this, args);
|
|
3265
|
+
};
|
|
3266
|
+
if (typeof update === 'function') {
|
|
3267
|
+
scene.update = guardedUpdate;
|
|
3268
|
+
}
|
|
3269
|
+
return {
|
|
3270
|
+
release() {
|
|
3271
|
+
listeners.abort();
|
|
3272
|
+
if (scene.update === guardedUpdate) {
|
|
3273
|
+
if (ownUpdate) {
|
|
3274
|
+
Object.defineProperty(scene, 'update', ownUpdate);
|
|
3275
|
+
} else {
|
|
3276
|
+
delete scene.update;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
if (scene.moveInput) {
|
|
3280
|
+
scene.moveInput.active = active;
|
|
3281
|
+
}
|
|
3282
|
+
},
|
|
3283
|
+
};
|
|
3284
|
+
}
|
|
3285
|
+
|
|
2288
3286
|
function lockInput(scene) {
|
|
2289
3287
|
scene.keys?.clear?.();
|
|
2290
3288
|
if (scene.moveInput) {
|