castle-web-cli 0.4.231 → 0.4.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +51 -3
- package/dist/castleJson.d.ts +4 -2
- package/dist/castleJson.js +2 -0
- package/dist/check.d.ts +3 -1
- package/dist/check.js +11 -1
- package/dist/devSessionStorage.js +47 -1
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +5 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +5 -0
- package/dist/save-deck.js +37 -4
- package/dist/serve.js +3 -0
- package/dist/serverBundle.js +5 -3
- package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +79 -2
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +1 -1
- package/kits/base/sdk/commands.d.ts +14 -0
- package/kits/base/sdk/hub.d.ts +6 -2
- package/kits/base/sdk/hub.js +13 -0
- package/kits/base/sdk/multiplayer.js +17 -1
- package/kits/base/sdk/save.js +2 -1
- package/kits/base/sdk/server/hub.d.ts +87 -0
- package/kits/base/sdk/server/hub.js +70 -0
- package/kits/base/sdk/server/platformHandle.d.ts +31 -1
- package/kits/base/sdk/server/storage.d.ts +13 -0
- package/kits/base/sdk/server/storage.js +46 -0
- package/kits/base/sdk/server/wrapper.d.ts +36 -5
- package/kits/base/sdk/server/wrapper.js +83 -8
- package/kits/hub-game/CLAUDE.md +352 -12
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +345 -32
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +251 -0
- package/kits/hub-game/code/client/ballot.js +467 -0
- package/kits/hub-game/code/client/build.js +22 -0
- package/kits/hub-game/code/client/chat.js +12 -0
- package/kits/hub-game/code/client/chrome.js +1334 -50
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/decor.js +509 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/grab.js +363 -20
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +328 -15
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/idle.js +163 -22
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +205 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/shot.js +92 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +131 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +538 -47
- package/kits/hub-game/code/client/tiers.js +541 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +98 -1
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +470 -97
- package/kits/hub-game/code/client/yours.js +199 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/actions.js +133 -0
- package/kits/hub-game/code/server/actors.js +14 -1
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +82 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/earned.js +461 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +232 -0
- package/kits/hub-game/code/server/grab.js +296 -11
- package/kits/hub-game/code/server/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1317 -52
- package/kits/hub-game/code/server/idle.js +30 -11
- package/kits/hub-game/code/server/index.js +2 -2
- package/kits/hub-game/code/server/labels.js +28 -2
- package/kits/hub-game/code/server/manifest.js +424 -8
- package/kits/hub-game/code/server/menu.js +133 -0
- package/kits/hub-game/code/server/npcs.js +830 -80
- package/kits/hub-game/code/server/party.js +13 -2
- package/kits/hub-game/code/server/players.js +22 -0
- package/kits/hub-game/code/server/say.js +8 -2
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +124 -0
- package/kits/hub-game/code/server/vis.js +113 -0
- package/kits/hub-game/code/server/wear.js +128 -11
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/shot.js +19 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1083 -85
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2440 -61
- package/kits/hub-game/docs/home-pieces.md +64 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +2 -0
- package/kits/hub-game/package.json +2 -1
- package/kits/hub-game/scripts/check.mjs +78 -11
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -17
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
- package/kits/hub-game/scripts/test-avatar.mjs +540 -7
- package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
- package/kits/hub-game/scripts/test-build.mjs +31 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +694 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
- package/kits/hub-game/scripts/test-decor.mjs +457 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1194 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +186 -3
- package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +864 -3
- package/kits/hub-game/scripts/test-hats.mjs +483 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1228 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +1000 -0
- package/kits/hub-game/scripts/test-idle.mjs +361 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +596 -0
- package/kits/hub-game/scripts/test-manifest.mjs +282 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
- package/kits/hub-game/scripts/test-menu.mjs +296 -0
- package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-party.mjs +22 -1
- package/kits/hub-game/scripts/test-picker.mjs +314 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-shot.mjs +756 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +416 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
- package/kits/hub-game/scripts/test-tiers.mjs +666 -3
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/hub-game/scripts/test-vis.mjs +343 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
- package/kits/hub-game/scripts/test-yours.mjs +372 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/physics-2d/CLAUDE.md +9 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +288 -1
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +370 -1
- package/kits/physics-3d/CLAUDE.md +1391 -0
- package/kits/physics-3d/behaviors/Player.jsx +921 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +12 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +98 -10
- package/kits/physics-3d/engine3d/actornode.js +86 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +96 -0
- package/kits/physics-3d/engine3d/gait.js +118 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +507 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +37 -19
- package/kits/physics-3d/engine3d/optimize.js +58 -5
- package/kits/physics-3d/engine3d/orbitinput.js +755 -0
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/shadowfade.js +882 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +870 -87
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
- package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +12 -2
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +4588 -0
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +13 -1
- package/kits/physics-3d/scripts/test-static-passes.mjs +1 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +635 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +474 -12
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +97 -19
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -111,7 +111,7 @@ function hidden(d, a, b) {
|
|
|
111
111
|
return Boolean(d.blockedPairs(d.h)?.get(a)?.has(b));
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
// `d` is the hub layer's own: `{ h, blockedPairs, usernameOf, placeAt, stand,
|
|
114
|
+
// `d` is the hub layer's own: `{ h, blockedPairs, usernameOf, standingY, placeAt, stand,
|
|
115
115
|
// jumpDoors, front }`.
|
|
116
116
|
export function message(d, player, data) {
|
|
117
117
|
const h = d.h;
|
|
@@ -256,7 +256,7 @@ export function toPad(d, playerId, door, n) {
|
|
|
256
256
|
}
|
|
257
257
|
const facing = ((door.t.rotationY ?? 0) + 180) * DEG;
|
|
258
258
|
const at = padPoint(h, door, n, playerId) ?? d.front(door);
|
|
259
|
-
d.placeAt(h, playerId, { x: at.x, y: 1.2, z: at.z }, facing);
|
|
259
|
+
d.placeAt(h, playerId, { x: at.x, y: d.standingY(h, { ...at, y: 1.2 }), z: at.z }, facing);
|
|
260
260
|
h.session?.send(playerId, { k: 'hub-jumped', facing });
|
|
261
261
|
return true;
|
|
262
262
|
}
|
|
@@ -405,6 +405,17 @@ export function coming(h, doorId) {
|
|
|
405
405
|
return n;
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
// Cues (v1.23): the door of a player's live party proposal -- one they made,
|
|
409
|
+
// or one they were asked about and have not answered -- or null.
|
|
410
|
+
export function proposalDoor(h, playerId) {
|
|
411
|
+
const partyId = h.party.of.get(keyOf(h, playerId));
|
|
412
|
+
const proposal = partyId ? h.party.proposals.get(partyId) : null;
|
|
413
|
+
if (!proposal || proposal.until <= Date.now()) {
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
return proposal.by === playerId || proposal.asked.has(playerId) ? proposal.door : null;
|
|
417
|
+
}
|
|
418
|
+
|
|
408
419
|
// `hub.partyOf(playerId)`: the other members of their party who are here.
|
|
409
420
|
export function matesHere(h, playerId) {
|
|
410
421
|
const partyId = h.party.of.get(keyOf(h, playerId));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// A hub's first WORLD must put a new body at standing height (v1.48). The
|
|
2
|
+
// multiplayer spawn's drop height lifted a client that had already landed,
|
|
3
|
+
// before the arrival row ran. A readable saved pose remains the player's own.
|
|
4
|
+
import * as Players from '@imports/castle.multiplayer-3d/code/server/players.js';
|
|
5
|
+
import { readPoint } from '@imports/castle.multiplayer-3d/code/server/limits.js';
|
|
6
|
+
|
|
7
|
+
// The hub layer has read the place and its actors in ready before admission.
|
|
8
|
+
// Keep a closure over that layer, so joins see spawned and hidden actors too.
|
|
9
|
+
export function hubPlayers(hub) {
|
|
10
|
+
return {
|
|
11
|
+
...Players,
|
|
12
|
+
addPlayer(sim, playerId, pose) {
|
|
13
|
+
const result = Players.addPlayer(sim, playerId, pose);
|
|
14
|
+
if (!pose || !readPoint(pose)) {
|
|
15
|
+
const player = sim.players.get(playerId);
|
|
16
|
+
player.at = { ...player.at, y: hub.standingY?.(sim, player.at) ?? player.at.y };
|
|
17
|
+
player.body.setTranslation(player.at, true);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -29,7 +29,10 @@ export function newSayState() {
|
|
|
29
29
|
return { sayRate: new Map() };
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// `d` is the hub layer's own: `{ h, blockedPairs, jumpDoors }
|
|
32
|
+
// `d` is the hub layer's own: `{ h, blockedPairs, jumpDoors }`, and under cues
|
|
33
|
+
// (v1.23, a deck whose manifest sets `cues`) `{ cues: true, goDoors(h),
|
|
34
|
+
// proposalDoor(h, playerId) }`: the doors the Doors list may go to, and the
|
|
35
|
+
// door of the player's live party proposal.
|
|
33
36
|
export function message(d, player, data) {
|
|
34
37
|
const h = d.h;
|
|
35
38
|
const playerId = player?.playerId;
|
|
@@ -52,7 +55,10 @@ export function message(d, player, data) {
|
|
|
52
55
|
best = { dist, id: door.id };
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
|
-
|
|
58
|
+
// Cues: the door their party is going to comes first, while that
|
|
59
|
+
// proposal is open and the place still has the door.
|
|
60
|
+
const proposed = d.cues ? d.proposalDoor(h, playerId) : null;
|
|
61
|
+
out.door = (proposed && d.goDoors(h).some((door) => door.id === proposed) ? proposed : null) ?? best?.id ?? null;
|
|
56
62
|
}
|
|
57
63
|
} else {
|
|
58
64
|
return;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// v1.61: private orbit shots. No buckets or pose storage until called.
|
|
2
|
+
import { warnOnce } from './actors.js';
|
|
3
|
+
import { shotValue } from '../shared/shot.js';
|
|
4
|
+
|
|
5
|
+
function refuse(h, key, text) {
|
|
6
|
+
warnOnce(h, `shot:${key}`, `hub.shot: ${text}`);
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const RENEW_MS = 2000;
|
|
11
|
+
|
|
12
|
+
function stopIfIdle(h) {
|
|
13
|
+
if (!h.renewShots) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
for (const budget of h.shotBudgets.values()) {
|
|
17
|
+
if (budget.pose) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
delete h.renewShots;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function renew(h, playerId, budget) {
|
|
25
|
+
if (!budget?.pose || !Number.isFinite(h.sim?.timeMs) || !h.session?.send || !h.sim.players.has(playerId) || !h.players.get(playerId)?.arrived || h.players.get(playerId).ended) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
h.session.send(playerId, { k: 'hub-shot', shot: budget.pose, lease: true });
|
|
30
|
+
budget.renewAt = h.sim.timeMs + RENEW_MS;
|
|
31
|
+
} catch {
|
|
32
|
+
refuse(h, 'renew', 'held shot could not be renewed');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Installed only while a pose is held. Walk shot entries, never the roster;
|
|
37
|
+
// lease sends do not spend tokens or change the explicit-call deduplication.
|
|
38
|
+
function renewHeld(h) {
|
|
39
|
+
for (const [playerId, budget] of h.shotBudgets) {
|
|
40
|
+
if (budget.pose && h.sim.timeMs >= budget.renewAt) {
|
|
41
|
+
renew(h, playerId, budget);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function joinedAfresh(h, playerId) {
|
|
47
|
+
renew(h, playerId, h.shotBudgets?.get(playerId));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function forgetPlayer(h, playerId) {
|
|
51
|
+
h.shotBudgets?.delete(playerId);
|
|
52
|
+
stopIfIdle(h);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function stopHolding(h, playerId) {
|
|
56
|
+
const budget = h.shotBudgets?.get(playerId);
|
|
57
|
+
if (budget) {
|
|
58
|
+
delete budget.pose;
|
|
59
|
+
delete budget.renewAt;
|
|
60
|
+
stopIfIdle(h);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function shot(h, playerId, value) {
|
|
65
|
+
const pose = shotValue(value);
|
|
66
|
+
if (value !== null && !pose) {
|
|
67
|
+
warnOnce(h, 'shot:value', 'hub.shot: invalid shot; clearing (finite look, distance > 0, pitch and yaw required)');
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const entry = h.players.get(playerId);
|
|
71
|
+
if (typeof playerId !== 'string' || !entry?.arrived || entry.ended || !h.sim?.players.has(playerId) || !h.session?.players?.some((p) => p.playerId === playerId) || !h.session?.send) {
|
|
72
|
+
return refuse(h, 'player', 'player is not connected here');
|
|
73
|
+
}
|
|
74
|
+
const now = h.sim.timeMs;
|
|
75
|
+
if (!Number.isFinite(now)) {
|
|
76
|
+
return refuse(h, 'clock', 'simulation clock is not ready');
|
|
77
|
+
}
|
|
78
|
+
const key = JSON.stringify(pose);
|
|
79
|
+
const budgets = (h.shotBudgets ??= new Map());
|
|
80
|
+
const b = budgets.get(playerId) ?? { tokens: 4, at: now };
|
|
81
|
+
b.tokens = Math.min(4, b.tokens + Math.max(0, now - b.at) * 0.004);
|
|
82
|
+
b.at = now;
|
|
83
|
+
budgets.set(playerId, b);
|
|
84
|
+
// A held lever can call each tick; one equal pose per second suffices.
|
|
85
|
+
// Held poses also renew independently of these explicit calls.
|
|
86
|
+
if (b.key === key && (pose === null || now - b.sentAt < 1000)) {
|
|
87
|
+
return refuse(h, 'equal', 'equal shot already sent');
|
|
88
|
+
}
|
|
89
|
+
// Clearing cannot be denied by a burst of changing views.
|
|
90
|
+
if (pose && b.tokens < 1) {
|
|
91
|
+
return refuse(h, 'rate', 'at most 4 shots a second per player (burst 4)');
|
|
92
|
+
}
|
|
93
|
+
h.session.send(playerId, { k: 'hub-shot', shot: pose });
|
|
94
|
+
if (pose) {
|
|
95
|
+
b.tokens -= 1;
|
|
96
|
+
}
|
|
97
|
+
b.key = key;
|
|
98
|
+
b.sentAt = now;
|
|
99
|
+
b.pose = pose;
|
|
100
|
+
b.renewAt = now + RENEW_MS;
|
|
101
|
+
if (pose) {
|
|
102
|
+
h.renewShots ??= () => renewHeld(h);
|
|
103
|
+
} else {
|
|
104
|
+
stopIfIdle(h);
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
} catch {
|
|
108
|
+
return refuse(h, 'invalid', 'shot could not be sent');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// The kit's default heights may only come down to a clear standing spot
|
|
2
|
+
// (v1.48). This proof is private: friend placement keeps its original
|
|
3
|
+
// clearance rules. Read each solid body's current pose without querying or
|
|
4
|
+
// stepping physics; authored Transforms are only for actors without bodies.
|
|
5
|
+
export function standingY(h, at) {
|
|
6
|
+
const size = bodySize(h);
|
|
7
|
+
if (!h?.sim || !Array.isArray(h.actors) || !size) {
|
|
8
|
+
return at.y;
|
|
9
|
+
}
|
|
10
|
+
const { radius, halfHeight } = size;
|
|
11
|
+
let support = h.noGround !== true ? 0 : null;
|
|
12
|
+
const spans = [];
|
|
13
|
+
let centredSupport = h.noGround !== true;
|
|
14
|
+
for (const { shape, pose, moving } of solids(h)) {
|
|
15
|
+
if (pose.upright && (shape.kind === 'box' || shape.kind === 'cylinder')) {
|
|
16
|
+
if (!footprintHas(shape, pose, at, radius)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const half = (shape.height ?? 1) / 2;
|
|
20
|
+
const top = pose.y + half;
|
|
21
|
+
const bottom = pose.y - half;
|
|
22
|
+
// Any non-fixed solid may move while the body settles. Keep the
|
|
23
|
+
// given height near it; only fixed solids may provide support.
|
|
24
|
+
if (moving && bottom <= at.y + halfHeight) {
|
|
25
|
+
return at.y;
|
|
26
|
+
}
|
|
27
|
+
spans.push({ top, bottom });
|
|
28
|
+
if (top <= at.y - halfHeight && (support === null || top > support)) {
|
|
29
|
+
support = top;
|
|
30
|
+
centredSupport = footprintHas(shape, pose, at, 0);
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
// Tilted and unfamiliar solids need a conservative enclosing sphere.
|
|
34
|
+
// A high ball or roof whose bottom is above the whole given body cannot
|
|
35
|
+
// block lowering; one near the body keeps the given height unchanged.
|
|
36
|
+
const bound = boundingRadius(shape);
|
|
37
|
+
if (!Number.isFinite(bound) || bound <= 0) {
|
|
38
|
+
return at.y;
|
|
39
|
+
}
|
|
40
|
+
if (Math.hypot(at.x - pose.x, at.z - pose.z) <= bound + radius && pose.y - bound <= at.y + halfHeight) {
|
|
41
|
+
return at.y;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// In a scene without ground, a rim beside the feet does not prove support
|
|
46
|
+
// beneath them. Keep the old drop rather than lower over a hole.
|
|
47
|
+
if (support === null || (h.noGround === true && !centredSupport)) {
|
|
48
|
+
return at.y;
|
|
49
|
+
}
|
|
50
|
+
const y = support + halfHeight + 0.06;
|
|
51
|
+
if (y > at.y || spans.some(({ top, bottom }) => top >= y - halfHeight && bottom <= y + halfHeight)) {
|
|
52
|
+
return at.y;
|
|
53
|
+
}
|
|
54
|
+
return y;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The private proof uses the scene player's standing envelope, not the
|
|
58
|
+
// larger clearance envelope used to find a spot beside a friend.
|
|
59
|
+
function bodySize(h) {
|
|
60
|
+
const shape = h?.sim?.template?.shape ?? { kind: 'capsule', radius: 0.35, height: 1.4 };
|
|
61
|
+
const halfHeight = shape.kind === 'sphere' ? shape.radius : shape.height / 2;
|
|
62
|
+
const radius = shape.kind === 'box' ? Math.hypot(shape.width, shape.depth) / 2 : shape.radius;
|
|
63
|
+
return Number.isFinite(radius) && radius > 0 && Number.isFinite(halfHeight) && halfHeight > 0
|
|
64
|
+
? { radius, halfHeight } : null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Spawned copies live outside h.actors. Hide/show changes h.hidden at once.
|
|
68
|
+
// hub.move keeps interpolation in h.moves/h.poses and queues a kinematic
|
|
69
|
+
// target; translation/rotation on the body are the pose physics is at now.
|
|
70
|
+
function* solids(h) {
|
|
71
|
+
const actors = [...h.actors, ...[...(h.spawned?.values() ?? [])].map((entry) => entry.actor)];
|
|
72
|
+
for (const actor of actors) {
|
|
73
|
+
const c = actor.components;
|
|
74
|
+
// The authored Player is a template, not a solid scene body.
|
|
75
|
+
if (c.Player || h.hidden?.has(actor.id) || !(c.Solid || c.Shape?.solid === true) || !c.Shape) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const body = h.sim.bodies?.get(actor.id);
|
|
79
|
+
let pose;
|
|
80
|
+
if (body) {
|
|
81
|
+
const p = body.translation();
|
|
82
|
+
const q = body.rotation();
|
|
83
|
+
pose = { ...p, upright: Math.hypot(q.x, q.z) < 1e-7,
|
|
84
|
+
yaw: Math.atan2(2 * (q.w * q.y + q.x * q.z), 1 - 2 * (q.y * q.y + q.z * q.z)) };
|
|
85
|
+
} else {
|
|
86
|
+
const t = c.Transform;
|
|
87
|
+
if (!t) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
pose = { x: t.x ?? 0, y: t.y ?? 0, z: t.z ?? 0,
|
|
91
|
+
upright: (t.rotationX ?? 0) === 0 && (t.rotationZ ?? 0) === 0,
|
|
92
|
+
yaw: (t.rotationY ?? 0) * Math.PI / 180 };
|
|
93
|
+
}
|
|
94
|
+
yield { shape: c.Shape, pose, moving: body ? !body.isFixed() : Boolean(c.Body?.type && c.Body.type !== 'fixed') };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function footprintHas(shape, pose, at, pad) {
|
|
99
|
+
const dx = at.x - pose.x;
|
|
100
|
+
const dz = at.z - pose.z;
|
|
101
|
+
if (shape.kind === 'box') {
|
|
102
|
+
const lx = dx * Math.cos(pose.yaw) - dz * Math.sin(pose.yaw);
|
|
103
|
+
const lz = dx * Math.sin(pose.yaw) + dz * Math.cos(pose.yaw);
|
|
104
|
+
return Math.abs(lx) <= (shape.width ?? 1) / 2 + pad && Math.abs(lz) <= (shape.depth ?? 1) / 2 + pad;
|
|
105
|
+
}
|
|
106
|
+
return Math.hypot(dx, dz) <= (shape.radius ?? 0.5) + pad;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function boundingRadius(shape) {
|
|
110
|
+
if (shape.kind === 'sphere') {
|
|
111
|
+
return shape.radius ?? 0.5;
|
|
112
|
+
}
|
|
113
|
+
if (shape.kind === 'box') {
|
|
114
|
+
return Math.hypot(shape.width ?? 1, shape.height ?? 1, shape.depth ?? 1) / 2;
|
|
115
|
+
}
|
|
116
|
+
if (shape.kind === 'capsule') {
|
|
117
|
+
return Math.max((shape.height ?? 1) / 2, (shape.radius ?? 0.5) + 0.01);
|
|
118
|
+
}
|
|
119
|
+
if (shape.kind === 'cylinder') {
|
|
120
|
+
return Math.hypot(shape.radius ?? 0.5, (shape.height ?? 1) / 2);
|
|
121
|
+
}
|
|
122
|
+
// No known enclosing shape means no proof that lowering is safe.
|
|
123
|
+
return NaN;
|
|
124
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// v1.62: private visibility replaces the shared state for this viewer only.
|
|
2
|
+
// Nothing is allocated or sent in a place that never calls hide/show with to.
|
|
3
|
+
import { isActor, warnOnce } from './actors.js';
|
|
4
|
+
|
|
5
|
+
const MAX_OVERRIDES = 256;
|
|
6
|
+
const connected = (h, id) => h.session?.players.some((p) => p.playerId === id) === true;
|
|
7
|
+
|
|
8
|
+
export function set(h, actorId, options, hidden) {
|
|
9
|
+
const op = hidden ? 'hide' : 'show';
|
|
10
|
+
if (!isActor(h, actorId)) {
|
|
11
|
+
warnOnce(h, `vis:${op}:actor`, `hub.${op}: not an actor of this place's scene`);
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
let targets;
|
|
15
|
+
let clear;
|
|
16
|
+
try {
|
|
17
|
+
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
18
|
+
throw Error('invalid options');
|
|
19
|
+
}
|
|
20
|
+
const { to, clear: drop } = options;
|
|
21
|
+
if (!Array.isArray(to) || (drop !== undefined && typeof drop !== 'boolean')) {
|
|
22
|
+
throw Error('invalid options');
|
|
23
|
+
}
|
|
24
|
+
const ids = [...to];
|
|
25
|
+
if (ids.some((id) => typeof id !== 'string')) {
|
|
26
|
+
throw Error('invalid targets');
|
|
27
|
+
}
|
|
28
|
+
targets = [...new Set(ids)].filter((id) => connected(h, id));
|
|
29
|
+
clear = drop === true;
|
|
30
|
+
} catch {
|
|
31
|
+
warnOnce(h, `vis:${op}:options`, `hub.${op}: visibility options need { to: [playerIds], clear?: boolean }`);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
// Preflight every viewer so a refused call changes nothing, even when one
|
|
35
|
+
// recipient has room and another has already reached the cap.
|
|
36
|
+
if (!clear && targets.some((id) => {
|
|
37
|
+
const mine = h.visMe?.get(id);
|
|
38
|
+
return mine && !mine.has(actorId) && mine.size >= MAX_OVERRIDES;
|
|
39
|
+
})) {
|
|
40
|
+
warnOnce(h, 'vis:cap', 'hub.hide/show: at most 256 visibility overrides per player');
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
for (const id of targets) {
|
|
44
|
+
if (clear) {
|
|
45
|
+
const mine = h.visMe?.get(id);
|
|
46
|
+
mine?.delete(actorId);
|
|
47
|
+
if (mine?.size === 0) {
|
|
48
|
+
h.visMe.delete(id);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
h.visMe ??= new Map();
|
|
52
|
+
if (!h.visMe.has(id)) {
|
|
53
|
+
h.visMe.set(id, new Map());
|
|
54
|
+
}
|
|
55
|
+
h.visMe.get(id).set(actorId, hidden);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function sendOne(h, playerId, fresh = false) {
|
|
62
|
+
const mine = h.visMe?.get(playerId);
|
|
63
|
+
const hide = [];
|
|
64
|
+
const show = [];
|
|
65
|
+
for (const [id, hidden] of mine ?? []) {
|
|
66
|
+
(hidden ? hide : show).push(id);
|
|
67
|
+
}
|
|
68
|
+
// Canonical ordering avoids messages when only insertion order changed.
|
|
69
|
+
const out = { k: 'hub-vis', hide: hide.sort(), show: show.sort() };
|
|
70
|
+
const json = JSON.stringify(out);
|
|
71
|
+
const last = h.sentVisMe?.get(playerId);
|
|
72
|
+
if ((fresh && mine?.size) || (last !== json && (mine?.size || last))) {
|
|
73
|
+
h.session.send(playerId, out);
|
|
74
|
+
h.sentVisMe ??= new Map();
|
|
75
|
+
if (mine?.size) {
|
|
76
|
+
h.sentVisMe.set(playerId, json);
|
|
77
|
+
} else {
|
|
78
|
+
h.sentVisMe.delete(playerId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function send(h) {
|
|
84
|
+
if (!h.visMe && !h.sentVisMe) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
for (const id of new Set([...(h.visMe?.keys() ?? []), ...(h.sentVisMe?.keys() ?? [])])) {
|
|
88
|
+
if (connected(h, id)) {
|
|
89
|
+
sendOne(h, id);
|
|
90
|
+
} else {
|
|
91
|
+
forget(h, id);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function joinedAfresh(h, playerId) {
|
|
97
|
+
if (h.visMe?.has(playerId) && connected(h, playerId)) {
|
|
98
|
+
sendOne(h, playerId, true);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function forget(h, playerId) {
|
|
103
|
+
h.visMe?.delete(playerId);
|
|
104
|
+
h.sentVisMe?.delete(playerId);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function prune(h) {
|
|
108
|
+
for (const id of h.visMe?.keys() ?? []) {
|
|
109
|
+
if (!connected(h, id)) {
|
|
110
|
+
forget(h, id);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
// The snapshot's `hubWear` is playerId -> wearable for helloed players who
|
|
9
9
|
// wear one, without anyone a block hides from someone here: theirs go to each
|
|
10
10
|
// player who may see them alone (`hub-wear`), as their avatars do (`hub-av`).
|
|
11
|
+
//
|
|
12
|
+
// A try-on (v1.28, `hub.tryOn(playerId, spec | null)`) is a wearable this
|
|
13
|
+
// place shows on a player instead of their own until it clears it: a hat on a
|
|
14
|
+
// shop's mat, a costume for a visit. It is kept here only (`trying`), never
|
|
15
|
+
// sent to ghost and never read back, so what the player owns is untouched;
|
|
16
|
+
// clients are told in `hubTry` and `hub-try`, the shape of `hubWear` and
|
|
17
|
+
// `hub-wear`, and draw it over the saved one. `trying` is empty until a place
|
|
18
|
+
// calls `hub.tryOn`, and every branch for it asks that first: a place that
|
|
19
|
+
// never does sends what it always did.
|
|
11
20
|
|
|
12
21
|
import { warnOnce } from './actors.js';
|
|
13
22
|
|
|
@@ -27,6 +36,14 @@ export function newWearState() {
|
|
|
27
36
|
wearSent: new Map(),
|
|
28
37
|
// playerId -> JSON of the wearables last sent to that player alone
|
|
29
38
|
sentWearMe: new Map(),
|
|
39
|
+
// playerId -> the wearable this place shows on them instead of their own
|
|
40
|
+
// (v1.28 `hub.tryOn`); empty in a place that never calls it
|
|
41
|
+
trying: new Map(),
|
|
42
|
+
// playerId -> JSON of the try-ons last sent to that player alone, or
|
|
43
|
+
// `RESEND` for a client that joined afresh and is to be told again
|
|
44
|
+
sentTryMe: new Map(),
|
|
45
|
+
// whether any player was ever sent try-ons alone (`hub-try`)
|
|
46
|
+
tryAloneUsed: false,
|
|
30
47
|
};
|
|
31
48
|
}
|
|
32
49
|
|
|
@@ -52,17 +69,27 @@ export function cleanWearable(spec) {
|
|
|
52
69
|
return { kind, color: color.toLowerCase(), rarity };
|
|
53
70
|
}
|
|
54
71
|
|
|
72
|
+
// What `hub.wear` and `hub.tryOn` (`api`) take: the wearable, `null` to clear,
|
|
73
|
+
// or `undefined` for one refused and logged once -- a player who is not here,
|
|
74
|
+
// or a spec that is not a wearable.
|
|
75
|
+
function asked(h, api, playerId, spec) {
|
|
76
|
+
if (typeof playerId !== 'string' || !(h.players.has(playerId) || h.sim?.players.has(playerId))) {
|
|
77
|
+
warnOnce(h, `${api}:${playerId}`, `hub.${api}: "${playerId}" is not a player here`);
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const clean = cleanWearable(spec === undefined ? null : spec);
|
|
81
|
+
if (clean === undefined) {
|
|
82
|
+
warnOnce(h, `${api}:spec`, `hub.${api}: a wearable is { kind, color: "#rrggbb", rarity: 0-9 } or null`);
|
|
83
|
+
}
|
|
84
|
+
return clean;
|
|
85
|
+
}
|
|
86
|
+
|
|
55
87
|
// `hub.wear(playerId, spec | null)`: true when it took. `platform` is the
|
|
56
88
|
// host's hub ops or null; `userId` the player's, or null for a guest, whose
|
|
57
89
|
// wearable is this session's alone; `refused` logs a refusal once.
|
|
58
90
|
export function wear(h, playerId, spec, { platform, userId, refused }) {
|
|
59
|
-
|
|
60
|
-
warnOnce(h, `wear:${playerId}`, `hub.wear: "${playerId}" is not a player here`);
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
const clean = cleanWearable(spec === undefined ? null : spec);
|
|
91
|
+
const clean = asked(h, 'wear', playerId, spec);
|
|
64
92
|
if (clean === undefined) {
|
|
65
|
-
warnOnce(h, 'wear:spec', 'hub.wear: a wearable is { kind, color: "#rrggbb", rarity: 0-9 } or null');
|
|
66
93
|
return false;
|
|
67
94
|
}
|
|
68
95
|
if (clean) {
|
|
@@ -84,6 +111,34 @@ export function wear(h, playerId, spec, { platform, userId, refused }) {
|
|
|
84
111
|
return true;
|
|
85
112
|
}
|
|
86
113
|
|
|
114
|
+
// `hub.tryOn(playerId, spec | null)` (v1.28): true when it took. Shown on the
|
|
115
|
+
// player in this place until `null`, their leaving or the place's end; the
|
|
116
|
+
// wearable they own (`wearing`, ghost's) is neither read nor written.
|
|
117
|
+
export function tryOn(h, playerId, spec) {
|
|
118
|
+
const clean = asked(h, 'tryOn', playerId, spec);
|
|
119
|
+
if (clean === undefined) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (clean) {
|
|
123
|
+
h.trying.set(playerId, clean);
|
|
124
|
+
} else {
|
|
125
|
+
h.trying.delete(playerId);
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// `hub.wearing(playerId)` (v1.41): the wearable a player here owns, as this
|
|
131
|
+
// place last knew it (a game's `hub.wear`, or ghost's on the arrival read),
|
|
132
|
+
// a copy; null for none, for a player not here, and while a try-on is shown
|
|
133
|
+
// it is still the one they own. So a place can say what someone is wearing.
|
|
134
|
+
export function wearing(h, playerId) {
|
|
135
|
+
if (!h.players.has(playerId)) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const worn = h.wearing.get(playerId);
|
|
139
|
+
return worn ? { ...worn } : null;
|
|
140
|
+
}
|
|
141
|
+
|
|
87
142
|
// Ghost's word on a player's wearable, from the arrival read: kept unless the
|
|
88
143
|
// game set one since the read began. A ghost older than wearables says
|
|
89
144
|
// nothing, which changes nothing.
|
|
@@ -106,8 +161,17 @@ export function applyRead(h, playerId, wearRev, read) {
|
|
|
106
161
|
// Everyone's wearables, for everyone: helloed players only, without the ones
|
|
107
162
|
// a block hides from someone here.
|
|
108
163
|
export function wearingOf(h, hidden) {
|
|
164
|
+
return shownOf(h, h.wearing, hidden);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Everyone's try-ons (v1.28), for everyone, under the same two rules.
|
|
168
|
+
export function tryingOf(h, hidden) {
|
|
169
|
+
return shownOf(h, h.trying, hidden);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function shownOf(h, worn, hidden) {
|
|
109
173
|
const out = {};
|
|
110
|
-
for (const [playerId, wearable] of
|
|
174
|
+
for (const [playerId, wearable] of worn) {
|
|
111
175
|
if (h.players.get(playerId)?.hello && !hidden?.has(playerId)) {
|
|
112
176
|
out[playerId] = wearable;
|
|
113
177
|
}
|
|
@@ -118,18 +182,69 @@ export function wearingOf(h, hidden) {
|
|
|
118
182
|
// The wearables of players in a hidden pair, each to the players who may see
|
|
119
183
|
// them, when they change. A session with no blocks sends nothing here.
|
|
120
184
|
export function sendOverrides(h, hidden) {
|
|
185
|
+
sendAlone(h, hidden, h.wearing, h.sentWearMe, (out) => ({ k: 'hub-wear', hubWear: out }));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// The same for try-ons (v1.28, `hub-try`). Asked only once a place has
|
|
189
|
+
// called `hub.tryOn` (`tryOnUsed`).
|
|
190
|
+
export function sendTryOverrides(h, hidden) {
|
|
191
|
+
sendAlone(h, hidden, h.trying, h.sentTryMe, (out) => {
|
|
192
|
+
h.tryAloneUsed = true;
|
|
193
|
+
return { k: 'hub-try', hubTry: out };
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// A client joined afresh (a hello that is not an avatar change: a reconnect,
|
|
198
|
+
// a reloaded page that resumed its player id). What it holds of `hub-try` is
|
|
199
|
+
// not known -- nothing, or a map from before it dropped out -- so it is sent
|
|
200
|
+
// the map as it is now, empty or not, on the next tick it has a body. Only in
|
|
201
|
+
// a place that has ever sent one: anywhere else no client holds any.
|
|
202
|
+
const RESEND = 'resend';
|
|
203
|
+
|
|
204
|
+
export function joinedAfresh(h, playerId) {
|
|
205
|
+
if (h.tryAloneUsed) {
|
|
206
|
+
h.sentTryMe.set(playerId, RESEND);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// A try-on is taken for a player with a body who has not said hello (as
|
|
211
|
+
// `hub.wear` takes one), and such a player's going is not a `forget`: drop
|
|
212
|
+
// what is kept for anyone who is neither known to the place nor in the
|
|
213
|
+
// simulation, so both maps hold only players who are here.
|
|
214
|
+
export function pruneTries(h) {
|
|
215
|
+
for (const kept of [h.trying, h.sentTryMe]) {
|
|
216
|
+
for (const playerId of [...kept.keys()]) {
|
|
217
|
+
if (!h.players.has(playerId) && !h.sim?.players.has(playerId)) {
|
|
218
|
+
kept.delete(playerId);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// The place is ending: every try-on with it.
|
|
225
|
+
export function endTries(h) {
|
|
226
|
+
h.trying.clear();
|
|
227
|
+
h.sentTryMe.clear();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Whether this place has a try-on up, or has told someone of one alone.
|
|
231
|
+
export function tryOnUsed(h) {
|
|
232
|
+
return h.trying.size > 0 || h.sentTryMe.size > 0;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function sendAlone(h, hidden, worn, sent, message) {
|
|
121
236
|
for (const playerId of h.sim.players.keys()) {
|
|
122
237
|
const out = {};
|
|
123
238
|
for (const shrouded of hidden?.keys() ?? []) {
|
|
124
|
-
const wearable =
|
|
239
|
+
const wearable = worn.get(shrouded);
|
|
125
240
|
if (wearable && h.players.get(shrouded)?.hello && !hidden.get(playerId)?.has(shrouded)) {
|
|
126
241
|
out[shrouded] = wearable;
|
|
127
242
|
}
|
|
128
243
|
}
|
|
129
244
|
const json = JSON.stringify(out);
|
|
130
|
-
if ((
|
|
131
|
-
|
|
132
|
-
h.session?.send(playerId,
|
|
245
|
+
if ((sent.get(playerId) ?? '{}') !== json) {
|
|
246
|
+
sent.set(playerId, json);
|
|
247
|
+
h.session?.send(playerId, message(out));
|
|
133
248
|
}
|
|
134
249
|
}
|
|
135
250
|
}
|
|
@@ -139,4 +254,6 @@ export function forget(h, playerId) {
|
|
|
139
254
|
h.wearRev.delete(playerId);
|
|
140
255
|
h.wearSent.delete(playerId);
|
|
141
256
|
h.sentWearMe.delete(playerId);
|
|
257
|
+
h.trying.delete(playerId);
|
|
258
|
+
h.sentTryMe.delete(playerId);
|
|
142
259
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// v1.54: private rows from the reads the kit already makes. No extra read.
|
|
2
|
+
export function cleanHearts(value) {
|
|
3
|
+
return [...new Set((Array.isArray(value) ? value : []).filter((id) => typeof id === 'string' && id.length > 0 && id.length <= 64))].slice(0, 8);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function score(value, unit) {
|
|
7
|
+
return `${value}${['ms', 's', 'points'].includes(unit) ? ` ${unit}` : ''}`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function rowsFor(doors, boards, history, hearts) {
|
|
11
|
+
const recent = history?.recent ?? [];
|
|
12
|
+
const records = history?.records ?? [];
|
|
13
|
+
const destination = (door) => ({
|
|
14
|
+
deck: boards.get(door.id)?.toDeckId ?? (door.to.startsWith('deck:') ? door.to.slice(5) : null),
|
|
15
|
+
place: door.to.startsWith('deck:') ? 'main' : door.to,
|
|
16
|
+
});
|
|
17
|
+
const matches = (row, door, record = false) => {
|
|
18
|
+
const to = destination(door);
|
|
19
|
+
return row.deckId === to.deck && ((!record && door.to.startsWith('deck:')) || row.place === to.place);
|
|
20
|
+
};
|
|
21
|
+
const order = [...hearts, ...recent.flatMap((r) => doors.filter((d) => matches(r, d)).map((d) => d.id))];
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const id of new Set(order)) {
|
|
24
|
+
const door = doors.find((d) => d.id === id);
|
|
25
|
+
if (!door) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const record = records.find((r) => matches(r, door, true));
|
|
29
|
+
const last = recent.find((r) => matches(r, door));
|
|
30
|
+
const unit = boards.get(id)?.unit ?? record?.unit ?? last?.unit;
|
|
31
|
+
const best = record?.bestScore;
|
|
32
|
+
const value = record?.lastScore ?? last?.score;
|
|
33
|
+
const result = Number.isFinite(best) ? `Best ${score(best, unit)}` : Number.isFinite(value) ? `Last ${score(value, unit)}` : record?.lastOutcome ?? last?.outcome ?? '';
|
|
34
|
+
const lastAt = Date.parse(record?.lastAt ?? last?.at);
|
|
35
|
+
out.push({ door: id, title: door.title, line: result, lastAt: Number.isFinite(lastAt) ? lastAt : null, hearted: hearts.includes(id) });
|
|
36
|
+
if (out.length === 5) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function send(h, doors, members) {
|
|
44
|
+
if (!h.manifest.yourGames || h.place.result) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const users = members(h, [...h.players.keys()]);
|
|
48
|
+
for (const playerId of users.values()) {
|
|
49
|
+
const entry = h.players.get(playerId);
|
|
50
|
+
const hearts = entry.hearts ?? [];
|
|
51
|
+
const rows = rowsFor(doors, h.boards, entry.history, hearts);
|
|
52
|
+
const key = JSON.stringify({ rows, hearts });
|
|
53
|
+
if (key === entry.yoursKey || (!rows.length && !entry.yoursKey)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
entry.yoursKey = key;
|
|
57
|
+
h.session?.send(playerId, { k: 'hub-yours', rows, hearts });
|
|
58
|
+
}
|
|
59
|
+
}
|