castle-web-cli 0.4.233 → 0.4.234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +17 -2
- package/dist/castle-host/host.js +793 -36
- package/dist/castleJson.d.ts +20 -1
- package/dist/castleJson.js +44 -2
- package/dist/check.js +9 -2
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +3 -1
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- package/dist/index.js +8 -2
- package/dist/init.js +1 -1
- package/dist/save-deck.d.ts +20 -1
- package/dist/save-deck.js +141 -5
- package/dist/serve.js +29 -11
- package/dist/shell/assets/{index-BjOxR-lW.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/index.html +1 -1
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +260 -3
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +162 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +33 -6
- package/kits/base/sdk/hub.js +50 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +140 -40
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +79 -6
- package/kits/base/sdk/server/hub.d.ts +31 -1
- package/kits/base/sdk/server/hub.js +50 -3
- package/kits/base/sdk/server/platformHandle.d.ts +13 -1
- package/kits/base/sdk/server/storage.d.ts +4 -0
- package/kits/base/sdk/server/storage.js +19 -3
- package/kits/base/sdk/server/wrapper.d.ts +7 -1
- package/kits/base/sdk/server/wrapper.js +10 -1
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +123 -3
- package/kits/hub-game/README.md +63 -0
- package/kits/hub-game/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/avatar.js +4 -2
- package/kits/hub-game/code/client/avatarShare.js +2 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +15 -10
- package/kits/hub-game/code/client/build.js +16 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +1148 -258
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +10 -4
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -0
- package/kits/hub-game/code/client/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +31 -11
- package/kits/hub-game/code/client/hookLayer.js +87 -8
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +14 -2
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/labelsNear.js +31 -2
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- package/kits/hub-game/code/client/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +64 -10
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -0
- package/kits/hub-game/code/client/state.js +53 -0
- package/kits/hub-game/code/client/talk.js +209 -45
- package/kits/hub-game/code/client/tiers.js +68 -66
- package/kits/hub-game/code/client/together.js +7 -2
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +10 -9
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +6 -1
- package/kits/hub-game/code/server/actors.js +2 -1
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- package/kits/hub-game/code/server/companion.js +28 -3
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +22 -5
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendsAmong.js +49 -9
- package/kits/hub-game/code/server/history.js +2 -0
- package/kits/hub-game/code/server/hub.js +1306 -95
- package/kits/hub-game/code/server/idle.js +30 -1
- package/kits/hub-game/code/server/index.js +26 -4
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +9 -1
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +211 -3
- package/kits/hub-game/code/server/menu.js +31 -3
- package/kits/hub-game/code/server/npcs.js +226 -64
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/players.js +9 -1
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/standing.js +4 -5
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +67 -5
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +35 -1
- package/kits/hub-game/code/systems/hub.js +970 -169
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/contract.md +1257 -42
- package/kits/hub-game/docs/home-pieces.md +9 -2
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/package-lock.json +10 -3
- package/kits/hub-game/package.json +6 -3
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +39 -5
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -1
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +11 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +5 -5
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +3 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +19 -3
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +3 -3
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -1
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +367 -2
- package/kits/hub-game/scripts/test-actors.mjs +20 -7
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +49 -10
- package/kits/hub-game/scripts/test-avatar.mjs +44 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +11 -4
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +20 -2
- package/kits/hub-game/scripts/test-chat.mjs +206 -5
- package/kits/hub-game/scripts/test-companion-chat.mjs +20 -2
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +45 -4
- package/kits/hub-game/scripts/test-decor.mjs +7 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned.mjs +33 -3
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +47 -4
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +321 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +879 -11
- package/kits/hub-game/scripts/test-hud-clear.mjs +162 -59
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +66 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +20 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-labels.mjs +71 -3
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +265 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +105 -0
- package/kits/hub-game/scripts/test-menu.mjs +23 -0
- package/kits/hub-game/scripts/test-npcs.mjs +819 -10
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +234 -7
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +699 -5
- package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +145 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +22 -17
- package/kits/hub-game/scripts/test-standing.mjs +35 -2
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +5 -4
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +86 -13
- package/kits/hub-game/scripts/test-tiers.mjs +7 -8
- package/kits/hub-game/scripts/test-vis.mjs +433 -6
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +50 -6
- package/kits/hub-game/scripts/test-yours.mjs +39 -8
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +369 -30
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +10 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +87 -5
- package/kits/physics-2d/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-3d/CLAUDE.md +25 -1651
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +35 -18
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +1 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -333
- package/kits/physics-3d/engine3d/actornode.js +1 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
- package/kits/physics-3d/engine3d/framecap.js +4 -1
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +8 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/look.js +7 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +3 -3
- package/kits/physics-3d/engine3d/nearshadows.js +77 -10
- package/kits/physics-3d/engine3d/orbitinput.js +59 -25
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +3 -3
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +23 -15
- package/kits/physics-3d/engine3d/sky.js +1 -1
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- package/kits/physics-3d/engine3d/world3d.js +468 -18
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +6 -3
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +52 -4
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +6 -3
- package/kits/physics-3d/scripts/test-frame-cap.mjs +1 -1
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1 -1
- package/kits/physics-3d/scripts/test-near-shadows.mjs +2 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +88 -7
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +40 -3
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +75 -1
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-sky.mjs +1 -1
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +3 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +5 -2
- package/kits/physics-3d/scripts/test-steady-hover.mjs +5 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/systems/physics3d.js +37 -4
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/session.js +6 -4
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import { showBuildStamp } from '../client/build.js';
|
|
2
|
+
import { landscapeViewport } from '../client/landscapeLayout.js';
|
|
3
|
+
import { loadingCover } from '../client/loadingCover.js';
|
|
4
|
+
import { joinErrorText } from '../client/joinError.js';
|
|
5
|
+
import { kitBackNeeded } from '../client/backVisibility.js';
|
|
6
|
+
import { faceArrivalCamera } from '../client/arrivalCamera.js';
|
|
7
|
+
import { makeDoorErrors } from '../client/doorErrors.js';
|
|
1
8
|
import { makeVisibility } from '../client/visibility.js';
|
|
9
|
+
import { makeInvites } from '../client/invites.js';
|
|
10
|
+
import { makeSignIn } from '../client/signIn.js';
|
|
11
|
+
import { makeWeakestTier, readDistricts } from '../client/weakestTier.js';
|
|
12
|
+
import { makeHudRate } from '../client/hudRate.js';
|
|
13
|
+
import { allActors, capWorldLabels, lowQuality, noteQualityInteraction, qualityFor, qualityPlayers, qualitySpawnIds, restoreDecor } from '../client/quality.js';
|
|
2
14
|
import { makeActorBudget } from '../client/actorBudget.js';
|
|
3
15
|
// The hub system: the door, and everything a place draws that a game cannot.
|
|
4
16
|
// It runs after the engine's behaviors every frame and owns the trip between
|
|
@@ -27,23 +39,35 @@ import { makeActorBudget } from '../client/actorBudget.js';
|
|
|
27
39
|
|
|
28
40
|
import * as castleSdk from 'castle-web-sdk';
|
|
29
41
|
import { attend, fadeNames, makeAttention } from '../client/attention.js';
|
|
30
|
-
import { chromeItem, labelBox, near, nearFor } from '../client/labelsNear.js';
|
|
42
|
+
import { chromeItem, goalAt, labelBox, near, nearCandidates, nearFor } from '../client/labelsNear.js';
|
|
43
|
+
import { mapWorldPoint, offsetWorldPoint, relevantLabels, worldLabelFocus } from '../client/worldLabels.js';
|
|
44
|
+
import { bodyBox, occupancyText, placeLabels } from '../client/padOccupancy.js';
|
|
45
|
+
import { padCuesEnabled } from '../client/padCues.js';
|
|
46
|
+
import { readPadArrival } from '../client/padCueArrival.js';
|
|
47
|
+
import { makePadReadability } from '../client/padReadability.js';
|
|
48
|
+
import { crowdNamesFor, layoutCrowdNames, readableSpriteBox, spriteBox } from '../client/crowdNames.js';
|
|
31
49
|
import { doorPoint } from '../client/doorFrame.js';
|
|
32
50
|
import * as Avatar from '../client/avatar.js';
|
|
51
|
+
import { pongJoin } from '../client/firstJoin.js';
|
|
33
52
|
import * as Rehello from '../client/rehello.js';
|
|
34
53
|
import * as AvatarCap from '../client/avatarCap.js';
|
|
35
54
|
import * as AvatarShare from '../client/avatarShare.js';
|
|
55
|
+
import { makeFarAvatars } from '../client/farAvatars.js';
|
|
36
56
|
import { makeYours } from '../client/yours.js';
|
|
57
|
+
import { askSlotKey, makeAskSlot, padsAt as askPadsAt } from '../client/askSlot.js';
|
|
37
58
|
import * as Cabinets from '../client/cabinets.js';
|
|
38
59
|
import { CHAT_BUBBLE_MS, makeChat } from '../client/chat.js';
|
|
60
|
+
import { chatModerationEnabled } from '../client/chatModeration.js';
|
|
39
61
|
import { makeChrome } from '../client/chrome.js';
|
|
40
62
|
import * as Packs from '../client/pack.js';
|
|
41
63
|
import * as Hub from '../client/state.js';
|
|
42
64
|
import { clearShot } from '../client/shot.js';
|
|
65
|
+
import { makeAct } from '../client/act.js';
|
|
43
66
|
import { makeGrab } from '../client/grab.js';
|
|
44
67
|
import { makeIdle } from '../client/idle.js';
|
|
45
68
|
import { makeDecor } from '../client/decor.js';
|
|
46
69
|
import { makeSay, REACTIONS } from '../client/say.js';
|
|
70
|
+
import { PLAY_NEAR_M } from '../shared/say.js';
|
|
47
71
|
import { cardFor, forget as forgetBallot, held as ballotHeld, makeBallot } from '../client/ballot.js';
|
|
48
72
|
import { makeSound } from '../client/sound.js';
|
|
49
73
|
import { makeSoundscape } from '../client/soundscape.js';
|
|
@@ -51,10 +75,15 @@ import { addSpinner, findSpinners, spinFrame } from '../client/spin.js';
|
|
|
51
75
|
import { makeStuck, resetStuck, STUCK_EVERY_MS, stuckDone, stuckFrame, stuckText, stuckWhere, walkInput } from '../client/stuck.js';
|
|
52
76
|
import { makeTalk } from '../client/talk.js';
|
|
53
77
|
import { makeInterestCap } from '../client/interestCap.js';
|
|
78
|
+
import { makeFpsTelemetry, fpsTelemetryFor } from '../client/fpsTelemetry.js';
|
|
79
|
+
import { loadTelemetryFor, reportLoadStage } from '../client/loadTelemetry.js';
|
|
80
|
+
import { LOAD_STAGES } from '../shared/loadStages.js';
|
|
54
81
|
import { makeTiers } from '../client/tiers.js';
|
|
55
82
|
import { goalPointers, goalText, makeTogether, pointerAt } from '../client/together.js';
|
|
56
83
|
import { makeEarned, makeWear } from '../client/wear.js';
|
|
57
84
|
import { makeCompanion } from '../client/companion.js';
|
|
85
|
+
import { makeDefaultEnvironment } from '../client/defaultEnvironment.js';
|
|
86
|
+
import { activeFallY, holdFallenPlayer } from '../client/fall.js';
|
|
58
87
|
|
|
59
88
|
// The door's three beats, in milliseconds: the door opens and the camera goes
|
|
60
89
|
// through it while the cover comes down; the swap and join happen under the
|
|
@@ -147,7 +176,7 @@ const AWAY_JOIN = { mode: 'hub', handoff: null, away: true };
|
|
|
147
176
|
// Castle refuses a player it has barred from the hub at every door and at the
|
|
148
177
|
// town itself with this code; the kit says so plainly and does not ask again.
|
|
149
178
|
export const HUB_BANNED = 'CAULDRON_HUB_BANNED';
|
|
150
|
-
export
|
|
179
|
+
export { BANNED_TEXT } from '../client/joinError.js';
|
|
151
180
|
|
|
152
181
|
const ease = (t) => t * t * (3 - 2 * t);
|
|
153
182
|
const lerp = (a, b, t) => a + (b - a) * t;
|
|
@@ -206,6 +235,7 @@ class HubSystem {
|
|
|
206
235
|
this.endLeaving = null;
|
|
207
236
|
this.helloNet = null;
|
|
208
237
|
this.helloAvatar = null;
|
|
238
|
+
this.signIn = makeSignIn({ api: castleSdk.Hub, signedIn: () => { this.helloNet = null; } });
|
|
209
239
|
this.scenePath = null;
|
|
210
240
|
this.sceneKey = null;
|
|
211
241
|
this.doorBase = new Map();
|
|
@@ -253,6 +283,10 @@ class HubSystem {
|
|
|
253
283
|
this.wentAsk = null;
|
|
254
284
|
// Cues (v1.29): the game this player just came back from, offered again.
|
|
255
285
|
this.againAsk = null;
|
|
286
|
+
// v1.125: every card which reaches the town's shared ask slot gets one
|
|
287
|
+
// client lease from its first display. This survives a reconnect replay;
|
|
288
|
+
// a new place/session clears it below.
|
|
289
|
+
this.askSlot = makeAskSlot();
|
|
256
290
|
this.chat = makeChat();
|
|
257
291
|
this.namesTouched = new WeakMap();
|
|
258
292
|
// Cues (v1.23), all unused in a deck without `hub.cues`: when the host
|
|
@@ -270,36 +304,245 @@ class HubSystem {
|
|
|
270
304
|
this.partySettleUntil = 0;
|
|
271
305
|
this.partyCarryUntil = 0;
|
|
272
306
|
this.partyAccepted = null;
|
|
307
|
+
this.environment = makeDefaultEnvironment();
|
|
273
308
|
}
|
|
274
309
|
|
|
275
310
|
// Other players' names in a town: near ones only, and smaller; never the
|
|
276
311
|
// player's own in a place (`attention.js`). After the multiplayer kit has placed them this frame.
|
|
277
312
|
fadeNames(scene) {
|
|
313
|
+
const hadCrowd = Object.hasOwn(this, 'crowdNamesHeld') || Object.hasOwn(this, 'crowdFrame') ||
|
|
314
|
+
Object.hasOwn(this, 'crowdHidden') || Object.hasOwn(this, 'crowdNameScales') || Object.hasOwn(this, 'crowdSprites');
|
|
315
|
+
this.restoreCrowdNameScales();
|
|
278
316
|
const place = Hub.hub.place;
|
|
279
317
|
const town = Boolean(place && !place.result && !this.trip);
|
|
318
|
+
const crowdNames = scene.data?.engine?.hubCrowdNames === true;
|
|
319
|
+
// Keep every sprite E owned hidden when current authorization/geometry is
|
|
320
|
+
// unavailable. In particular the SDK retains the net object and roster
|
|
321
|
+
// while reconnecting, and multiplayer itself may disappear for a frame.
|
|
322
|
+
if (crowdNames && !this.crowdNamesReady(scene)) {
|
|
323
|
+
fadeNames(scene.multiplayer, scene.actorWith('Player')?.components.Transform, town, this.namesTouched, Boolean(place));
|
|
324
|
+
this.invalidateCrowdNames(scene);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// Undo only E's previous-frame suppression before the ordinary name pass
|
|
328
|
+
// establishes this frame's baseline. This also restores game-place names
|
|
329
|
+
// and a live toggle OFF, where attention.js otherwise has no town touch.
|
|
330
|
+
if (this.crowdHidden) {
|
|
331
|
+
for (const sprite of this.crowdHidden) {sprite.visible = true;}
|
|
332
|
+
delete this.crowdHidden;
|
|
333
|
+
}
|
|
280
334
|
fadeNames(scene.multiplayer, scene.actorWith('Player')?.components.Transform, town, this.namesTouched, Boolean(place));
|
|
335
|
+
if (crowdNames) {
|
|
336
|
+
this.layoutCrowdNames(scene, performance.now());
|
|
337
|
+
} else {
|
|
338
|
+
// The baseline pass above restores every sprite E may have suppressed.
|
|
339
|
+
// Dropping the holder also removes visit-local ranks on a live toggle.
|
|
340
|
+
if (Object.hasOwn(this, 'crowdNamesHeld')) {delete this.crowdNamesHeld;}
|
|
341
|
+
if (Object.hasOwn(this, 'crowdFrame')) {delete this.crowdFrame;}
|
|
342
|
+
if (Object.hasOwn(this, 'crowdSprites')) {delete this.crowdSprites;}
|
|
343
|
+
if (hadCrowd) {this.chrome.setCrowdNameSummary?.(null);}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
crowdNamesReady(scene) {
|
|
348
|
+
const frame = this.crowdFrame;
|
|
349
|
+
const net = scene.multiplayer?.net;
|
|
350
|
+
const cam = scene.three?.camera;
|
|
351
|
+
return Boolean(frame && net && cam && frame.scene === scene && frame.data === scene.data && frame.net === net && frame.camera === cam &&
|
|
352
|
+
net?.status?.()?.state === 'connected');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
restoreCrowdNameScales() {
|
|
356
|
+
if (!this.crowdNameScales) {return;}
|
|
357
|
+
for (const [sprite, scale] of this.crowdNameScales) {
|
|
358
|
+
// Multiplayer may already have moved/resized or replaced this sprite.
|
|
359
|
+
// Restore only the exact E write, never a newer renderer decision.
|
|
360
|
+
if (sprite.scale.x === scale.scaledX && sprite.scale.y === scale.scaledY) {
|
|
361
|
+
sprite.scale.x = scale.x;
|
|
362
|
+
sprite.scale.y = scale.y;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
delete this.crowdNameScales;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
layoutCrowdNames(scene, now) {
|
|
369
|
+
const frame = this.crowdFrame;
|
|
370
|
+
const mp = scene.multiplayer;
|
|
371
|
+
const net = mp?.net;
|
|
372
|
+
const cam = scene.three?.camera;
|
|
373
|
+
if (!this.crowdNamesReady(scene)) {
|
|
374
|
+
this.invalidateCrowdNames(scene);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const roster = net.others?.() ?? new Map();
|
|
378
|
+
const friendIds = this.friendsAll === null ? null : new Set(this.friendsAll.map((friend) => String(friend.userId)));
|
|
379
|
+
const candidates = [];
|
|
380
|
+
const sprites = new Map();
|
|
381
|
+
const hidden = new Set();
|
|
382
|
+
const allSprites = new Set();
|
|
383
|
+
const tiny = frame.view.w <= 509 && frame.view.h <= 218;
|
|
384
|
+
for (const [playerId, tag] of mp.avatars?.tags ?? []) {
|
|
385
|
+
if (playerId === 'self') {continue;}
|
|
386
|
+
const sprite = tag?.sprite;
|
|
387
|
+
if (sprite) {allSprites.add(sprite);}
|
|
388
|
+
// A tag can survive one renderer frame after a roster/hook revocation.
|
|
389
|
+
// E intersects it with the current authorized roster before it can be
|
|
390
|
+
// named or counted.
|
|
391
|
+
if (!sprite || !roster.has(playerId) || roster.get(playerId) === null || AvatarCap.shown(playerId) === null) {
|
|
392
|
+
if (sprite) {
|
|
393
|
+
sprite.visible = false;
|
|
394
|
+
hidden.add(sprite);
|
|
395
|
+
}
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (!sprite.visible || !(sprite.material?.opacity > 0)) {continue;}
|
|
399
|
+
const actorId = mp.avatars?.actors?.get(playerId);
|
|
400
|
+
const at = actorId ? scene.getActor(actorId)?.components.Transform : null;
|
|
401
|
+
if (!at) {
|
|
402
|
+
sprite.visible = false;
|
|
403
|
+
hidden.add(sprite);
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
const userId = net.userId?.(playerId);
|
|
407
|
+
const geometry = tiny
|
|
408
|
+
? { box: spriteBox(sprite, cam, frame.view, project), resized: null }
|
|
409
|
+
: readableSpriteBox(sprite, cam, frame.view, project);
|
|
410
|
+
if (geometry.resized) {
|
|
411
|
+
(this.crowdNameScales ??= new Map()).set(sprite, geometry.resized);
|
|
412
|
+
}
|
|
413
|
+
candidates.push({
|
|
414
|
+
id: String(playerId),
|
|
415
|
+
friend: Boolean(friendIds && userId && friendIds.has(String(userId))),
|
|
416
|
+
distance: frame.local ? Math.hypot(at.x - frame.local.x, at.z - frame.local.z) : Infinity,
|
|
417
|
+
at,
|
|
418
|
+
box: geometry.box,
|
|
419
|
+
});
|
|
420
|
+
sprites.set(String(playerId), sprite);
|
|
421
|
+
}
|
|
422
|
+
const state = crowdNamesFor((this.crowdNamesHeld ??= {}), {
|
|
423
|
+
scene: sceneKeyOf(scene),
|
|
424
|
+
data: scene.data,
|
|
425
|
+
net,
|
|
426
|
+
place: Hub.hub.place,
|
|
427
|
+
visit: `${this.helloMark?.selfId ?? ''}:${this.helloMark?.again ?? ''}`,
|
|
428
|
+
});
|
|
429
|
+
const labelBoxes = this.chrome.crowdNameLabelBoxes?.() ?? [];
|
|
430
|
+
const obstacles = [...frame.controls, ...(frame.own ? [frame.own] : []), ...labelBoxes];
|
|
431
|
+
const result = layoutCrowdNames(state, candidates, { now, view: frame.view, obstacles });
|
|
432
|
+
for (const [playerId, sprite] of sprites) {
|
|
433
|
+
sprite.visible = result.visible.has(playerId);
|
|
434
|
+
if (!sprite.visible) {hidden.add(sprite);}
|
|
435
|
+
}
|
|
436
|
+
if (hidden.size) {this.crowdHidden = hidden;}
|
|
437
|
+
this.crowdSprites = allSprites;
|
|
438
|
+
let summary = [];
|
|
439
|
+
if (result.summary && this.chrome.measureLabel) {
|
|
440
|
+
const text = result.summary.tiny ? `${result.summary.count} people nearby` : `+${result.summary.count} more`;
|
|
441
|
+
const size = this.chrome.measureLabel(text, false, false, false);
|
|
442
|
+
const item = {
|
|
443
|
+
id: 'crowd:summary',
|
|
444
|
+
text,
|
|
445
|
+
x: result.summary.x,
|
|
446
|
+
y: result.summary.y,
|
|
447
|
+
box: {
|
|
448
|
+
left: result.summary.x - size.w / 2,
|
|
449
|
+
right: result.summary.x + size.w / 2,
|
|
450
|
+
top: result.summary.y - size.h,
|
|
451
|
+
bottom: result.summary.y,
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
const selected = candidates.filter((candidate) => result.visible.has(candidate.id) && candidate.box).map((candidate) => candidate.box);
|
|
455
|
+
summary = placeLabels([item], frame.own, [...frame.controls, ...labelBoxes, ...selected], frame.view, (...args) => this.chrome.measureLabel(...args));
|
|
456
|
+
}
|
|
457
|
+
// Ordinary labels have already completed HUD clearance. Updating only
|
|
458
|
+
// E's summary preserves those final DOM positions for this paint.
|
|
459
|
+
this.chrome.setCrowdNameSummary?.(summary[0] ?? null);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
invalidateCrowdNames(scene) {
|
|
463
|
+
// Without current geometry and authorization E cannot associate a name
|
|
464
|
+
// or count with an avatar. Remove all visit-local decisions and finish
|
|
465
|
+
// this paint with every current nonself tag hidden. Recovery begins from
|
|
466
|
+
// a new state once all prerequisites belong to this scene again.
|
|
467
|
+
if (Object.hasOwn(this, 'crowdNamesHeld')) {delete this.crowdNamesHeld;}
|
|
468
|
+
if (Object.hasOwn(this, 'crowdFrame')) {delete this.crowdFrame;}
|
|
469
|
+
this.chrome.setCrowdNameSummary?.(null);
|
|
470
|
+
let hidden = this.crowdHidden ?? null;
|
|
471
|
+
for (const sprite of this.crowdSprites ?? []) {
|
|
472
|
+
sprite.visible = false;
|
|
473
|
+
(hidden ??= new Set()).add(sprite);
|
|
474
|
+
}
|
|
475
|
+
for (const [playerId, tag] of scene.multiplayer?.avatars?.tags ?? []) {
|
|
476
|
+
const sprite = tag?.sprite;
|
|
477
|
+
if (playerId !== 'self' && sprite) {
|
|
478
|
+
sprite.visible = false;
|
|
479
|
+
(hidden ??= new Set()).add(sprite);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (hidden) {this.crowdHidden = hidden;}
|
|
483
|
+
if (Object.hasOwn(this, 'crowdSprites')) {delete this.crowdSprites;}
|
|
281
484
|
}
|
|
282
485
|
|
|
283
486
|
afterBehaviors(scene, dt) {
|
|
487
|
+
// Snapshot layout before any of this frame's chrome setters write DOM.
|
|
488
|
+
const canvas = scene.three?.renderer?.domElement;
|
|
489
|
+
this.frameCanvas = this.chrome?.beginLayoutFrame?.(canvas) ?? canvas?.getBoundingClientRect?.();
|
|
490
|
+
this.act?.beginLayoutFrame?.();
|
|
491
|
+
// Late hub systems (crowd names, sound replies) still read the snapshot,
|
|
492
|
+
// so it ends once this synchronous frame has returned, not at a system.
|
|
493
|
+
if (!this.layoutEndQueued) {
|
|
494
|
+
this.layoutEndQueued = true;
|
|
495
|
+
queueMicrotask(() => {
|
|
496
|
+
this.layoutEndQueued = false;
|
|
497
|
+
this.endLayoutFrame();
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
loadingCover?.sync(scene);
|
|
284
501
|
const mp = scene.multiplayer;
|
|
285
502
|
if (!mp) {
|
|
503
|
+
this.endLayoutFrame();
|
|
286
504
|
return;
|
|
287
505
|
}
|
|
288
506
|
const now = performance.now();
|
|
289
|
-
this.
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
507
|
+
if (Hub.hub.place?.result || this.doorErrors) {
|
|
508
|
+
this.doorErrors ??= makeDoorErrors();
|
|
509
|
+
this.doorErrors.sync(mp.net, Boolean(Hub.hub.place?.result) && !this.trip, now);
|
|
510
|
+
}
|
|
511
|
+
if (!this.chrome) {
|
|
512
|
+
this.chrome = makeChrome({
|
|
513
|
+
worldLabelsDefault: !Hub.deck.labels,
|
|
514
|
+
...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
|
|
515
|
+
onBack: () => this.backFromControl(scene),
|
|
516
|
+
onAvatar: (i) => Avatar.choose(scene, i),
|
|
517
|
+
onColor: (color) => Avatar.chooseColor(scene, color),
|
|
518
|
+
avatarCount: Avatar.AVATARS,
|
|
519
|
+
onPerson: (person, action) => this.join(this.scene, person, action),
|
|
520
|
+
onJumpDoor: (door) => this.goDoor(this.scene, door),
|
|
521
|
+
// A heart on the ask card is one of that card's actions, bound by its
|
|
522
|
+
// lease; a Doors list heart is not.
|
|
523
|
+
onHeart: (door, ask) => ask ? this.heartAsk(this.scene, ask, door) : this.yours?.toggle(door),
|
|
524
|
+
onAsk: (ask, yes) => this.answer(this.scene, ask, yes, true),
|
|
525
|
+
onLeaveParty: () => this.scene?.multiplayer?.net?.send({ k: 'hub-party', op: 'leave' }),
|
|
526
|
+
onReportChat: (line) => this.reportChat(line),
|
|
527
|
+
onBlockChat: (line) => this.blockChat(line),
|
|
528
|
+
onReport: (person) => this.report(person),
|
|
529
|
+
...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
|
|
530
|
+
});
|
|
531
|
+
// Initial chrome sources are new this frame; subsequent frames read
|
|
532
|
+
// them at the start above. The canvas already has its start-of-frame read.
|
|
533
|
+
this.chrome.beginLayoutFrame?.();
|
|
534
|
+
}
|
|
535
|
+
this.chrome.setWorldLabelFocus?.(worldLabelFocus(Hub.deck.labels, Boolean(Hub.hub.place?.result), scene.persistent.hubDepth > 0 || Boolean(scene.persistent.hubTickets?.length)));
|
|
536
|
+
this.chrome.beginWorldLabels?.();
|
|
537
|
+
// Shift lock belongs to the engine, including in places without Chirp.
|
|
538
|
+
this.chrome.layoutCompanion(scene.three?.renderer?.domElement?.parentElement);
|
|
539
|
+
const lock = scene.three?.renderer?.domElement?.parentElement?.querySelector?.('button[aria-label^="Shift lock"]');
|
|
540
|
+
this.chrome.safeSurface?.('engine-shift-lock', lock, 'control');
|
|
541
|
+
for (const name of ['score', 'look']) {
|
|
542
|
+
const node = scene.three?.renderer?.domElement?.parentElement?.querySelector?.(`[data-engine-hud="${name}"]`);
|
|
543
|
+
this.chrome.safeSurface?.(`engine-${name}`, node, 'text');
|
|
544
|
+
}
|
|
545
|
+
this.chrome.safeSurface?.('invite-dialog', this.invites?.surface?.());
|
|
303
546
|
Avatar.load(scene);
|
|
304
547
|
this.talk ??= makeTalk(this.chrome);
|
|
305
548
|
this.grab ??= makeGrab(this.chrome);
|
|
@@ -313,6 +556,11 @@ class HubSystem {
|
|
|
313
556
|
this.chrome.onSay?.((what) => this.saying(what));
|
|
314
557
|
}
|
|
315
558
|
this.scene = scene;
|
|
559
|
+
// The last place a manifest named: a Back after a close cleared it
|
|
560
|
+
// (`watchSession`) still knows whether it was leaving a game.
|
|
561
|
+
if (Hub.hub.place) {
|
|
562
|
+
this.knownPlace = Hub.hub.place;
|
|
563
|
+
}
|
|
316
564
|
// The host's Back control (a host that draws one, over a hub place) is
|
|
317
565
|
// answered the way the kit's own is: back through the door (contract §5).
|
|
318
566
|
if (!this.backHooked && typeof castleSdk.Hub?.onBack === 'function') {
|
|
@@ -323,7 +571,9 @@ class HubSystem {
|
|
|
323
571
|
per.hubTickets ??= [];
|
|
324
572
|
this.keepResident(scene, per.hubTickets);
|
|
325
573
|
// A handle for test drivers and phone measurements.
|
|
326
|
-
|
|
574
|
+
const serverBuild = Hub.deck.build ? mp?.net?.serverBuild ?? null : null;
|
|
575
|
+
globalThis.__hub = { scene, system: this, state: Hub.hub, ...(Hub.deck.build ? { build: Hub.deck.build, serverBuild } : {}) };
|
|
576
|
+
showBuildStamp(Hub.deck.build ? { ...Hub.deck.build, server: serverBuild } : null);
|
|
327
577
|
Object.defineProperty(globalThis.__hub, 'avatarPlatform', { enumerable: true, get: Avatar.diagnostics });
|
|
328
578
|
globalThis.__hubPacks ??= () => Packs.cachedPacks().length;
|
|
329
579
|
|
|
@@ -335,12 +585,18 @@ class HubSystem {
|
|
|
335
585
|
this.applyTune(local);
|
|
336
586
|
this.watchSession(scene, mp);
|
|
337
587
|
this.sayHello(scene, mp);
|
|
588
|
+
if (Hub.hub.place?.push?.version === 1 && Hub.hub.arrivedFacing !== null && mp.net) {
|
|
589
|
+
this.pushVisit = reportPushVisit(mp.net, Hub.hub.place, Rehello.mark(mp, mp.net), this.pushVisit);
|
|
590
|
+
}
|
|
338
591
|
if (Hub.hub.place?.visibility === true || this.visibility) {
|
|
339
592
|
this.visibility ??= makeVisibility();
|
|
340
593
|
this.visibility.sync(mp.net, this.sceneKey, Hub.hub.place?.visibility === true && !this.trip);
|
|
341
594
|
}
|
|
595
|
+
const held = Hub.hub.held.has(mp.net?.selfId?.());
|
|
596
|
+
const fallY = activeFallY(Hub.hub.place?.fallY, held, Boolean(this.trip));
|
|
342
597
|
this.followPlace(scene);
|
|
343
|
-
this.holdFall(scene, local);
|
|
598
|
+
this.holdFall(scene, local, fallY);
|
|
599
|
+
this.environment.frame(scene, local, fallY, dt, Hub.deck.defaultEnvironment);
|
|
344
600
|
this.turnSpinners(scene, dt);
|
|
345
601
|
this.applySpawns(scene);
|
|
346
602
|
this.applyTints(scene);
|
|
@@ -353,10 +609,17 @@ class HubSystem {
|
|
|
353
609
|
}
|
|
354
610
|
this.registerInterest(scene);
|
|
355
611
|
this.applyVisibility(scene);
|
|
356
|
-
this.applyWear(scene);
|
|
612
|
+
this.applyWear(scene, Hub.deck.weakestTier === true && this.weakestTier?.active && this.weakestTier.profile === 'weakest' ? local : undefined);
|
|
357
613
|
// Different characters draw from shared materials (`avatarShare.js`).
|
|
358
614
|
AvatarShare.share(scene, [local?.id, ...(mp?.avatars?.actors?.values() ?? [])]);
|
|
359
615
|
this.adoptLate(scene);
|
|
616
|
+
if (Hub.hub.place?.invite === true) {
|
|
617
|
+
this.invites ??= makeInvites(castleSdk.Hub, () => {},
|
|
618
|
+
(door) => { if (!this.trip && this.scene) {this.goHub(this.scene, { door, title: "Your friend's house" });} },
|
|
619
|
+
undefined, (text) => {this.toast = { text, until: performance.now() + TOAST_MS };}, () => Hub.deck.title,
|
|
620
|
+
(node) => this.chrome?.safeSurface?.('invite-dialog', node));
|
|
621
|
+
if (!this.trip) {this.invites.frame(mp.net);}
|
|
622
|
+
} else if (Hub.hub.place && this.invites) { this.invites.dispose(); this.invites = null; }
|
|
360
623
|
this.runCommands(scene, now);
|
|
361
624
|
this.askFriends(scene, mp, now);
|
|
362
625
|
this.together.frame(mp, this.friendsAll, !this.trip && this.pendingEnd === null, now, this.chrome.peopleOpen?.() === true);
|
|
@@ -368,10 +631,9 @@ class HubSystem {
|
|
|
368
631
|
if (Hub.hub.place?.decor && !this.decor) {
|
|
369
632
|
this.decor = makeDecor(this.chrome);
|
|
370
633
|
}
|
|
371
|
-
this.decor?.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking());
|
|
634
|
+
this.decor?.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && this.chrome.pickerSheetOpen?.() !== true);
|
|
372
635
|
const decorating = this.decor?.opened() === true;
|
|
373
636
|
this.stepEnd(scene, mp, now);
|
|
374
|
-
const held = Hub.hub.held.has(mp.net?.selfId?.());
|
|
375
637
|
// v1.68, rule B (`client/ballot.js`): the choice card runs only while
|
|
376
638
|
// its one gate holds a card (`ballotHeld`), which a place without
|
|
377
639
|
// `ballot` never does; when it lets go (another connection), the sheet
|
|
@@ -383,6 +645,7 @@ class HubSystem {
|
|
|
383
645
|
if (ballotHeld) {
|
|
384
646
|
// A chip tap sounds as the chrome's do, only with UI cues.
|
|
385
647
|
this.ballot ??= makeBallot({
|
|
648
|
+
...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
|
|
386
649
|
send: (ids) => this.scene?.multiplayer?.net?.send({ k: 'hub-ballot', ...ids }),
|
|
387
650
|
...(Hub.deck.soundscape?.ui === true ? { onChip: () => this.soundscape?.cue('tap', performance.now()) } : {}),
|
|
388
651
|
});
|
|
@@ -404,6 +667,12 @@ class HubSystem {
|
|
|
404
667
|
Hub.hub.npcEvents.some((msg) => msg.k === 'hub-npc' && msg.open))) {
|
|
405
668
|
this.chrome.cancelMenu();
|
|
406
669
|
}
|
|
670
|
+
if (this.actionInput && (card !== null || this.talk.talking() || decorating || this.trip || this.pendingEnd !== null ||
|
|
671
|
+
(Hub.hub.place?.ask === true && this.chrome.textAskPending(Hub.hub.ask)) ||
|
|
672
|
+
(Hub.hub.place?.menu === true && Hub.hub.menu?.spec) ||
|
|
673
|
+
Hub.hub.npcEvents.some((msg) => msg.k === 'hub-npc' && msg.open))) {
|
|
674
|
+
this.chrome.cancelActionOverflow();
|
|
675
|
+
}
|
|
407
676
|
this.talk.frame(scene, mp, !this.trip && this.pendingEnd === null);
|
|
408
677
|
if (Hub.hub.place?.ask === true) {
|
|
409
678
|
this.askDrawn = true;
|
|
@@ -450,7 +719,7 @@ class HubSystem {
|
|
|
450
719
|
}
|
|
451
720
|
// Idle play (v1.6): before input is locked, since a sitter's move is
|
|
452
721
|
// what gets them up (a seat is a hold).
|
|
453
|
-
this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded, this.sceneKey);
|
|
722
|
+
this.idle.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.actionInput, this.sceneKey);
|
|
454
723
|
this.idle.draw(scene, local);
|
|
455
724
|
// The soundscape, only in a deck with `hub.soundscape`: its sound control
|
|
456
725
|
// also says how loud the place's own files play. Without the key the
|
|
@@ -460,17 +729,22 @@ class HubSystem {
|
|
|
460
729
|
} else {
|
|
461
730
|
this.sound.frame(scene, local, !this.trip);
|
|
462
731
|
}
|
|
463
|
-
if (this.trip || held || this.talk.typing() || this.chrome.chatFocused?.() || decorating || this.askInput || this.menuInput) {
|
|
732
|
+
if (this.trip || held || this.talk.typing() || this.chrome.chatFocused?.() || decorating || this.askInput || this.menuInput || this.actionInput) {
|
|
464
733
|
lockInput(scene);
|
|
465
734
|
// Under the engine's orbit camera key the player's drags and wheel do
|
|
466
735
|
// not move the trip's camera, nor queue up for after it.
|
|
467
|
-
if ((this.trip || decorating || this.askInput || this.menuInput) && scene.cameraControl === 'orbit') {
|
|
736
|
+
if ((this.trip || decorating || this.askInput || this.menuInput || this.actionInput) && scene.cameraControl === 'orbit') {
|
|
468
737
|
scene.lookInput?.lock?.();
|
|
469
738
|
}
|
|
470
739
|
}
|
|
471
740
|
// Grabbing and throwing (v1.3), in a place that offers it: after this
|
|
472
741
|
// frame's physics step, before the multiplayer kit reports what it owns.
|
|
473
|
-
this.grab.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating
|
|
742
|
+
this.grab.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput,
|
|
743
|
+
Hub.deck.act === true && Boolean(this.actionInput) && !this.trip && this.pendingEnd === null);
|
|
744
|
+
if (Hub.deck.act === true) {
|
|
745
|
+
this.act ??= makeAct(this.chrome, this.grab, this.talk);
|
|
746
|
+
this.act.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput && !this.askInput && !this.menuInput && !this.carded);
|
|
747
|
+
}
|
|
474
748
|
if (this.trip) {
|
|
475
749
|
this.stepTrip(scene, mp, local, now);
|
|
476
750
|
} else if (!Hub.hub.faced) {
|
|
@@ -496,9 +770,22 @@ class HubSystem {
|
|
|
496
770
|
delete this.companionTappedUntil;
|
|
497
771
|
}
|
|
498
772
|
this.drawChrome(scene, local, now);
|
|
499
|
-
if (Hub.hub.place?.actions === true) {
|
|
773
|
+
if (Hub.hub.place?.actions === true || Hub.hub.place?.anonymousEntry === true) {
|
|
500
774
|
this.actionsDrawn = true;
|
|
501
|
-
|
|
775
|
+
const hud = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
776
|
+
const items = this.signIn.items(Hub.hub.place, hud, Hub.hub.actions?.items ?? null);
|
|
777
|
+
this.chrome.setActions(items, (id, n) => {
|
|
778
|
+
if (id === 'signin' && Hub.hub.place?.anonymousEntry === true) {void this.signIn.press(hud?.text ?? 'Keep your progress');}
|
|
779
|
+
else {mp.net?.send({ k: 'hub-action', id, n });}
|
|
780
|
+
}, !this.signIn.pending() && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput,
|
|
781
|
+
Hub.hub.actions?.n, scene.data?.engine?.hubActionOverflow === true || !landscapeViewport(), (open) => {
|
|
782
|
+
if (open) {
|
|
783
|
+
this.actionInput = holdAskInput(scene);
|
|
784
|
+
} else if (this.actionInput) {
|
|
785
|
+
this.actionInput.release();
|
|
786
|
+
delete this.actionInput;
|
|
787
|
+
}
|
|
788
|
+
});
|
|
502
789
|
} else if (this.actionsDrawn) {
|
|
503
790
|
this.chrome.clearActions();
|
|
504
791
|
delete this.actionsDrawn;
|
|
@@ -508,7 +795,24 @@ class HubSystem {
|
|
|
508
795
|
const box = this.carded ? this.chrome.hudClearBox?.() : null;
|
|
509
796
|
this.ballot.frame(this.carded ? cardFor(mp.net ?? null) : null, Hub.hub.place?.ballot?.lines ?? [], mp.net?.selfId?.() ?? null, Hub.simNow(), box ? box.bottom : 0);
|
|
510
797
|
}
|
|
798
|
+
this.chrome.safeSurface?.('ballot', this.ballot?.surface?.());
|
|
799
|
+
this.chrome.flushWorldLabels?.();
|
|
800
|
+
this.reportLoad(mp);
|
|
511
801
|
this.measure(scene, mp, now);
|
|
802
|
+
if (this.lateFor !== scene) {this.endLayoutFrame();}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// v1.138: an opted-in town hears once per transport that this browser's body
|
|
806
|
+
// is placed while it still waits for hub-arrived (shared/loadStages.js).
|
|
807
|
+
reportLoad(mp) {
|
|
808
|
+
const net = mp?.net;
|
|
809
|
+
if (loadTelemetryFor(net) && Hub.hub.arrivedFacing === null && mp.placed?.()) {reportLoadStage(net, LOAD_STAGES.placed);}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
endLayoutFrame() {
|
|
813
|
+
this.chrome?.endLayoutFrame?.();
|
|
814
|
+
this.act?.endLayoutFrame?.();
|
|
815
|
+
this.frameCanvas = null;
|
|
512
816
|
}
|
|
513
817
|
|
|
514
818
|
// The soundscape (`client/soundscape.js`), only in a deck whose castle.json
|
|
@@ -541,15 +845,42 @@ class HubSystem {
|
|
|
541
845
|
return;
|
|
542
846
|
}
|
|
543
847
|
if (!this.tiers) {
|
|
544
|
-
this.tiers = makeTiers(
|
|
848
|
+
this.tiers = qualityFor(scene)?.tiers ?? makeTiers({ weakest: Hub.deck.weakestTier === true,
|
|
849
|
+
onLayout: (node) => this.chrome?.safeSurface?.('cells-debug', node, 'text') });
|
|
545
850
|
const pick = (mode) => {
|
|
546
851
|
this.tiers.set(mode);
|
|
547
|
-
this.chrome?.setGraphics?.(this.tiers.mode, pick);
|
|
852
|
+
this.chrome?.setGraphics?.(this.tiers.mode, pick, Hub.deck.weakestTier === true);
|
|
548
853
|
};
|
|
549
|
-
this.chrome?.setGraphics?.(this.tiers.mode, pick);
|
|
854
|
+
this.chrome?.setGraphics?.(this.tiers.mode, pick, Hub.deck.weakestTier === true);
|
|
550
855
|
}
|
|
551
856
|
const counts = !this.trip && this.pendingEnd === null && mp?.placed?.() === true;
|
|
552
857
|
this.tiers.frame(scene, counts, now);
|
|
858
|
+
const profile = Hub.deck.weakestTier === true
|
|
859
|
+
? (this.tiers.weakest() ? 'weakest' : this.tiers.middle?.() ? 'middle' : null)
|
|
860
|
+
: null;
|
|
861
|
+
if (profile && (this.weakestTier || readDistricts(scene.data?.weakestDistricts))) {
|
|
862
|
+
if (this.weakestTier && this.weakestTier.profile !== profile) {
|
|
863
|
+
this.weakestTier.restore();
|
|
864
|
+
this.weakestTier = null;
|
|
865
|
+
}
|
|
866
|
+
this.weakestTier ??= makeWeakestTier({ profile });
|
|
867
|
+
// Weakest protects only this player's guidance targets; Middle protects
|
|
868
|
+
// shared labels too. Sleeping targets remain available through getActor.
|
|
869
|
+
const pointerTargets = new Set([
|
|
870
|
+
...(profile === 'middle' ? Object.keys(Hub.hub.labels ?? {}) : []),
|
|
871
|
+
...Object.keys(Hub.hub.labelsMe ?? {}),
|
|
872
|
+
]);
|
|
873
|
+
this.weakestTier.frame(scene, true, now, Hub.deck.weakestLookBake === true, pointerTargets);
|
|
874
|
+
} else if (this.weakestTier?.active) {
|
|
875
|
+
this.weakestTier.restore();
|
|
876
|
+
}
|
|
877
|
+
const weakestActive = this.weakestTier?.active && this.weakestTier.profile === 'weakest';
|
|
878
|
+
if ((Hub.deck.mergeFarAvatars === true || weakestActive) && this.tiers?.current() === 'low' && !scene.content && scene.three?.staticActorsOff !== true) {
|
|
879
|
+
this.farAvatars ??= makeFarAvatars();
|
|
880
|
+
this.farAvatars.update(scene, mp?.avatars?.actors?.values() ?? [], scene.actorWith('Player')?.id, true, now, weakestActive ? 12 : Infinity);
|
|
881
|
+
} else {
|
|
882
|
+
this.farAvatars?.clear();
|
|
883
|
+
}
|
|
553
884
|
if (Hub.deck.lowActorBudget) {
|
|
554
885
|
this.actorBudget ??= makeActorBudget();
|
|
555
886
|
this.actorBudget(scene, this.tiers.current() === 'low' && !scene.content, now);
|
|
@@ -557,6 +888,14 @@ class HubSystem {
|
|
|
557
888
|
if (Hub.hub.place?.interest === 'cells') {
|
|
558
889
|
this.interestTier = this.tiers.current();
|
|
559
890
|
}
|
|
891
|
+
if (fpsTelemetryFor(mp?.net)) {this.fpsTier = this.tiers.weakest() ? 3 : this.tiers.current() === 'low' ? 1 : 2;}
|
|
892
|
+
if (Hub.deck.quality || Hub.deck.highOnly) {
|
|
893
|
+
const quality = qualityFor(scene);
|
|
894
|
+
if (quality) {
|
|
895
|
+
restoreDecor(scene, quality, quality.build);
|
|
896
|
+
if (Hub.deck.quality) {qualityPlayers(scene, quality, now);}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
560
899
|
globalThis.__hub.tier = this.tiers.handle;
|
|
561
900
|
}
|
|
562
901
|
|
|
@@ -586,6 +925,8 @@ class HubSystem {
|
|
|
586
925
|
|
|
587
926
|
// The systems that run after every other one, registered once per runtime.
|
|
588
927
|
registerLate(scene) {
|
|
928
|
+
if (this.lateScenes?.has(scene)) {return;}
|
|
929
|
+
(this.lateScenes ??= new WeakSet()).add(scene);
|
|
589
930
|
scene.registerSystem({
|
|
590
931
|
afterBehaviors: (s) => {
|
|
591
932
|
this.applyVisibility(s);
|
|
@@ -602,12 +943,6 @@ class HubSystem {
|
|
|
602
943
|
// Complete sound recovery after every system, including the transport
|
|
603
944
|
// drain. A keyless deck registers no sound completion hook.
|
|
604
945
|
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
946
|
scene.registerSystem({ afterBehaviors: (s) => {
|
|
612
947
|
const local = s.actorWith('Player');
|
|
613
948
|
const now = performance.now();
|
|
@@ -657,15 +992,8 @@ class HubSystem {
|
|
|
657
992
|
// stops just under it until the place puts them back: a pose past the
|
|
658
993
|
// world's floor is never read, so a client that kept falling would never be
|
|
659
994
|
// caught.
|
|
660
|
-
holdFall(scene, local) {
|
|
661
|
-
|
|
662
|
-
const t = local?.components.Transform;
|
|
663
|
-
if (typeof fallY !== 'number' || this.trip || !t || t.y >= fallY - 1) {
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
t.y = fallY - 1;
|
|
667
|
-
scene.physics3d?.bodyOf?.(local)?.setTranslation({ x: t.x, y: t.y, z: t.z }, true);
|
|
668
|
-
scene.physics3d?.setVelocity?.(local, { x: 0, y: 0, z: 0 });
|
|
995
|
+
holdFall(scene, local, fallY) {
|
|
996
|
+
holdFallenPlayer(scene, local, fallY);
|
|
669
997
|
}
|
|
670
998
|
|
|
671
999
|
clearMenu() {
|
|
@@ -685,6 +1013,10 @@ class HubSystem {
|
|
|
685
1013
|
}
|
|
686
1014
|
|
|
687
1015
|
enterScene(scene) {
|
|
1016
|
+
this.clearPadReadability();
|
|
1017
|
+
if (this.actionInput) {
|
|
1018
|
+
this.chrome.cancelActionOverflow();
|
|
1019
|
+
}
|
|
688
1020
|
if (this.sceneKey !== null && this.sceneKey !== undefined && this.menuDrawn) {
|
|
689
1021
|
this.clearMenu();
|
|
690
1022
|
delete Hub.hub.menu;
|
|
@@ -714,6 +1046,7 @@ class HubSystem {
|
|
|
714
1046
|
this.playAsk = null;
|
|
715
1047
|
this.wentAsk = null;
|
|
716
1048
|
this.againAsk = null;
|
|
1049
|
+
this.askSlot.clear();
|
|
717
1050
|
this.playAsked.clear();
|
|
718
1051
|
this.yours?.clear();
|
|
719
1052
|
}
|
|
@@ -721,6 +1054,13 @@ class HubSystem {
|
|
|
721
1054
|
// Every scene load, the same scene reloaded included: the actors are the
|
|
722
1055
|
// file's again, so what was dropped, painted or spawned in them is gone.
|
|
723
1056
|
reset(scene) {
|
|
1057
|
+
this.clearPadReadability();
|
|
1058
|
+
if (this.actionInput) {
|
|
1059
|
+
this.chrome.cancelActionOverflow();
|
|
1060
|
+
}
|
|
1061
|
+
this.weakestTier?.restore();
|
|
1062
|
+
this.environment.restore();
|
|
1063
|
+
this.farAvatars?.clear();
|
|
724
1064
|
if (this.menuDrawn) {
|
|
725
1065
|
this.clearMenu();
|
|
726
1066
|
delete Hub.hub.menu;
|
|
@@ -750,7 +1090,7 @@ class HubSystem {
|
|
|
750
1090
|
// What players wear (`hub.wear`, v1.4), over each avatar and this player's
|
|
751
1091
|
// own body. Also after every other system, as visibility is: the
|
|
752
1092
|
// multiplayer kit moves the other avatars after this one runs.
|
|
753
|
-
applyWear(scene) {
|
|
1093
|
+
applyWear(scene, local) {
|
|
754
1094
|
const self = scene.multiplayer?.net?.selfId?.() ?? null;
|
|
755
1095
|
const style = Avatar.style();
|
|
756
1096
|
// Dressed as the avatar drawn: `known` for the others, or the stand-in
|
|
@@ -758,7 +1098,7 @@ class HubSystem {
|
|
|
758
1098
|
const indexOf = (playerId) => (playerId === self ? Avatar.current(scene) : AvatarCap.shown(playerId));
|
|
759
1099
|
this.wear.frame(
|
|
760
1100
|
scene,
|
|
761
|
-
scene.actorWith('Player'),
|
|
1101
|
+
local ?? scene.actorWith('Player'),
|
|
762
1102
|
Hub.hub.wearing,
|
|
763
1103
|
(playerId) => {
|
|
764
1104
|
const index = indexOf(playerId);
|
|
@@ -774,7 +1114,7 @@ class HubSystem {
|
|
|
774
1114
|
// Earned items (v1.53): no work at all while nobody shows one and
|
|
775
1115
|
// nothing is drawn.
|
|
776
1116
|
if (Hub.hub.earned.size > 0 || this.earned.size > 0) {
|
|
777
|
-
this.earned.frame(scene, scene.actorWith('Player'), Hub.hub.earned, (playerId) => {
|
|
1117
|
+
this.earned.frame(scene, local ?? scene.actorWith('Player'), Hub.hub.earned, (playerId) => {
|
|
778
1118
|
const index = indexOf(playerId);
|
|
779
1119
|
return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
|
|
780
1120
|
});
|
|
@@ -865,11 +1205,22 @@ class HubSystem {
|
|
|
865
1205
|
// The same session again (the avatar changed): the place keeps what it
|
|
866
1206
|
// knows this client holds (a cabinet's card, v1.7).
|
|
867
1207
|
const again = net === this.helloNet;
|
|
1208
|
+
let inviteNear = null;
|
|
1209
|
+
if (!again && (Hub.hub.place?.invite === true || !Hub.hub.place && Hub.deck.invite)) {
|
|
1210
|
+
this.invites ??= makeInvites(castleSdk.Hub, () => {},
|
|
1211
|
+
(door) => { if (!this.trip && this.scene) { this.goHub(this.scene, { door, title: "Your friend's house" }); } },
|
|
1212
|
+
undefined, (text) => {this.toast = { text, until: performance.now() + TOAST_MS };}, () => Hub.deck.title,
|
|
1213
|
+
(node) => this.chrome?.safeSurface?.('invite-dialog', node));
|
|
1214
|
+
const arrival = this.invites.hello(net);
|
|
1215
|
+
if (!arrival.ready) {return;}
|
|
1216
|
+
inviteNear = arrival.near;
|
|
1217
|
+
}
|
|
868
1218
|
if (!again) {
|
|
869
1219
|
this.identityPlace = null;
|
|
870
1220
|
this.freshSession(scene);
|
|
871
1221
|
}
|
|
872
|
-
this.sendHello(scene, mp, net, avatar, { again });
|
|
1222
|
+
this.sendHello(scene, mp, net, avatar, { again, inviteNear });
|
|
1223
|
+
if (!again) {this.invites?.landed();}
|
|
873
1224
|
}
|
|
874
1225
|
|
|
875
1226
|
// The same connection under another player id is another session: what the
|
|
@@ -877,26 +1228,30 @@ class HubSystem {
|
|
|
877
1228
|
// and the snapshot's state) goes before the new one's packets are applied,
|
|
878
1229
|
// as on any switch of session, along with what this client kept of it.
|
|
879
1230
|
newIdentity() {
|
|
1231
|
+
this.pushVisit = null;
|
|
880
1232
|
console.log('[hub] the connection has a new player id: a new session');
|
|
881
1233
|
this.identityPlace = Hub.hub.place ?? this.identityPlace;
|
|
882
1234
|
Hub.clear();
|
|
1235
|
+
// The server forgets invitations with an old player identity. Hub.clear
|
|
1236
|
+
// resets that occurrence, while the shared slot retains other expired
|
|
1237
|
+
// client offers (notably Your games) through the reconnect.
|
|
883
1238
|
if (ballotHeld) {
|
|
884
1239
|
forgetBallot();
|
|
885
1240
|
}
|
|
886
1241
|
if (this.scene) {
|
|
887
|
-
this.freshSession(this.scene);
|
|
1242
|
+
this.freshSession(this.scene, { keepAskSlot: true });
|
|
888
1243
|
}
|
|
889
1244
|
// A recovery, not a walk-in: no automatic start beside a friend.
|
|
890
1245
|
this.startNear = null;
|
|
891
1246
|
}
|
|
892
1247
|
|
|
893
1248
|
// What this client keeps of one session, cleared when it joins another.
|
|
894
|
-
freshSession(scene) {
|
|
1249
|
+
freshSession(scene, { keepAskSlot = false } = {}) {
|
|
895
1250
|
// A player who walks in (no door, no jump to a friend) starts beside a
|
|
896
1251
|
// friend or party member who is already here, once, if one turns up in
|
|
897
1252
|
// the first moments and the player has not walked off.
|
|
898
1253
|
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;
|
|
1254
|
+
this.startNear = !this.invites?.accepted() && !arrivingNow?.door && typeof arrivingNow?.near !== 'string' ? { until: performance.now() + START_NEAR_MS, at: null, asked: false } : null;
|
|
900
1255
|
this.friendsAt = -Infinity;
|
|
901
1256
|
this.friendsGameAt = -Infinity;
|
|
902
1257
|
this.friendsGameWarm = false;
|
|
@@ -907,6 +1262,9 @@ class HubSystem {
|
|
|
907
1262
|
this.playAsk = null;
|
|
908
1263
|
this.wentAsk = null;
|
|
909
1264
|
this.againAsk = null;
|
|
1265
|
+
if (!keepAskSlot) {
|
|
1266
|
+
this.askSlot.clear();
|
|
1267
|
+
}
|
|
910
1268
|
this.playAsked.clear();
|
|
911
1269
|
this.chat.reset();
|
|
912
1270
|
this.talk?.reset();
|
|
@@ -924,7 +1282,7 @@ class HubSystem {
|
|
|
924
1282
|
|
|
925
1283
|
// `solo`: a party of one carrying nothing and naming no friend, as `resume`
|
|
926
1284
|
// is, without saying it resumes (a game's new session, `helloAfter`).
|
|
927
|
-
sendHello(scene, mp, net, avatar, { again = false, resume = false, solo = resume } = {}) {
|
|
1285
|
+
sendHello(scene, mp, net, avatar, { again = false, resume = false, solo = resume, inviteNear = null } = {}) {
|
|
928
1286
|
if (resume && (this.menuDrawn || Object.hasOwn(Hub.hub, 'menu'))) {
|
|
929
1287
|
this.clearMenu();
|
|
930
1288
|
delete Hub.hub.menu;
|
|
@@ -954,7 +1312,8 @@ class HubSystem {
|
|
|
954
1312
|
party: solo ? 1 : arriving?.party ?? 1,
|
|
955
1313
|
carry: !solo && arriving?.returning && per.hubResult ? { result: per.hubResult } : null,
|
|
956
1314
|
// A jump to a friend: the place puts this player beside them.
|
|
957
|
-
...(!solo && typeof arriving?.near === 'string' ? { near: arriving.near } : {}),
|
|
1315
|
+
...(!solo && typeof (inviteNear ?? arriving?.near) === 'string' ? { near: inviteNear ?? arriving.near } : {}),
|
|
1316
|
+
...((Hub.hub.place?.invite === true || !Hub.hub.place && Hub.deck.invite) && this.invites?.accepted() ? { invited: true } : {}),
|
|
958
1317
|
...(again ? { again: true } : {}),
|
|
959
1318
|
...(resume ? { resume: true } : {}),
|
|
960
1319
|
});
|
|
@@ -1000,7 +1359,21 @@ class HubSystem {
|
|
|
1000
1359
|
applySpawns(scene) {
|
|
1001
1360
|
const want = Hub.hub.spawned;
|
|
1002
1361
|
const mp = scene.multiplayer;
|
|
1003
|
-
|
|
1362
|
+
const quality = Hub.deck.quality ? lowQuality(scene) : null;
|
|
1363
|
+
const allowed = quality ? qualitySpawnIds(want, Hub.hub.spawnTemplates, scene.actorWith('Player')?.components.Transform, quality.spawned) : null;
|
|
1364
|
+
if (allowed) {
|
|
1365
|
+
for (const id of this.spawnedHere) {
|
|
1366
|
+
if (Object.hasOwn(want, id) && !allowed.has(id) && Hub.hub.spawnTemplates[want[id].from]?.decor === true) {
|
|
1367
|
+
this.spawnedHere.delete(id);
|
|
1368
|
+
this.stash.delete(id); this.tinted.delete(id);
|
|
1369
|
+
mp?.avatars?.retired?.add(id);
|
|
1370
|
+
scene.despawnActor(id);
|
|
1371
|
+
mp?.forgetObject?.(id);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
const copies = allowed ? [...allowed].map((id) => [id, want[id]]) : Object.entries(want);
|
|
1376
|
+
for (const [id, copy] of copies) {
|
|
1004
1377
|
if (this.spawnedHere.has(id) || scene.getActor(id) || mp?.gone?.has(id)) {
|
|
1005
1378
|
continue;
|
|
1006
1379
|
}
|
|
@@ -1010,6 +1383,7 @@ class HubSystem {
|
|
|
1010
1383
|
continue;
|
|
1011
1384
|
}
|
|
1012
1385
|
const components = JSON.parse(JSON.stringify(template));
|
|
1386
|
+
if (Hub.deck.quality) {delete components.decor;}
|
|
1013
1387
|
components.Transform = { ...components.Transform, x: copy.x, y: copy.y, z: copy.z, rotationY: copy.rotationY };
|
|
1014
1388
|
scene.spawnActor({ id, components });
|
|
1015
1389
|
this.spawnedHere.add(id);
|
|
@@ -1106,31 +1480,37 @@ class HubSystem {
|
|
|
1106
1480
|
}
|
|
1107
1481
|
this.lastNet = null;
|
|
1108
1482
|
const inGame = Boolean(Hub.hub.place?.result);
|
|
1109
|
-
const
|
|
1483
|
+
const refused = joinErrorText(last.closeError?.());
|
|
1484
|
+
// A player coming back from away is still under the multiplayer kit's
|
|
1485
|
+
// cover, and what the page holds is the place as it was before they left:
|
|
1486
|
+
// the way back starts under the trip's cover, with no door beat over it.
|
|
1487
|
+
const covered = mp.returning?.() === true;
|
|
1110
1488
|
Hub.clear();
|
|
1111
1489
|
if (inGame && scene.persistent.hubTickets.length) {
|
|
1112
1490
|
this.toast = { text: 'The game ended', until: performance.now() + TOAST_MS };
|
|
1113
|
-
this.back(scene);
|
|
1114
|
-
} else if (!inGame && !
|
|
1491
|
+
this.back(scene, { covered });
|
|
1492
|
+
} else if (!inGame && !refused && mp.target?.mode === 'hub' && !(scene.persistent.hubDepth > 0)) {
|
|
1115
1493
|
console.warn('[hub-door] this place ended under a hub join: joining it again');
|
|
1116
|
-
mp.switchSession(scene, scene.persistent.hubRootJoin ?? { mode: 'public' });
|
|
1494
|
+
mp.switchSession(scene, pongJoin(scene.persistent.hubRootJoin ?? { mode: 'public' }, Hub.deck.pongTimeoutMs));
|
|
1117
1495
|
this.helloNet = null;
|
|
1118
1496
|
this.toast = { text: 'Reconnecting…', until: performance.now() + TOAST_MS };
|
|
1119
|
-
} else if (!inGame && !
|
|
1497
|
+
} else if (!inGame && !refused && mp.target?.mode === 'hub') {
|
|
1120
1498
|
console.warn('[hub-door] this place ended under a hub join behind a door: leaving by its way back');
|
|
1121
1499
|
const title = scene.persistent.hubTickets.at(-1)?.title;
|
|
1122
1500
|
this.toast = {
|
|
1123
1501
|
text: title ? `This place was updated. Back to ${title}…` : 'This place was updated. Going back…',
|
|
1124
1502
|
until: performance.now() + TOAST_MS,
|
|
1125
1503
|
};
|
|
1126
|
-
this.back(scene);
|
|
1504
|
+
this.back(scene, { covered });
|
|
1127
1505
|
}
|
|
1128
1506
|
}
|
|
1129
1507
|
|
|
1130
1508
|
runCommands(scene, now) {
|
|
1131
1509
|
while (Hub.hub.commands.length && !this.trip) {
|
|
1132
1510
|
const msg = Hub.hub.commands.shift();
|
|
1133
|
-
if (msg.k === 'hub-
|
|
1511
|
+
if (msg.k === 'hub-invite' && Hub.hub.place?.invite === true) {
|
|
1512
|
+
this.invites?.open(msg.share === true);
|
|
1513
|
+
} else if (msg.k === 'hub-home-unlock') {
|
|
1134
1514
|
// v1.77: a harbour boat deed names the Harbour; anything else is the house.
|
|
1135
1515
|
this.toast = { text: msg.to === 'boat' ? 'Sent to your boat at the Harbour' : 'Sent to your house', until: now + TOAST_MS };
|
|
1136
1516
|
} else if (msg.k === 'hub-go' && msg.classic) {
|
|
@@ -1144,7 +1524,11 @@ class HubSystem {
|
|
|
1144
1524
|
} else if (msg.k === 'hub-result') {
|
|
1145
1525
|
scene.persistent.hubResult = { ...msg.result, at: Date.now() };
|
|
1146
1526
|
} else if (msg.k === 'hub-end' && Rehello.takesEnd(msg, this.pendingEnd, this.endSession, sessionKey(scene))) {
|
|
1147
|
-
|
|
1527
|
+
// An end that meets a player coming back from away (a game that ran
|
|
1528
|
+
// out meanwhile, a fresh admission it ends at once) is not paused on:
|
|
1529
|
+
// the way back starts now, under the trip's cover (`watchSession`).
|
|
1530
|
+
this.endCovered = scene.multiplayer?.returning?.() === true;
|
|
1531
|
+
this.pendingEnd = this.endCovered ? now : now + END_PAUSE_MS;
|
|
1148
1532
|
this.endSession = sessionKey(scene);
|
|
1149
1533
|
this.endLeaving = null;
|
|
1150
1534
|
const r = scene.persistent.hubResult;
|
|
@@ -1184,7 +1568,9 @@ class HubSystem {
|
|
|
1184
1568
|
scene: null,
|
|
1185
1569
|
content: undefined,
|
|
1186
1570
|
deck: msg.title ?? msg.door,
|
|
1187
|
-
|
|
1571
|
+
retryDoor: msg.door,
|
|
1572
|
+
retryOwner: msg.owner ?? null,
|
|
1573
|
+
pending: this.resolveHub(scene, () => hubGo(msg.door, msg.owner)),
|
|
1188
1574
|
join: null,
|
|
1189
1575
|
title: msg.title,
|
|
1190
1576
|
exitDoor: doorActor(scene, msg.door),
|
|
@@ -1246,6 +1632,7 @@ class HubSystem {
|
|
|
1246
1632
|
// handoff (one from before cabinets), which is given back. In the chain
|
|
1247
1633
|
// with every other acquisition and cancel (`resolveHub`).
|
|
1248
1634
|
resolveClassic(acquire) {
|
|
1635
|
+
this.fpsTelemetry?.leave();
|
|
1249
1636
|
const state = { done: false, error: null, code: null, abandoned: false, target: null };
|
|
1250
1637
|
const run = async () => {
|
|
1251
1638
|
let giveBack = false;
|
|
@@ -1295,8 +1682,8 @@ class HubSystem {
|
|
|
1295
1682
|
pending.abandoned = true;
|
|
1296
1683
|
pending.target = trip.target;
|
|
1297
1684
|
}
|
|
1298
|
-
if (pending.code
|
|
1299
|
-
trip.target.stuck =
|
|
1685
|
+
if (joinErrorText(pending.code)) {
|
|
1686
|
+
trip.target.stuck = joinErrorText(pending.code);
|
|
1300
1687
|
}
|
|
1301
1688
|
this.shutDoor(scene, trip, pending.error ?? 'it took too long', now);
|
|
1302
1689
|
}
|
|
@@ -1385,6 +1772,7 @@ class HubSystem {
|
|
|
1385
1772
|
// none, so acquisitions and their cancels run one after another
|
|
1386
1773
|
// (`hubChain`): a late cancel can never reach a newer trip's acquisition.
|
|
1387
1774
|
resolveHub(scene, acquire, stay) {
|
|
1775
|
+
this.fpsTelemetry?.leave();
|
|
1388
1776
|
const state = { done: false, content: null, error: null, join: null, stayed: false, abandoned: false };
|
|
1389
1777
|
const keep = new Set(scene.persistent.hubTickets.map((t) => t.content?.sha256).filter(Boolean));
|
|
1390
1778
|
if (scene.content) {
|
|
@@ -1400,6 +1788,7 @@ class HubSystem {
|
|
|
1400
1788
|
if (handoff?.status !== 'ok') {
|
|
1401
1789
|
throw new Error(handoff?.status ?? 'unavailable');
|
|
1402
1790
|
}
|
|
1791
|
+
state.acquiredAt = performance.now();
|
|
1403
1792
|
state.join = { mode: 'hub', handoff };
|
|
1404
1793
|
if (stay?.content && stay.content.sha256 === handoff.bundleHash) {
|
|
1405
1794
|
// Held in the pack cache, unless it was evicted: then fetched again.
|
|
@@ -1641,6 +2030,13 @@ class HubSystem {
|
|
|
1641
2030
|
say(`Invited ${person.username ?? 'them'} to your party`);
|
|
1642
2031
|
} else if (action === 'goto' && person.playerId) {
|
|
1643
2032
|
this.sendJump(net, { k: 'hub-goto', player: person.playerId });
|
|
2033
|
+
} else if (action === 'door' && person.door && person.owner) {
|
|
2034
|
+
// A friend at home: the place sends this player through their House
|
|
2035
|
+
// door with the owner (`hub-go` carrying `owner`), ending the visit here
|
|
2036
|
+
// as any door's trip does. A host that predates the owner acquires this
|
|
2037
|
+
// player's own House, as the pad would have.
|
|
2038
|
+
this.sendJump(net, { k: 'hub-house-visit', door: person.door, owner: person.owner });
|
|
2039
|
+
say(`Going to ${person.username ?? 'your friend'}'s House`);
|
|
1644
2040
|
} else if (action === 'door' && person.door) {
|
|
1645
2041
|
this.sendJump(net, { k: 'hub-door-jump', door: person.door });
|
|
1646
2042
|
// A friend inside the game is said to be; someone standing at the door
|
|
@@ -1822,6 +2218,18 @@ class HubSystem {
|
|
|
1822
2218
|
});
|
|
1823
2219
|
}
|
|
1824
2220
|
|
|
2221
|
+
blockChat(line) {
|
|
2222
|
+
if (!chatModerationEnabled(this.scene)) {
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
this.chat.reportAndBlock(line?.id, line?.userId, (ok) => {
|
|
2226
|
+
if (ok) {
|
|
2227
|
+
this.say.hideUser(line.userId);
|
|
2228
|
+
}
|
|
2229
|
+
this.toast = { text: ok ? 'Reported and blocked.' : "The block wasn't confirmed. Try again.", until: performance.now() + TOAST_MS };
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
|
|
1825
2233
|
reportChat(line) {
|
|
1826
2234
|
this.chat.report(line?.id, (ok) => {
|
|
1827
2235
|
this.toast = { text: ok ? 'Reported. Thanks.' : "That report didn't go through.", until: performance.now() + TOAST_MS };
|
|
@@ -1830,7 +2238,7 @@ class HubSystem {
|
|
|
1830
2238
|
|
|
1831
2239
|
// The question the chrome puts to the player, from the place's word on
|
|
1832
2240
|
// their party: a door their party proposed, else an invitation.
|
|
1833
|
-
ask() {
|
|
2241
|
+
ask(now = performance.now()) {
|
|
1834
2242
|
const { invite, proposal } = Hub.hub.party;
|
|
1835
2243
|
if (proposal?.asked) {
|
|
1836
2244
|
const title = Hub.hub.doors.find((d) => d.id === proposal.door)?.title ?? 'a game';
|
|
@@ -1838,7 +2246,8 @@ class HubSystem {
|
|
|
1838
2246
|
}
|
|
1839
2247
|
// Someone here said "Let's play <door>": Go takes this player to its pad.
|
|
1840
2248
|
const play = this.playAsk;
|
|
1841
|
-
|
|
2249
|
+
const playCard = play ? { key: `play:${play.from}:${play.door}:${play.until}`, kind: 'play' } : null;
|
|
2250
|
+
if (play && (now < play.until || this.askSlot.known(playCard)) && Hub.hub.doors.some((d) => d.id === play.door) && !invite) {
|
|
1842
2251
|
const title = Hub.hub.doors.find((d) => d.id === play.door)?.title ?? 'a game';
|
|
1843
2252
|
// A game that takes no late joiners cannot be followed into: the player
|
|
1844
2253
|
// is told where their friend is, and that they will be back.
|
|
@@ -1850,15 +2259,24 @@ class HubSystem {
|
|
|
1850
2259
|
return { key: `play:${play.from}:${play.door}:${play.until}`, kind: 'play', door: play.door, text, yes: play.went ? 'Follow' : 'Go', no: 'Not now' };
|
|
1851
2260
|
}
|
|
1852
2261
|
if (invite) {
|
|
1853
|
-
|
|
2262
|
+
const occurrence = Hub.invitationOccurrence(invite);
|
|
2263
|
+
return { key: `invite:${invite.from}:${occurrence.n}`, kind: 'invite', from: invite.from, text: `${invite.username ?? 'Someone'} invited you to their party`, yes: 'Join party', no: 'No thanks' };
|
|
1854
2264
|
}
|
|
1855
2265
|
// Cues (v1.29): back from a game with nothing else asked -- the same game
|
|
1856
2266
|
// again, with the party when there is one (the Doors list's own Go).
|
|
1857
2267
|
if (Hub.deck.yourGames && !proposal) {
|
|
1858
|
-
|
|
2268
|
+
const ask = this.yours?.ask(Hub.hub.yours, Hub.hub.doors, Hub.hub.party.members, now) ?? null;
|
|
2269
|
+
// A returned offer begins only after the server's arrival pose has been
|
|
2270
|
+
// applied. Once displayed, its slot lease remains the authority through
|
|
2271
|
+
// reconnects even while the next placement receipt is still pending.
|
|
2272
|
+
if (ask?.requiresArrivalPlacement && !this.askSlot.known(ask) && !Hub.hub.arrivalPlaced) {
|
|
2273
|
+
return null;
|
|
2274
|
+
}
|
|
2275
|
+
return ask;
|
|
1859
2276
|
}
|
|
1860
2277
|
const again = Hub.deck.cues && !Hub.deck.yourGames ? this.againAsk : null;
|
|
1861
|
-
const
|
|
2278
|
+
const againCard = again ? { key: `again:${again.door}:${again.until}`, kind: 'again' } : null;
|
|
2279
|
+
const door = again && (now < again.until || this.askSlot.known(againCard)) ? Hub.hub.doors.find((d) => d.id === again.door) : null;
|
|
1862
2280
|
if (door) {
|
|
1863
2281
|
const together = Hub.hub.party.members?.length && !door.solo;
|
|
1864
2282
|
return { key: `again:${again.door}:${again.until}`, kind: 'again', door: door.id, text: `Play ${door.title ?? 'that'} again${together ? ' together' : ''}?`, yes: together ? 'Go together' : 'Play again', no: 'Not now' };
|
|
@@ -1866,14 +2284,30 @@ class HubSystem {
|
|
|
1866
2284
|
return null;
|
|
1867
2285
|
}
|
|
1868
2286
|
|
|
1869
|
-
answer(scene, ask, yes) {
|
|
2287
|
+
answer(scene, ask, yes, fromChrome = false) {
|
|
1870
2288
|
const net = scene?.multiplayer?.net;
|
|
1871
2289
|
if (!net || !ask) {
|
|
1872
2290
|
return;
|
|
1873
2291
|
}
|
|
2292
|
+
if (fromChrome) {
|
|
2293
|
+
const current = this.liveAsk(scene, ask);
|
|
2294
|
+
if (!current) {
|
|
2295
|
+
this.chrome?.setAsk?.(null);
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
// The same occurrence redrawn (hearts or arrival data changed between
|
|
2299
|
+
// render and tap): the tap answered words no longer up, so it does
|
|
2300
|
+
// nothing and keeps the lease; the next frame shows the current card.
|
|
2301
|
+
if (current.key !== ask.key || current.door !== ask.door) {
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
// The server may take a frame to clear an accepted/declined offer. It
|
|
2305
|
+
// cannot reopen after the local action which consumed this display.
|
|
2306
|
+
this.askSlot.retire(ask);
|
|
2307
|
+
}
|
|
1874
2308
|
if (ask.kind === 'yours') {
|
|
1875
2309
|
const current = this.ask();
|
|
1876
|
-
if (!Hub.deck.yourGames || current?.key !== ask.key || this.trip || Hub.hub.place?.result) {
|
|
2310
|
+
if (!Hub.deck.yourGames || current?.key !== ask.key || current?.door !== ask.door || this.trip || Hub.hub.place?.result) {
|
|
1877
2311
|
return;
|
|
1878
2312
|
}
|
|
1879
2313
|
this.yours.dismiss();
|
|
@@ -1886,7 +2320,7 @@ class HubSystem {
|
|
|
1886
2320
|
// Only the offer that is up: one whose time ran out, or that a later
|
|
1887
2321
|
// return replaced, is answered by nothing.
|
|
1888
2322
|
const again = this.againAsk;
|
|
1889
|
-
if (!Hub.deck.cues || !again || ask.key !== `again:${again.door}:${again.until}`
|
|
2323
|
+
if (!Hub.deck.cues || !again || ask.key !== `again:${again.door}:${again.until}`) {
|
|
1890
2324
|
return;
|
|
1891
2325
|
}
|
|
1892
2326
|
this.againAsk = null;
|
|
@@ -1918,6 +2352,47 @@ class HubSystem {
|
|
|
1918
2352
|
}
|
|
1919
2353
|
}
|
|
1920
2354
|
|
|
2355
|
+
// The card up now, when `ask` (as the chrome drew it) is that occurrence
|
|
2356
|
+
// and its lease still takes a tap; null otherwise.
|
|
2357
|
+
liveAsk(scene, ask) {
|
|
2358
|
+
const now = performance.now();
|
|
2359
|
+
const at = scene?.actorWith?.('Player')?.components?.Transform ?? null;
|
|
2360
|
+
const pads = askPadsAt(scene, at, Hub.hub.hidden);
|
|
2361
|
+
const place = Hub.hub.place;
|
|
2362
|
+
const eligible = !this.trip && place && !place.result && this.pendingEnd === null && !this.talk?.talking?.() && !this.carded &&
|
|
2363
|
+
!this.askInput && !this.menuInput && !this.actionInput && this.decor?.opened() !== true;
|
|
2364
|
+
const current = eligible ? this.ask(now) : null;
|
|
2365
|
+
return askSlotKey(current) === askSlotKey(ask) && this.askSlot.accepts(ask, at, pads, now) ? current : null;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
// The heart on a Your games card: toggled only while that card's lease
|
|
2369
|
+
// takes a tap, and only for the presentation it was drawn with. It leaves
|
|
2370
|
+
// the lease running: Go and Not now stay available until the boundary.
|
|
2371
|
+
heartAsk(scene, ask, door) {
|
|
2372
|
+
const current = this.liveAsk(scene, ask);
|
|
2373
|
+
if (!current) {
|
|
2374
|
+
this.chrome?.setAsk?.(null);
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2377
|
+
if (current.kind !== 'yours' || current.key !== ask.key || current.door !== door) {
|
|
2378
|
+
return;
|
|
2379
|
+
}
|
|
2380
|
+
this.yours?.toggle(door);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
retireExpiredAsk(ask) {
|
|
2384
|
+
if (!ask || !this.askSlot.expired(ask)) {
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
if (ask.kind === 'play' && this.playAsk && ask.key === `play:${this.playAsk.from}:${this.playAsk.door}:${this.playAsk.until}`) {
|
|
2388
|
+
this.playAsk = null;
|
|
2389
|
+
} else if (ask.kind === 'again' && this.againAsk && ask.key === `again:${this.againAsk.door}:${this.againAsk.until}`) {
|
|
2390
|
+
this.againAsk = null;
|
|
2391
|
+
} else if (ask.kind === 'yours') {
|
|
2392
|
+
this.yours?.dismiss();
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
|
|
1921
2396
|
// Cues (v1.23): the friends found already in this layer are told to the
|
|
1922
2397
|
// player ("amy is here") and pointed to, one at a time and never over
|
|
1923
2398
|
// another toast -- the result line of a game just left, or "You're next to
|
|
@@ -2005,12 +2480,17 @@ class HubSystem {
|
|
|
2005
2480
|
});
|
|
2006
2481
|
}
|
|
2007
2482
|
|
|
2008
|
-
// A user Back first dismisses
|
|
2483
|
+
// A user Back first dismisses transient chrome; automatic travel still uses back.
|
|
2009
2484
|
backFromControl(scene) {
|
|
2485
|
+
if (this.chrome?.actionOverflowOpen?.()) {
|
|
2486
|
+
this.chrome.cancelActionOverflow();
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2010
2489
|
if (this.chrome?.menuOpen?.()) {
|
|
2011
2490
|
this.chrome.cancelMenu();
|
|
2012
2491
|
return;
|
|
2013
2492
|
}
|
|
2493
|
+
if (Hub.hub.place?.result) {scene.multiplayer?.net?.send({ k: 'hub-door-quit' });}
|
|
2014
2494
|
this.back(scene);
|
|
2015
2495
|
}
|
|
2016
2496
|
|
|
@@ -2067,14 +2547,37 @@ class HubSystem {
|
|
|
2067
2547
|
const place = Hub.hub.place?.id ?? 'main';
|
|
2068
2548
|
// Another deck's place runs that deck's server: its key keeps the prefix.
|
|
2069
2549
|
const prefix = scene.content?.sessionKeyPrefix ?? '';
|
|
2550
|
+
// A fresh instance is a game's Again, and how the dev serve keys its
|
|
2551
|
+
// places. A town joined publicly or through a door is not left for one:
|
|
2552
|
+
// ghost opens no door from a private instance (no hub pin, no public
|
|
2553
|
+
// shard), so a player sent there was alone with every door shut until a
|
|
2554
|
+
// reload (a QA runner's Back at the town root did it twice). It rejoins
|
|
2555
|
+
// the join this runtime began with, and says who sent it.
|
|
2556
|
+
// The visit a town ended (`hub.end`, a longest visit) is settled here:
|
|
2557
|
+
// the rejoin can be the same session, which `settleEnd` would never
|
|
2558
|
+
// count as leaving it, and the end would send the player Back again.
|
|
2559
|
+
let join;
|
|
2560
|
+
const known = Hub.hub.place ?? this.knownPlace ?? null;
|
|
2561
|
+
if (!known?.result && scene.multiplayer?.target?.mode !== 'named') {
|
|
2562
|
+
console.warn('[hub-door] Back at a town root without a ticket: rejoining the root join', new Error().stack?.split('\n').slice(0, 7).join('\n'));
|
|
2563
|
+
join = per.hubRootJoin ?? { mode: 'public' };
|
|
2564
|
+
this.pendingEnd = null;
|
|
2565
|
+
this.endSession = null;
|
|
2566
|
+
this.endLeaving = null;
|
|
2567
|
+
} else {
|
|
2568
|
+
join = { mode: 'named', key: `${prefix}hub.${place}.${Math.random().toString(36).slice(2, 10)}` };
|
|
2569
|
+
}
|
|
2070
2570
|
this.startTrip(scene, {
|
|
2071
2571
|
scene: this.scenePath,
|
|
2072
|
-
join
|
|
2572
|
+
join,
|
|
2073
2573
|
title: Hub.hub.place?.title ?? '',
|
|
2074
2574
|
exitDoor: null,
|
|
2075
2575
|
arrive: { door: null, party: 1, returning: false },
|
|
2076
2576
|
lost,
|
|
2077
2577
|
}, previousTrip);
|
|
2578
|
+
if (covered && this.trip) {
|
|
2579
|
+
this.trip.startedAt -= OPEN_MS;
|
|
2580
|
+
}
|
|
2078
2581
|
return;
|
|
2079
2582
|
}
|
|
2080
2583
|
this.startTrip(scene, {
|
|
@@ -2101,6 +2604,7 @@ class HubSystem {
|
|
|
2101
2604
|
if (this.trip) {
|
|
2102
2605
|
return;
|
|
2103
2606
|
}
|
|
2607
|
+
this.fpsTelemetry?.leave();
|
|
2104
2608
|
clearShot();
|
|
2105
2609
|
if (Hub.deck.soundscape?.ui === true && target.exitDoor) {
|
|
2106
2610
|
this.soundscape?.cue('door', performance.now());
|
|
@@ -2205,7 +2709,7 @@ class HubSystem {
|
|
|
2205
2709
|
const hubJoin = trip.target.join?.mode === 'hub' && typeof mp.joinState === 'function';
|
|
2206
2710
|
// A hub join's messages wait for its scene: the destination's WORLD
|
|
2207
2711
|
// must place this player in the destination, not the place it left.
|
|
2208
|
-
mp.switchSession(scene, trip.target.join, { quiet: true, hold: hubJoin });
|
|
2712
|
+
mp.switchSession(scene, pongJoin(trip.target.join, Hub.deck.pongTimeoutMs), { quiet: true, hold: hubJoin });
|
|
2209
2713
|
this.helloNet = null;
|
|
2210
2714
|
// A hub join is the host's trip: nothing of the destination is
|
|
2211
2715
|
// mounted until the host has committed it, so a refused join leaves
|
|
@@ -2222,6 +2726,22 @@ class HubSystem {
|
|
|
2222
2726
|
this.setTripCover(1, trip);
|
|
2223
2727
|
return;
|
|
2224
2728
|
}
|
|
2729
|
+
if (trip.phase === 'retrying-door') {
|
|
2730
|
+
this.setTripCover(1, trip);
|
|
2731
|
+
if (now < trip.retryDoorAt) {return;}
|
|
2732
|
+
if (!trip.target.pending) {
|
|
2733
|
+
// The refused nonce is spent. Give it back before acquiring again;
|
|
2734
|
+
// never replay it or add another ticket/depth to this same trip.
|
|
2735
|
+
this.cancelHub();
|
|
2736
|
+
trip.target.pending = this.resolveHub(scene, () => hubGo(trip.target.retryDoor, trip.target.retryOwner));
|
|
2737
|
+
trip.target.pendingFrom = now;
|
|
2738
|
+
}
|
|
2739
|
+
if (!this.contentReady(scene, trip, now)) {return;}
|
|
2740
|
+
mp.switchSession(scene, pongJoin(trip.target.join, Hub.deck.pongTimeoutMs), { quiet: true, hold: true });
|
|
2741
|
+
this.helloNet = null;
|
|
2742
|
+
trip.phase = 'committing';
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2225
2745
|
if (trip.phase === 'committing') {
|
|
2226
2746
|
this.setTripCover(1, trip);
|
|
2227
2747
|
const state = mp.joinState();
|
|
@@ -2232,6 +2752,15 @@ class HubSystem {
|
|
|
2232
2752
|
per.hubDepth = Math.max(0, (per.hubDepth ?? 0) + (trip.target.hubStep ?? 0));
|
|
2233
2753
|
this.mount(scene, trip, now);
|
|
2234
2754
|
} else if (state === 'failed') {
|
|
2755
|
+
const age = now - trip.target.acquiredAt;
|
|
2756
|
+
if (trip.target.retryDoor && !trip.doorRetried && mp.joinFailure?.closeCode === 4404 &&
|
|
2757
|
+
mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <= 5000) {
|
|
2758
|
+
trip.doorRetried = true;
|
|
2759
|
+
trip.retryDoorAt = now + 2500;
|
|
2760
|
+
trip.phase = 'retrying-door';
|
|
2761
|
+
console.log(`[hub-door-retry] ${JSON.stringify({ door: trip.target.retryDoor, reason: 'not_running', attempt: 1, acquiredMs: Math.round(age), delayMs: 2500 })}`);
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2235
2764
|
this.uncommitted(scene, trip, now);
|
|
2236
2765
|
}
|
|
2237
2766
|
return;
|
|
@@ -2329,8 +2858,8 @@ class HubSystem {
|
|
|
2329
2858
|
// back refused as unavailable is asked once more under the cover: ghost
|
|
2330
2859
|
// refuses one while the place's session is between pins, which passes in
|
|
2331
2860
|
// moments. Only then does the door stay shut.
|
|
2332
|
-
if (pending.done && pending.code
|
|
2333
|
-
trip.target.stuck =
|
|
2861
|
+
if (pending.done && joinErrorText(pending.code)) {
|
|
2862
|
+
trip.target.stuck = joinErrorText(pending.code);
|
|
2334
2863
|
} else if (pending.done && pending.error === 'unavailable' && trip.target.retryBack && (trip.target.attempt ?? 0) < 1) {
|
|
2335
2864
|
trip.target.attempt = (trip.target.attempt ?? 0) + 1;
|
|
2336
2865
|
trip.target.pending = trip.target.retryBack();
|
|
@@ -2366,11 +2895,13 @@ class HubSystem {
|
|
|
2366
2895
|
// Acquired and loaded, and still not taken.
|
|
2367
2896
|
this.cancelHub();
|
|
2368
2897
|
}
|
|
2369
|
-
this.
|
|
2898
|
+
if (trip.phase === 'retrying-door') {this.uncommitted(scene, trip, now);}
|
|
2899
|
+
else {this.shutDoor(scene, trip, error, now);}
|
|
2370
2900
|
return false;
|
|
2371
2901
|
}
|
|
2372
2902
|
trip.marks.resolved = now;
|
|
2373
2903
|
if (pending.join) {
|
|
2904
|
+
trip.target.acquiredAt = pending.acquiredAt;
|
|
2374
2905
|
trip.target.join = pending.join;
|
|
2375
2906
|
}
|
|
2376
2907
|
if (pending.stayed) {
|
|
@@ -2448,7 +2979,7 @@ class HubSystem {
|
|
|
2448
2979
|
lostJoin(scene, trip, mp, now) {
|
|
2449
2980
|
const tries = trip.target.lost ?? 0;
|
|
2450
2981
|
console.warn(`[hub-door] the session ${trip.target.deck ?? trip.target.scene} led to closed before placing this player`);
|
|
2451
|
-
if (tries >= LOST_TRIES_MAX || mp.joinError
|
|
2982
|
+
if (tries >= LOST_TRIES_MAX || joinErrorText(mp.joinError)) {
|
|
2452
2983
|
trip.lost = 'the session closed before placing this player';
|
|
2453
2984
|
return false;
|
|
2454
2985
|
}
|
|
@@ -2459,7 +2990,7 @@ class HubSystem {
|
|
|
2459
2990
|
trip.target.join = rejoin;
|
|
2460
2991
|
Hub.clear();
|
|
2461
2992
|
// Held, as the hub join was, until the destination's scene is in.
|
|
2462
|
-
mp.switchSession(scene, rejoin, { quiet: true, hold: trip.marks.sceneLoaded === undefined });
|
|
2993
|
+
mp.switchSession(scene, pongJoin(rejoin, Hub.deck.pongTimeoutMs), { quiet: true, hold: trip.marks.sceneLoaded === undefined });
|
|
2463
2994
|
this.helloNet = null;
|
|
2464
2995
|
trip.loadingFrom = now;
|
|
2465
2996
|
if (trip.target.stuck) {
|
|
@@ -2582,7 +3113,7 @@ class HubSystem {
|
|
|
2582
3113
|
// Armed until the player is out of the ended session (settleEnd): a
|
|
2583
3114
|
// way back that fails is tried again a pause later.
|
|
2584
3115
|
this.pendingEnd = now + END_PAUSE_MS;
|
|
2585
|
-
this.back(scene);
|
|
3116
|
+
this.back(scene, { covered: this.endCovered === true });
|
|
2586
3117
|
}
|
|
2587
3118
|
}
|
|
2588
3119
|
|
|
@@ -2607,7 +3138,7 @@ class HubSystem {
|
|
|
2607
3138
|
if (Hub.deck.soundscape?.ui === true && !this.trip && !Hub.hub.faced) {
|
|
2608
3139
|
this.soundscape?.uiArrival(performance.now());
|
|
2609
3140
|
}
|
|
2610
|
-
scene
|
|
3141
|
+
faceArrivalCamera(scene, Hub.hub.arrivedFacing);
|
|
2611
3142
|
// Under the engine's orbit camera key the character's facing is not
|
|
2612
3143
|
// PI - camAngle: it is asked for.
|
|
2613
3144
|
if (scene.cameraControl === 'orbit') {
|
|
@@ -2708,6 +3239,37 @@ class HubSystem {
|
|
|
2708
3239
|
t.rotationY = base.rotationY + amount * DOOR_SWING_DEG;
|
|
2709
3240
|
}
|
|
2710
3241
|
|
|
3242
|
+
// A phrase still draws its bubble/feed even when it cannot offer a card.
|
|
3243
|
+
offerPlay(scene, local, now, playerId, name, door) {
|
|
3244
|
+
let stranger = false;
|
|
3245
|
+
if (Hub.deck.playCards) {
|
|
3246
|
+
const userId = scene.multiplayer?.net?.userId?.(playerId);
|
|
3247
|
+
const friend = userId && this.friendsAll?.some((f) => String(f.userId) === String(userId));
|
|
3248
|
+
stranger = !friend && !Hub.hub.party.members?.includes(playerId);
|
|
3249
|
+
if (stranger) {
|
|
3250
|
+
// Displayed avatars deliberately lag; use the newest received pose.
|
|
3251
|
+
const pose = scene.multiplayer?.players?.get(playerId)?.samples?.at(-1)?.pose;
|
|
3252
|
+
const lt = local?.components.Transform;
|
|
3253
|
+
if (!pose || !lt || !(Math.hypot(pose[0] - lt.x, pose[2] - lt.z) <= PLAY_NEAR_M)) {
|
|
3254
|
+
return;
|
|
3255
|
+
}
|
|
3256
|
+
// Never replace another live stranger card, including later events
|
|
3257
|
+
// in this frame. Suppressed events spend no cooldown.
|
|
3258
|
+
const current = this.playAsk;
|
|
3259
|
+
const currentCard = current ? { key: `play:${current.from}:${current.door}:${current.until}`, kind: 'play' } : null;
|
|
3260
|
+
if (current?.stranger && (now < current.until || this.askSlot.known(currentCard))) {
|
|
3261
|
+
return;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
const key = Hub.deck.playCards && stranger ? playerId : `${playerId}:${door}`;
|
|
3266
|
+
if ((this.playAsked.get(key) ?? -Infinity) > now - PLAY_ASK_AGAIN_MS) {
|
|
3267
|
+
return;
|
|
3268
|
+
}
|
|
3269
|
+
this.playAsked.set(key, now);
|
|
3270
|
+
this.playAsk = { from: playerId, name, door, until: now + PLAY_ASK_MS, ...(Hub.deck.playCards ? { stranger } : {}) };
|
|
3271
|
+
}
|
|
3272
|
+
|
|
2711
3273
|
drawChrome(scene, local, now) {
|
|
2712
3274
|
const chrome = this.chrome;
|
|
2713
3275
|
const place = Hub.hub.place;
|
|
@@ -2719,27 +3281,29 @@ class HubSystem {
|
|
|
2719
3281
|
const inGame = Boolean(place?.result);
|
|
2720
3282
|
// Away in a classic deck, the cover is down and Back is the only control.
|
|
2721
3283
|
const away = this.trip?.phase === 'away';
|
|
3284
|
+
const hostTrail = scene.persistent.hubDepth > 0;
|
|
2722
3285
|
chrome.showBack(
|
|
2723
|
-
//
|
|
2724
|
-
//
|
|
2725
|
-
(away || (idle && this.pendingEnd === null)) &&
|
|
2726
|
-
ticket?.title ?? 'Again',
|
|
3286
|
+
// Old Android landscape hosts draw Exit deck, so keep a way back into
|
|
3287
|
+
// town. Hosts advertising their landscape Back retain sole ownership.
|
|
3288
|
+
(away || (idle && this.pendingEnd === null)) && (hostTrail ? place !== null && kitBackNeeded() : inGame || Boolean(ticket)),
|
|
3289
|
+
ticket?.title ?? (hostTrail && kitBackNeeded() ? 'Back' : 'Again'),
|
|
2727
3290
|
);
|
|
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
3291
|
const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking() && !this.carded;
|
|
2730
3292
|
const town = free && !inGame;
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
3293
|
+
const weakest = this.weakestTier?.active && this.weakestTier.profile === 'weakest';
|
|
3294
|
+
if (!weakest) {this.drawPanelControls(scene, now, place, idle, inGame, free, town);}
|
|
3295
|
+
else if (Hub.deck.yourGames) {this.yourGames().frame(town, Hub.hub.yours, now);}
|
|
3296
|
+
const askAt = local?.components?.Transform ?? null;
|
|
3297
|
+
const askPads = askPadsAt(scene, askAt, Hub.hub.hidden);
|
|
3298
|
+
this.askSlot.frame(askAt, askPads, now);
|
|
3299
|
+
// Prompt and editor shields sit above the shared question card, and a
|
|
3300
|
+
// hidden or suspended page draws none. Do not start a lease behind
|
|
3301
|
+
// either, but keep aging a lease that was already shown.
|
|
3302
|
+
const askVisible = town && !this.askInput && !this.menuInput && !this.actionInput && this.decor?.opened() !== true &&
|
|
3303
|
+
chrome.askShowable?.() !== false;
|
|
3304
|
+
const ask = askVisible ? this.ask(now) : null;
|
|
3305
|
+
chrome.setAsk?.(askVisible ? this.askSlot.display(ask, askAt, askPads, now) : null);
|
|
3306
|
+
this.retireExpiredAsk(ask);
|
|
2743
3307
|
this.startBeside(scene, local, town, now);
|
|
2744
3308
|
// A friend or party member went through a door: say so, and offer to follow.
|
|
2745
3309
|
// Kept until the question can be put (not while talking to an NPC): the
|
|
@@ -2782,17 +3346,7 @@ class HubSystem {
|
|
|
2782
3346
|
selfId,
|
|
2783
3347
|
(playerId) => net?.others?.().get(playerId) ?? null,
|
|
2784
3348
|
(playerId) => this.together.ping(playerId, now),
|
|
2785
|
-
|
|
2786
|
-
// Once from a player for a door: saying it again neither keeps the
|
|
2787
|
-
// card up nor brings it back after Not now, until the pause has passed.
|
|
2788
|
-
(playerId, name, door) => {
|
|
2789
|
-
const key = `${playerId}:${door}`;
|
|
2790
|
-
if ((this.playAsked.get(key) ?? -Infinity) > now - PLAY_ASK_AGAIN_MS) {
|
|
2791
|
-
return;
|
|
2792
|
-
}
|
|
2793
|
-
this.playAsked.set(key, now);
|
|
2794
|
-
this.playAsk = { from: playerId, name, door, until: now + PLAY_ASK_MS };
|
|
2795
|
-
},
|
|
3349
|
+
(playerId, name, door) => this.offerPlay(scene, local, now, playerId, name, door),
|
|
2796
3350
|
);
|
|
2797
3351
|
// Cues: someone new in the roster may be one this player can chat with,
|
|
2798
3352
|
// so the host is asked soon, not at the end of its idle wait. In a town
|
|
@@ -2828,6 +3382,7 @@ class HubSystem {
|
|
|
2828
3382
|
continue;
|
|
2829
3383
|
}
|
|
2830
3384
|
const from = message.mine ? { playerId: selfId, username: 'You' } : byUser.get(String(message.fromUserId));
|
|
3385
|
+
if (Hub.deck.quality && !message.mine && from?.playerId) {noteQualityInteraction(scene, from.playerId, now);}
|
|
2831
3386
|
this.say.chat(now, from?.playerId ?? null, from?.username ?? message.fromUsername ?? 'Someone', message, CHAT_BUBBLE_MS);
|
|
2832
3387
|
}
|
|
2833
3388
|
const reach = (this.chat.peers ?? []).map((userId) => byUser.get(userId)?.username).filter(Boolean);
|
|
@@ -2852,42 +3407,74 @@ class HubSystem {
|
|
|
2852
3407
|
chatPart.placeholder = chatPart.input ? CHAT_HINT.on : CHAT_HINT.off;
|
|
2853
3408
|
chatPart.label = chatPart.input ? CHAT_HINT.label : CHAT_HINT.why;
|
|
2854
3409
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
}
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
3410
|
+
let panels = true;
|
|
3411
|
+
if (weakest) {
|
|
3412
|
+
// Prompts settle before the decision; panels still precede world placement.
|
|
3413
|
+
this.drawNearPrompt(scene, local, town);
|
|
3414
|
+
this.hudRate ??= makeHudRate();
|
|
3415
|
+
// A new door offer must replace its Go buttons at once: a stale one
|
|
3416
|
+
// still jumps. HUD and toast copy can confirm an earlier input, so their
|
|
3417
|
+
// text wakes the pass too; only the timer's ticking waits.
|
|
3418
|
+
if (this.hudDoors !== Hub.hub.doors) {
|
|
3419
|
+
this.hudDoors = Hub.hub.doors;
|
|
3420
|
+
this.hudDoorsSeen = (this.hudDoorsSeen ?? 0) + 1;
|
|
3421
|
+
}
|
|
3422
|
+
const spec = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
3423
|
+
const leaving = this.leavingToast && now < this.leavingToast.until && this.toast === this.leavingToast.previousToast;
|
|
3424
|
+
const toastText = leaving ? this.leavingToast.text : now < this.toast.until ? this.toast.text : '';
|
|
3425
|
+
panels = this.hudRate.frame(true, JSON.stringify([chrome.hudPromptSignature?.(), Hub.hub.prompts,
|
|
3426
|
+
place?.id, this.trip?.phase, this.pendingEnd !== null, this.carded, this.decor?.opened() === true,
|
|
3427
|
+
Boolean(this.askInput), Boolean(this.menuInput), Boolean(this.actionInput),
|
|
3428
|
+
this.hudDoorsSeen, Hub.hub.party.members?.length ?? 0, spec ? { ...spec, timer: undefined } : null,
|
|
3429
|
+
toastText, joinErrorText(scene.multiplayer?.joinError)]));
|
|
3430
|
+
if (panels) {this.drawPanelControls(scene, now, place, idle, inGame, free, town, false);}
|
|
3431
|
+
} else {
|
|
3432
|
+
this.hudRate?.frame(false);
|
|
2871
3433
|
}
|
|
2872
|
-
|
|
2873
|
-
const
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
} else if (spec?.timer?.until !== undefined) {
|
|
2878
|
-
timer = Math.max(0, (spec.timer.until - Hub.simNow()) / 1000);
|
|
3434
|
+
if (panels) {chrome.setSay?.(free ? { reactions: REACTIONS, phrases: this.say.phrases(), chat: chatPart } : null);}
|
|
3435
|
+
const moderation = chatModerationEnabled(scene);
|
|
3436
|
+
if (moderation !== (this.chatModeration === true)) {
|
|
3437
|
+
chrome.setChatModeration?.(moderation);
|
|
3438
|
+
this.chatModeration = moderation;
|
|
2879
3439
|
}
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
3440
|
+
if (panels) {chrome.setFeed?.(idle && place !== null && !this.carded ? this.say.feed() : []);}
|
|
3441
|
+
if (!weakest) {this.drawNearPrompt(scene, local, town);}
|
|
3442
|
+
const joinText = joinErrorText(scene.multiplayer?.joinError);
|
|
3443
|
+
if (joinText) {
|
|
3444
|
+
this.toast = { text: joinText, until: now + TOAST_MS };
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
if (panels) {
|
|
3448
|
+
const spec = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
3449
|
+
let timer = null;
|
|
3450
|
+
if (spec?.timer?.since !== undefined) {
|
|
3451
|
+
timer = Math.max(0, (Hub.simNow() - spec.timer.since) / 1000);
|
|
3452
|
+
} else if (spec?.timer?.until !== undefined) {
|
|
3453
|
+
timer = Math.max(0, (spec.timer.until - Hub.simNow()) / 1000);
|
|
3454
|
+
}
|
|
3455
|
+
// A place that asks (`hud.clear`, v1.26) has its HUD kept short and its
|
|
3456
|
+
// labels kept out from under it; any other is drawn as it always was.
|
|
3457
|
+
if (place?.hud?.clear === true || this.hudClear) {
|
|
3458
|
+
this.hudClear = place?.hud?.clear === true;
|
|
3459
|
+
chrome.setHudClear?.(this.hudClear);
|
|
3460
|
+
}
|
|
3461
|
+
chrome.setHud(idle || this.trip?.phase === 'revealing' ? spec : null, timer);
|
|
2885
3462
|
}
|
|
2886
|
-
chrome.setHud(idle || this.trip?.phase === 'revealing' ? spec : null, timer);
|
|
2887
3463
|
|
|
2888
3464
|
const cam = scene.three?.camera;
|
|
2889
3465
|
const view = { w: window.innerWidth, h: window.innerHeight };
|
|
3466
|
+
if (worldLabelFocus(Hub.deck.labels, inGame, hostTrail || Boolean(ticket))) {
|
|
3467
|
+
const canvas = this.frameCanvas ?? scene.three?.renderer?.domElement?.getBoundingClientRect?.();
|
|
3468
|
+
if (canvas?.width > 0 && canvas.height > 0) {view.world = canvas;}
|
|
3469
|
+
}
|
|
3470
|
+
chrome.setWorldViewport?.(view.world ?? null);
|
|
2890
3471
|
const labels = [];
|
|
3472
|
+
const padOccupancy = scene.data?.engine?.hubPadOccupancy === true;
|
|
3473
|
+
const crowdNames = scene.data?.engine?.hubCrowdNames === true;
|
|
3474
|
+
if (crowdNames && cam?.parent === null && cam.matrixWorldAutoUpdate === true) {
|
|
3475
|
+
cam.updateMatrixWorld();
|
|
3476
|
+
}
|
|
3477
|
+
let worldLabelCount = 0;
|
|
2891
3478
|
// This player's goals: scene actors a `goal` label points at.
|
|
2892
3479
|
const goals = [];
|
|
2893
3480
|
if (cam && idle) {
|
|
@@ -2898,7 +3485,7 @@ class HubSystem {
|
|
|
2898
3485
|
if (id === talkingWith && label.style === 'speech') {
|
|
2899
3486
|
continue;
|
|
2900
3487
|
}
|
|
2901
|
-
const at = scene.getActor(id)?.components.Transform;
|
|
3488
|
+
const at = goalAt(label, scene.getActor(id)?.components.Transform);
|
|
2902
3489
|
if (at && label.style === 'goal') {
|
|
2903
3490
|
// Where the place is sending this player (v1.13): a pointer, not a label.
|
|
2904
3491
|
goals.push({ id, at, label });
|
|
@@ -2911,39 +3498,83 @@ class HubSystem {
|
|
|
2911
3498
|
}
|
|
2912
3499
|
// In a town only what the player stands by is labelled (`attention.js`).
|
|
2913
3500
|
const lt = local?.components.Transform;
|
|
3501
|
+
let activePad = null;
|
|
3502
|
+
if (padOccupancy) {
|
|
3503
|
+
const active = placed.find(({ id, label }) => Object.hasOwn(Hub.hub.labelsMe, id) && scene.getActor(id)?.components.HubPad && occupancyText(label.text));
|
|
3504
|
+
if (active) {
|
|
3505
|
+
activePad = active.id;
|
|
3506
|
+
this.attention.plate = active.id;
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
2914
3509
|
const shown = place && !inGame && lt
|
|
2915
3510
|
? attend(
|
|
2916
3511
|
this.attention,
|
|
2917
3512
|
placed
|
|
2918
3513
|
.filter(({ always }) => !always)
|
|
2919
|
-
.map(({ id, at, label }) => ({ id, d: Math.hypot(at.x - lt.x, at.z - lt.z), speech: label.style === 'speech' })),
|
|
3514
|
+
.map(({ id, at, label }) => ({ id, d: id === activePad ? 0 : Math.hypot(at.x - lt.x, at.z - lt.z), speech: label.style === 'speech' })),
|
|
2920
3515
|
now,
|
|
2921
3516
|
)
|
|
2922
3517
|
: null;
|
|
2923
|
-
if (
|
|
3518
|
+
if (lt && worldLabelFocus(Hub.deck.labels, inGame, hostTrail || Boolean(ticket)) && chrome.measureLabel) {
|
|
3519
|
+
labels.push(...this.nearLabels(scene, placed, lt, cam, view, now, padOccupancy, true));
|
|
3520
|
+
} else if (shown && (Hub.deck.labels || padOccupancy) && chrome.measureLabel) {
|
|
2924
3521
|
// `hub.labels: "near"` (v1.43): signs near the player only, no two
|
|
2925
3522
|
// world labels overlapping, three at most (`labelsNear.js`).
|
|
2926
|
-
labels.push(...this.nearLabels(scene, placed, lt, cam, view, now));
|
|
3523
|
+
labels.push(...this.nearLabels(scene, placed, lt, cam, view, now, padOccupancy));
|
|
2927
3524
|
} else {
|
|
2928
3525
|
for (const { id, at, label, always } of placed) {
|
|
2929
3526
|
const opacity = shown && !always ? shown.get(id) : 1;
|
|
2930
3527
|
const screen = opacity ? project(cam, at.x, at.y + 1.6, at.z, view) : null;
|
|
2931
3528
|
if (screen) {
|
|
2932
|
-
|
|
3529
|
+
if (padOccupancy && chrome.measureLabel) {
|
|
3530
|
+
const speech = label.style === 'speech';
|
|
3531
|
+
const npc = label.npc === true;
|
|
3532
|
+
const pad = Boolean(scene.getActor(id)?.components.HubPad);
|
|
3533
|
+
const box = labelBox(screen.x, screen.y, chrome.measureLabel(label.text, speech, npc, pad), npc, view, chrome.hudClearBox?.() ?? null, chrome.hudPromptBox?.() ?? null);
|
|
3534
|
+
if (!box) {continue;}
|
|
3535
|
+
const item = chromeItem(id, label.text, speech, npc, box, opacity);
|
|
3536
|
+
if (Hub.deck.quality) {item.actorId = id;}
|
|
3537
|
+
if (pad) {item.padOccupancy = true;}
|
|
3538
|
+
labels.push(item);
|
|
3539
|
+
} else {
|
|
3540
|
+
labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity });
|
|
3541
|
+
}
|
|
2933
3542
|
}
|
|
2934
3543
|
}
|
|
2935
3544
|
}
|
|
3545
|
+
if (Hub.deck.quality) {
|
|
3546
|
+
const quality = lowQuality(scene);
|
|
3547
|
+
if (quality && lt) {
|
|
3548
|
+
const party = new Set((Hub.hub.party.members ?? []).map((id) => scene.multiplayer?.avatars?.actors?.get(id)));
|
|
3549
|
+
// Party world labels bypass numerical caps, including the ordinary
|
|
3550
|
+
// near-label slots. Door labels still go through their 12/14 m rule.
|
|
3551
|
+
for (const { id, at, label } of placed) {
|
|
3552
|
+
if (!party.has(id) || labels.some((item) => (item.actorId ?? item.id) === id)) {continue;}
|
|
3553
|
+
const screen = project(cam, at.x, at.y + 1.6, at.z, view);
|
|
3554
|
+
if (screen) {labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity: 1 });}
|
|
3555
|
+
}
|
|
3556
|
+
const capped = capWorldLabels(labels, placed, lt, quality.labels, party);
|
|
3557
|
+
labels.splice(0, labels.length, ...capped);
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
worldLabelCount = labels.length;
|
|
2936
3561
|
}
|
|
2937
|
-
const
|
|
3562
|
+
const pointerView = view.world ? { w: view.world.width, h: view.world.height } : view;
|
|
3563
|
+
const pointers = cam && idle && place && !inGame && this.pendingEnd === null ? this.together.pointers(scene, local, cam, pointerView) : [];
|
|
2938
3564
|
const me = local?.components.Transform;
|
|
2939
3565
|
if (cam && me && this.pendingEnd === null) {
|
|
2940
3566
|
// The nearest drawable goals, each with how far it is.
|
|
2941
3567
|
const near = goals.map((g) => ({ ...g, d: Math.hypot(g.at.x - me.x, g.at.z - me.z) }));
|
|
2942
3568
|
pointers.push(...goalPointers(near, GOALS_MAX, (g) =>
|
|
2943
|
-
pointerAt(cam,
|
|
3569
|
+
pointerAt(cam, pointerView, { x: g.at.x, y: g.at.y + 1.6, z: g.at.z }, `goal:${g.id}`, goalText(g.label, g.d, GOAL_NEAR_M)),
|
|
2944
3570
|
));
|
|
2945
3571
|
}
|
|
2946
|
-
|
|
3572
|
+
const invitePointer = cam && idle && place?.invite === true && !inGame && this.pendingEnd === null ? this.invites?.pointer(scene) : null;
|
|
3573
|
+
if (invitePointer) {
|
|
3574
|
+
const { id, at } = invitePointer;
|
|
3575
|
+
pointers.unshift(pointerAt(cam, pointerView, { x: at.x, y: at.y + 1.9, z: at.z }, `invite:${id}`, 'Your friend'));
|
|
3576
|
+
}
|
|
3577
|
+
chrome.setPointers?.(pointers.map((point) => offsetWorldPoint(point, view)));
|
|
2947
3578
|
if (cam && idle) {
|
|
2948
3579
|
labels.push(...this.markItems(scene, local, cam, view));
|
|
2949
3580
|
labels.push(...this.idle.labels(scene, local, cam, view, project));
|
|
@@ -2952,10 +3583,9 @@ class HubSystem {
|
|
|
2952
3583
|
if (Hub.hub.place?.companion === true && cam && idle) {
|
|
2953
3584
|
labels.push(...(this.companion?.labels(cam, view, project, now) ?? []));
|
|
2954
3585
|
}
|
|
2955
|
-
chrome.setLabels(labels);
|
|
3586
|
+
if (!padOccupancy && !crowdNames) {chrome.setLabels(labels);}
|
|
2956
3587
|
if (place?.companionChat) {
|
|
2957
3588
|
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
3589
|
chrome.setCompanionBadge?.(Boolean(canTalk && Hub.hub.companion?.c && place.companion === true && local), place.companionChat.name, () => this.talk.openCompanion(scene));
|
|
2960
3590
|
this.companionTalkDrawn = true;
|
|
2961
3591
|
chrome.setCompanionTalk?.(canTalk ? this.companion?.screen(cam, view, project) : null, place.companionChat.name, () => {
|
|
@@ -2964,7 +3594,6 @@ class HubSystem {
|
|
|
2964
3594
|
});
|
|
2965
3595
|
} else if (this.companionTalkDrawn) {
|
|
2966
3596
|
chrome.setCompanionBadge?.(false);
|
|
2967
|
-
chrome.layoutCompanion?.(null);
|
|
2968
3597
|
chrome.setCompanionTalk(null);
|
|
2969
3598
|
delete this.companionTalkDrawn;
|
|
2970
3599
|
}
|
|
@@ -2975,12 +3604,49 @@ class HubSystem {
|
|
|
2975
3604
|
const r = scene.persistent.hubResult;
|
|
2976
3605
|
const showRibbon = !inGame && idle && r && Date.now() - r.at < RIBBON_MS && lt && cam;
|
|
2977
3606
|
chrome.setRibbon(showRibbon ? project(cam, lt.x, lt.y + 1.7, lt.z, view) : null, r ? `🏅 ${resultLine(r)}` : '');
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3607
|
+
if (panels) {
|
|
3608
|
+
const leaving = this.leavingToast && now < this.leavingToast.until && this.toast === this.leavingToast.previousToast;
|
|
3609
|
+
const toast = leaving ? this.leavingToast : this.toast;
|
|
3610
|
+
if (leaving) {
|
|
3611
|
+
chrome.setToast(toast.text, { wrap: true });
|
|
3612
|
+
} else {
|
|
3613
|
+
chrome.setToast(now < toast.until ? toast.text : '');
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
const index = Avatar.current(scene);
|
|
3617
|
+
const model = local?.components.Model;
|
|
3618
|
+
const scale = Math.abs(model?.scale ?? 1);
|
|
3619
|
+
const height = Avatar.top(index, Avatar.drawn(scene.files, index, Avatar.style())) * scale + 0.5;
|
|
3620
|
+
// The avatar rig is drawn at Model.yOffset relative to the collider
|
|
3621
|
+
// centre (the stock rig uses -0.7), not with its feet at Transform.y.
|
|
3622
|
+
const yOffset = model ? model.yOffset ?? 0 : -(local?.components.Shape?.height ?? 1.4) / 2;
|
|
3623
|
+
const own = cam && lt ? bodyBox(lt, height, Math.max(0.65 * scale, local?.components.Player?.radius ?? 0.35), (x, y, z) => project(cam, x, y, z, view), yOffset) : null;
|
|
3624
|
+
chrome.setWorldAvatar?.(own);
|
|
3625
|
+
if (padOccupancy || crowdNames) {
|
|
3626
|
+
// Cabinet/ribbon/pointers must already occupy their final HUD-cleared
|
|
3627
|
+
// boxes before the pad pass reserves them. Boxed labels move no later.
|
|
3628
|
+
if (this.hudClear) {chrome.flushHudClear?.();}
|
|
3629
|
+
const controls = chrome.padOccupancyControls?.() ?? [];
|
|
3630
|
+
controls.push({ left: 0, right: 64, top: 0, bottom: 56 });
|
|
3631
|
+
const lock = scene.three?.renderer?.domElement?.parentElement?.querySelector?.('button[aria-label^="Shift lock"]');
|
|
3632
|
+
if (lock && lock.style.display !== 'none') {
|
|
3633
|
+
const rect = chrome.layoutGeometry?.()?.rect?.(lock);
|
|
3634
|
+
if (rect?.width && rect.height) {controls.push(rect);}
|
|
3635
|
+
}
|
|
3636
|
+
const world = padOccupancy
|
|
3637
|
+
? own ? placeLabels(labels.slice(0, worldLabelCount), own, controls, view, (...args) => chrome.measureLabel(...args), now - Hub.hub.lastTAt > 2000) : []
|
|
3638
|
+
: labels.slice(0, worldLabelCount);
|
|
3639
|
+
const finalLabels = [...world, ...labels.slice(worldLabelCount)];
|
|
3640
|
+
// Keep E's one summary node for its late update. Its setter removes the
|
|
3641
|
+
// node in the same frame when no summary remains; OFF takes the legacy
|
|
3642
|
+
// one-argument path and removes it here.
|
|
3643
|
+
chrome.setLabels(finalLabels, crowdNames);
|
|
3644
|
+
if (crowdNames) {
|
|
3645
|
+
// The late system runs after multiplayer has put every tag at its
|
|
3646
|
+
// final pose. It reuses this one own-body/control pass and the final
|
|
3647
|
+
// DOM label boxes; it never projects the local body a second time.
|
|
3648
|
+
this.crowdFrame = { scene, data: scene.data, net: scene.multiplayer?.net, camera: cam, local: lt, own, controls, view, labels: finalLabels };
|
|
3649
|
+
}
|
|
2984
3650
|
}
|
|
2985
3651
|
// A clear HUD (v1.26): everything drawn above is measured, then moved
|
|
2986
3652
|
// out from under it, once for the frame. Never said in any other place.
|
|
@@ -2997,6 +3663,83 @@ class HubSystem {
|
|
|
2997
3663
|
if (Hub.deck.stuck) {
|
|
2998
3664
|
this.offerUnstick(scene, local, town, now);
|
|
2999
3665
|
}
|
|
3666
|
+
// Optional pad readability, after the chip: nothing above makes way for
|
|
3667
|
+
// the caption, which takes every final rect this frame (the chip's too).
|
|
3668
|
+
if (padCuesEnabled(scene.data?.engine) || this.padReadability) {
|
|
3669
|
+
this.drawPadReadability(scene, local);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
|
|
3673
|
+
drawPanelControls(scene, now, place, idle, inGame, free, town, frameYours = true) {
|
|
3674
|
+
const chrome = this.chrome;
|
|
3675
|
+
const inviteNet = scene.multiplayer?.net;
|
|
3676
|
+
// A guest is an over-13 player like any other: the host's canInvite
|
|
3677
|
+
// answer alone decides the rail.
|
|
3678
|
+
const inviteRail = scene.data?.engine?.hubInviteRail === true && !inGame && place?.invite === true &&
|
|
3679
|
+
this.invites?.canInvite(inviteNet, castleSdk.User) === true;
|
|
3680
|
+
const pickerFree = idle && place !== null && !this.talk.talking() && !this.carded;
|
|
3681
|
+
chrome.showPicker(pickerFree && !inGame, Avatar.current(scene), { available: Avatar.colorsAvailable(), style: Avatar.style(), color: Avatar.currentColor(scene), files: scene.files, model: Avatar.colorsAvailable() && Avatar.style() === 'toon' ? Avatar.model(scene.files, Avatar.current(scene), 'toon') : null }, ...(inviteRail ? [{
|
|
3682
|
+
onPick: () => {
|
|
3683
|
+
// A stale menu cannot mint after a scene/connection change or a trip.
|
|
3684
|
+
if (this.scene !== scene || scene.multiplayer?.net !== inviteNet || this.trip || this.pendingEnd !== null ||
|
|
3685
|
+
scene.data?.engine?.hubInviteRail !== true || Hub.hub.place !== place || Boolean(place.result) || this.talk.talking() || this.carded ||
|
|
3686
|
+
this.invites?.canInvite(inviteNet, castleSdk.User) !== true) {return;}
|
|
3687
|
+
this.invites?.open(true);
|
|
3688
|
+
},
|
|
3689
|
+
}] : []));
|
|
3690
|
+
// "Stuck?" (v1.33), only in a deck with `hub.stuck`, and there only in a
|
|
3691
|
+
// place that says it takes it (a town): a row over the Doors list.
|
|
3692
|
+
const stuckRow = Hub.deck.stuck && town && Hub.hub.stuck ? { where: Hub.hub.stuck.hook ? stuckWhere(null, true) : stuckWhere(Hub.hub.stuck.to), onPick: () => this.unstick(this.scene) } : null;
|
|
3693
|
+
let yours = null;
|
|
3694
|
+
if (Hub.deck.yourGames) {
|
|
3695
|
+
const controller = this.yourGames();
|
|
3696
|
+
if (frameYours) {controller.frame(town, Hub.hub.yours, now);}
|
|
3697
|
+
yours = { rows: controller.rows(Hub.hub.yours, Hub.hub.doors), ...controller.controls() };
|
|
3698
|
+
}
|
|
3699
|
+
chrome.setDoors?.(town ? Hub.hub.doors : null, Hub.hub.party.members?.length ? 'Go together' : 'Go', stuckRow, yours);
|
|
3700
|
+
chrome.setPeople?.(free ? this.people(scene, inGame) : null, town ? this.together.partyLine() : null);
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3703
|
+
drawNearPrompt(scene, local, town) {
|
|
3704
|
+
const chrome = this.chrome;
|
|
3705
|
+
// Standing still beside someone: a small button invites them.
|
|
3706
|
+
const beside = town && !Hub.hub.party.invite && local ? this.together.beside(scene, local) : null;
|
|
3707
|
+
chrome.nearPrompt?.(
|
|
3708
|
+
beside ? `${beside.sent ? 'Invited' : '+ Party'} · ${beside.username ?? 'this player'}` : null,
|
|
3709
|
+
() => {
|
|
3710
|
+
if (!beside.sent) {
|
|
3711
|
+
this.together.invited(beside.playerId);
|
|
3712
|
+
this.join(scene, beside, 'invite');
|
|
3713
|
+
}
|
|
3714
|
+
},
|
|
3715
|
+
);
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
clearPadReadability() {
|
|
3719
|
+
this.padReadability?.dispose();
|
|
3720
|
+
delete this.padReadability;
|
|
3721
|
+
delete this.padReadabilityScope;
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
drawPadReadability(scene, local) {
|
|
3725
|
+
const engine = scene.data?.engine;
|
|
3726
|
+
if (!padCuesEnabled(engine) || !Hub.hub.place || !scene.three?.scene) {
|
|
3727
|
+
this.clearPadReadability();
|
|
3728
|
+
return;
|
|
3729
|
+
}
|
|
3730
|
+
const scope = this.padReadabilityScope;
|
|
3731
|
+
if (!scope || scope.data !== scene.data || scope.place !== Hub.hub.place.id ||
|
|
3732
|
+
scope.context !== engine.hubPadContext || scope.ring !== engine.hubPadRing || scope.spawn !== engine.hubSpawnRing) {
|
|
3733
|
+
this.clearPadReadability();
|
|
3734
|
+
this.padReadability = makePadReadability(engine, {
|
|
3735
|
+
world: scene.three.scene, chrome: this.chrome,
|
|
3736
|
+
arrival: engine.hubSpawnRing === true ? readPadArrival(scene, Hub.hub.place, Hub.localArrival.for(Hub.hub.place.id)) : null,
|
|
3737
|
+
});
|
|
3738
|
+
this.padReadabilityScope = { data: scene.data, place: Hub.hub.place.id,
|
|
3739
|
+
context: engine.hubPadContext, ring: engine.hubPadRing, spawn: engine.hubSpawnRing };
|
|
3740
|
+
}
|
|
3741
|
+
this.padReadability.frame(scene.actors, Hub.hub.hidden, local?.components.Transform, Boolean(this.trip),
|
|
3742
|
+
this.carded || this.decor?.opened() === true);
|
|
3000
3743
|
}
|
|
3001
3744
|
|
|
3002
3745
|
// A town's world labels under `hub.labels: "near"` (v1.43): the plate and
|
|
@@ -3015,11 +3758,13 @@ class HubSystem {
|
|
|
3015
3758
|
// label exactly there and moves it no more. A label whose style changes
|
|
3016
3759
|
// gets a node of its own (the chrome styles a node once), so the node drawn
|
|
3017
3760
|
// is always one measured as it is styled.
|
|
3018
|
-
nearLabels(scene, placed, lt, cam, view, now) {
|
|
3761
|
+
nearLabels(scene, placed, lt, cam, view, now, padOccupancy = false, defaults = false) {
|
|
3019
3762
|
const chrome = this.chrome;
|
|
3020
3763
|
const mine = Hub.hub.labelsMe;
|
|
3021
3764
|
const state = nearFor((this.nearHeld ??= {}), { scene: sceneKeyOf(scene), data: scene.data, net: scene.multiplayer?.net ?? null, place: Hub.hub.place });
|
|
3022
3765
|
const hud = chrome.hudClearBox?.() ?? null;
|
|
3766
|
+
const prompt = chrome.hudPromptBox?.() ?? null;
|
|
3767
|
+
const candidates = nearCandidates((this.nearCandidates ??= {}), placed, lt, now, state, defaults);
|
|
3023
3768
|
const items = [];
|
|
3024
3769
|
const drawn = new Map();
|
|
3025
3770
|
for (const { id, at, label, always } of placed) {
|
|
@@ -3027,19 +3772,29 @@ class HubSystem {
|
|
|
3027
3772
|
const kind = always ? 'sign' : speech ? 'speech' : 'plate';
|
|
3028
3773
|
const pick = !always && id === (speech ? this.attention.speech : this.attention.plate);
|
|
3029
3774
|
// A plate or a line the attention rule passed over: only one still fading.
|
|
3030
|
-
if (!always && !pick && !state.alpha.has(id)) {
|
|
3775
|
+
if (!defaults && !always && !pick && !state.alpha.has(id)) {
|
|
3031
3776
|
continue;
|
|
3032
3777
|
}
|
|
3033
3778
|
const npc = label.npc === true;
|
|
3034
|
-
const
|
|
3035
|
-
const
|
|
3036
|
-
|
|
3037
|
-
|
|
3779
|
+
const pad = padOccupancy && Boolean(scene.getActor(id)?.components.HubPad);
|
|
3780
|
+
const screen = candidates.has(id) ? project(cam, at.x, at.y + 1.6, at.z, view) : null;
|
|
3781
|
+
const box = screen ? labelBox(screen.x, screen.y, chrome.measureLabel(label.text, speech, npc, pad), npc, view, hud, prompt) : null;
|
|
3782
|
+
items.push({ id, kind, pick, d: candidates.has(id) ? Math.hypot(at.x - lt.x, at.z - lt.z) : Infinity, mine: Object.hasOwn(mine, id), box });
|
|
3783
|
+
drawn.set(id, { text: label.text, speech, npc, box, pad });
|
|
3038
3784
|
}
|
|
3039
3785
|
const out = [];
|
|
3040
|
-
for (const [id, opacity] of near(state, items, view, now)) {
|
|
3786
|
+
for (const [id, opacity] of (defaults ? relevantLabels(state, items, view, now) : near(state, items, view, now))) {
|
|
3041
3787
|
const d = drawn.get(id);
|
|
3042
|
-
|
|
3788
|
+
if (!d?.box) {continue;}
|
|
3789
|
+
const item = chromeItem(id, d.text, d.speech, d.npc, d.box, opacity);
|
|
3790
|
+
if (Hub.deck.quality) {
|
|
3791
|
+
item.actorId = id;
|
|
3792
|
+
// Admission by the near-label rule grants the exemption, regardless
|
|
3793
|
+
// of whether a door, pad or linked actor carries the caption.
|
|
3794
|
+
item.qualityNear = true;
|
|
3795
|
+
}
|
|
3796
|
+
if (d.pad) {item.padOccupancy = true;}
|
|
3797
|
+
out.push(item);
|
|
3043
3798
|
}
|
|
3044
3799
|
return out;
|
|
3045
3800
|
}
|
|
@@ -3110,6 +3865,23 @@ class HubSystem {
|
|
|
3110
3865
|
}
|
|
3111
3866
|
|
|
3112
3867
|
measure(scene, mp, now) {
|
|
3868
|
+
const net = mp?.net;
|
|
3869
|
+
const config = fpsTelemetryFor(net);
|
|
3870
|
+
if (this.fpsTelemetry && (this.fpsNet !== net || !config)) {
|
|
3871
|
+
this.fpsTelemetry.dispose();
|
|
3872
|
+
this.fpsTelemetry = null;
|
|
3873
|
+
this.fpsNet = null;
|
|
3874
|
+
}
|
|
3875
|
+
if (config && !this.trip && this.scenePath === config.scene) {
|
|
3876
|
+
if (!this.fpsTelemetry) {
|
|
3877
|
+
// Bind departures to their original transport even after a scene swap.
|
|
3878
|
+
this.fpsNet = net;
|
|
3879
|
+
this.fpsTelemetry = makeFpsTelemetry({ send: (data) => net.send(data) });
|
|
3880
|
+
}
|
|
3881
|
+
const tier = this.fpsTier ?? 0;
|
|
3882
|
+
this.fpsTelemetry.frame(now, { scene: this.scenePath, tier, avatars: Math.min(255, (mp.avatars?.actors?.size ?? 0) + 1) });
|
|
3883
|
+
}
|
|
3884
|
+
else {this.fpsTelemetry?.pause();}
|
|
3113
3885
|
if (!this.stats) {
|
|
3114
3886
|
return;
|
|
3115
3887
|
}
|
|
@@ -3122,7 +3894,11 @@ class HubSystem {
|
|
|
3122
3894
|
}
|
|
3123
3895
|
const avatars = (mp.avatars?.actors?.size ?? 0) + 1;
|
|
3124
3896
|
const heap = heapMB();
|
|
3125
|
-
|
|
3897
|
+
const build = Hub.deck.build;
|
|
3898
|
+
const stamp = build ? `\n${build.sha.slice(0, 12)} · ${build.savedAt}${build.hubGameBuiltinVersion ? ` · hub-game ${build.hubGameBuiltinVersion}` : ''}` : '';
|
|
3899
|
+
const server = globalThis.__hub?.serverBuild;
|
|
3900
|
+
const serverLine = server ? `\nserver ${server.bundleId ?? server.bundleSha256?.slice(0, 12)}` : '';
|
|
3901
|
+
this.chrome.setStats(`${Math.round(this.fps)} fps · ${avatars} avatars${heap !== null ? ` · ${heap} MB` : ''}${stamp}${serverLine}`);
|
|
3126
3902
|
if (now - this.statsAt >= STATS_EVERY_MS) {
|
|
3127
3903
|
this.statsAt = now;
|
|
3128
3904
|
const record = { scene: this.scenePath, fps: Math.round(this.fps * 10) / 10, avatars, heapMB: heap, trips: this.tripCount, ...gpuCounts(scene), ...this.lastFrame };
|
|
@@ -3132,6 +3908,20 @@ class HubSystem {
|
|
|
3132
3908
|
}
|
|
3133
3909
|
|
|
3134
3910
|
dispose() {
|
|
3911
|
+
this.clearPadReadability();
|
|
3912
|
+
this.hudRate?.dispose();
|
|
3913
|
+
this.hudRate = null;
|
|
3914
|
+
this.fpsTelemetry?.dispose();
|
|
3915
|
+
this.fpsTelemetry = null;
|
|
3916
|
+
this.fpsNet = null;
|
|
3917
|
+
|
|
3918
|
+
this.doorErrors?.dispose();
|
|
3919
|
+
loadingCover?.detach();
|
|
3920
|
+
this.invites?.dispose();
|
|
3921
|
+
this.invites = null;
|
|
3922
|
+
this.weakestTier?.restore();
|
|
3923
|
+
this.environment.restore();
|
|
3924
|
+
this.farAvatars?.clear();
|
|
3135
3925
|
this.visibility?.sync(null, null, false);
|
|
3136
3926
|
this.visibility = null;
|
|
3137
3927
|
if (this.menuDrawn) {this.clearMenu();}
|
|
@@ -3143,8 +3933,12 @@ class HubSystem {
|
|
|
3143
3933
|
this.decor.dispose();
|
|
3144
3934
|
this.decor = null;
|
|
3145
3935
|
}
|
|
3936
|
+
this.act?.dispose();
|
|
3937
|
+
this.act = null;
|
|
3146
3938
|
this.chrome?.dispose();
|
|
3147
3939
|
this.chrome = null;
|
|
3940
|
+
this.actionInput?.release();
|
|
3941
|
+
delete this.actionInput;
|
|
3148
3942
|
this.talk = null;
|
|
3149
3943
|
this.grab?.dispose();
|
|
3150
3944
|
this.grab = null;
|
|
@@ -3214,7 +4008,7 @@ function doorActor(scene, door) {
|
|
|
3214
4008
|
if (!door) {
|
|
3215
4009
|
return null;
|
|
3216
4010
|
}
|
|
3217
|
-
for (const actor of scene
|
|
4011
|
+
for (const actor of allActors(scene)) {
|
|
3218
4012
|
if (actor.components?.HubDoor?.id === door) {
|
|
3219
4013
|
return actor.id;
|
|
3220
4014
|
}
|
|
@@ -3303,12 +4097,18 @@ function followCamera(scene, local) {
|
|
|
3303
4097
|
return { x: t.x - distance * Math.sin(angle), y: t.y + height, z: t.z + distance * Math.cos(angle) };
|
|
3304
4098
|
}
|
|
3305
4099
|
|
|
4100
|
+
// Hub.go through a door; with an owner (a friend at home), into that owner's
|
|
4101
|
+
// House. Without one the call is the door alone, as it always was.
|
|
4102
|
+
function hubGo(door, owner) {
|
|
4103
|
+
return owner ? castleSdk.Hub.go(door, { ownerUserId: owner }) : castleSdk.Hub.go(door);
|
|
4104
|
+
}
|
|
4105
|
+
|
|
3306
4106
|
function project(cam, x, y, z, view) {
|
|
3307
4107
|
const v = cam.position.clone().set(x, y, z).project(cam);
|
|
3308
4108
|
if (v.z > 1 || v.z < -1) {
|
|
3309
4109
|
return null;
|
|
3310
4110
|
}
|
|
3311
|
-
return { x: ((v.x + 1) / 2) * view.w, y: ((1 - v.y) / 2) * view.h };
|
|
4111
|
+
return mapWorldPoint({ x: ((v.x + 1) / 2) * view.w, y: ((1 - v.y) / 2) * view.h }, view);
|
|
3312
4112
|
}
|
|
3313
4113
|
|
|
3314
4114
|
function statsWanted() {
|
|
@@ -3343,3 +4143,4 @@ function frameCounts(scene) {
|
|
|
3343
4143
|
info.reset();
|
|
3344
4144
|
return counts;
|
|
3345
4145
|
}
|
|
4146
|
+
import { reportPushVisit } from '../client/pushVisit.js';
|