castle-web-cli 0.4.232 → 0.4.234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/api.d.ts +11 -0
- package/dist/api.js +43 -0
- package/dist/bundle.d.ts +64 -0
- package/dist/bundle.js +558 -2
- package/dist/castle-host/host.d.ts +18 -2
- package/dist/castle-host/host.js +844 -39
- package/dist/castleJson.d.ts +23 -2
- package/dist/castleJson.js +46 -2
- package/dist/check.d.ts +3 -1
- package/dist/check.js +20 -3
- package/dist/chunkLoader.d.ts +3 -0
- package/dist/chunkLoader.js +111 -0
- package/dist/devParty.d.ts +26 -0
- package/dist/devParty.js +231 -0
- package/dist/devSaveStorage.js +4 -0
- package/dist/devSessionStorage.js +50 -2
- package/dist/devSocial.d.ts +24 -0
- package/dist/devSocial.js +70 -0
- package/dist/ide.d.ts +2 -0
- package/dist/ide.js +119 -15
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +11 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +25 -1
- package/dist/save-deck.js +178 -9
- package/dist/serve.js +32 -11
- package/dist/shell/assets/{index-D2tWM896.js → index-DulbYIJm.js} +97 -97
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/dist/vitePlugins.d.ts +2 -1
- package/dist/vitePlugins.js +13 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +339 -5
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +7 -3
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +176 -1
- package/kits/base/sdk/commands.js +3 -0
- package/kits/base/sdk/display.d.ts +3 -0
- package/kits/base/sdk/display.js +9 -3
- package/kits/base/sdk/hub.d.ts +37 -6
- package/kits/base/sdk/hub.js +63 -4
- package/kits/base/sdk/multiplayer.d.ts +7 -1
- package/kits/base/sdk/multiplayer.js +148 -32
- package/kits/base/sdk/multiplayerProtocol.d.ts +2 -0
- package/kits/base/sdk/party.d.ts +23 -0
- package/kits/base/sdk/party.js +91 -0
- package/kits/base/sdk/reconnectBudget.d.ts +23 -0
- package/kits/base/sdk/reconnectBudget.js +96 -0
- package/kits/base/sdk/save.d.ts +38 -1
- package/kits/base/sdk/save.js +81 -7
- package/kits/base/sdk/server/hub.d.ts +117 -0
- package/kits/base/sdk/server/hub.js +119 -2
- package/kits/base/sdk/server/platformHandle.d.ts +43 -1
- package/kits/base/sdk/server/storage.d.ts +17 -0
- package/kits/base/sdk/server/storage.js +65 -3
- package/kits/base/sdk/server/wrapper.d.ts +43 -6
- package/kits/base/sdk/server/wrapper.js +93 -9
- package/kits/base/sdk/social.d.ts +9 -0
- package/kits/base/sdk/social.js +5 -0
- package/kits/hub-game/CLAUDE.md +451 -13
- package/kits/hub-game/README.md +63 -0
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/castle.json +5 -5
- package/kits/hub-game/code/client/act.js +312 -0
- package/kits/hub-game/code/client/actionLayout.js +147 -0
- package/kits/hub-game/code/client/actionOverflow.js +556 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/arrivalCamera.js +50 -0
- package/kits/hub-game/code/client/askSlot.js +117 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +311 -35
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +253 -0
- package/kits/hub-game/code/client/backVisibility.js +13 -0
- package/kits/hub-game/code/client/ballot.js +472 -0
- package/kits/hub-game/code/client/build.js +38 -0
- package/kits/hub-game/code/client/chat.js +41 -5
- package/kits/hub-game/code/client/chatModeration.js +5 -0
- package/kits/hub-game/code/client/chrome.js +2144 -160
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/crowdNames.js +241 -0
- package/kits/hub-game/code/client/decor.js +515 -0
- package/kits/hub-game/code/client/defaultEnvironment.js +194 -0
- package/kits/hub-game/code/client/doorErrors.js +39 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/fall.js +18 -0
- package/kits/hub-game/code/client/farAvatars.js +233 -0
- package/kits/hub-game/code/client/firstJoin.js +9 -2
- package/kits/hub-game/code/client/fpsTelemetry.js +50 -0
- package/kits/hub-game/code/client/frameBatch.js +5 -0
- package/kits/hub-game/code/client/grab.js +368 -29
- package/kits/hub-game/code/client/hookLayer.js +385 -20
- package/kits/hub-game/code/client/hudCopy.js +51 -0
- package/kits/hub-game/code/client/hudRate.js +20 -0
- package/kits/hub-game/code/client/idle.js +177 -24
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/invites.js +231 -0
- package/kits/hub-game/code/client/joinError.js +9 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +234 -0
- package/kits/hub-game/code/client/landscapeLayout.js +17 -0
- package/kits/hub-game/code/client/layoutCache.js +264 -0
- package/kits/hub-game/code/client/loadTelemetry.js +20 -0
- package/kits/hub-game/code/client/loadingCover.js +148 -0
- package/kits/hub-game/code/client/loadingEntry.js +8 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/menuRows.js +43 -0
- package/kits/hub-game/code/client/modelReady.js +7 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/padCueArrival.js +23 -0
- package/kits/hub-game/code/client/padCues.js +112 -0
- package/kits/hub-game/code/client/padOccupancy.js +88 -0
- package/kits/hub-game/code/client/padReadability.js +26 -0
- package/kits/hub-game/code/client/padRings.js +69 -0
- package/kits/hub-game/code/client/pushVisit.js +14 -0
- package/kits/hub-game/code/client/quality.js +205 -0
- package/kits/hub-game/code/client/qualityEntry.js +55 -0
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/safeLayout.js +338 -0
- package/kits/hub-game/code/client/safeStyle.js +42 -0
- package/kits/hub-game/code/client/say.js +12 -3
- package/kits/hub-game/code/client/shot.js +146 -0
- package/kits/hub-game/code/client/shotFit.js +56 -0
- package/kits/hub-game/code/client/signIn.js +28 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +162 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +714 -59
- package/kits/hub-game/code/client/tiers.js +543 -52
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +39 -2
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/weakestLookBake.js +92 -0
- package/kits/hub-game/code/client/weakestTier.js +295 -0
- package/kits/hub-game/code/client/wear.js +461 -170
- package/kits/hub-game/code/client/worldLabels.js +241 -0
- package/kits/hub-game/code/client/yours.js +200 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/npcDisplayText.js +55 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/act.js +124 -0
- package/kits/hub-game/code/server/actions.js +138 -0
- package/kits/hub-game/code/server/actors.js +11 -2
- package/kits/hub-game/code/server/analytics.js +83 -0
- package/kits/hub-game/code/server/anonymousEntry.js +49 -0
- package/kits/hub-game/code/server/arrivalPose.js +36 -0
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +107 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/doorAnalytics.js +52 -0
- package/kits/hub-game/code/server/earned.js +478 -0
- package/kits/hub-game/code/server/frameBatch.js +183 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +272 -0
- package/kits/hub-game/code/server/history.js +7 -0
- package/kits/hub-game/code/server/hub.js +2510 -95
- package/kits/hub-game/code/server/idle.js +60 -12
- package/kits/hub-game/code/server/index.js +28 -6
- package/kits/hub-game/code/server/invites.js +19 -0
- package/kits/hub-game/code/server/labels.js +36 -2
- package/kits/hub-game/code/server/loadAbandon.js +106 -0
- package/kits/hub-game/code/server/manifest.js +586 -7
- package/kits/hub-game/code/server/menu.js +161 -0
- package/kits/hub-game/code/server/npcs.js +1025 -113
- package/kits/hub-game/code/server/observe.js +408 -0
- package/kits/hub-game/code/server/padOccupancy.js +85 -0
- package/kits/hub-game/code/server/party.js +2 -2
- package/kits/hub-game/code/server/players.js +30 -0
- package/kits/hub-game/code/server/resumePose.js +152 -0
- package/kits/hub-game/code/server/say.js +1 -1
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +123 -0
- package/kits/hub-game/code/server/storageLimit.js +187 -0
- package/kits/hub-game/code/server/vis.js +175 -0
- package/kits/hub-game/code/server/wear.js +12 -0
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/act.js +35 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/danceIdle.js +28 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/loadStages.js +12 -0
- package/kits/hub-game/code/shared/quality.js +74 -0
- package/kits/hub-game/code/shared/say.js +2 -0
- package/kits/hub-game/code/shared/shot.js +53 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1753 -202
- package/kits/hub-game/docs/analytics.md +279 -0
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +3475 -77
- package/kits/hub-game/docs/home-pieces.md +71 -0
- package/kits/hub-game/docs/observed-progress.md +252 -0
- package/kits/hub-game/main.jsx +2 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +10 -1
- package/kits/hub-game/package.json +6 -2
- package/kits/hub-game/play/player.js +142 -0
- package/kits/hub-game/play/registry.js +47 -0
- package/kits/hub-game/play.jsx +37 -0
- package/kits/hub-game/scripts/check.mjs +117 -16
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +132 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +26 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +123 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/pose-storage-fixture.mjs +46 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-act-client.mjs +186 -0
- package/kits/hub-game/scripts/test-act.mjs +171 -0
- package/kits/hub-game/scripts/test-action-layout.mjs +80 -0
- package/kits/hub-game/scripts/test-action-observers.mjs +46 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +853 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +38 -23
- package/kits/hub-game/scripts/test-analytics.mjs +76 -0
- package/kits/hub-game/scripts/test-anonymous-entry.mjs +28 -0
- package/kits/hub-game/scripts/test-arrival-pose-server.mjs +196 -0
- package/kits/hub-game/scripts/test-arrival-pose.mjs +24 -0
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask-slot.mjs +85 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +792 -0
- package/kits/hub-game/scripts/test-avatar.mjs +584 -7
- package/kits/hub-game/scripts/test-back-visibility.mjs +82 -0
- package/kits/hub-game/scripts/test-ballot.mjs +1008 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +121 -13
- package/kits/hub-game/scripts/test-build.mjs +49 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +863 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +216 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-control-layout-dom.mjs +120 -0
- package/kits/hub-game/scripts/test-crowd-names.mjs +205 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +344 -0
- package/kits/hub-game/scripts/test-decor.mjs +464 -0
- package/kits/hub-game/scripts/test-default-environment-root.mjs +95 -0
- package/kits/hub-game/scripts/test-default-environment.mjs +267 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +58 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +100 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1224 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-far-avatars.mjs +340 -0
- package/kits/hub-game/scripts/test-fps-telemetry.mjs +112 -0
- package/kits/hub-game/scripts/test-frame-batch.mjs +252 -0
- package/kits/hub-game/scripts/test-fresh-friends.mjs +118 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-orbit.mjs +961 -0
- package/kits/hub-game/scripts/test-grab.mjs +7 -0
- package/kits/hub-game/scripts/test-hats.mjs +422 -168
- package/kits/hub-game/scripts/test-high-only.mjs +170 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +758 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1594 -12
- package/kits/hub-game/scripts/test-hud-clear.mjs +484 -57
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +100 -0
- package/kits/hub-game/scripts/test-hud-rate.mjs +224 -0
- package/kits/hub-game/scripts/test-hud-safe-visibility-dom.mjs +83 -0
- package/kits/hub-game/scripts/test-idle.mjs +427 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +513 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-interest.mjs +15 -0
- package/kits/hub-game/scripts/test-invites-client.mjs +430 -0
- package/kits/hub-game/scripts/test-invites.mjs +109 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +664 -0
- package/kits/hub-game/scripts/test-landscape-layout.mjs +194 -0
- package/kits/hub-game/scripts/test-list-scroll-dom.mjs +49 -0
- package/kits/hub-game/scripts/test-load-abandon.mjs +246 -0
- package/kits/hub-game/scripts/test-loading-cover.mjs +162 -0
- package/kits/hub-game/scripts/test-manifest.mjs +472 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +585 -0
- package/kits/hub-game/scripts/test-menu.mjs +319 -0
- package/kits/hub-game/scripts/test-npcs.mjs +2528 -13
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-observed.mjs +745 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-pad-cues.mjs +304 -0
- package/kits/hub-game/scripts/test-pad-occupancy.mjs +177 -0
- package/kits/hub-game/scripts/test-picker.mjs +541 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +690 -0
- package/kits/hub-game/scripts/test-progress-reset.mjs +559 -0
- package/kits/hub-game/scripts/test-push-visit.mjs +26 -0
- package/kits/hub-game/scripts/test-quality.mjs +385 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1733 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-resume-action-order.mjs +598 -0
- package/kits/hub-game/scripts/test-resume-held.mjs +239 -0
- package/kits/hub-game/scripts/test-resume-pose.mjs +142 -0
- package/kits/hub-game/scripts/test-safe-events-dom.mjs +116 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +330 -0
- package/kits/hub-game/scripts/test-say.mjs +1 -1
- package/kits/hub-game/scripts/test-shot.mjs +901 -0
- package/kits/hub-game/scripts/test-signin-client.mjs +45 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5437 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +449 -0
- package/kits/hub-game/scripts/test-storage-limit.mjs +333 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1904 -0
- package/kits/hub-game/scripts/test-talk-overlay-dom.mjs +130 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +412 -0
- package/kits/hub-game/scripts/test-tiers.mjs +476 -2
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +22 -22
- package/kits/hub-game/scripts/test-vis.mjs +770 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-weakest-tier.mjs +924 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +367 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +210 -0
- package/kits/hub-game/scripts/test-yours.mjs +403 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/joinFailure.js +27 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +139 -0
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +443 -34
- package/kits/multiplayer-3d/package-lock.json +8 -1
- package/kits/multiplayer-3d/package.json +3 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +436 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +624 -0
- package/kits/physics-2d/CLAUDE.md +19 -1
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/frozenActors.js +233 -0
- package/kits/physics-2d/engine/scene.js +337 -3
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/eslint.config.js +1 -1
- package/kits/physics-2d/play/behaviors/AnalogStick.js +198 -0
- package/kits/physics-2d/play/behaviors/Camera.js +40 -0
- package/kits/physics-2d/play/behaviors/Collider.js +122 -0
- package/kits/physics-2d/play/behaviors/Draggable.js +115 -0
- package/kits/physics-2d/play/behaviors/Goal.js +46 -0
- package/kits/physics-2d/play/behaviors/Joints.js +126 -0
- package/kits/physics-2d/play/behaviors/Layout.js +71 -0
- package/kits/physics-2d/play/behaviors/RigidBody.js +57 -0
- package/kits/physics-2d/play/behaviors/Slingshot.js +142 -0
- package/kits/physics-2d/play/behaviors/SoundPlayer.js +263 -0
- package/kits/physics-2d/play/behaviors/Sprite.js +406 -0
- package/kits/physics-2d/play/behaviors/Style.js +209 -0
- package/kits/physics-2d/play/behaviors/Text.js +85 -0
- package/kits/physics-2d/play/behaviors/Video.js +93 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
- package/kits/physics-3d/CLAUDE.md +42 -529
- package/kits/physics-3d/behaviors/Body.jsx +3 -0
- package/kits/physics-3d/behaviors/Model.jsx +3 -0
- package/kits/physics-3d/behaviors/Player.jsx +661 -87
- package/kits/physics-3d/behaviors/Shape.jsx +3 -0
- package/kits/physics-3d/behaviors/Solid.jsx +3 -0
- package/kits/physics-3d/behaviors/Transform.jsx +3 -0
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/engine-camera.md +542 -0
- package/kits/physics-3d/docs/engine-frame-cap.md +136 -0
- package/kits/physics-3d/docs/engine-load.md +149 -0
- package/kits/physics-3d/docs/engine-look.md +114 -0
- package/kits/physics-3d/docs/engine-shadows.md +372 -0
- package/kits/physics-3d/docs/engine-skip-work.md +187 -0
- package/kits/physics-3d/docs/engine-sky.md +198 -0
- package/kits/physics-3d/docs/engine-static-actors.md +226 -0
- package/kits/physics-3d/docs/engine-view.md +37 -0
- package/kits/physics-3d/docs/pxmodel-format.md +9 -1
- package/kits/physics-3d/engine3d/PlayOnly3D.jsx +5 -1
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +19 -277
- package/kits/physics-3d/engine3d/actornode.js +87 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/branches.js +3 -13
- package/kits/physics-3d/engine3d/cage.js +2 -7
- package/kits/physics-3d/engine3d/cageops.js +2 -17
- package/kits/physics-3d/engine3d/dataBehaviors.js +12 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +99 -0
- package/kits/physics-3d/engine3d/frozenphysics.js +140 -0
- package/kits/physics-3d/engine3d/frozenstatics.js +273 -0
- package/kits/physics-3d/engine3d/gait.js +126 -0
- package/kits/physics-3d/engine3d/initialModelFiles.js +18 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +514 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/modelFiles.js +3 -17
- package/kits/physics-3d/engine3d/modelMath.js +49 -0
- package/kits/physics-3d/engine3d/modelready.js +16 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +106 -21
- package/kits/physics-3d/engine3d/optimize.js +9 -5
- package/kits/physics-3d/engine3d/orbitinput.js +522 -10
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/partgeometry.js +1 -16
- package/kits/physics-3d/engine3d/paths.js +1 -9
- package/kits/physics-3d/engine3d/playTimings.js +50 -0
- package/kits/physics-3d/engine3d/playerRun.js +372 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/rapier.js +27 -0
- package/kits/physics-3d/engine3d/scatter.js +1 -11
- package/kits/physics-3d/engine3d/shadowfade.js +890 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/squarefirst.js +177 -0
- package/kits/physics-3d/engine3d/stillshadows.js +399 -0
- package/kits/physics-3d/engine3d/sweep.js +1 -25
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +1253 -76
- package/kits/physics-3d/eslint.config.js +2 -1
- package/kits/physics-3d/main.jsx +10 -2
- package/kits/physics-3d/package-lock.json +7 -0
- package/kits/physics-3d/package.json +5 -1
- package/kits/physics-3d/play/behaviors/Body.js +31 -0
- package/kits/physics-3d/play/behaviors/Door.js +37 -0
- package/kits/physics-3d/play/behaviors/Lookable.js +16 -0
- package/kits/physics-3d/play/behaviors/Model.js +23 -0
- package/kits/physics-3d/play/behaviors/Pickup.js +46 -0
- package/kits/physics-3d/play/behaviors/Player.js +1204 -0
- package/kits/physics-3d/play/behaviors/Shape.js +47 -0
- package/kits/physics-3d/play/behaviors/Solid.js +16 -0
- package/kits/physics-3d/play/behaviors/Transform.js +29 -0
- package/kits/physics-3d/pnpm-lock.yaml +8 -0
- package/kits/physics-3d/scripts/bench-shadow-fade.mjs +37 -0
- package/kits/physics-3d/scripts/build-rapier-gz.mjs +56 -0
- package/kits/physics-3d/scripts/frozen-statics-fixture.mjs +141 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +5 -1
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +2613 -82
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +2 -2
- package/kits/physics-3d/scripts/test-empty-gait-hints.mjs +89 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +438 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-frozen-nested.mjs +49 -0
- package/kits/physics-3d/scripts/test-frozen-statics-legacy-physics2d.mjs +123 -0
- package/kits/physics-3d/scripts/test-frozen-statics.mjs +434 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +5 -2
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +2001 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +582 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +657 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-rapier-gz.mjs +106 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-square-first.mjs +921 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +10 -1
- package/kits/physics-3d/scripts/test-static-physics.mjs +4 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2174 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +7 -2
- package/kits/physics-3d/scripts/test-still-shadows.mjs +477 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +419 -9
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +33 -10
- package/kits/real-time/code/client/gameHooks.js +2 -0
- package/kits/real-time/code/client/joinOverlay.js +9 -4
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +102 -22
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// What the engine keeps, and how, for scenes that hold actors still
|
|
2
|
+
// (`"engine": { "staticActors": true }`; scene.js has the still set, the 3d
|
|
3
|
+
// kit's CLAUDE.md the terms). Two things, used the same way by everything that
|
|
4
|
+
// leaves still actors out of a per-frame pass: the runtime's `update`, the 3d
|
|
5
|
+
// world's pass over the actors, and the 3d physics pass.
|
|
6
|
+
//
|
|
7
|
+
// THE CLOCK. The versions of every scene's still set come from one sequence,
|
|
8
|
+
// so a number names one state of one runtime's still set, and `stillClock()`
|
|
9
|
+
// moves whenever any runtime's still set changes -- an actor touched or
|
|
10
|
+
// despawned, a scene loaded, the behaviour classes changed. The 3d kit's
|
|
11
|
+
// frozen nodes read it: a touch thaws them at once.
|
|
12
|
+
//
|
|
13
|
+
// THE KEEPER. A system may leave still actors out of a pass only while it has
|
|
14
|
+
// ADOPTED the still set, and the rule for that is one rule:
|
|
15
|
+
//
|
|
16
|
+
// A system adopts the still set only AFTER an ordinary pass (every actor)
|
|
17
|
+
// has completed without throwing. While any pass, or anything it calls back
|
|
18
|
+
// into, is running, no still state is trusted. Any interruption -- a throw,
|
|
19
|
+
// a pass entered from inside another, by this runtime or any other -- leaves
|
|
20
|
+
// the next pass ordinary.
|
|
21
|
+
//
|
|
22
|
+
// A StillKeeper is that rule and nothing else; each system has one and never
|
|
23
|
+
// keeps an adoption anywhere but in it:
|
|
24
|
+
//
|
|
25
|
+
// - `passes` counts every entry into the system's pass (settled or ordinary,
|
|
26
|
+
// whichever runtime, nested or not) and every other interruption a system
|
|
27
|
+
// reports (`interrupt`). It only goes up. (A throw needs no count of its
|
|
28
|
+
// own: the pass it leaves does not complete, and a pass around that one
|
|
29
|
+
// saw the entry.)
|
|
30
|
+
// - `begin(version)` counts the entry and says whether this pass may be
|
|
31
|
+
// settled: only when there is an adoption, made (or last confirmed) at the
|
|
32
|
+
// count as it stood just before this entry, for this very `version` of the
|
|
33
|
+
// still set. If not, the adoption is dropped THERE, before the pass does
|
|
34
|
+
// anything. A system with reasons of its own to refuse (`demote`) drops it
|
|
35
|
+
// the same way.
|
|
36
|
+
// - `end(pass, completed, version, adopt)` is called once, in the `finally`
|
|
37
|
+
// of the WHOLE operation. Unless the pass completed, `passes` is still the
|
|
38
|
+
// pass's own count (nobody entered, nothing was reported), no other pass of
|
|
39
|
+
// this system is running, and the still set's version is what it was at
|
|
40
|
+
// `begin`, the adoption is dropped. Otherwise a settled pass confirms its
|
|
41
|
+
// adoption at the new count, and an ordinary one records what `adopt()`
|
|
42
|
+
// returns (or nothing, if that is null).
|
|
43
|
+
//
|
|
44
|
+
// So nothing is ever put back: a pass that was interrupted leaves no adoption,
|
|
45
|
+
// whoever interrupted it and whatever they caught. An adoption holds numbers
|
|
46
|
+
// and whatever plain data its system adds; it names a runtime only by the
|
|
47
|
+
// version of its still set, which no other runtime's can equal.
|
|
48
|
+
let last = 0;
|
|
49
|
+
|
|
50
|
+
export function nextStillVersion() {
|
|
51
|
+
last += 1;
|
|
52
|
+
return last;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function stillClock() {
|
|
56
|
+
return last;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class StillKeeper {
|
|
60
|
+
passes = 0;
|
|
61
|
+
running = 0;
|
|
62
|
+
adopted = null;
|
|
63
|
+
|
|
64
|
+
begin(version) {
|
|
65
|
+
const before = this.passes;
|
|
66
|
+
this.passes += 1;
|
|
67
|
+
this.running += 1;
|
|
68
|
+
const adopted = this.adopted;
|
|
69
|
+
const settled = adopted !== null && adopted.at === before && adopted.version === version;
|
|
70
|
+
if (!settled) this.adopted = null;
|
|
71
|
+
return { mine: this.passes, version, settled };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Whether `pass` is still the only thing that has happened to this system
|
|
75
|
+
// since it began, on the still set it began with.
|
|
76
|
+
alone(pass, version) {
|
|
77
|
+
return this.passes === pass.mine && version === pass.version;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// A pass that began settled finds it may not be after all.
|
|
81
|
+
demote(pass) {
|
|
82
|
+
pass.settled = false;
|
|
83
|
+
this.adopted = null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Something the pass count does not see by itself: code that is not the
|
|
87
|
+
// engine's is about to run inside a pass, or the system is being reset.
|
|
88
|
+
interrupt() {
|
|
89
|
+
this.passes += 1;
|
|
90
|
+
this.adopted = null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
end(pass, completed, version, adopt) {
|
|
94
|
+
this.running -= 1;
|
|
95
|
+
if (!completed || this.running !== 0 || !this.alone(pass, version)) {
|
|
96
|
+
this.adopted = null;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (pass.settled) {
|
|
100
|
+
this.adopted.at = this.passes;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const data = adopt();
|
|
104
|
+
this.adopted = data ? { ...data, at: this.passes, version } : null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Optional client-owned cadence, in seconds. No flag means the original dt.
|
|
2
|
+
// Events and systems still run each frame; only this actor's update is budgeted.
|
|
3
|
+
const clocks = new WeakMap();
|
|
4
|
+
export function actorUpdateDt(actor, dt) {
|
|
5
|
+
const every = actor.runtime?.updateEvery;
|
|
6
|
+
if (!(Number.isFinite(every) && every > 0) || !(dt > 0)) {
|
|
7
|
+
const elapsed = clocks.get(actor)?.elapsed ?? 0;
|
|
8
|
+
clocks.delete(actor);
|
|
9
|
+
return elapsed ? dt + elapsed : dt;
|
|
10
|
+
}
|
|
11
|
+
const prior = clocks.get(actor);
|
|
12
|
+
if (!prior || prior.every !== every) {
|
|
13
|
+
clocks.set(actor, { every, elapsed: 0 });
|
|
14
|
+
return dt + (prior?.elapsed ?? 0);
|
|
15
|
+
}
|
|
16
|
+
prior.elapsed += dt;
|
|
17
|
+
if (prior.elapsed + 1e-9 < every) return null;
|
|
18
|
+
const elapsed = prior.elapsed;
|
|
19
|
+
prior.elapsed = 0;
|
|
20
|
+
return elapsed;
|
|
21
|
+
}
|
|
@@ -28,7 +28,7 @@ export default [
|
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
files: ['engine/**/*.{js,jsx}', 'editors/**/*.{js,jsx}', 'behaviors/**/*.{js,jsx}', '*.js', '*.jsx'],
|
|
31
|
+
files: ['play/**/*.{js,jsx}', 'engine/**/*.{js,jsx}', 'editors/**/*.{js,jsx}', 'behaviors/**/*.{js,jsx}', '*.js', '*.jsx'],
|
|
32
32
|
languageOptions: {
|
|
33
33
|
ecmaVersion: 'latest',
|
|
34
34
|
sourceType: 'module',
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// Generated from ../../behaviors/AnalogStick.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { acquirePress, GREEDY_CLAIM, length, clampLength } from '../../engine/physics/controls';
|
|
3
|
+
|
|
4
|
+
// AnalogStick: on-screen virtual joystick (press anywhere) that drives the
|
|
5
|
+
// actor with OG-style force mode — ramp in, hard top speed, idle-only brake.
|
|
6
|
+
// Screen-fixed: the ring stays under the thumb while a Camera scrolls, and does
|
|
7
|
+
// not rotate with the actor. Needs a RigidBody (dynamic) + Collider. Never
|
|
8
|
+
// touches an undriven axis.
|
|
9
|
+
//
|
|
10
|
+
// speed -> top speed at full deflection (px per fixed step).
|
|
11
|
+
// rampTime -> seconds from rest to speed at full deflection (0 = instant).
|
|
12
|
+
// slowDown -> deceleration while idle, speed units lost per second (0 = coast).
|
|
13
|
+
// turnBoost -> extra accel when velocity points away from the stick (OG turnFriction).
|
|
14
|
+
// maxRadius -> stick throw radius in pixels.
|
|
15
|
+
// axes -> 'horizontal' / 'vertical' / 'both'.
|
|
16
|
+
//
|
|
17
|
+
// Sibling hooks (fired on this actor only): onAnalogStickBegin / onAnalogStickEnd
|
|
18
|
+
// (actor, scene) — begin on first nonzero deflection, end on release or disable.
|
|
19
|
+
//
|
|
20
|
+
// Force-mode math lives here (only consumer): stickDrive / stickBrake return
|
|
21
|
+
// velocity deltas via applyImpulse — mass-independent, composable, and
|
|
22
|
+
// restricted to driven axes so gravity on an undriven axis is never clamped.
|
|
23
|
+
// Stick displacement from origin, clamped to maxRadius.
|
|
24
|
+
function stickVector(pointer, origin, maxRadius = 60) {
|
|
25
|
+
return clampLength({ x: pointer.x - origin.x, y: pointer.y - origin.y }, maxRadius);
|
|
26
|
+
}
|
|
27
|
+
// Card coords before the camera — for screen-fixed controls reading a pointer.
|
|
28
|
+
function screenPoint(pointer) {
|
|
29
|
+
return { x: pointer.screenX, y: pointer.screenY };
|
|
30
|
+
}
|
|
31
|
+
// Keep only the axes the stick is allowed to drive. An undriven axis (gravity
|
|
32
|
+
// in a platformer) must never be clamped or braked by the stick.
|
|
33
|
+
function drivenAxes(v, axes) {
|
|
34
|
+
return {
|
|
35
|
+
x: axes === 'vertical' ? 0 : v.x,
|
|
36
|
+
y: axes === 'horizontal' ? 0 : v.y,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Smallest signed angle from `from` to `to`, wrapped into [−π, π].
|
|
40
|
+
function angleDelta(from, to) {
|
|
41
|
+
let d = Math.atan2(to.y, to.x) - Math.atan2(from.y, from.x);
|
|
42
|
+
if (d > Math.PI)
|
|
43
|
+
d -= 2 * Math.PI;
|
|
44
|
+
if (d < -Math.PI)
|
|
45
|
+
d += 2 * Math.PI;
|
|
46
|
+
return d;
|
|
47
|
+
}
|
|
48
|
+
// Velocity delta while held: accelerate toward deflection × speed with turn
|
|
49
|
+
// boost on reversals, then clamp driven axes to `speed`. Impulse only.
|
|
50
|
+
function stickDrive(velocity, deflection, props = {}, dt) {
|
|
51
|
+
const speed = props.speed ?? 6;
|
|
52
|
+
const rampTime = props.rampTime ?? 0.2;
|
|
53
|
+
const turnBoost = props.turnBoost ?? 3;
|
|
54
|
+
const axes = props.axes ?? 'both';
|
|
55
|
+
const vDriven = drivenAxes(velocity, axes);
|
|
56
|
+
let boost = 1;
|
|
57
|
+
if (turnBoost > 0 && length(velocity) > 0 && length(deflection) > 0) {
|
|
58
|
+
boost = 1 + turnBoost * (Math.abs(angleDelta(velocity, deflection)) / Math.PI);
|
|
59
|
+
}
|
|
60
|
+
let delta;
|
|
61
|
+
if (rampTime <= 0) {
|
|
62
|
+
const target = drivenAxes({ x: deflection.x * speed, y: deflection.y * speed }, axes);
|
|
63
|
+
delta = { x: target.x - vDriven.x, y: target.y - vDriven.y };
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const accel = speed / rampTime;
|
|
67
|
+
delta = drivenAxes({ x: deflection.x * accel * boost * dt, y: deflection.y * accel * boost * dt }, axes);
|
|
68
|
+
const capped = clampLength({ x: vDriven.x + delta.x, y: vDriven.y + delta.y }, speed);
|
|
69
|
+
delta = { x: capped.x - vDriven.x, y: capped.y - vDriven.y };
|
|
70
|
+
}
|
|
71
|
+
return delta;
|
|
72
|
+
}
|
|
73
|
+
// Velocity delta while idle: Coulomb brake on driven axes only.
|
|
74
|
+
// `slowDown` is speed units lost per second (px/step per second). 0 = coast.
|
|
75
|
+
function stickBrake(velocity, props = {}, dt) {
|
|
76
|
+
const slowDown = props.slowDown ?? 20;
|
|
77
|
+
if (slowDown <= 0)
|
|
78
|
+
return { x: 0, y: 0 };
|
|
79
|
+
const axes = props.axes ?? 'both';
|
|
80
|
+
const vDriven = drivenAxes(velocity, axes);
|
|
81
|
+
const len = length(vDriven);
|
|
82
|
+
if (len === 0)
|
|
83
|
+
return { x: 0, y: 0 };
|
|
84
|
+
const reduce = Math.min(len, slowDown * dt);
|
|
85
|
+
const s = -reduce / len;
|
|
86
|
+
return { x: vDriven.x * s, y: vDriven.y * s };
|
|
87
|
+
}
|
|
88
|
+
function fireStickHook(actor, scene, hook) {
|
|
89
|
+
scene.forEachBehavior(actor, (inst) => inst[hook]?.(actor, scene));
|
|
90
|
+
}
|
|
91
|
+
function resetStick(state) {
|
|
92
|
+
state.began = false;
|
|
93
|
+
state.pointerId = null;
|
|
94
|
+
state.origin = null;
|
|
95
|
+
state.knob = null;
|
|
96
|
+
}
|
|
97
|
+
class AnalogStick {
|
|
98
|
+
static behaviorName = 'AnalogStick';
|
|
99
|
+
// Drives a body, so it needs one: Collider + dynamic RigidBody.
|
|
100
|
+
static expectedSiblings = ['Collider', 'RigidBody'];
|
|
101
|
+
static defaultProps = {
|
|
102
|
+
speed: 6,
|
|
103
|
+
rampTime: 0.2,
|
|
104
|
+
slowDown: 20,
|
|
105
|
+
turnBoost: 3,
|
|
106
|
+
maxRadius: 60,
|
|
107
|
+
axes: 'both',
|
|
108
|
+
};
|
|
109
|
+
// `maxRadius` is the stick's travel in px; below ~10 the knob has no usable
|
|
110
|
+
// throw and the control reads as broken. slowDown humanizes to "Slow Down".
|
|
111
|
+
static propertyMeta = {
|
|
112
|
+
speed: { min: 0, step: 0.5 },
|
|
113
|
+
rampTime: { min: 0, step: 0.05 },
|
|
114
|
+
slowDown: { min: 0, step: 1 },
|
|
115
|
+
turnBoost: { min: 0, step: 0.5 },
|
|
116
|
+
maxRadius: { min: 10, step: 5 },
|
|
117
|
+
};
|
|
118
|
+
static initialState = { began: false, pointerId: null, origin: null, knob: null };
|
|
119
|
+
constructor(props) {
|
|
120
|
+
this.props = props;
|
|
121
|
+
}
|
|
122
|
+
// The finger this stick is following, placing it on a fresh press if it isn't
|
|
123
|
+
// following one yet. The stick stays with the finger that placed it, so a
|
|
124
|
+
// second finger elsewhere (another stick, a drag) never yanks it -- and it
|
|
125
|
+
// gives the pointer up if a targeted control outranks its claim.
|
|
126
|
+
trackedPointer(actor, scene) {
|
|
127
|
+
const state = this.state;
|
|
128
|
+
if (state.pointerId != null && scene.ownsPointer(state.pointerId, actor.id)) {
|
|
129
|
+
const held = scene.pointers.get(state.pointerId);
|
|
130
|
+
if (held?.down)
|
|
131
|
+
return held;
|
|
132
|
+
}
|
|
133
|
+
state.pointerId = null;
|
|
134
|
+
// Any fresh press will do -- the stick is placed wherever you touch -- but
|
|
135
|
+
// only one nobody more specific wants.
|
|
136
|
+
const press = acquirePress(scene, actor.id, () => GREEDY_CLAIM);
|
|
137
|
+
if (!press)
|
|
138
|
+
return null;
|
|
139
|
+
state.pointerId = press.id;
|
|
140
|
+
state.origin = { x: press.screenX, y: press.screenY };
|
|
141
|
+
return press;
|
|
142
|
+
}
|
|
143
|
+
update(actor, scene, dt) {
|
|
144
|
+
const state = this.state;
|
|
145
|
+
const p = this.trackedPointer(actor, scene);
|
|
146
|
+
if (p?.down && state.origin) {
|
|
147
|
+
const maxRadius = this.props.maxRadius ?? 60;
|
|
148
|
+
const sp = screenPoint(p);
|
|
149
|
+
const knob = stickVector(sp, state.origin, maxRadius);
|
|
150
|
+
state.knob = knob;
|
|
151
|
+
const deflection = { x: knob.x / maxRadius, y: knob.y / maxRadius };
|
|
152
|
+
const vel = scene.physics.getVelocity(actor);
|
|
153
|
+
scene.physics.applyImpulse(actor, stickDrive(vel, deflection, this.props, dt));
|
|
154
|
+
// OG fires on first movement, not on a still press.
|
|
155
|
+
if (!state.began && length(deflection) > 0) {
|
|
156
|
+
state.began = true;
|
|
157
|
+
fireStickHook(actor, scene, 'onAnalogStickBegin');
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (state.began) {
|
|
162
|
+
fireStickHook(actor, scene, 'onAnalogStickEnd');
|
|
163
|
+
}
|
|
164
|
+
resetStick(state);
|
|
165
|
+
// Idle every frame: brake on driven axes only (gravity/momentum elsewhere stay).
|
|
166
|
+
const vel = scene.physics.getVelocity(actor);
|
|
167
|
+
scene.physics.applyImpulse(actor, stickBrake(vel, this.props, dt));
|
|
168
|
+
}
|
|
169
|
+
// Switched off mid-hold: fire end and drop runtime state. `update` stops
|
|
170
|
+
// running once disabled, so this is the only chance to release the gesture.
|
|
171
|
+
onDisable(actor, scene) {
|
|
172
|
+
const state = this.state;
|
|
173
|
+
if (state.began)
|
|
174
|
+
fireStickHook(actor, scene, 'onAnalogStickEnd');
|
|
175
|
+
resetStick(state);
|
|
176
|
+
}
|
|
177
|
+
// Drawn in screen space (drawUi) so the ring stays under the thumb while the
|
|
178
|
+
// camera scrolls, and doesn't rotate with the actor.
|
|
179
|
+
drawUi(actor, scene, ctx) {
|
|
180
|
+
const state = this.state;
|
|
181
|
+
if (!state.origin)
|
|
182
|
+
return;
|
|
183
|
+
const o = state.origin;
|
|
184
|
+
const k = state.knob ?? { x: 0, y: 0 };
|
|
185
|
+
const radius = this.props.maxRadius ?? 60;
|
|
186
|
+
ctx.strokeStyle = 'rgba(255, 255, 255, 0.5)';
|
|
187
|
+
ctx.lineWidth = 3;
|
|
188
|
+
ctx.beginPath();
|
|
189
|
+
ctx.arc(o.x, o.y, radius, 0, Math.PI * 2);
|
|
190
|
+
ctx.stroke();
|
|
191
|
+
ctx.fillStyle = 'rgba(255, 255, 255, 0.85)';
|
|
192
|
+
ctx.beginPath();
|
|
193
|
+
ctx.arc(o.x + k.x, o.y + k.y, 20, 0, Math.PI * 2);
|
|
194
|
+
ctx.fill();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export { AnalogStick };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Camera.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { layoutCenter } from '../../engine/layout';
|
|
3
|
+
import { cardSize } from '../../engine/scene';
|
|
4
|
+
|
|
5
|
+
// Follow camera: keeps the target actor centered in the viewport, clamped to
|
|
6
|
+
// the room bounds so the empty area past the room edges never scrolls in.
|
|
7
|
+
class Camera {
|
|
8
|
+
static behaviorName = 'Camera';
|
|
9
|
+
static defaultProps = {
|
|
10
|
+
target: '',
|
|
11
|
+
followX: true,
|
|
12
|
+
followY: true,
|
|
13
|
+
roomWidth: 900,
|
|
14
|
+
roomHeight: 1100,
|
|
15
|
+
};
|
|
16
|
+
constructor(props) {
|
|
17
|
+
this.props = props;
|
|
18
|
+
}
|
|
19
|
+
update(_actor, scene) {
|
|
20
|
+
const target = this.props.target ? scene.getActor(this.props.target) : undefined;
|
|
21
|
+
const center = layoutCenter(target?.components.Layout);
|
|
22
|
+
if (!center)
|
|
23
|
+
return;
|
|
24
|
+
const desiredX = center.x - cardSize.width / 2;
|
|
25
|
+
const desiredY = center.y - cardSize.height / 2;
|
|
26
|
+
scene.camera = {
|
|
27
|
+
x: this.props.followX
|
|
28
|
+
? clamp(desiredX, 0, this.props.roomWidth - cardSize.width)
|
|
29
|
+
: 0,
|
|
30
|
+
y: this.props.followY
|
|
31
|
+
? clamp(desiredY, 0, this.props.roomHeight - cardSize.height)
|
|
32
|
+
: 0,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function clamp(value, min, max) {
|
|
37
|
+
return Math.max(min, Math.min(Math.max(min, max), value));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { Camera };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Collider.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { POSITIVE } from '../../engine/propertyRanges';
|
|
3
|
+
import { computeAutoFit, getColliderShapes } from '../../engine/collider';
|
|
4
|
+
export { getColliderRect, getColliderShapes, intersects } from '../../engine/collider';
|
|
5
|
+
|
|
6
|
+
// The pre-list spelling of the shape, still on decks authored before shapes
|
|
7
|
+
// became a list. Only consulted when there is no `shapes[0]` to ask.
|
|
8
|
+
function legacyShape(props) {
|
|
9
|
+
return typeof props.shape === 'string' && props.shape ? props.shape : 'box';
|
|
10
|
+
}
|
|
11
|
+
// Draw one resolved (world-space) collider shape as an outline.
|
|
12
|
+
function drawShape(ctx, s) {
|
|
13
|
+
if (s.type === 'circle') {
|
|
14
|
+
ctx.beginPath();
|
|
15
|
+
ctx.arc(s.cx, s.cy, s.radius, 0, Math.PI * 2);
|
|
16
|
+
ctx.stroke();
|
|
17
|
+
}
|
|
18
|
+
else if (s.type === 'triangle' || s.type === 'polygon') {
|
|
19
|
+
if (!s.points || s.points.length < 2)
|
|
20
|
+
return;
|
|
21
|
+
ctx.beginPath();
|
|
22
|
+
ctx.moveTo(s.points[0].x, s.points[0].y);
|
|
23
|
+
for (let k = 1; k < s.points.length; k++)
|
|
24
|
+
ctx.lineTo(s.points[k].x, s.points[k].y);
|
|
25
|
+
ctx.closePath();
|
|
26
|
+
ctx.stroke();
|
|
27
|
+
}
|
|
28
|
+
else if (s.angle) {
|
|
29
|
+
// Rotate the outline about the box center to match the (angled) matter part.
|
|
30
|
+
ctx.save();
|
|
31
|
+
ctx.translate(s.cx, s.cy);
|
|
32
|
+
ctx.rotate((s.angle * Math.PI) / 180);
|
|
33
|
+
ctx.strokeRect(-s.width / 2 + 1, -s.height / 2 + 1, s.width - 2, s.height - 2);
|
|
34
|
+
ctx.restore();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
ctx.strokeRect(s.x + 1, s.y + 1, s.width - 2, s.height - 2);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class Collider {
|
|
41
|
+
static behaviorName = 'Collider';
|
|
42
|
+
// A Collider is a LIST of shapes (`shapes`), each a fraction of the Layout box
|
|
43
|
+
// -- so it keeps its relative size when the box is resized. Unset `shapes` = one
|
|
44
|
+
// full-box shape. Only material fields live here; geometry is authored into
|
|
45
|
+
// `shapes` through the inspector.
|
|
46
|
+
static defaultProps = {
|
|
47
|
+
// `isTrigger` marks a sensor: reports overlaps (draws yellow, pass-through
|
|
48
|
+
// zone for pickup/goal logic) but doesn't block -- collisions are data.
|
|
49
|
+
isTrigger: false,
|
|
50
|
+
debug: false,
|
|
51
|
+
// Physics material, read by engine/physics/matterBridge.js. `bounciness` =
|
|
52
|
+
// restitution (0 dead .. ~1 very bouncy); `friction` = surface friction;
|
|
53
|
+
// `density` sets mass (= density x total shape area); matter's default 0.001.
|
|
54
|
+
bounciness: 0,
|
|
55
|
+
friction: 0.1,
|
|
56
|
+
// `frictionStatic` is stiction -- resistance to *starting* to slide (matter
|
|
57
|
+
// default 0.5). `density` sets mass (= density x total shape area).
|
|
58
|
+
frictionStatic: 0.5,
|
|
59
|
+
density: 0.001,
|
|
60
|
+
};
|
|
61
|
+
// Shape, and how many of them -- a compound collider's shape count is the
|
|
62
|
+
// thing you cannot see from the canvas without turning debug on.
|
|
63
|
+
static summary(props) {
|
|
64
|
+
const list = Array.isArray(props.shapes) ? props.shapes : [];
|
|
65
|
+
// A compound collider's shape COUNT is the thing you cannot see from the
|
|
66
|
+
// canvas without turning debug on, so it wins over naming one of them.
|
|
67
|
+
const shape = list.length > 1
|
|
68
|
+
? `${list.length} shapes`
|
|
69
|
+
// `shapes[0].type` is where the shape lives now; `props.shape` is the
|
|
70
|
+
// pre-list spelling, still on decks authored before the change.
|
|
71
|
+
: list[0]?.type ?? legacyShape(props);
|
|
72
|
+
return props.isTrigger ? `${shape} · trigger` : shape;
|
|
73
|
+
}
|
|
74
|
+
// Inspector ranges. No `max` on any of these: matter treats them as open-ended
|
|
75
|
+
// (bounciness "can exceed 1" per the docs, and stiction above 1 is meaningful),
|
|
76
|
+
// and a max is a hard authoring ceiling here -- typed entry is clamped to it,
|
|
77
|
+
// not just the slider. `min: 0` and a fine step are the parts that are safe.
|
|
78
|
+
static propertyMeta = {
|
|
79
|
+
bounciness: POSITIVE,
|
|
80
|
+
friction: POSITIVE,
|
|
81
|
+
frictionStatic: POSITIVE,
|
|
82
|
+
};
|
|
83
|
+
constructor(props) {
|
|
84
|
+
this.props = props;
|
|
85
|
+
}
|
|
86
|
+
// Seed props when first added: fit a single box to the sprite's opaque bounds
|
|
87
|
+
// (or the full box when there's nothing to fit to).
|
|
88
|
+
static initialProps(actor, ctx) {
|
|
89
|
+
const fit = computeAutoFit(actor, ctx?.sprites);
|
|
90
|
+
return fit ? { ...Collider.defaultProps, shapes: [fit] } : { ...Collider.defaultProps };
|
|
91
|
+
}
|
|
92
|
+
draw(actor, scene, ctx, options) {
|
|
93
|
+
// A selected instance always shows its collider -- but the editor's selection
|
|
94
|
+
// overlay draws it, so skip here to avoid a double outline.
|
|
95
|
+
if (options.colliderOverlayIds?.includes(actor.id))
|
|
96
|
+
return;
|
|
97
|
+
// Otherwise draw when this actor's blueprint is selected in the hotbar (so
|
|
98
|
+
// all its instances light up), or when the per-collider debug flag is on
|
|
99
|
+
// (unselected actors in the editor, and during play).
|
|
100
|
+
const blueprintSelected = scene.usesBlueprint(actor, options.dimBlueprintPath);
|
|
101
|
+
if (!blueprintSelected && !options.showDebugColliders && !this.props.debug)
|
|
102
|
+
return;
|
|
103
|
+
const shapes = getColliderShapes(actor);
|
|
104
|
+
if (!shapes)
|
|
105
|
+
return;
|
|
106
|
+
const isSensor = Boolean(this.props.isTrigger) || this.props.kind === 'pickup';
|
|
107
|
+
// When editing this blueprint (hotbar), highlight the shape the inspector has
|
|
108
|
+
// selected so you can tell which chip is which on its lit instances -- the
|
|
109
|
+
// selected-instance path does this via the SelectionOverlay instead.
|
|
110
|
+
const highlight = blueprintSelected ? options.colliderShapeSel ?? -1 : -1;
|
|
111
|
+
ctx.save();
|
|
112
|
+
shapes.forEach((s, k) => {
|
|
113
|
+
const on = k === highlight;
|
|
114
|
+
ctx.strokeStyle = on ? '#ffd24a' : isSensor ? '#ffe17a' : '#8db7ff';
|
|
115
|
+
ctx.lineWidth = on ? 3.5 : 2;
|
|
116
|
+
drawShape(ctx, s);
|
|
117
|
+
});
|
|
118
|
+
ctx.restore();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { Collider };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Draggable.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { UNIT } from '../../engine/propertyRanges';
|
|
3
|
+
import { TARGETED_CLAIM, dragHold, inActorWorldSpace } from '../../engine/physics/controls';
|
|
4
|
+
|
|
5
|
+
// Draggable: grab the actor with the pointer and fling it around. The grab is a
|
|
6
|
+
// real physics constraint from the exact spot that was touched to the pointer,
|
|
7
|
+
// so the object still collides with the world AND turns when held off-center --
|
|
8
|
+
// grab a plank by its end and it swings.
|
|
9
|
+
//
|
|
10
|
+
// The touch zone is the actor's COLLIDER at its current orientation (via
|
|
11
|
+
// scene.physics.actorAtPoint), not its Layout box, so a circle is round and a
|
|
12
|
+
// rotated actor's grabbable area rotates with it.
|
|
13
|
+
//
|
|
14
|
+
// A drag belongs to the finger that started it: it follows that pointer alone
|
|
15
|
+
// until that pointer lifts, so later fingers can't steal or drop it, and a
|
|
16
|
+
// second finger can drag a second actor at the same time.
|
|
17
|
+
//
|
|
18
|
+
// stiffness -> how tightly the object is held, 0 (loose and swingy) to 1
|
|
19
|
+
// (rigid, snaps to the pointer). Mapped through `dragHold`, which spreads the
|
|
20
|
+
// authored range over matter's very compressed useful band and eases damping
|
|
21
|
+
// along with it, so the low end is genuinely floppy rather than just slow.
|
|
22
|
+
class Draggable {
|
|
23
|
+
static behaviorName = 'Draggable';
|
|
24
|
+
// Inert without a body to hold: needs a Collider (to have one at all) and a
|
|
25
|
+
// dynamic RigidBody (so the grab can actually move it).
|
|
26
|
+
static expectedSiblings = ['Collider', 'RigidBody'];
|
|
27
|
+
static defaultProps = {
|
|
28
|
+
stiffness: 0.3,
|
|
29
|
+
};
|
|
30
|
+
// 0..1 with a fine step, so the inspector renders a real slider over the
|
|
31
|
+
// whole range rather than an unbounded whole-number scrubber.
|
|
32
|
+
static propertyMeta = {
|
|
33
|
+
stiffness: UNIT,
|
|
34
|
+
};
|
|
35
|
+
static initialState = { pointerId: null };
|
|
36
|
+
constructor(props) {
|
|
37
|
+
this.props = props;
|
|
38
|
+
}
|
|
39
|
+
// Switched off mid-drag, this is the only thing that can let go: `update` is
|
|
40
|
+
// the sole caller of `release`, and it stops running the moment the behavior
|
|
41
|
+
// is disabled. Without this the actor stays welded to the pointer.
|
|
42
|
+
onDisable(actor, scene) {
|
|
43
|
+
if (this.state.pointerId == null)
|
|
44
|
+
return;
|
|
45
|
+
scene.physics.release(actor);
|
|
46
|
+
this.state.pointerId = null;
|
|
47
|
+
}
|
|
48
|
+
update(actor, scene) {
|
|
49
|
+
const state = this.state;
|
|
50
|
+
const held = state.pointerId == null ? null : scene.pointers.get(state.pointerId);
|
|
51
|
+
// The finger that started this drag lifted (or its contact was cancelled).
|
|
52
|
+
if (state.pointerId != null && !held?.down) {
|
|
53
|
+
scene.physics.release(actor);
|
|
54
|
+
state.pointerId = null;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (held)
|
|
58
|
+
return scene.physics.moveGrab(actor, held.x, held.y);
|
|
59
|
+
// Idle: look for a new press on this actor. Each pointer carries its own
|
|
60
|
+
// press edge, so a finger landing while another is already down still
|
|
61
|
+
// registers -- and an actor already being dragged never gets here, so the
|
|
62
|
+
// first finger keeps it.
|
|
63
|
+
for (const p of scene.pointers.values()) {
|
|
64
|
+
if (!p.justPressed)
|
|
65
|
+
continue;
|
|
66
|
+
if (scene.physics.actorAtPoint(p.x, p.y)?.id !== actor.id)
|
|
67
|
+
continue;
|
|
68
|
+
// A press on this collider is unambiguous, so it outranks any control that
|
|
69
|
+
// merely takes presses anywhere -- whatever order the actors update in.
|
|
70
|
+
if (!scene.claimPointer(p.id, actor.id, TARGETED_CLAIM))
|
|
71
|
+
continue;
|
|
72
|
+
if (scene.physics.grab(actor, p.x, p.y, dragHold(this.props.stiffness))) {
|
|
73
|
+
state.pointerId = p.id;
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Feedback while held (castle-client's Drag overlay): a circle where the
|
|
79
|
+
// object is actually being held + a circle at the touch, connected by a line
|
|
80
|
+
// -- both translucent white with a solid white border. The handle comes from
|
|
81
|
+
// the constraint the simulation is solving, so it sits exactly where the
|
|
82
|
+
// physics holds the object and tracks it through rotation. Drawn in world
|
|
83
|
+
// space so the overlay itself doesn't spin with the actor.
|
|
84
|
+
draw(actor, scene, ctx) {
|
|
85
|
+
const id = this.state.pointerId;
|
|
86
|
+
if (id == null)
|
|
87
|
+
return;
|
|
88
|
+
const handle = scene.physics.grabPoint(actor);
|
|
89
|
+
const touch = scene.pointers.get(id);
|
|
90
|
+
if (!handle || !touch)
|
|
91
|
+
return;
|
|
92
|
+
inActorWorldSpace(ctx, actor.components.Layout, (g) => drawDrag(g, handle, { x: touch.x, y: touch.y }));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Matches sling/drag.cpp: line first, then a circle at each end -- translucent
|
|
96
|
+
// white fill (0.3) + solid white border (0.8), radius 18.
|
|
97
|
+
function drawDrag(ctx, a, b) {
|
|
98
|
+
const radius = 18;
|
|
99
|
+
ctx.lineWidth = 1.5;
|
|
100
|
+
ctx.strokeStyle = 'rgba(255, 255, 255, 0.8)';
|
|
101
|
+
ctx.beginPath();
|
|
102
|
+
ctx.moveTo(a.x, a.y);
|
|
103
|
+
ctx.lineTo(b.x, b.y);
|
|
104
|
+
ctx.stroke();
|
|
105
|
+
for (const p of [a, b]) {
|
|
106
|
+
ctx.beginPath();
|
|
107
|
+
ctx.arc(p.x, p.y, radius, 0, Math.PI * 2);
|
|
108
|
+
ctx.fillStyle = 'rgba(255, 255, 255, 0.3)';
|
|
109
|
+
ctx.fill();
|
|
110
|
+
ctx.strokeStyle = 'rgba(255, 255, 255, 0.8)';
|
|
111
|
+
ctx.stroke();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { Draggable };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Generated from ../../behaviors/Goal.jsx; run npm run sync:play-behaviors.
|
|
2
|
+
import { layoutRect } from '../../engine/layout';
|
|
3
|
+
|
|
4
|
+
// Goal: a sensor zone that counts when a physics body enters it, and flashes
|
|
5
|
+
// green briefly. Demonstrates the physics collision callbacks + a Collider with
|
|
6
|
+
// `isTrigger: true`. Put it on an actor with a Layout and a trigger Collider.
|
|
7
|
+
class Goal {
|
|
8
|
+
static behaviorName = 'Goal';
|
|
9
|
+
// Scores on collision callbacks, which only fire for an actor with a body.
|
|
10
|
+
static expectedSiblings = ['Collider'];
|
|
11
|
+
static defaultProps = {};
|
|
12
|
+
static initialState = { scored: 0, flashUntil: 0 };
|
|
13
|
+
constructor(props) {
|
|
14
|
+
this.props = props;
|
|
15
|
+
}
|
|
16
|
+
onCollisionEnter(actor, scene, other) {
|
|
17
|
+
if (!other.components.RigidBody)
|
|
18
|
+
return; // only score moving bodies
|
|
19
|
+
this.score();
|
|
20
|
+
}
|
|
21
|
+
// Public method other behaviors can call directly:
|
|
22
|
+
// `other.behaviors.Goal?.score()`. A pure refactor of the old
|
|
23
|
+
// onCollisionEnter body -- same increment, same flash window.
|
|
24
|
+
score() {
|
|
25
|
+
this.state.scored += 1;
|
|
26
|
+
this.state.flashUntil = this.scene.time + 0.6;
|
|
27
|
+
// Kept as the older spelling -- a deck reading `goal.runtime.scored` or
|
|
28
|
+
// `.flashUntil` (where this lived before `this.state`) still sees them.
|
|
29
|
+
this.actor.runtime.scored = this.state.scored;
|
|
30
|
+
this.actor.runtime.flashUntil = this.state.flashUntil;
|
|
31
|
+
}
|
|
32
|
+
draw(actor, scene, ctx) {
|
|
33
|
+
const box = layoutRect(actor.components.Layout);
|
|
34
|
+
if (!box)
|
|
35
|
+
return;
|
|
36
|
+
const lit = this.state.flashUntil > scene.time;
|
|
37
|
+
ctx.save();
|
|
38
|
+
ctx.strokeStyle = lit ? '#5ac54f' : 'rgba(255, 235, 87, 0.9)';
|
|
39
|
+
ctx.lineWidth = 4;
|
|
40
|
+
ctx.setLineDash([6, 4]);
|
|
41
|
+
ctx.strokeRect(box.x + 2, box.y + 2, box.width - 4, box.height - 4);
|
|
42
|
+
ctx.restore();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Goal };
|