castle-web-cli 0.4.232 → 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/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 +329 -11
- 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 +309 -35
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +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/chrome.js +1144 -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 +339 -20
- package/kits/hub-game/code/client/hookLayer.js +299 -13
- 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 +109 -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 +516 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +32 -0
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- 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 +9 -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/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1254 -50
- 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 +378 -7
- 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 +2 -2
- package/kits/hub-game/code/server/players.js +22 -0
- 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 +12 -0
- 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 +845 -95
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2244 -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 +662 -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-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- package/kits/hub-game/scripts/test-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 +716 -2
- package/kits/hub-game/scripts/test-hud-clear.mjs +328 -4
- 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 +207 -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-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-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 +477 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- package/kits/hub-game/scripts/test-vis.mjs +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 +253 -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 +326 -1
- package/kits/physics-3d/CLAUDE.md +1169 -30
- package/kits/physics-3d/behaviors/Player.jsx +629 -72
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +8 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +69 -13
- 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 +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +487 -9
- 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 +796 -69
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2563 -80
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
- 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 +8 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +2 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +383 -6
- 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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -127,6 +127,18 @@ export function tryOn(h, playerId, spec) {
|
|
|
127
127
|
return true;
|
|
128
128
|
}
|
|
129
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
|
+
|
|
130
142
|
// Ghost's word on a player's wearable, from the arrival read: kept unless the
|
|
131
143
|
// game set one since the read began. A ghost older than wearables says
|
|
132
144
|
// nothing, which changes nothing.
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Named place cues (v1.50). Client-observed actions have their own voices;
|
|
2
|
+
// they are not place ops. Pads have no structured client countdown state.
|
|
3
|
+
export const CUE_NAMES = Object.freeze([
|
|
4
|
+
'kick', 'goal', 'cast', 'nibble', 'bite', 'catch', 'token', 'hat-bought',
|
|
5
|
+
'hat-on', 'lantern', 'stamp', 'trial-start', 'trial-gate', 'trial-finish',
|
|
6
|
+
'pad-tick', 'pad-go',
|
|
7
|
+
'court-chime', 'court-bell', 'court-splash', 'court-flutter',
|
|
8
|
+
'busker-jig', 'busker-waltz',
|
|
9
|
+
]);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Decorating (v1.67): cell footprints shared by the preview and spec checks.
|
|
2
|
+
export const DECOR_ID = /^[a-z][a-z0-9_-]{0,23}$/;
|
|
3
|
+
|
|
4
|
+
export function footprint(item, rot) {
|
|
5
|
+
return rot % 2 ? { w: item.d, d: item.w } : { w: item.w, d: item.d };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function fits(grid, items, placed, piece) {
|
|
9
|
+
const item = items.find((i) => i.id === piece.item);
|
|
10
|
+
if (!item) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const { w, d } = footprint(item, piece.rot);
|
|
14
|
+
if (piece.x < 0 || piece.z < 0 || piece.x + w > grid.w || piece.z + d > grid.d) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return !placed.some((other) => {
|
|
18
|
+
if (other.key === piece.key || other.layer !== item.layer) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const otherItem = items.find((i) => i.id === other.item);
|
|
22
|
+
if (!otherItem) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const size = footprint(otherItem, other.rot);
|
|
26
|
+
return piece.x < other.x + size.w && piece.x + w > other.x && piece.z < other.z + size.d && piece.z + d > other.z;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function freeCell(grid, items, placed, item, near = { x: 0, z: 0 }) {
|
|
31
|
+
const cells = [];
|
|
32
|
+
for (let z = 0; z < grid.d; z += 1) {
|
|
33
|
+
for (let x = 0; x < grid.w; x += 1) {
|
|
34
|
+
if (fits(grid, items, placed, { item: item.id, x, z, rot: 0 })) {
|
|
35
|
+
cells.push({ x, z });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
cells.sort((a, b) => Math.hypot(a.x - near.x, a.z - near.z) - Math.hypot(b.x - near.x, b.z - near.z));
|
|
40
|
+
return cells[0] ?? null;
|
|
41
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The orbit camera's finite pose contract, copied into a plain wire value.
|
|
2
|
+
// Pitch is drawn within 89 degrees by physics-3d's Player too.
|
|
3
|
+
export function shotValue(shot) {
|
|
4
|
+
try {
|
|
5
|
+
const look = shot?.look;
|
|
6
|
+
const x = look?.x;
|
|
7
|
+
const y = look?.y;
|
|
8
|
+
const z = look?.z;
|
|
9
|
+
const distance = shot?.distance;
|
|
10
|
+
const pitch = shot?.pitch;
|
|
11
|
+
const yaw = shot?.yaw;
|
|
12
|
+
if (![x, y, z, distance, pitch, yaw].every(Number.isFinite) || distance <= 0) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return { look: { x, y, z }, distance, pitch: Math.max(-89, Math.min(89, pitch)), yaw };
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Turning displays (contract v1.55): a scene actor carrying `HubSpin`
|
|
2
|
+
// (`{ rate }`, degrees a second about its vertical axis, the sign its way
|
|
3
|
+
// round) is turned by every client on its own, from scene data: no server
|
|
4
|
+
// traffic, no snapshot field, no body. A hat on a stand, a sign, a trophy.
|
|
5
|
+
// Shared by the publish check (scripts/check.mjs), which refuses what this
|
|
6
|
+
// refuses, and the client (code/client/spin.js), which turns only what it
|
|
7
|
+
// allows, so a scene that skipped the check still turns nothing it may not.
|
|
8
|
+
|
|
9
|
+
export const SPIN_COMPONENT = 'HubSpin';
|
|
10
|
+
// Two turns a second at most: faster reads as a blur, not a display.
|
|
11
|
+
export const SPIN_RATE_MAX = 720;
|
|
12
|
+
const KEYS = new Set(['rate']);
|
|
13
|
+
// What already decides an actor's facing: the avatar, a door's swing, an
|
|
14
|
+
// NPC's turn to the player it answers, the way a seat sits its sitter.
|
|
15
|
+
const OWN_FACING = ['Player', 'HubDoor', 'HubNpc', 'HubSeat', 'Pickup'];
|
|
16
|
+
|
|
17
|
+
// Why an actor with these components (a blueprint's merged in, as the engine
|
|
18
|
+
// merges them) may not carry its `HubSpin`, or null when it may.
|
|
19
|
+
export function spinProblem(components) {
|
|
20
|
+
const props = components?.[SPIN_COMPONENT];
|
|
21
|
+
if (!props || typeof props !== 'object' || Array.isArray(props)) {
|
|
22
|
+
return `${SPIN_COMPONENT} is { rate }`;
|
|
23
|
+
}
|
|
24
|
+
for (const key of Object.keys(props)) {
|
|
25
|
+
if (!KEYS.has(key)) {
|
|
26
|
+
return `${SPIN_COMPONENT}.${key} is not part of the hub contract`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const rate = props.rate;
|
|
30
|
+
if (typeof rate !== 'number' || !Number.isFinite(rate) || rate === 0 || Math.abs(rate) > SPIN_RATE_MAX) {
|
|
31
|
+
return `${SPIN_COMPONENT}.rate must be a number of degrees a second, not 0, from -${SPIN_RATE_MAX} to ${SPIN_RATE_MAX}`;
|
|
32
|
+
}
|
|
33
|
+
// The turn is drawn on each client and never simulated: a body is moved by
|
|
34
|
+
// its simulation (dynamic) or by the server (kinematic, `hub.move`), and a
|
|
35
|
+
// solid collider would turn on every client and stand still on the server.
|
|
36
|
+
const type = components.Body?.type;
|
|
37
|
+
if (type === 'dynamic' || type === 'kinematic') {
|
|
38
|
+
return `a ${type} Body cannot carry ${SPIN_COMPONENT}; only a non-solid actor with no moving body turns`;
|
|
39
|
+
}
|
|
40
|
+
if (components.Solid || components.Shape?.solid) {
|
|
41
|
+
return `a solid actor cannot carry ${SPIN_COMPONENT}; put the turning part on its own non-solid actor`;
|
|
42
|
+
}
|
|
43
|
+
const owner = OWN_FACING.find((name) => components[name]);
|
|
44
|
+
if (owner) {
|
|
45
|
+
return `an actor with ${owner} cannot carry ${SPIN_COMPONENT}; it is already turned`;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The rate an actor turns at, degrees a second, or 0: no `HubSpin`, or one
|
|
51
|
+
// `spinProblem` refuses.
|
|
52
|
+
export function spinRate(components) {
|
|
53
|
+
if (!components?.[SPIN_COMPONENT]) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
return spinProblem(components) ? 0 : components[SPIN_COMPONENT].rate;
|
|
57
|
+
}
|