castle-web-cli 0.4.237 → 0.4.239
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/bundle.d.ts +24 -0
- package/dist/bundle.js +447 -4
- package/dist/bundleLatin1.d.ts +6 -0
- package/dist/bundleLatin1.js +333 -0
- package/dist/castle-host/host.d.ts +10 -1
- package/dist/castle-host/host.js +133 -9
- package/dist/castleJson.d.ts +2 -0
- package/dist/castleJson.js +1 -0
- package/dist/deckExports.d.ts +35 -0
- package/dist/deckExports.js +365 -0
- package/dist/importCheckHook.d.ts +1 -0
- package/dist/importCheckHook.js +1 -1
- package/dist/index.js +21 -0
- package/dist/init.js +2 -1
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +2 -1
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +8 -3
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.js +4 -0
- package/kits/base/CLAUDE.md +1 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +113 -2
- package/kits/base/sdk/castle.d.ts +6 -2
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +56 -1
- package/kits/base/sdk/commands.js +29 -1
- package/kits/base/sdk/hub.d.ts +17 -0
- package/kits/base/sdk/hub.js +33 -9
- package/kits/base/sdk/localCache.d.ts +27 -0
- package/kits/base/sdk/localCache.js +115 -0
- package/kits/base/sdk/localCacheStore.d.ts +15 -0
- package/kits/base/sdk/localCacheStore.js +358 -0
- package/kits/base/sdk/multiplayer.js +30 -0
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +1 -0
- package/kits/base/sdk/transport.js +4 -5
- package/kits/hub-game/CLAUDE.md +22 -2
- package/kits/hub-game/castle.json +8 -5
- package/kits/hub-game/code/client/act.js +66 -91
- package/kits/hub-game/code/client/actCore.js +134 -0
- package/kits/hub-game/code/client/car.js +35 -0
- package/kits/hub-game/code/client/chrome.js +208 -381
- package/kits/hub-game/code/client/crowdNames.js +2 -2
- package/kits/hub-game/code/client/emoteWheel.js +109 -0
- package/kits/hub-game/code/client/hats.js +2 -0
- package/kits/hub-game/code/client/hookLayer.js +99 -48
- package/kits/hub-game/code/client/hostGo.js +77 -0
- package/kits/hub-game/code/client/hubControls.js +125 -0
- package/kits/hub-game/code/client/hubEntry.js +187 -0
- package/kits/hub-game/code/client/hudSurface.js +148 -0
- package/kits/hub-game/code/client/hudTree.js +96 -0
- package/kits/hub-game/code/client/idle.js +59 -13
- package/kits/hub-game/code/client/invites.js +13 -4
- package/kits/hub-game/code/client/menuIcons.js +8 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/noTrips.js +38 -0
- package/kits/hub-game/code/client/qualityEntry.js +6 -1
- package/kits/hub-game/code/client/rehello.js +3 -1
- package/kits/hub-game/code/client/riders.js +26 -0
- package/kits/hub-game/code/client/role.js +79 -0
- package/kits/hub-game/code/client/safeLayout.js +32 -3
- package/kits/hub-game/code/client/sound.js +10 -3
- package/kits/hub-game/code/client/soundscape.js +2 -2
- package/kits/hub-game/code/client/soundscapeAmbience.js +38 -8
- package/kits/hub-game/code/client/soundscapeBaked.js +24 -5
- package/kits/hub-game/code/client/soundscapeCues.js +2 -1
- package/kits/hub-game/code/client/state.js +19 -0
- package/kits/hub-game/code/client/stuck.js +2 -1
- package/kits/hub-game/code/client/talkSurface.js +178 -0
- package/kits/hub-game/code/client/talkTree.js +238 -0
- package/kits/hub-game/code/client/tiers.js +8 -5
- package/kits/hub-game/code/client/uiDom.js +600 -0
- package/kits/hub-game/code/client/uiTree.js +359 -0
- package/kits/hub-game/code/client/vehicle.js +156 -0
- package/kits/hub-game/code/client/wear.js +27 -5
- package/kits/hub-game/code/client/worldLabels.js +13 -3
- package/kits/hub-game/code/client/yours.js +10 -3
- package/kits/hub-game/code/server/actors.js +4 -3
- package/kits/hub-game/code/server/analytics.js +61 -18
- package/kits/hub-game/code/server/decor.js +56 -16
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/hub.js +261 -46
- package/kits/hub-game/code/server/idle.js +118 -5
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +46 -4
- package/kits/hub-game/code/server/npcs.js +4 -2
- package/kits/hub-game/code/server/players.js +3 -0
- package/kits/hub-game/code/server/role.js +142 -0
- package/kits/hub-game/code/server/standing.js +6 -4
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +126 -0
- package/kits/hub-game/code/shared/car.js +52 -0
- package/kits/hub-game/code/shared/deckFlags.js +34 -0
- package/kits/hub-game/code/shared/deviceClass.js +39 -0
- package/kits/hub-game/code/shared/expression.js +9 -0
- package/kits/hub-game/code/systems/hub.js +281 -86
- package/kits/hub-game/docs/analytics.md +15 -3
- package/kits/hub-game/docs/contract.md +352 -14
- package/kits/hub-game/docs/vehicle-preset.md +132 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +89 -0
- package/kits/hub-game/models/hats/chef-toque.pxmodel +60 -0
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +87 -0
- package/kits/hub-game/models/hats/hard-hat.pxmodel +71 -0
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +61 -0
- package/kits/hub-game/models/hats/police-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +52 -0
- package/kits/hub-game/models/role/square/top-apron.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-cardigan.pxmodel +141 -0
- package/kits/hub-game/models/role/square/top-coat.pxmodel +157 -0
- package/kits/hub-game/models/role/square/top-scrubs.pxmodel +93 -0
- package/kits/hub-game/models/role/square/top-tabard.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-vest.pxmodel +109 -0
- package/kits/hub-game/models/role/tool-bag.pxmodel +75 -0
- package/kits/hub-game/models/role/tool-bell.pxmodel +71 -0
- package/kits/hub-game/models/role/tool-hose.pxmodel +60 -0
- package/kits/hub-game/models/role/tool-parcel.pxmodel +61 -0
- package/kits/hub-game/models/role/tool-torch.pxmodel +55 -0
- package/kits/hub-game/models/role/tool-tray.pxmodel +75 -0
- package/kits/hub-game/models/role/top-apron.pxmodel +70 -0
- package/kits/hub-game/models/role/top-cardigan.pxmodel +102 -0
- package/kits/hub-game/models/role/top-coat.pxmodel +79 -0
- package/kits/hub-game/models/role/top-scrubs.pxmodel +54 -0
- package/kits/hub-game/models/role/top-tabard.pxmodel +70 -0
- package/kits/hub-game/models/role/top-vest.pxmodel +70 -0
- package/kits/hub-game/package-lock.json +1 -1
- package/kits/hub-game/package.json +1 -1
- package/kits/hub-game/scripts/check.mjs +7 -4
- package/kits/hub-game/scripts/fixtures/car-vectors.json +279 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +2 -1
- package/kits/hub-game/scripts/fixtures/hud-surface.json +670 -0
- package/kits/hub-game/scripts/fixtures/talk-surface.json +3930 -0
- package/kits/hub-game/scripts/gen-hats.mjs +46 -2
- package/kits/hub-game/scripts/gen-role.mjs +80 -0
- package/kits/hub-game/scripts/test-act-core.mjs +167 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +34 -0
- package/kits/hub-game/scripts/test-actors.mjs +48 -0
- package/kits/hub-game/scripts/test-analytics.mjs +100 -6
- package/kits/hub-game/scripts/test-apply-deck.mjs +122 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +3 -1
- package/kits/hub-game/scripts/test-ballot.mjs +2 -0
- package/kits/hub-game/scripts/test-car.mjs +43 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +2 -1
- package/kits/hub-game/scripts/test-decor.mjs +77 -0
- package/kits/hub-game/scripts/test-device-class.mjs +83 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-emote-wheel.mjs +374 -0
- package/kits/hub-game/scripts/test-hats.mjs +5 -4
- package/kits/hub-game/scripts/test-host-go.mjs +265 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +108 -0
- package/kits/hub-game/scripts/test-hub-entry.mjs +531 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +103 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +20 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +12 -2
- package/kits/hub-game/scripts/test-hud-rate.mjs +6 -2
- package/kits/hub-game/scripts/test-hud-surface.mjs +272 -0
- package/kits/hub-game/scripts/test-idle.mjs +347 -1
- package/kits/hub-game/scripts/test-interest-cells.mjs +8 -1
- package/kits/hub-game/scripts/test-invites-client.mjs +42 -1
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-manifest.mjs +30 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +1 -1
- package/kits/hub-game/scripts/test-no-trips.mjs +42 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-quality.mjs +13 -0
- package/kits/hub-game/scripts/test-rehello.mjs +258 -3
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +203 -0
- package/kits/hub-game/scripts/test-resync.mjs +196 -0
- package/kits/hub-game/scripts/test-role-client.mjs +427 -0
- package/kits/hub-game/scripts/test-role.mjs +350 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +50 -1
- package/kits/hub-game/scripts/test-soundscape.mjs +124 -7
- package/kits/hub-game/scripts/test-standing.mjs +15 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +296 -0
- package/kits/hub-game/scripts/test-tiers.mjs +13 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +96 -0
- package/kits/hub-game/scripts/test-ui-tree.mjs +711 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +168 -0
- package/kits/hub-game/scripts/test-vehicle.mjs +135 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +40 -0
- package/kits/hub-game/scripts/test-yours.mjs +33 -0
- package/kits/hub-game/tools/hubScene/export.mjs +613 -0
- package/kits/hub-game/tools/hubScene/hubdata.mjs +921 -0
- package/kits/hub-game/tools/hubScene/merge-root.mjs +39 -0
- package/kits/hub-game/tools/hubScene/nodeworld.mjs +227 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +810 -0
- package/kits/hub-game/tools/hubScene/test/fixture.json +637 -0
- package/kits/hub-game/tools/hubScene/test/paint-export.mjs +40 -0
- package/kits/hub-game/tools/hubScene/test/upload.test.mjs +655 -0
- package/kits/hub-game/tools/hubScene/upload.mjs +636 -0
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +301 -0
- package/kits/multiplayer-3d/castle.json +4 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +30 -2
- package/kits/multiplayer-3d/code/client/steer.js +3 -1
- package/kits/multiplayer-3d/code/systems/multiplayer.js +30 -2
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +74 -2
- package/kits/physics-3d/CLAUDE.md +1 -1
- package/kits/physics-3d/behaviors/Player.jsx +37 -27
- package/kits/physics-3d/castle.json +2 -2
- package/kits/physics-3d/docs/engine-geometry-memory.md +23 -0
- package/kits/physics-3d/engine3d/memoryprofile.js +17 -0
- package/kits/physics-3d/engine3d/playerRun.js +6 -1
- package/kits/physics-3d/engine3d/pxmodel.js +6 -1
- package/kits/physics-3d/engine3d/world3d.js +6 -3
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/play/behaviors/Player.js +40 -28
- package/kits/physics-3d/scripts/test-memory-profile.mjs +237 -0
- package/kits/physics-3d/systems/physics3d.js +5 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/messages.js +5 -0
- package/kits/real-time/code/server/session.js +28 -1
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +5 -4
- package/vendor/three/LICENSE +21 -0
- package/vendor/three/build/three.core.js +58773 -0
- package/vendor/three/build/three.module.js +18251 -0
- package/vendor/three/examples/jsm/controls/OrbitControls.js +1860 -0
- package/vendor/three/examples/jsm/controls/TransformControls.js +1918 -0
- package/vendor/three/examples/jsm/exporters/GLTFExporter.js +3595 -0
- package/vendor/three/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
- package/vendor/three/examples/jsm/math/MeshSurfaceSampler.js +315 -0
- package/vendor/three/examples/jsm/postprocessing/EffectComposer.js +363 -0
- package/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
- package/vendor/three/examples/jsm/postprocessing/OutputPass.js +139 -0
- package/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
- package/vendor/three/examples/jsm/postprocessing/RenderPass.js +183 -0
- package/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
- package/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
- package/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
- package/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
- package/vendor/three/package.json +134 -0
|
@@ -7,6 +7,9 @@ import { faceArrivalCamera } from '../client/arrivalCamera.js';
|
|
|
7
7
|
import { makeDoorErrors } from '../client/doorErrors.js';
|
|
8
8
|
import { makeVisibility } from '../client/visibility.js';
|
|
9
9
|
import { makeInvites } from '../client/invites.js';
|
|
10
|
+
import { makeHubEntry, planHubEntry } from '../client/hubEntry.js';
|
|
11
|
+
import { makeHostGo } from '../client/hostGo.js';
|
|
12
|
+
import { makeNoTrips } from '../client/noTrips.js';
|
|
10
13
|
import { makeSignIn } from '../client/signIn.js';
|
|
11
14
|
import { makeWeakestTier, readDistricts } from '../client/weakestTier.js';
|
|
12
15
|
import { makeHudRate } from '../client/hudRate.js';
|
|
@@ -59,10 +62,13 @@ import * as Cabinets from '../client/cabinets.js';
|
|
|
59
62
|
import { CHAT_BUBBLE_MS, makeChat } from '../client/chat.js';
|
|
60
63
|
import { chatModerationEnabled } from '../client/chatModeration.js';
|
|
61
64
|
import { makeChrome } from '../client/chrome.js';
|
|
65
|
+
import { setUiTreeTime, syncUiTreeTime } from '../client/uiTree.js';
|
|
66
|
+
import { hudInputs } from '../client/hudSurface.js';
|
|
62
67
|
import * as Packs from '../client/pack.js';
|
|
63
68
|
import * as Hub from '../client/state.js';
|
|
64
69
|
import { clearShot } from '../client/shot.js';
|
|
65
70
|
import { makeAct } from '../client/act.js';
|
|
71
|
+
import { backControl, backPress, backRoute, personAction, reportPerson } from '../client/hubControls.js';
|
|
66
72
|
import { makeGrab } from '../client/grab.js';
|
|
67
73
|
import { makeIdle } from '../client/idle.js';
|
|
68
74
|
import { makeDecor } from '../client/decor.js';
|
|
@@ -78,9 +84,13 @@ import { makeInterestCap } from '../client/interestCap.js';
|
|
|
78
84
|
import { makeFpsTelemetry, fpsTelemetryFor } from '../client/fpsTelemetry.js';
|
|
79
85
|
import { loadTelemetryFor, reportLoadStage } from '../client/loadTelemetry.js';
|
|
80
86
|
import { LOAD_STAGES } from '../shared/loadStages.js';
|
|
87
|
+
import { encodeDeviceClass } from '../shared/deviceClass.js';
|
|
81
88
|
import { makeTiers } from '../client/tiers.js';
|
|
82
89
|
import { goalPointers, goalText, makeTogether, pointerAt } from '../client/together.js';
|
|
83
|
-
import {
|
|
90
|
+
import { makeVehicle } from '../client/vehicle.js';
|
|
91
|
+
import { carInput } from '../client/car.js';
|
|
92
|
+
import { makeEarned, makeRole, makeWear } from '../client/wear.js';
|
|
93
|
+
import { roleEarned, roleItems, roleWearing } from '../client/role.js';
|
|
84
94
|
import { makeCompanion } from '../client/companion.js';
|
|
85
95
|
import { makeDefaultEnvironment } from '../client/defaultEnvironment.js';
|
|
86
96
|
import { activeFallY, holdFallenPlayer } from '../client/fall.js';
|
|
@@ -109,6 +119,10 @@ const GOAL_NEAR_M = 6;
|
|
|
109
119
|
// A way back the host refused as unavailable is asked again once, this long
|
|
110
120
|
// after, before the door stays shut.
|
|
111
121
|
const BACK_RETRY_MS = 1500;
|
|
122
|
+
// A door whose destination the proxy could not route yet (4404 before hello)
|
|
123
|
+
// is acquired again when the join failed within this long of the handoff. The
|
|
124
|
+
// SDK has already tried the same nonce for a few seconds by then.
|
|
125
|
+
const DOOR_RETRY_WINDOW_MS = 10000;
|
|
112
126
|
// How many times one way somewhere recovers from a hub join lost before the
|
|
113
127
|
// session placed the player (`lostJoin`) before it gives up and uncovers.
|
|
114
128
|
const LOST_TRIES_MAX = 2;
|
|
@@ -178,6 +192,9 @@ const CABINET_CAM_OUT = 1.5;
|
|
|
178
192
|
// What the multiplayer kit is switched to while a player is away in a classic
|
|
179
193
|
// deck: no session. It is never joined (`leaveSession`).
|
|
180
194
|
const AWAY_JOIN = { mode: 'hub', handoff: null, away: true };
|
|
195
|
+
// Place actions whose pick calls hub.invite (a town's Invite a friend, a win's
|
|
196
|
+
// Share, a house's Share): drawn only while the host makes links for this player.
|
|
197
|
+
const INVITE_ACTIONS = new Set(['invite-friend', 'share-win', 'share-town']);
|
|
181
198
|
// Castle refuses a player it has barred from the hub at every door and at the
|
|
182
199
|
// town itself with this code; the kit says so plainly and does not ask again.
|
|
183
200
|
export const HUB_BANNED = 'CAULDRON_HUB_BANNED';
|
|
@@ -252,7 +269,9 @@ class HubSystem {
|
|
|
252
269
|
this.spinData = null;
|
|
253
270
|
this.spin = null;
|
|
254
271
|
this.wear = makeWear();
|
|
272
|
+
this.vehicle = makeVehicle();
|
|
255
273
|
this.earned = makeEarned();
|
|
274
|
+
this.roles = makeRole();
|
|
256
275
|
this.toast = { text: '', until: 0 };
|
|
257
276
|
this.leavingToast = null;
|
|
258
277
|
this.stats = statsWanted();
|
|
@@ -431,6 +450,9 @@ class HubSystem {
|
|
|
431
450
|
place: Hub.hub.place,
|
|
432
451
|
visit: `${this.helloMark?.selfId ?? ''}:${this.helloMark?.again ?? ''}`,
|
|
433
452
|
});
|
|
453
|
+
if (Hub.hub.roles.size > 0) {
|
|
454
|
+
this.chrome.syncRoleLabels?.(roleItems(scene, scene.actorWith('Player'), cam, frame.view, Hub.hub.roles, project));
|
|
455
|
+
}
|
|
434
456
|
const labelBoxes = this.chrome.crowdNameLabelBoxes?.() ?? [];
|
|
435
457
|
const obstacles = [...frame.controls, ...(frame.own ? [frame.own] : []), ...labelBoxes];
|
|
436
458
|
const result = layoutCrowdNames(state, candidates, { now, view: frame.view, obstacles });
|
|
@@ -462,6 +484,11 @@ class HubSystem {
|
|
|
462
484
|
// Ordinary labels have already completed HUD clearance. Updating only
|
|
463
485
|
// E's summary preserves those final DOM positions for this paint.
|
|
464
486
|
this.chrome.setCrowdNameSummary?.(summary[0] ?? null);
|
|
487
|
+
// After the summary's flush, which restores what layout hid: a role chip
|
|
488
|
+
// whose name the crowd pass rejected stays hidden with it.
|
|
489
|
+
if (Hub.hub.roles.size > 0) {
|
|
490
|
+
this.chrome.syncRoleLabels?.(roleItems(scene, scene.actorWith('Player'), cam, frame.view, Hub.hub.roles, project), null, false);
|
|
491
|
+
}
|
|
465
492
|
}
|
|
466
493
|
|
|
467
494
|
invalidateCrowdNames(scene) {
|
|
@@ -485,6 +512,9 @@ class HubSystem {
|
|
|
485
512
|
}
|
|
486
513
|
}
|
|
487
514
|
if (hidden) {this.crowdHidden = hidden;}
|
|
515
|
+
if (Hub.hub.roles.size > 0) {
|
|
516
|
+
this.chrome.syncRoleLabels?.([], scene.multiplayer?.net?.selfId?.());
|
|
517
|
+
}
|
|
488
518
|
if (Object.hasOwn(this, 'crowdSprites')) {delete this.crowdSprites;}
|
|
489
519
|
}
|
|
490
520
|
|
|
@@ -514,6 +544,9 @@ class HubSystem {
|
|
|
514
544
|
this.doorErrors.sync(mp.net, Boolean(Hub.hub.place?.result) && !this.trip, now);
|
|
515
545
|
}
|
|
516
546
|
if (!this.chrome) {
|
|
547
|
+
// A UI tree host reads every `clock` in the simulation's time; each
|
|
548
|
+
// root it is sent carries this time.
|
|
549
|
+
setUiTreeTime(() => Hub.simNow() / 1000);
|
|
517
550
|
this.chrome = makeChrome({
|
|
518
551
|
worldLabelsDefault: !Hub.deck.labels,
|
|
519
552
|
...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
|
|
@@ -554,7 +587,7 @@ class HubSystem {
|
|
|
554
587
|
this.idle ??= makeIdle(this.chrome);
|
|
555
588
|
this.sound ??= makeSound();
|
|
556
589
|
if (Hub.deck.soundscape && !this.soundscape) {
|
|
557
|
-
this.hearPlace();
|
|
590
|
+
this.hearPlace(scene);
|
|
558
591
|
}
|
|
559
592
|
if (!this.sayHooked) {
|
|
560
593
|
this.sayHooked = true;
|
|
@@ -572,6 +605,7 @@ class HubSystem {
|
|
|
572
605
|
this.backHooked = true;
|
|
573
606
|
castleSdk.Hub.onBack(() => this.backFromControl(this.scene));
|
|
574
607
|
}
|
|
608
|
+
this.hookHostGo();
|
|
575
609
|
const per = (scene.persistent ??= {});
|
|
576
610
|
per.hubTickets ??= [];
|
|
577
611
|
this.keepResident(scene, per.hubTickets);
|
|
@@ -588,6 +622,7 @@ class HubSystem {
|
|
|
588
622
|
const local = scene.actorWith('Player');
|
|
589
623
|
this.wearAvatar(scene, local);
|
|
590
624
|
this.applyTune(local);
|
|
625
|
+
this.vehicle.frame(scene, local, Hub.hub.cars, !this.trip && this.pendingEnd === null);
|
|
591
626
|
this.watchSession(scene, mp);
|
|
592
627
|
this.sayHello(scene, mp);
|
|
593
628
|
if (Hub.hub.place?.push?.version === 1 && Hub.hub.arrivedFacing !== null && mp.net) {
|
|
@@ -626,6 +661,8 @@ class HubSystem {
|
|
|
626
661
|
if (!this.trip) {this.invites.frame(mp.net);}
|
|
627
662
|
} else if (Hub.hub.place && this.invites) { this.invites.dispose(); this.invites = null; }
|
|
628
663
|
this.runCommands(scene, now);
|
|
664
|
+
this.hubEntryFrame(scene, mp, local);
|
|
665
|
+
this.hostGoFrame(scene, mp, local);
|
|
629
666
|
this.askFriends(scene, mp, now);
|
|
630
667
|
this.together.frame(mp, this.friendsAll, !this.trip && this.pendingEnd === null, now, this.chrome.peopleOpen?.() === true);
|
|
631
668
|
|
|
@@ -744,8 +781,12 @@ class HubSystem {
|
|
|
744
781
|
}
|
|
745
782
|
// Grabbing and throwing (v1.3), in a place that offers it: after this
|
|
746
783
|
// frame's physics step, before the multiplayer kit reports what it owns.
|
|
747
|
-
this.grab.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput,
|
|
784
|
+
this.grab.frame(scene, mp, local, !Object.hasOwn(Hub.hub.cars, mp.net?.selfId?.()) && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput,
|
|
748
785
|
Hub.deck.act === true && Boolean(this.actionInput) && !this.trip && this.pendingEnd === null);
|
|
786
|
+
const myCar = Hub.hub.cars[mp.net?.selfId?.()];
|
|
787
|
+
if (myCar?.horn && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded) {
|
|
788
|
+
this.chrome.hornPrompt?.(() => mp.net?.send({ k: 'hub-horn' }));
|
|
789
|
+
}
|
|
749
790
|
if (Hub.deck.act === true) {
|
|
750
791
|
this.act ??= makeAct(this.chrome, this.grab, this.talk);
|
|
751
792
|
this.act.frame(scene, mp, local, !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.actionInput && !this.askInput && !this.menuInput && !this.carded);
|
|
@@ -779,9 +820,12 @@ class HubSystem {
|
|
|
779
820
|
if (Hub.hub.place?.actions === true || Hub.hub.place?.anonymousEntry === true) {
|
|
780
821
|
this.actionsDrawn = true;
|
|
781
822
|
const hud = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
782
|
-
const
|
|
823
|
+
const inviting = () => Hub.hub.place?.invite === true && this.invites?.canInvite(mp.net, castleSdk.User) === true;
|
|
824
|
+
const offered = Hub.hub.actions?.items ?? null, invites = offered?.some((item) => INVITE_ACTIONS.has(item?.id)) ? inviting() : true;
|
|
825
|
+
const items = this.signIn.items(Hub.hub.place, hud, invites ? offered : offered.filter((item) => !INVITE_ACTIONS.has(item?.id)));
|
|
783
826
|
this.chrome.setActions(items, (id, n) => {
|
|
784
827
|
if (id === 'signin' && Hub.hub.place?.anonymousEntry === true) {void this.signIn.press(hud?.text ?? 'Keep your progress');}
|
|
828
|
+
else if (INVITE_ACTIONS.has(id) && !inviting()) {return;}
|
|
785
829
|
else {mp.net?.send({ k: 'hub-action', id, n });}
|
|
786
830
|
}, !this.signIn.pending() && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput,
|
|
787
831
|
Hub.hub.actions?.n, scene.data?.engine?.hubActionOverflow === true || !landscapeViewport(), (open) => {
|
|
@@ -826,8 +870,8 @@ class HubSystem {
|
|
|
826
870
|
// listener, storage read or chrome of it is made. Made with the chrome, and
|
|
827
871
|
// put away with it (`dispose`): an NPC's line in the talk panel is heard as
|
|
828
872
|
// the panel is given it, by this player alone.
|
|
829
|
-
hearPlace() {
|
|
830
|
-
const soundscape = makeSoundscape(Hub.deck.soundscape, { onHide: () => this.sound?.hush(), isOn: () => !this.trip, loudestLoop: () => this.sound?.loudestLoop() ?? 0 });
|
|
873
|
+
hearPlace(scene) {
|
|
874
|
+
const soundscape = makeSoundscape(Hub.deck.soundscape, { lowMemory: scene?.three?.lowMemory === true, onHide: () => this.sound?.hush(), isOn: () => !this.trip, loudestLoop: () => this.sound?.loudestLoop() ?? 0 });
|
|
831
875
|
this.soundscape = soundscape;
|
|
832
876
|
this.sound?.filterEvents?.(soundscape.live);
|
|
833
877
|
this.soundHandlers = { onVolume: (volume) => soundscape.setVolume(volume), onMuted: (muted) => soundscape.setMuted(muted) };
|
|
@@ -852,6 +896,7 @@ class HubSystem {
|
|
|
852
896
|
}
|
|
853
897
|
if (!this.tiers) {
|
|
854
898
|
this.tiers = qualityFor(scene)?.tiers ?? makeTiers({ weakest: Hub.deck.weakestTier === true,
|
|
899
|
+
lowMemory: scene.three?.lowMemory === true,
|
|
855
900
|
onLayout: (node) => this.chrome?.safeSurface?.('cells-debug', node, 'text') });
|
|
856
901
|
const pick = (mode) => {
|
|
857
902
|
this.tiers.set(mode);
|
|
@@ -930,6 +975,15 @@ class HubSystem {
|
|
|
930
975
|
}
|
|
931
976
|
|
|
932
977
|
// The systems that run after every other one, registered once per runtime.
|
|
978
|
+
// Cars (v1.160) after the multiplayer kit has placed every avatar: each
|
|
979
|
+
// look under its driver's node, riders on their seats, a rider's camera.
|
|
980
|
+
applyCars(s) {
|
|
981
|
+
this.vehicle.draw(s, s.actorWith('Player'), Hub.hub.cars);
|
|
982
|
+
if (Object.keys(Hub.hub.cars).length) {
|
|
983
|
+
this.vehicle.camera(s, s.actorWith('Player'), Hub.hub.cars);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
933
987
|
registerLate(scene) {
|
|
934
988
|
if (this.lateScenes?.has(scene)) {return;}
|
|
935
989
|
(this.lateScenes ??= new WeakSet()).add(scene);
|
|
@@ -937,6 +991,7 @@ class HubSystem {
|
|
|
937
991
|
afterBehaviors: (s) => {
|
|
938
992
|
this.applyVisibility(s);
|
|
939
993
|
this.applyWear(s);
|
|
994
|
+
this.applyCars(s);
|
|
940
995
|
this.fadeNames(s);
|
|
941
996
|
},
|
|
942
997
|
});
|
|
@@ -1039,8 +1094,10 @@ class HubSystem {
|
|
|
1039
1094
|
this.tinted.clear();
|
|
1040
1095
|
this.spawnedHere.clear();
|
|
1041
1096
|
this.companion?.clear();
|
|
1097
|
+
this.vehicle.clear();
|
|
1042
1098
|
this.wear.clear(scene);
|
|
1043
1099
|
this.earned.clear();
|
|
1100
|
+
this.roles.clear();
|
|
1044
1101
|
this.idle?.release();
|
|
1045
1102
|
if (this.decor) {
|
|
1046
1103
|
this.decor.dispose();
|
|
@@ -1084,12 +1141,15 @@ class HubSystem {
|
|
|
1084
1141
|
this.stash.clear();
|
|
1085
1142
|
this.tinted.clear();
|
|
1086
1143
|
this.spawnedHere.clear();
|
|
1144
|
+
this.vehicle.clear();
|
|
1087
1145
|
if (scene) {
|
|
1088
1146
|
this.wear.clear(scene);
|
|
1089
1147
|
this.earned.clear();
|
|
1148
|
+
this.roles.clear();
|
|
1090
1149
|
} else {
|
|
1091
1150
|
this.wear.forget();
|
|
1092
1151
|
this.earned.forget();
|
|
1152
|
+
this.roles.forget();
|
|
1093
1153
|
}
|
|
1094
1154
|
}
|
|
1095
1155
|
|
|
@@ -1105,7 +1165,7 @@ class HubSystem {
|
|
|
1105
1165
|
this.wear.frame(
|
|
1106
1166
|
scene,
|
|
1107
1167
|
local ?? scene.actorWith('Player'),
|
|
1108
|
-
Hub.hub.wearing,
|
|
1168
|
+
roleWearing(Hub.hub.wearing, Hub.hub.roles),
|
|
1109
1169
|
(playerId) => {
|
|
1110
1170
|
const index = indexOf(playerId);
|
|
1111
1171
|
return Avatar.top(index, Avatar.drawn(scene.files, index, style));
|
|
@@ -1117,10 +1177,16 @@ class HubSystem {
|
|
|
1117
1177
|
return Avatar.hatFit(index, Avatar.drawn(scene.files, index, style));
|
|
1118
1178
|
},
|
|
1119
1179
|
);
|
|
1180
|
+
if (Hub.hub.roles.size > 0 || this.roles.size > 0) {
|
|
1181
|
+
this.roles.frame(scene, local ?? scene.actorWith('Player'), Hub.hub.roles, (playerId) => {
|
|
1182
|
+
const index = indexOf(playerId);
|
|
1183
|
+
return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1120
1186
|
// Earned items (v1.53): no work at all while nobody shows one and
|
|
1121
1187
|
// nothing is drawn.
|
|
1122
1188
|
if (Hub.hub.earned.size > 0 || this.earned.size > 0) {
|
|
1123
|
-
this.earned.frame(scene, local ?? scene.actorWith('Player'), Hub.hub.earned, (playerId) => {
|
|
1189
|
+
this.earned.frame(scene, local ?? scene.actorWith('Player'), roleEarned(Hub.hub.earned, Hub.hub.roles), (playerId) => {
|
|
1124
1190
|
const index = indexOf(playerId);
|
|
1125
1191
|
return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
|
|
1126
1192
|
});
|
|
@@ -1138,6 +1204,7 @@ class HubSystem {
|
|
|
1138
1204
|
if (this.tuneBase?.player !== player) {
|
|
1139
1205
|
this.tuneBase = { player, speed: player.speed, jumpSpeed: player.jumpSpeed };
|
|
1140
1206
|
}
|
|
1207
|
+
if (Object.hasOwn(Hub.hub.cars, this.scene?.multiplayer?.net?.selfId?.())) {return;}
|
|
1141
1208
|
const t = Hub.hub.tune;
|
|
1142
1209
|
const mul = (v, lo, hi) => (typeof v === 'number' && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : 1);
|
|
1143
1210
|
const speed = this.tuneBase.speed * mul(t?.speed, 0.25, 3);
|
|
@@ -1186,6 +1253,9 @@ class HubSystem {
|
|
|
1186
1253
|
const color = Avatar.currentColor(scene);
|
|
1187
1254
|
if (net === this.helloNet) {
|
|
1188
1255
|
const back = Rehello.resumed(mp, net, this.helloMark);
|
|
1256
|
+
if (back) {
|
|
1257
|
+
this.admitEpoch = (this.admitEpoch ?? 0) + 1;
|
|
1258
|
+
}
|
|
1189
1259
|
// (Another player id was reset for by `newIdentity`, already.) A game
|
|
1190
1260
|
// (a place with `result`) back under the same id keeps the old way, as
|
|
1191
1261
|
// its server does, unless its place says `resume: true` (v1.72); under a
|
|
@@ -1196,6 +1266,7 @@ class HubSystem {
|
|
|
1196
1266
|
if (say !== 'none') {
|
|
1197
1267
|
console.log(`[hub] the connection came back (${back}): saying a ${say} hello`);
|
|
1198
1268
|
this.sendHello(scene, mp, net, avatar, say === 'resume' ? { resume: true } : { solo: true });
|
|
1269
|
+
this.noTripsAfterHello(net);
|
|
1199
1270
|
if (back === 'world') {
|
|
1200
1271
|
this.talk?.resume();
|
|
1201
1272
|
}
|
|
@@ -1226,6 +1297,7 @@ class HubSystem {
|
|
|
1226
1297
|
this.freshSession(scene);
|
|
1227
1298
|
}
|
|
1228
1299
|
this.sendHello(scene, mp, net, avatar, { again, inviteNear });
|
|
1300
|
+
this.noTripsAfterHello(net);
|
|
1229
1301
|
if (!again) {this.invites?.landed();}
|
|
1230
1302
|
}
|
|
1231
1303
|
|
|
@@ -1235,6 +1307,7 @@ class HubSystem {
|
|
|
1235
1307
|
// as on any switch of session, along with what this client kept of it.
|
|
1236
1308
|
newIdentity() {
|
|
1237
1309
|
this.pushVisit = null;
|
|
1310
|
+
this.admitEpoch = (this.admitEpoch ?? 0) + 1;
|
|
1238
1311
|
console.log('[hub] the connection has a new player id: a new session');
|
|
1239
1312
|
this.identityPlace = Hub.hub.place ?? this.identityPlace;
|
|
1240
1313
|
Hub.clear();
|
|
@@ -1286,6 +1359,13 @@ class HubSystem {
|
|
|
1286
1359
|
}
|
|
1287
1360
|
}
|
|
1288
1361
|
|
|
1362
|
+
// v1.156: after a hello, an app that cannot go through doors says so
|
|
1363
|
+
// (`client/noTrips.js`).
|
|
1364
|
+
noTripsAfterHello(net) {
|
|
1365
|
+
this.noTrips ??= makeNoTrips(castleSdk);
|
|
1366
|
+
this.noTrips.afterHello(net, () => this.helloNet === net);
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1289
1369
|
// `solo`: a party of one carrying nothing and naming no friend, as `resume`
|
|
1290
1370
|
// is, without saying it resumes (a game's new session, `helloAfter`).
|
|
1291
1371
|
sendHello(scene, mp, net, avatar, { again = false, resume = false, solo = resume, inviteNear = null } = {}) {
|
|
@@ -1310,8 +1390,18 @@ class HubSystem {
|
|
|
1310
1390
|
this.helloMark = Rehello.mark(mp, net, () => this.newIdentity());
|
|
1311
1391
|
const per = scene.persistent;
|
|
1312
1392
|
const arriving = per.hubArriving ?? null;
|
|
1393
|
+
const readDevice = (read) => { try { return read(); } catch { return undefined; } };
|
|
1394
|
+
const device = encodeDeviceClass({
|
|
1395
|
+
lowMemory: scene.three?.lowMemory === true,
|
|
1396
|
+
cores: readDevice(() => typeof navigator === 'undefined' ? undefined : navigator.hardwareConcurrency),
|
|
1397
|
+
dpr: readDevice(() => typeof devicePixelRatio === 'undefined' ? undefined : devicePixelRatio),
|
|
1398
|
+
width: readDevice(() => typeof screen === 'undefined' ? undefined : screen.width),
|
|
1399
|
+
height: readDevice(() => typeof screen === 'undefined' ? undefined : screen.height),
|
|
1400
|
+
deviceMemory: readDevice(() => typeof navigator === 'undefined' ? undefined : navigator.deviceMemory),
|
|
1401
|
+
});
|
|
1313
1402
|
net.send({
|
|
1314
1403
|
k: 'hub-hello',
|
|
1404
|
+
...(device ? { device } : {}),
|
|
1315
1405
|
avatar,
|
|
1316
1406
|
...(Number.isInteger(this.helloColor) && this.helloColor > 0 ? { color: this.helloColor } : {}),
|
|
1317
1407
|
from: arriving?.door ?? null,
|
|
@@ -1537,10 +1627,132 @@ class HubSystem {
|
|
|
1537
1627
|
this.pendingEnd = this.endCovered ? now : now + END_PAUSE_MS;
|
|
1538
1628
|
this.endSession = sessionKey(scene);
|
|
1539
1629
|
this.endLeaving = null;
|
|
1630
|
+
// Only a game is over: a place without a result that sends a player
|
|
1631
|
+
// back (the House's front door, the first room's way to the Town)
|
|
1632
|
+
// says what it says in its own HUD.
|
|
1540
1633
|
const r = scene.persistent.hubResult;
|
|
1541
|
-
|
|
1634
|
+
if (Hub.hub.place?.result) {
|
|
1635
|
+
this.toast = { text: r && Date.now() - r.at < 30000 ? resultLine(r) : 'Game over', until: now + END_PAUSE_MS + 200 };
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
// A hub-entry link (`client/hubEntry.js`): the Town's link for the House or
|
|
1642
|
+
// one of its doors, read once per page load on the first place it enters
|
|
1643
|
+
// at the root. An invite wins; a trip or session swap first spends it.
|
|
1644
|
+
hubEntryFrame(scene, mp, local) {
|
|
1645
|
+
this.hubEntry ??= makeHubEntry({
|
|
1646
|
+
joinHint: () => castleSdk.Multiplayer?.joinHint?.() ?? null,
|
|
1647
|
+
extras: (target) => this.hubEntryExtras(target),
|
|
1648
|
+
act: (target, info) => this.hubEntryAct(this.scene, target, info),
|
|
1649
|
+
current: () => this.hubEntryContext(this.scene),
|
|
1650
|
+
});
|
|
1651
|
+
// Admissions are counted from the first look at a connection, not only
|
|
1652
|
+
// from its first hello: an invite check can hold that hello back, and a
|
|
1653
|
+
// re-admission meanwhile must spend the link too.
|
|
1654
|
+
if (mp.net && this.hubEntry.state() !== 'done' && this.entryWatch?.net !== mp.net) {
|
|
1655
|
+
this.entryWatch = { net: mp.net, w: Rehello.watch(mp, mp.net) };
|
|
1656
|
+
}
|
|
1657
|
+
this.hubEntry.frame(this.hubEntryContext(scene, mp, local));
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
// The host's Go (v1.155, `client/hostGo.js`): through a door of this
|
|
1661
|
+
// place as if its pad had fired. An SDK without `Hub.onGo` never sends one.
|
|
1662
|
+
hookHostGo() {
|
|
1663
|
+
if (this.hostGoHooked || typeof castleSdk.Hub?.onGo !== 'function') {
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
this.hostGoHooked = true;
|
|
1667
|
+
this.hostGo ??= makeHostGo();
|
|
1668
|
+
castleSdk.Hub.onGo((go) => this.hostGo.offer(go, { at: performance.now(), tripping: Boolean(this.trip) }));
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
hostGoFrame(scene, mp, local) {
|
|
1672
|
+
const msg = this.hostGo?.take({
|
|
1673
|
+
now: performance.now(),
|
|
1674
|
+
settled: this.hubEntryContext(scene, mp, local).settled,
|
|
1675
|
+
tripping: Boolean(this.trip),
|
|
1676
|
+
result: Boolean(Hub.hub.place?.result),
|
|
1677
|
+
doors: Hub.hub.doors,
|
|
1678
|
+
});
|
|
1679
|
+
if (msg) {
|
|
1680
|
+
console.log(`[hub-host-go] ${JSON.stringify({ door: msg.door, party: msg.party, owner: Boolean(msg.owner) })}`);
|
|
1681
|
+
this.goHub(scene, { ...msg, host: true });
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
// Where the first entry stands now. `epoch` moves at every re-admission
|
|
1686
|
+
// on a greeted connection and every new player id (`sayHello`,
|
|
1687
|
+
// `newIdentity`): a reconnect on the same net spends the link.
|
|
1688
|
+
hubEntryContext(scene, mp = scene?.multiplayer, local = scene?.actorWith?.('Player')) {
|
|
1689
|
+
const place = Hub.hub.place;
|
|
1690
|
+
const per = scene?.persistent ?? {};
|
|
1691
|
+
const net = mp?.net ?? null;
|
|
1692
|
+
const selfId = net?.selfId?.() ?? null;
|
|
1693
|
+
return {
|
|
1694
|
+
known: Boolean(place),
|
|
1695
|
+
root: Boolean(scene && mp && place) && !place.result && !this.trip && this.tripCount === 0 && !(per.hubDepth > 0) &&
|
|
1696
|
+
!(per.hubTickets?.length) && mp.target?.mode !== 'hub' && !per.hubArriving?.door,
|
|
1697
|
+
net,
|
|
1698
|
+
selfId,
|
|
1699
|
+
epoch: net ? `${this.admitEpoch ?? 0}:${this.entryWatch?.net === net ? this.entryWatch.w.again : '-'}` : null,
|
|
1700
|
+
invited: this.invites?.carried?.() === true,
|
|
1701
|
+
settled: Boolean(net) && net === this.helloNet && !net.closed?.() && mp?.placed?.() === true &&
|
|
1702
|
+
this.pendingEnd === null && Boolean(local) && Hub.hub.doors.length > 0 && !Hub.hub.held.has(selfId),
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
// Read just before deciding: whether this player is a guest (no House the
|
|
1707
|
+
// kit can host: firstVisit.js in the Town), and the host's door rows.
|
|
1708
|
+
async hubEntryExtras(target) {
|
|
1709
|
+
const selfId = this.scene?.multiplayer?.net?.selfId?.();
|
|
1710
|
+
let guest = Hub.hub.guests?.has?.(selfId) === true ? true : null;
|
|
1711
|
+
if (guest === null) {
|
|
1712
|
+
try {
|
|
1713
|
+
const me = await castleSdk.User?.getCurrent?.();
|
|
1714
|
+
guest = me && typeof me === 'object' ? !me.userId || me.isAnonymous === true : null;
|
|
1715
|
+
} catch { guest = null; }
|
|
1716
|
+
}
|
|
1717
|
+
let host = null;
|
|
1718
|
+
if (target.kind === 'door') {
|
|
1719
|
+
try {
|
|
1720
|
+
const answer = await castleSdk.Hub?.doors?.();
|
|
1721
|
+
if (answer?.status === 'ok' && Array.isArray(answer.doors)) {
|
|
1722
|
+
host = new Map(answer.doors.filter((d) => typeof d?.doorId === 'string').map((d) => [d.doorId, d]));
|
|
1723
|
+
}
|
|
1724
|
+
} catch { host = null; }
|
|
1725
|
+
}
|
|
1726
|
+
return { guest, host };
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
hubEntryAct(scene, target, { guest = null, host = null } = {}) {
|
|
1730
|
+
const mp = scene?.multiplayer;
|
|
1731
|
+
// `makeHubEntry` checked the whole context again just now; this is the backstop.
|
|
1732
|
+
if (!scene || !mp?.net || this.trip || this.tripCount > 0 || this.pendingEnd !== null || Hub.hub.place?.result ||
|
|
1733
|
+
Hub.hub.held.has(mp.net.selfId?.())) {
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const me = scene.actorWith('Player')?.components.Transform;
|
|
1737
|
+
const homes = [];
|
|
1738
|
+
for (const actor of allActors(scene)) {
|
|
1739
|
+
const door = actor.components?.HubDoor;
|
|
1740
|
+
if (door?.to === 'deck:house' && typeof door.id === 'string') {
|
|
1741
|
+
const t = actor.components.Transform;
|
|
1742
|
+
homes.push({ id: door.id, d: me && t ? Math.hypot(t.x - me.x, t.z - me.z) : Infinity });
|
|
1542
1743
|
}
|
|
1543
1744
|
}
|
|
1745
|
+
homes.sort((a, b) => a.d - b.d);
|
|
1746
|
+
const plan = planHubEntry(target, { listed: Hub.hub.doors, homes: homes.map((h) => h.id), host, guest });
|
|
1747
|
+
console.log(`[hub-entry] ${JSON.stringify({ target, plan: plan ? Object.keys(plan) : null })}`);
|
|
1748
|
+
if (plan?.go) {
|
|
1749
|
+
this.goHub(scene, { door: plan.go.door, title: plan.go.title });
|
|
1750
|
+
} else if (plan?.jump) {
|
|
1751
|
+
this.goDoor(scene, plan.jump);
|
|
1752
|
+
}
|
|
1753
|
+
if (plan?.toast) {
|
|
1754
|
+
this.toast = { text: plan.toast, until: performance.now() + TOAST_MS };
|
|
1755
|
+
}
|
|
1544
1756
|
}
|
|
1545
1757
|
|
|
1546
1758
|
// Through a door ghost fixed a group for (the place's server fired its pad):
|
|
@@ -1574,7 +1786,10 @@ class HubSystem {
|
|
|
1574
1786
|
scene: null,
|
|
1575
1787
|
content: undefined,
|
|
1576
1788
|
deck: msg.title ?? msg.door,
|
|
1577
|
-
|
|
1789
|
+
// A host's Go rides an acquisition the host made from its own session:
|
|
1790
|
+
// asked again from this one, whose player never stood on the pad, ghost
|
|
1791
|
+
// refuses it, so a host's trip has no door retry.
|
|
1792
|
+
retryDoor: msg.host ? null : msg.door,
|
|
1578
1793
|
retryOwner: msg.owner ?? null,
|
|
1579
1794
|
pending: this.resolveHub(scene, () => hubGo(msg.door, msg.owner)),
|
|
1580
1795
|
join: null,
|
|
@@ -2020,40 +2235,20 @@ class HubSystem {
|
|
|
2020
2235
|
// invitation into the party (Invite), or Join -- beside a party member or a
|
|
2021
2236
|
// friend in this layer (the place moves this player), into the layer of
|
|
2022
2237
|
// this place a friend is in (a jump), or to the door of the game a friend
|
|
2023
|
-
// is inside.
|
|
2238
|
+
// is inside (`personAction`, shared with a native host).
|
|
2024
2239
|
join(scene, person, action) {
|
|
2025
|
-
|
|
2026
|
-
if (!net || this.trip || !person) {
|
|
2240
|
+
if (this.trip) {
|
|
2027
2241
|
return;
|
|
2028
2242
|
}
|
|
2029
|
-
|
|
2030
|
-
this.
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
}
|
|
2038
|
-
this.sendJump(net, { k: 'hub-goto', player: person.playerId });
|
|
2039
|
-
} else if (action === 'door' && person.door && person.owner) {
|
|
2040
|
-
// A friend at home: the place sends this player through their House
|
|
2041
|
-
// door with the owner (`hub-go` carrying `owner`), ending the visit here
|
|
2042
|
-
// as any door's trip does. A host that predates the owner acquires this
|
|
2043
|
-
// player's own House, as the pad would have.
|
|
2044
|
-
this.sendJump(net, { k: 'hub-house-visit', door: person.door, owner: person.owner });
|
|
2045
|
-
say(`Going to ${person.username ?? 'your friend'}'s House`);
|
|
2046
|
-
} else if (action === 'door' && person.door) {
|
|
2047
|
-
this.sendJump(net, { k: 'hub-door-jump', door: person.door });
|
|
2048
|
-
// A friend inside the game is said to be; someone standing at the door
|
|
2049
|
-
// is simply gone to.
|
|
2050
|
-
if (person.playerId === null) {
|
|
2051
|
-
const title = Hub.hub.doors.find((d) => d.id === person.door)?.title ?? 'that game';
|
|
2052
|
-
say(`${person.username ?? 'Your friend'} is inside ${title}`);
|
|
2053
|
-
}
|
|
2054
|
-
} else if (action === 'jump' && person.userId) {
|
|
2055
|
-
this.jump(scene, { userId: person.userId, username: person.username });
|
|
2056
|
-
}
|
|
2243
|
+
personAction(scene?.multiplayer?.net, person, action, {
|
|
2244
|
+
together: this.together,
|
|
2245
|
+
say: (text) => {
|
|
2246
|
+
this.toast = { text, until: performance.now() + TOAST_MS };
|
|
2247
|
+
},
|
|
2248
|
+
jump: (net, message) => this.sendJump(net, message),
|
|
2249
|
+
jumpTo: (friend) => this.jump(scene, friend),
|
|
2250
|
+
doors: Hub.hub.doors,
|
|
2251
|
+
});
|
|
2057
2252
|
}
|
|
2058
2253
|
|
|
2059
2254
|
// "Stuck?" (v1.33, `client/stuck.js`), only in a deck whose castle.json asks
|
|
@@ -2074,7 +2269,8 @@ class HubSystem {
|
|
|
2074
2269
|
return;
|
|
2075
2270
|
}
|
|
2076
2271
|
this.stuck ??= makeStuck();
|
|
2077
|
-
const
|
|
2272
|
+
const driving = Object.hasOwn(Hub.hub.cars, selfId);
|
|
2273
|
+
const walking = driving ? carInput(scene.keys, scene.moveInput).forward !== 0 : walkInput(scene.keys, scene.moveInput, scene.cameraControl === 'orbit');
|
|
2078
2274
|
const hidden = globalThis.document?.visibilityState === 'hidden';
|
|
2079
2275
|
const shown = stuckFrame(this.stuck, { key: `${this.sceneKey}|${Hub.hub.place.id}`, x: t.x, z: t.z, walking, hidden }, now);
|
|
2080
2276
|
let text = shown ? stuckText(offer.to) : null;
|
|
@@ -2094,6 +2290,7 @@ class HubSystem {
|
|
|
2094
2290
|
this.toast = { text: stuckDone(done.to, done.spot), until: now + TOAST_MS };
|
|
2095
2291
|
}
|
|
2096
2292
|
}
|
|
2293
|
+
if (driving && shown) {text = stuckText(null, false, true);}
|
|
2097
2294
|
this.stuckShown = shown;
|
|
2098
2295
|
this.chrome.stuckPrompt?.(text, () => this.unstick(this.scene));
|
|
2099
2296
|
}
|
|
@@ -2488,15 +2685,20 @@ class HubSystem {
|
|
|
2488
2685
|
|
|
2489
2686
|
// A user Back first dismisses transient chrome; automatic travel still uses back.
|
|
2490
2687
|
backFromControl(scene) {
|
|
2491
|
-
|
|
2688
|
+
const press = backPress({
|
|
2689
|
+
overflowOpen: this.chrome?.actionOverflowOpen?.(),
|
|
2690
|
+
menuOpen: this.chrome?.menuOpen?.(),
|
|
2691
|
+
inGame: Boolean(Hub.hub.place?.result),
|
|
2692
|
+
});
|
|
2693
|
+
if (press === 'overflow') {
|
|
2492
2694
|
this.chrome.cancelActionOverflow();
|
|
2493
2695
|
return;
|
|
2494
2696
|
}
|
|
2495
|
-
if (
|
|
2697
|
+
if (press === 'menu') {
|
|
2496
2698
|
this.chrome.cancelMenu();
|
|
2497
2699
|
return;
|
|
2498
2700
|
}
|
|
2499
|
-
if (
|
|
2701
|
+
if (press === 'quit') {scene.multiplayer?.net?.send({ k: 'hub-door-quit' });}
|
|
2500
2702
|
this.back(scene);
|
|
2501
2703
|
}
|
|
2502
2704
|
|
|
@@ -2515,10 +2717,11 @@ class HubSystem {
|
|
|
2515
2717
|
}
|
|
2516
2718
|
const per = scene.persistent;
|
|
2517
2719
|
const ticket = per.hubTickets.pop();
|
|
2720
|
+
const route = backRoute({ ticket, hubDepth: per.hubDepth });
|
|
2518
2721
|
// A place reached by a hub trip goes back the way the host says (`Hub.back`):
|
|
2519
2722
|
// to the place in this runtime the ticket remembers, or, with no ticket, to
|
|
2520
2723
|
// wherever ghost's return ticket leads, from its pack.
|
|
2521
|
-
if (
|
|
2724
|
+
if (route === 'host') {
|
|
2522
2725
|
const stay = ticket ? { content: ticket.content ?? null } : undefined;
|
|
2523
2726
|
this.startTrip(scene, {
|
|
2524
2727
|
scene: ticket?.scene ?? null,
|
|
@@ -2549,7 +2752,7 @@ class HubSystem {
|
|
|
2549
2752
|
}
|
|
2550
2753
|
return;
|
|
2551
2754
|
}
|
|
2552
|
-
if (
|
|
2755
|
+
if (route === 'instance') {
|
|
2553
2756
|
const place = Hub.hub.place?.id ?? 'main';
|
|
2554
2757
|
// Another deck's place runs that deck's server: its key keeps the prefix.
|
|
2555
2758
|
const prefix = scene.content?.sessionKeyPrefix ?? '';
|
|
@@ -2760,7 +2963,7 @@ class HubSystem {
|
|
|
2760
2963
|
} else if (state === 'failed') {
|
|
2761
2964
|
const age = now - trip.target.acquiredAt;
|
|
2762
2965
|
if (trip.target.retryDoor && !trip.doorRetried && mp.joinFailure?.closeCode === 4404 &&
|
|
2763
|
-
mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <=
|
|
2966
|
+
mp.joinFailure.code === 'MULTIPLAYER_CONNECTION_FAILED' && age >= 0 && age <= DOOR_RETRY_WINDOW_MS) {
|
|
2764
2967
|
trip.doorRetried = true;
|
|
2765
2968
|
trip.retryDoorAt = now + 2500;
|
|
2766
2969
|
trip.phase = 'retrying-door';
|
|
@@ -3230,7 +3433,7 @@ class HubSystem {
|
|
|
3230
3433
|
}
|
|
3231
3434
|
}
|
|
3232
3435
|
if (Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
3233
|
-
this.yourGames().returned(trip.target.arrive.door, r);
|
|
3436
|
+
this.yourGames().returned(trip.target.arrive.door, r, houseDoor(scene, trip.target.arrive.door));
|
|
3234
3437
|
}
|
|
3235
3438
|
if (Hub.deck.cues && !Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
3236
3439
|
// Cues: a next step, put once the player is back in the town, whether
|
|
@@ -3309,11 +3512,12 @@ class HubSystem {
|
|
|
3309
3512
|
// Away in a classic deck, the cover is down and Back is the only control.
|
|
3310
3513
|
const away = this.trip?.phase === 'away';
|
|
3311
3514
|
const hostTrail = scene.persistent.hubDepth > 0;
|
|
3515
|
+
// Old Android landscape hosts draw Exit deck, so keep a way back into
|
|
3516
|
+
// town. Hosts advertising their landscape Back retain sole ownership.
|
|
3517
|
+
const back = backControl({ away, idle, pendingEnd: this.pendingEnd, hostTrail, place, ticket, kitBack: hostTrail && kitBackNeeded() });
|
|
3312
3518
|
chrome.showBack(
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
(away || (idle && this.pendingEnd === null)) && (hostTrail ? place !== null && kitBackNeeded() : inGame || Boolean(ticket)),
|
|
3316
|
-
ticket?.title ?? (hostTrail && kitBackNeeded() ? 'Back' : 'Again'),
|
|
3519
|
+
back.show,
|
|
3520
|
+
back.label,
|
|
3317
3521
|
);
|
|
3318
3522
|
const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking() && !this.carded;
|
|
3319
3523
|
const town = free && !inGame;
|
|
@@ -3472,21 +3676,21 @@ class HubSystem {
|
|
|
3472
3676
|
}
|
|
3473
3677
|
|
|
3474
3678
|
if (panels) {
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
if (spec?.timer?.since !== undefined) {
|
|
3478
|
-
timer = Math.max(0, (Hub.simNow() - spec.timer.since) / 1000);
|
|
3479
|
-
} else if (spec?.timer?.until !== undefined) {
|
|
3480
|
-
timer = Math.max(0, (spec.timer.until - Hub.simNow()) / 1000);
|
|
3481
|
-
}
|
|
3679
|
+
// The player's own HUD over the place's, and its timer's seconds now.
|
|
3680
|
+
const { spec, timer } = hudInputs(Hub.hub, Hub.simNow());
|
|
3482
3681
|
// A place that asks (`hud.clear`, v1.26) has its HUD kept short and its
|
|
3483
3682
|
// labels kept out from under it; any other is drawn as it always was.
|
|
3484
3683
|
if (place?.hud?.clear === true || this.hudClear) {
|
|
3485
3684
|
this.hudClear = place?.hud?.clear === true;
|
|
3486
3685
|
chrome.setHudClear?.(this.hudClear);
|
|
3487
3686
|
}
|
|
3488
|
-
|
|
3687
|
+
// The sim time lets the chrome send the timer as a clock that counts
|
|
3688
|
+
// by itself, sent again only when its base moves.
|
|
3689
|
+
chrome.setHud(idle || this.trip?.phase === 'revealing' ? spec : null, timer, Hub.simNow());
|
|
3489
3690
|
}
|
|
3691
|
+
// A server time correction with nothing else changed still reaches a UI
|
|
3692
|
+
// tree host, whose clocks read the simulation time.
|
|
3693
|
+
syncUiTreeTime();
|
|
3490
3694
|
|
|
3491
3695
|
const cam = scene.three?.camera;
|
|
3492
3696
|
const view = { w: window.innerWidth, h: window.innerHeight };
|
|
@@ -3604,6 +3808,7 @@ class HubSystem {
|
|
|
3604
3808
|
chrome.setPointers?.(pointers.map((point) => offsetWorldPoint(point, view)));
|
|
3605
3809
|
if (cam && idle) {
|
|
3606
3810
|
labels.push(...this.markItems(scene, local, cam, view));
|
|
3811
|
+
labels.push(...roleItems(scene, local, cam, view, Hub.hub.roles, project));
|
|
3607
3812
|
labels.push(...this.idle.labels(scene, local, cam, view, project));
|
|
3608
3813
|
labels.push(...this.say.labels(scene, local, cam, view, project, scene.multiplayer?.net?.selfId?.() ?? null));
|
|
3609
3814
|
}
|
|
@@ -3847,31 +4052,14 @@ class HubSystem {
|
|
|
3847
4052
|
|
|
3848
4053
|
// Reports a player to Castle (`Hub.report`), one at a time.
|
|
3849
4054
|
report(person) {
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
.then((answer) => {
|
|
3859
|
-
if (answer?.status === 'ok') {
|
|
3860
|
-
say('Reported. Thanks.');
|
|
3861
|
-
return;
|
|
3862
|
-
}
|
|
3863
|
-
this.reportOff = true;
|
|
3864
|
-
say("Reporting isn't available here.");
|
|
3865
|
-
})
|
|
3866
|
-
.catch((err) => {
|
|
3867
|
-
if (err?.code === 'UNKNOWN_COMMAND' || err?.code === 'CASTLE_HOST_UNAVAILABLE') {
|
|
3868
|
-
this.reportOff = true;
|
|
3869
|
-
}
|
|
3870
|
-
say("That report didn't go through. Try again later.");
|
|
3871
|
-
})
|
|
3872
|
-
.finally(() => {
|
|
3873
|
-
this.reporting = false;
|
|
3874
|
-
});
|
|
4055
|
+
reportPerson(person, {
|
|
4056
|
+
report: typeof castleSdk.Hub?.report === 'function' ? (userId) => castleSdk.Hub.report(userId) : null,
|
|
4057
|
+
// `reporting` and `reportOff` are this system's own.
|
|
4058
|
+
gate: this,
|
|
4059
|
+
say: (text) => {
|
|
4060
|
+
this.toast = { text, until: performance.now() + TOAST_MS };
|
|
4061
|
+
},
|
|
4062
|
+
});
|
|
3875
4063
|
}
|
|
3876
4064
|
|
|
3877
4065
|
// The tags the place put over players (`hub.mark`): over this player's own
|
|
@@ -3982,8 +4170,10 @@ class HubSystem {
|
|
|
3982
4170
|
// What players wear hangs on the avatars' nodes and holds shares of the
|
|
3983
4171
|
// hat builds: given back with the runtime.
|
|
3984
4172
|
this.companion?.dispose();
|
|
4173
|
+
this.vehicle?.clear();
|
|
3985
4174
|
this.wear?.clear();
|
|
3986
4175
|
this.earned?.clear();
|
|
4176
|
+
this.roles?.clear();
|
|
3987
4177
|
}
|
|
3988
4178
|
}
|
|
3989
4179
|
|
|
@@ -4031,6 +4221,11 @@ function isCabinet(door) {
|
|
|
4031
4221
|
}
|
|
4032
4222
|
|
|
4033
4223
|
// The scene actor of a door id: the actor whose `HubDoor` names it.
|
|
4224
|
+
// Whether this place's door leads into a House (a player's own, or a friend's).
|
|
4225
|
+
function houseDoor(scene, door) {
|
|
4226
|
+
return Boolean(door) && allActors(scene).some((actor) => actor.components?.HubDoor?.id === door && actor.components.HubDoor.to === 'deck:house');
|
|
4227
|
+
}
|
|
4228
|
+
|
|
4034
4229
|
function doorActor(scene, door) {
|
|
4035
4230
|
if (!door) {
|
|
4036
4231
|
return null;
|