castle-web-cli 0.4.237 → 0.4.238
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 +78 -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 +5 -0
- package/dist/init.js +2 -1
- package/dist/save-deck.js +4 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +47 -0
- package/kits/base/sdk/castle.d.ts +3 -1
- package/kits/base/sdk/castle.js +1 -0
- package/kits/base/sdk/commands.d.ts +25 -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/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 +4 -1
- 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 +207 -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/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 +154 -0
- package/kits/hub-game/code/client/wear.js +27 -5
- package/kits/hub-game/code/client/worldLabels.js +3 -2
- 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 +56 -6
- package/kits/hub-game/code/server/decor.js +56 -16
- package/kits/hub-game/code/server/hub.js +258 -46
- package/kits/hub-game/code/server/idle.js +118 -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/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 +272 -84
- package/kits/hub-game/docs/analytics.md +11 -2
- 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 +99 -5
- 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-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 +75 -0
- 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-manifest.mjs +30 -0
- 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 +183 -0
- package/kits/hub-game/scripts/test-role-client.mjs +421 -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-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 +159 -0
- package/kits/hub-game/scripts/test-vehicle.mjs +135 -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 +798 -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 +291 -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';
|
|
@@ -178,6 +188,9 @@ const CABINET_CAM_OUT = 1.5;
|
|
|
178
188
|
// What the multiplayer kit is switched to while a player is away in a classic
|
|
179
189
|
// deck: no session. It is never joined (`leaveSession`).
|
|
180
190
|
const AWAY_JOIN = { mode: 'hub', handoff: null, away: true };
|
|
191
|
+
// Place actions whose pick calls hub.invite (a town's Invite a friend, a win's
|
|
192
|
+
// Share, a house's Share): drawn only while the host makes links for this player.
|
|
193
|
+
const INVITE_ACTIONS = new Set(['invite-friend', 'share-win', 'share-town']);
|
|
181
194
|
// Castle refuses a player it has barred from the hub at every door and at the
|
|
182
195
|
// town itself with this code; the kit says so plainly and does not ask again.
|
|
183
196
|
export const HUB_BANNED = 'CAULDRON_HUB_BANNED';
|
|
@@ -252,7 +265,9 @@ class HubSystem {
|
|
|
252
265
|
this.spinData = null;
|
|
253
266
|
this.spin = null;
|
|
254
267
|
this.wear = makeWear();
|
|
268
|
+
this.vehicle = makeVehicle();
|
|
255
269
|
this.earned = makeEarned();
|
|
270
|
+
this.roles = makeRole();
|
|
256
271
|
this.toast = { text: '', until: 0 };
|
|
257
272
|
this.leavingToast = null;
|
|
258
273
|
this.stats = statsWanted();
|
|
@@ -431,6 +446,9 @@ class HubSystem {
|
|
|
431
446
|
place: Hub.hub.place,
|
|
432
447
|
visit: `${this.helloMark?.selfId ?? ''}:${this.helloMark?.again ?? ''}`,
|
|
433
448
|
});
|
|
449
|
+
if (Hub.hub.roles.size > 0) {
|
|
450
|
+
this.chrome.syncRoleLabels?.(roleItems(scene, scene.actorWith('Player'), cam, frame.view, Hub.hub.roles, project));
|
|
451
|
+
}
|
|
434
452
|
const labelBoxes = this.chrome.crowdNameLabelBoxes?.() ?? [];
|
|
435
453
|
const obstacles = [...frame.controls, ...(frame.own ? [frame.own] : []), ...labelBoxes];
|
|
436
454
|
const result = layoutCrowdNames(state, candidates, { now, view: frame.view, obstacles });
|
|
@@ -462,6 +480,11 @@ class HubSystem {
|
|
|
462
480
|
// Ordinary labels have already completed HUD clearance. Updating only
|
|
463
481
|
// E's summary preserves those final DOM positions for this paint.
|
|
464
482
|
this.chrome.setCrowdNameSummary?.(summary[0] ?? null);
|
|
483
|
+
// After the summary's flush, which restores what layout hid: a role chip
|
|
484
|
+
// whose name the crowd pass rejected stays hidden with it.
|
|
485
|
+
if (Hub.hub.roles.size > 0) {
|
|
486
|
+
this.chrome.syncRoleLabels?.(roleItems(scene, scene.actorWith('Player'), cam, frame.view, Hub.hub.roles, project), null, false);
|
|
487
|
+
}
|
|
465
488
|
}
|
|
466
489
|
|
|
467
490
|
invalidateCrowdNames(scene) {
|
|
@@ -485,6 +508,9 @@ class HubSystem {
|
|
|
485
508
|
}
|
|
486
509
|
}
|
|
487
510
|
if (hidden) {this.crowdHidden = hidden;}
|
|
511
|
+
if (Hub.hub.roles.size > 0) {
|
|
512
|
+
this.chrome.syncRoleLabels?.([], scene.multiplayer?.net?.selfId?.());
|
|
513
|
+
}
|
|
488
514
|
if (Object.hasOwn(this, 'crowdSprites')) {delete this.crowdSprites;}
|
|
489
515
|
}
|
|
490
516
|
|
|
@@ -514,6 +540,9 @@ class HubSystem {
|
|
|
514
540
|
this.doorErrors.sync(mp.net, Boolean(Hub.hub.place?.result) && !this.trip, now);
|
|
515
541
|
}
|
|
516
542
|
if (!this.chrome) {
|
|
543
|
+
// A UI tree host reads every `clock` in the simulation's time; each
|
|
544
|
+
// root it is sent carries this time.
|
|
545
|
+
setUiTreeTime(() => Hub.simNow() / 1000);
|
|
517
546
|
this.chrome = makeChrome({
|
|
518
547
|
worldLabelsDefault: !Hub.deck.labels,
|
|
519
548
|
...((Hub.deck.safeInsets === true || Hub.deck.act === true) ? { safeInsets: true } : {}),
|
|
@@ -554,7 +583,7 @@ class HubSystem {
|
|
|
554
583
|
this.idle ??= makeIdle(this.chrome);
|
|
555
584
|
this.sound ??= makeSound();
|
|
556
585
|
if (Hub.deck.soundscape && !this.soundscape) {
|
|
557
|
-
this.hearPlace();
|
|
586
|
+
this.hearPlace(scene);
|
|
558
587
|
}
|
|
559
588
|
if (!this.sayHooked) {
|
|
560
589
|
this.sayHooked = true;
|
|
@@ -572,6 +601,7 @@ class HubSystem {
|
|
|
572
601
|
this.backHooked = true;
|
|
573
602
|
castleSdk.Hub.onBack(() => this.backFromControl(this.scene));
|
|
574
603
|
}
|
|
604
|
+
this.hookHostGo();
|
|
575
605
|
const per = (scene.persistent ??= {});
|
|
576
606
|
per.hubTickets ??= [];
|
|
577
607
|
this.keepResident(scene, per.hubTickets);
|
|
@@ -588,6 +618,7 @@ class HubSystem {
|
|
|
588
618
|
const local = scene.actorWith('Player');
|
|
589
619
|
this.wearAvatar(scene, local);
|
|
590
620
|
this.applyTune(local);
|
|
621
|
+
this.vehicle.frame(scene, local, Hub.hub.cars, !this.trip && this.pendingEnd === null);
|
|
591
622
|
this.watchSession(scene, mp);
|
|
592
623
|
this.sayHello(scene, mp);
|
|
593
624
|
if (Hub.hub.place?.push?.version === 1 && Hub.hub.arrivedFacing !== null && mp.net) {
|
|
@@ -626,6 +657,8 @@ class HubSystem {
|
|
|
626
657
|
if (!this.trip) {this.invites.frame(mp.net);}
|
|
627
658
|
} else if (Hub.hub.place && this.invites) { this.invites.dispose(); this.invites = null; }
|
|
628
659
|
this.runCommands(scene, now);
|
|
660
|
+
this.hubEntryFrame(scene, mp, local);
|
|
661
|
+
this.hostGoFrame(scene, mp, local);
|
|
629
662
|
this.askFriends(scene, mp, now);
|
|
630
663
|
this.together.frame(mp, this.friendsAll, !this.trip && this.pendingEnd === null, now, this.chrome.peopleOpen?.() === true);
|
|
631
664
|
|
|
@@ -744,8 +777,12 @@ class HubSystem {
|
|
|
744
777
|
}
|
|
745
778
|
// Grabbing and throwing (v1.3), in a place that offers it: after this
|
|
746
779
|
// 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,
|
|
780
|
+
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
781
|
Hub.deck.act === true && Boolean(this.actionInput) && !this.trip && this.pendingEnd === null);
|
|
782
|
+
const myCar = Hub.hub.cars[mp.net?.selfId?.()];
|
|
783
|
+
if (myCar?.horn && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded) {
|
|
784
|
+
this.chrome.hornPrompt?.(() => mp.net?.send({ k: 'hub-horn' }));
|
|
785
|
+
}
|
|
749
786
|
if (Hub.deck.act === true) {
|
|
750
787
|
this.act ??= makeAct(this.chrome, this.grab, this.talk);
|
|
751
788
|
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 +816,12 @@ class HubSystem {
|
|
|
779
816
|
if (Hub.hub.place?.actions === true || Hub.hub.place?.anonymousEntry === true) {
|
|
780
817
|
this.actionsDrawn = true;
|
|
781
818
|
const hud = Hub.hub.hudMe ?? Hub.hub.hud;
|
|
782
|
-
const
|
|
819
|
+
const inviting = () => Hub.hub.place?.invite === true && this.invites?.canInvite(mp.net, castleSdk.User) === true;
|
|
820
|
+
const offered = Hub.hub.actions?.items ?? null, invites = offered?.some((item) => INVITE_ACTIONS.has(item?.id)) ? inviting() : true;
|
|
821
|
+
const items = this.signIn.items(Hub.hub.place, hud, invites ? offered : offered.filter((item) => !INVITE_ACTIONS.has(item?.id)));
|
|
783
822
|
this.chrome.setActions(items, (id, n) => {
|
|
784
823
|
if (id === 'signin' && Hub.hub.place?.anonymousEntry === true) {void this.signIn.press(hud?.text ?? 'Keep your progress');}
|
|
824
|
+
else if (INVITE_ACTIONS.has(id) && !inviting()) {return;}
|
|
785
825
|
else {mp.net?.send({ k: 'hub-action', id, n });}
|
|
786
826
|
}, !this.signIn.pending() && !this.trip && this.pendingEnd === null && !this.talk.talking() && !decorating && !this.carded && !this.askInput && !this.menuInput,
|
|
787
827
|
Hub.hub.actions?.n, scene.data?.engine?.hubActionOverflow === true || !landscapeViewport(), (open) => {
|
|
@@ -826,8 +866,8 @@ class HubSystem {
|
|
|
826
866
|
// listener, storage read or chrome of it is made. Made with the chrome, and
|
|
827
867
|
// put away with it (`dispose`): an NPC's line in the talk panel is heard as
|
|
828
868
|
// 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 });
|
|
869
|
+
hearPlace(scene) {
|
|
870
|
+
const soundscape = makeSoundscape(Hub.deck.soundscape, { lowMemory: scene?.three?.lowMemory === true, onHide: () => this.sound?.hush(), isOn: () => !this.trip, loudestLoop: () => this.sound?.loudestLoop() ?? 0 });
|
|
831
871
|
this.soundscape = soundscape;
|
|
832
872
|
this.sound?.filterEvents?.(soundscape.live);
|
|
833
873
|
this.soundHandlers = { onVolume: (volume) => soundscape.setVolume(volume), onMuted: (muted) => soundscape.setMuted(muted) };
|
|
@@ -852,6 +892,7 @@ class HubSystem {
|
|
|
852
892
|
}
|
|
853
893
|
if (!this.tiers) {
|
|
854
894
|
this.tiers = qualityFor(scene)?.tiers ?? makeTiers({ weakest: Hub.deck.weakestTier === true,
|
|
895
|
+
lowMemory: scene.three?.lowMemory === true,
|
|
855
896
|
onLayout: (node) => this.chrome?.safeSurface?.('cells-debug', node, 'text') });
|
|
856
897
|
const pick = (mode) => {
|
|
857
898
|
this.tiers.set(mode);
|
|
@@ -930,6 +971,15 @@ class HubSystem {
|
|
|
930
971
|
}
|
|
931
972
|
|
|
932
973
|
// The systems that run after every other one, registered once per runtime.
|
|
974
|
+
// Cars (v1.160) after the multiplayer kit has placed every avatar: each
|
|
975
|
+
// look under its driver's node, riders on their seats, a rider's camera.
|
|
976
|
+
applyCars(s) {
|
|
977
|
+
this.vehicle.draw(s, s.actorWith('Player'), Hub.hub.cars);
|
|
978
|
+
if (Object.keys(Hub.hub.cars).length) {
|
|
979
|
+
this.vehicle.camera(s, s.actorWith('Player'), Hub.hub.cars);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
933
983
|
registerLate(scene) {
|
|
934
984
|
if (this.lateScenes?.has(scene)) {return;}
|
|
935
985
|
(this.lateScenes ??= new WeakSet()).add(scene);
|
|
@@ -937,6 +987,7 @@ class HubSystem {
|
|
|
937
987
|
afterBehaviors: (s) => {
|
|
938
988
|
this.applyVisibility(s);
|
|
939
989
|
this.applyWear(s);
|
|
990
|
+
this.applyCars(s);
|
|
940
991
|
this.fadeNames(s);
|
|
941
992
|
},
|
|
942
993
|
});
|
|
@@ -1039,8 +1090,10 @@ class HubSystem {
|
|
|
1039
1090
|
this.tinted.clear();
|
|
1040
1091
|
this.spawnedHere.clear();
|
|
1041
1092
|
this.companion?.clear();
|
|
1093
|
+
this.vehicle.clear();
|
|
1042
1094
|
this.wear.clear(scene);
|
|
1043
1095
|
this.earned.clear();
|
|
1096
|
+
this.roles.clear();
|
|
1044
1097
|
this.idle?.release();
|
|
1045
1098
|
if (this.decor) {
|
|
1046
1099
|
this.decor.dispose();
|
|
@@ -1084,12 +1137,15 @@ class HubSystem {
|
|
|
1084
1137
|
this.stash.clear();
|
|
1085
1138
|
this.tinted.clear();
|
|
1086
1139
|
this.spawnedHere.clear();
|
|
1140
|
+
this.vehicle.clear();
|
|
1087
1141
|
if (scene) {
|
|
1088
1142
|
this.wear.clear(scene);
|
|
1089
1143
|
this.earned.clear();
|
|
1144
|
+
this.roles.clear();
|
|
1090
1145
|
} else {
|
|
1091
1146
|
this.wear.forget();
|
|
1092
1147
|
this.earned.forget();
|
|
1148
|
+
this.roles.forget();
|
|
1093
1149
|
}
|
|
1094
1150
|
}
|
|
1095
1151
|
|
|
@@ -1105,7 +1161,7 @@ class HubSystem {
|
|
|
1105
1161
|
this.wear.frame(
|
|
1106
1162
|
scene,
|
|
1107
1163
|
local ?? scene.actorWith('Player'),
|
|
1108
|
-
Hub.hub.wearing,
|
|
1164
|
+
roleWearing(Hub.hub.wearing, Hub.hub.roles),
|
|
1109
1165
|
(playerId) => {
|
|
1110
1166
|
const index = indexOf(playerId);
|
|
1111
1167
|
return Avatar.top(index, Avatar.drawn(scene.files, index, style));
|
|
@@ -1117,10 +1173,16 @@ class HubSystem {
|
|
|
1117
1173
|
return Avatar.hatFit(index, Avatar.drawn(scene.files, index, style));
|
|
1118
1174
|
},
|
|
1119
1175
|
);
|
|
1176
|
+
if (Hub.hub.roles.size > 0 || this.roles.size > 0) {
|
|
1177
|
+
this.roles.frame(scene, local ?? scene.actorWith('Player'), Hub.hub.roles, (playerId) => {
|
|
1178
|
+
const index = indexOf(playerId);
|
|
1179
|
+
return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1120
1182
|
// Earned items (v1.53): no work at all while nobody shows one and
|
|
1121
1183
|
// nothing is drawn.
|
|
1122
1184
|
if (Hub.hub.earned.size > 0 || this.earned.size > 0) {
|
|
1123
|
-
this.earned.frame(scene, local ?? scene.actorWith('Player'), Hub.hub.earned, (playerId) => {
|
|
1185
|
+
this.earned.frame(scene, local ?? scene.actorWith('Player'), roleEarned(Hub.hub.earned, Hub.hub.roles), (playerId) => {
|
|
1124
1186
|
const index = indexOf(playerId);
|
|
1125
1187
|
return Avatar.earnedFit(index, Avatar.drawn(scene.files, index, style));
|
|
1126
1188
|
});
|
|
@@ -1138,6 +1200,7 @@ class HubSystem {
|
|
|
1138
1200
|
if (this.tuneBase?.player !== player) {
|
|
1139
1201
|
this.tuneBase = { player, speed: player.speed, jumpSpeed: player.jumpSpeed };
|
|
1140
1202
|
}
|
|
1203
|
+
if (Object.hasOwn(Hub.hub.cars, this.scene?.multiplayer?.net?.selfId?.())) {return;}
|
|
1141
1204
|
const t = Hub.hub.tune;
|
|
1142
1205
|
const mul = (v, lo, hi) => (typeof v === 'number' && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : 1);
|
|
1143
1206
|
const speed = this.tuneBase.speed * mul(t?.speed, 0.25, 3);
|
|
@@ -1186,6 +1249,9 @@ class HubSystem {
|
|
|
1186
1249
|
const color = Avatar.currentColor(scene);
|
|
1187
1250
|
if (net === this.helloNet) {
|
|
1188
1251
|
const back = Rehello.resumed(mp, net, this.helloMark);
|
|
1252
|
+
if (back) {
|
|
1253
|
+
this.admitEpoch = (this.admitEpoch ?? 0) + 1;
|
|
1254
|
+
}
|
|
1189
1255
|
// (Another player id was reset for by `newIdentity`, already.) A game
|
|
1190
1256
|
// (a place with `result`) back under the same id keeps the old way, as
|
|
1191
1257
|
// its server does, unless its place says `resume: true` (v1.72); under a
|
|
@@ -1196,6 +1262,7 @@ class HubSystem {
|
|
|
1196
1262
|
if (say !== 'none') {
|
|
1197
1263
|
console.log(`[hub] the connection came back (${back}): saying a ${say} hello`);
|
|
1198
1264
|
this.sendHello(scene, mp, net, avatar, say === 'resume' ? { resume: true } : { solo: true });
|
|
1265
|
+
this.noTripsAfterHello(net);
|
|
1199
1266
|
if (back === 'world') {
|
|
1200
1267
|
this.talk?.resume();
|
|
1201
1268
|
}
|
|
@@ -1226,6 +1293,7 @@ class HubSystem {
|
|
|
1226
1293
|
this.freshSession(scene);
|
|
1227
1294
|
}
|
|
1228
1295
|
this.sendHello(scene, mp, net, avatar, { again, inviteNear });
|
|
1296
|
+
this.noTripsAfterHello(net);
|
|
1229
1297
|
if (!again) {this.invites?.landed();}
|
|
1230
1298
|
}
|
|
1231
1299
|
|
|
@@ -1235,6 +1303,7 @@ class HubSystem {
|
|
|
1235
1303
|
// as on any switch of session, along with what this client kept of it.
|
|
1236
1304
|
newIdentity() {
|
|
1237
1305
|
this.pushVisit = null;
|
|
1306
|
+
this.admitEpoch = (this.admitEpoch ?? 0) + 1;
|
|
1238
1307
|
console.log('[hub] the connection has a new player id: a new session');
|
|
1239
1308
|
this.identityPlace = Hub.hub.place ?? this.identityPlace;
|
|
1240
1309
|
Hub.clear();
|
|
@@ -1286,6 +1355,13 @@ class HubSystem {
|
|
|
1286
1355
|
}
|
|
1287
1356
|
}
|
|
1288
1357
|
|
|
1358
|
+
// v1.156: after a hello, an app that cannot go through doors says so
|
|
1359
|
+
// (`client/noTrips.js`).
|
|
1360
|
+
noTripsAfterHello(net) {
|
|
1361
|
+
this.noTrips ??= makeNoTrips(castleSdk);
|
|
1362
|
+
this.noTrips.afterHello(net, () => this.helloNet === net);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1289
1365
|
// `solo`: a party of one carrying nothing and naming no friend, as `resume`
|
|
1290
1366
|
// is, without saying it resumes (a game's new session, `helloAfter`).
|
|
1291
1367
|
sendHello(scene, mp, net, avatar, { again = false, resume = false, solo = resume, inviteNear = null } = {}) {
|
|
@@ -1310,8 +1386,18 @@ class HubSystem {
|
|
|
1310
1386
|
this.helloMark = Rehello.mark(mp, net, () => this.newIdentity());
|
|
1311
1387
|
const per = scene.persistent;
|
|
1312
1388
|
const arriving = per.hubArriving ?? null;
|
|
1389
|
+
const readDevice = (read) => { try { return read(); } catch { return undefined; } };
|
|
1390
|
+
const device = encodeDeviceClass({
|
|
1391
|
+
lowMemory: scene.three?.lowMemory === true,
|
|
1392
|
+
cores: readDevice(() => typeof navigator === 'undefined' ? undefined : navigator.hardwareConcurrency),
|
|
1393
|
+
dpr: readDevice(() => typeof devicePixelRatio === 'undefined' ? undefined : devicePixelRatio),
|
|
1394
|
+
width: readDevice(() => typeof screen === 'undefined' ? undefined : screen.width),
|
|
1395
|
+
height: readDevice(() => typeof screen === 'undefined' ? undefined : screen.height),
|
|
1396
|
+
deviceMemory: readDevice(() => typeof navigator === 'undefined' ? undefined : navigator.deviceMemory),
|
|
1397
|
+
});
|
|
1313
1398
|
net.send({
|
|
1314
1399
|
k: 'hub-hello',
|
|
1400
|
+
...(device ? { device } : {}),
|
|
1315
1401
|
avatar,
|
|
1316
1402
|
...(Number.isInteger(this.helloColor) && this.helloColor > 0 ? { color: this.helloColor } : {}),
|
|
1317
1403
|
from: arriving?.door ?? null,
|
|
@@ -1537,10 +1623,132 @@ class HubSystem {
|
|
|
1537
1623
|
this.pendingEnd = this.endCovered ? now : now + END_PAUSE_MS;
|
|
1538
1624
|
this.endSession = sessionKey(scene);
|
|
1539
1625
|
this.endLeaving = null;
|
|
1626
|
+
// Only a game is over: a place without a result that sends a player
|
|
1627
|
+
// back (the House's front door, the first room's way to the Town)
|
|
1628
|
+
// says what it says in its own HUD.
|
|
1540
1629
|
const r = scene.persistent.hubResult;
|
|
1541
|
-
|
|
1630
|
+
if (Hub.hub.place?.result) {
|
|
1631
|
+
this.toast = { text: r && Date.now() - r.at < 30000 ? resultLine(r) : 'Game over', until: now + END_PAUSE_MS + 200 };
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
// A hub-entry link (`client/hubEntry.js`): the Town's link for the House or
|
|
1638
|
+
// one of its doors, read once per page load on the first place it enters
|
|
1639
|
+
// at the root. An invite wins; a trip or session swap first spends it.
|
|
1640
|
+
hubEntryFrame(scene, mp, local) {
|
|
1641
|
+
this.hubEntry ??= makeHubEntry({
|
|
1642
|
+
joinHint: () => castleSdk.Multiplayer?.joinHint?.() ?? null,
|
|
1643
|
+
extras: (target) => this.hubEntryExtras(target),
|
|
1644
|
+
act: (target, info) => this.hubEntryAct(this.scene, target, info),
|
|
1645
|
+
current: () => this.hubEntryContext(this.scene),
|
|
1646
|
+
});
|
|
1647
|
+
// Admissions are counted from the first look at a connection, not only
|
|
1648
|
+
// from its first hello: an invite check can hold that hello back, and a
|
|
1649
|
+
// re-admission meanwhile must spend the link too.
|
|
1650
|
+
if (mp.net && this.hubEntry.state() !== 'done' && this.entryWatch?.net !== mp.net) {
|
|
1651
|
+
this.entryWatch = { net: mp.net, w: Rehello.watch(mp, mp.net) };
|
|
1652
|
+
}
|
|
1653
|
+
this.hubEntry.frame(this.hubEntryContext(scene, mp, local));
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
// The host's Go (v1.155, `client/hostGo.js`): through a door of this
|
|
1657
|
+
// place as if its pad had fired. An SDK without `Hub.onGo` never sends one.
|
|
1658
|
+
hookHostGo() {
|
|
1659
|
+
if (this.hostGoHooked || typeof castleSdk.Hub?.onGo !== 'function') {
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
this.hostGoHooked = true;
|
|
1663
|
+
this.hostGo ??= makeHostGo();
|
|
1664
|
+
castleSdk.Hub.onGo((go) => this.hostGo.offer(go, { at: performance.now(), tripping: Boolean(this.trip) }));
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
hostGoFrame(scene, mp, local) {
|
|
1668
|
+
const msg = this.hostGo?.take({
|
|
1669
|
+
now: performance.now(),
|
|
1670
|
+
settled: this.hubEntryContext(scene, mp, local).settled,
|
|
1671
|
+
tripping: Boolean(this.trip),
|
|
1672
|
+
result: Boolean(Hub.hub.place?.result),
|
|
1673
|
+
doors: Hub.hub.doors,
|
|
1674
|
+
});
|
|
1675
|
+
if (msg) {
|
|
1676
|
+
console.log(`[hub-host-go] ${JSON.stringify({ door: msg.door, party: msg.party, owner: Boolean(msg.owner) })}`);
|
|
1677
|
+
this.goHub(scene, msg);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
// Where the first entry stands now. `epoch` moves at every re-admission
|
|
1682
|
+
// on a greeted connection and every new player id (`sayHello`,
|
|
1683
|
+
// `newIdentity`): a reconnect on the same net spends the link.
|
|
1684
|
+
hubEntryContext(scene, mp = scene?.multiplayer, local = scene?.actorWith?.('Player')) {
|
|
1685
|
+
const place = Hub.hub.place;
|
|
1686
|
+
const per = scene?.persistent ?? {};
|
|
1687
|
+
const net = mp?.net ?? null;
|
|
1688
|
+
const selfId = net?.selfId?.() ?? null;
|
|
1689
|
+
return {
|
|
1690
|
+
known: Boolean(place),
|
|
1691
|
+
root: Boolean(scene && mp && place) && !place.result && !this.trip && this.tripCount === 0 && !(per.hubDepth > 0) &&
|
|
1692
|
+
!(per.hubTickets?.length) && mp.target?.mode !== 'hub' && !per.hubArriving?.door,
|
|
1693
|
+
net,
|
|
1694
|
+
selfId,
|
|
1695
|
+
epoch: net ? `${this.admitEpoch ?? 0}:${this.entryWatch?.net === net ? this.entryWatch.w.again : '-'}` : null,
|
|
1696
|
+
invited: this.invites?.carried?.() === true,
|
|
1697
|
+
settled: Boolean(net) && net === this.helloNet && !net.closed?.() && mp?.placed?.() === true &&
|
|
1698
|
+
this.pendingEnd === null && Boolean(local) && Hub.hub.doors.length > 0 && !Hub.hub.held.has(selfId),
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
// Read just before deciding: whether this player is a guest (no House the
|
|
1703
|
+
// kit can host: firstVisit.js in the Town), and the host's door rows.
|
|
1704
|
+
async hubEntryExtras(target) {
|
|
1705
|
+
const selfId = this.scene?.multiplayer?.net?.selfId?.();
|
|
1706
|
+
let guest = Hub.hub.guests?.has?.(selfId) === true ? true : null;
|
|
1707
|
+
if (guest === null) {
|
|
1708
|
+
try {
|
|
1709
|
+
const me = await castleSdk.User?.getCurrent?.();
|
|
1710
|
+
guest = me && typeof me === 'object' ? !me.userId || me.isAnonymous === true : null;
|
|
1711
|
+
} catch { guest = null; }
|
|
1712
|
+
}
|
|
1713
|
+
let host = null;
|
|
1714
|
+
if (target.kind === 'door') {
|
|
1715
|
+
try {
|
|
1716
|
+
const answer = await castleSdk.Hub?.doors?.();
|
|
1717
|
+
if (answer?.status === 'ok' && Array.isArray(answer.doors)) {
|
|
1718
|
+
host = new Map(answer.doors.filter((d) => typeof d?.doorId === 'string').map((d) => [d.doorId, d]));
|
|
1719
|
+
}
|
|
1720
|
+
} catch { host = null; }
|
|
1721
|
+
}
|
|
1722
|
+
return { guest, host };
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
hubEntryAct(scene, target, { guest = null, host = null } = {}) {
|
|
1726
|
+
const mp = scene?.multiplayer;
|
|
1727
|
+
// `makeHubEntry` checked the whole context again just now; this is the backstop.
|
|
1728
|
+
if (!scene || !mp?.net || this.trip || this.tripCount > 0 || this.pendingEnd !== null || Hub.hub.place?.result ||
|
|
1729
|
+
Hub.hub.held.has(mp.net.selfId?.())) {
|
|
1730
|
+
return;
|
|
1731
|
+
}
|
|
1732
|
+
const me = scene.actorWith('Player')?.components.Transform;
|
|
1733
|
+
const homes = [];
|
|
1734
|
+
for (const actor of allActors(scene)) {
|
|
1735
|
+
const door = actor.components?.HubDoor;
|
|
1736
|
+
if (door?.to === 'deck:house' && typeof door.id === 'string') {
|
|
1737
|
+
const t = actor.components.Transform;
|
|
1738
|
+
homes.push({ id: door.id, d: me && t ? Math.hypot(t.x - me.x, t.z - me.z) : Infinity });
|
|
1542
1739
|
}
|
|
1543
1740
|
}
|
|
1741
|
+
homes.sort((a, b) => a.d - b.d);
|
|
1742
|
+
const plan = planHubEntry(target, { listed: Hub.hub.doors, homes: homes.map((h) => h.id), host, guest });
|
|
1743
|
+
console.log(`[hub-entry] ${JSON.stringify({ target, plan: plan ? Object.keys(plan) : null })}`);
|
|
1744
|
+
if (plan?.go) {
|
|
1745
|
+
this.goHub(scene, { door: plan.go.door, title: plan.go.title });
|
|
1746
|
+
} else if (plan?.jump) {
|
|
1747
|
+
this.goDoor(scene, plan.jump);
|
|
1748
|
+
}
|
|
1749
|
+
if (plan?.toast) {
|
|
1750
|
+
this.toast = { text: plan.toast, until: performance.now() + TOAST_MS };
|
|
1751
|
+
}
|
|
1544
1752
|
}
|
|
1545
1753
|
|
|
1546
1754
|
// Through a door ghost fixed a group for (the place's server fired its pad):
|
|
@@ -2020,40 +2228,20 @@ class HubSystem {
|
|
|
2020
2228
|
// invitation into the party (Invite), or Join -- beside a party member or a
|
|
2021
2229
|
// friend in this layer (the place moves this player), into the layer of
|
|
2022
2230
|
// this place a friend is in (a jump), or to the door of the game a friend
|
|
2023
|
-
// is inside.
|
|
2231
|
+
// is inside (`personAction`, shared with a native host).
|
|
2024
2232
|
join(scene, person, action) {
|
|
2025
|
-
|
|
2026
|
-
if (!net || this.trip || !person) {
|
|
2233
|
+
if (this.trip) {
|
|
2027
2234
|
return;
|
|
2028
2235
|
}
|
|
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
|
-
}
|
|
2236
|
+
personAction(scene?.multiplayer?.net, person, action, {
|
|
2237
|
+
together: this.together,
|
|
2238
|
+
say: (text) => {
|
|
2239
|
+
this.toast = { text, until: performance.now() + TOAST_MS };
|
|
2240
|
+
},
|
|
2241
|
+
jump: (net, message) => this.sendJump(net, message),
|
|
2242
|
+
jumpTo: (friend) => this.jump(scene, friend),
|
|
2243
|
+
doors: Hub.hub.doors,
|
|
2244
|
+
});
|
|
2057
2245
|
}
|
|
2058
2246
|
|
|
2059
2247
|
// "Stuck?" (v1.33, `client/stuck.js`), only in a deck whose castle.json asks
|
|
@@ -2074,7 +2262,8 @@ class HubSystem {
|
|
|
2074
2262
|
return;
|
|
2075
2263
|
}
|
|
2076
2264
|
this.stuck ??= makeStuck();
|
|
2077
|
-
const
|
|
2265
|
+
const driving = Object.hasOwn(Hub.hub.cars, selfId);
|
|
2266
|
+
const walking = driving ? carInput(scene.keys, scene.moveInput).forward !== 0 : walkInput(scene.keys, scene.moveInput, scene.cameraControl === 'orbit');
|
|
2078
2267
|
const hidden = globalThis.document?.visibilityState === 'hidden';
|
|
2079
2268
|
const shown = stuckFrame(this.stuck, { key: `${this.sceneKey}|${Hub.hub.place.id}`, x: t.x, z: t.z, walking, hidden }, now);
|
|
2080
2269
|
let text = shown ? stuckText(offer.to) : null;
|
|
@@ -2094,6 +2283,7 @@ class HubSystem {
|
|
|
2094
2283
|
this.toast = { text: stuckDone(done.to, done.spot), until: now + TOAST_MS };
|
|
2095
2284
|
}
|
|
2096
2285
|
}
|
|
2286
|
+
if (driving && shown) {text = stuckText(null, false, true);}
|
|
2097
2287
|
this.stuckShown = shown;
|
|
2098
2288
|
this.chrome.stuckPrompt?.(text, () => this.unstick(this.scene));
|
|
2099
2289
|
}
|
|
@@ -2488,15 +2678,20 @@ class HubSystem {
|
|
|
2488
2678
|
|
|
2489
2679
|
// A user Back first dismisses transient chrome; automatic travel still uses back.
|
|
2490
2680
|
backFromControl(scene) {
|
|
2491
|
-
|
|
2681
|
+
const press = backPress({
|
|
2682
|
+
overflowOpen: this.chrome?.actionOverflowOpen?.(),
|
|
2683
|
+
menuOpen: this.chrome?.menuOpen?.(),
|
|
2684
|
+
inGame: Boolean(Hub.hub.place?.result),
|
|
2685
|
+
});
|
|
2686
|
+
if (press === 'overflow') {
|
|
2492
2687
|
this.chrome.cancelActionOverflow();
|
|
2493
2688
|
return;
|
|
2494
2689
|
}
|
|
2495
|
-
if (
|
|
2690
|
+
if (press === 'menu') {
|
|
2496
2691
|
this.chrome.cancelMenu();
|
|
2497
2692
|
return;
|
|
2498
2693
|
}
|
|
2499
|
-
if (
|
|
2694
|
+
if (press === 'quit') {scene.multiplayer?.net?.send({ k: 'hub-door-quit' });}
|
|
2500
2695
|
this.back(scene);
|
|
2501
2696
|
}
|
|
2502
2697
|
|
|
@@ -2515,10 +2710,11 @@ class HubSystem {
|
|
|
2515
2710
|
}
|
|
2516
2711
|
const per = scene.persistent;
|
|
2517
2712
|
const ticket = per.hubTickets.pop();
|
|
2713
|
+
const route = backRoute({ ticket, hubDepth: per.hubDepth });
|
|
2518
2714
|
// A place reached by a hub trip goes back the way the host says (`Hub.back`):
|
|
2519
2715
|
// to the place in this runtime the ticket remembers, or, with no ticket, to
|
|
2520
2716
|
// wherever ghost's return ticket leads, from its pack.
|
|
2521
|
-
if (
|
|
2717
|
+
if (route === 'host') {
|
|
2522
2718
|
const stay = ticket ? { content: ticket.content ?? null } : undefined;
|
|
2523
2719
|
this.startTrip(scene, {
|
|
2524
2720
|
scene: ticket?.scene ?? null,
|
|
@@ -2549,7 +2745,7 @@ class HubSystem {
|
|
|
2549
2745
|
}
|
|
2550
2746
|
return;
|
|
2551
2747
|
}
|
|
2552
|
-
if (
|
|
2748
|
+
if (route === 'instance') {
|
|
2553
2749
|
const place = Hub.hub.place?.id ?? 'main';
|
|
2554
2750
|
// Another deck's place runs that deck's server: its key keeps the prefix.
|
|
2555
2751
|
const prefix = scene.content?.sessionKeyPrefix ?? '';
|
|
@@ -3230,7 +3426,7 @@ class HubSystem {
|
|
|
3230
3426
|
}
|
|
3231
3427
|
}
|
|
3232
3428
|
if (Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
3233
|
-
this.yourGames().returned(trip.target.arrive.door, r);
|
|
3429
|
+
this.yourGames().returned(trip.target.arrive.door, r, houseDoor(scene, trip.target.arrive.door));
|
|
3234
3430
|
}
|
|
3235
3431
|
if (Hub.deck.cues && !Hub.deck.yourGames && trip.target.arrive?.returning && trip.target.arrive.door) {
|
|
3236
3432
|
// Cues: a next step, put once the player is back in the town, whether
|
|
@@ -3309,11 +3505,12 @@ class HubSystem {
|
|
|
3309
3505
|
// Away in a classic deck, the cover is down and Back is the only control.
|
|
3310
3506
|
const away = this.trip?.phase === 'away';
|
|
3311
3507
|
const hostTrail = scene.persistent.hubDepth > 0;
|
|
3508
|
+
// Old Android landscape hosts draw Exit deck, so keep a way back into
|
|
3509
|
+
// town. Hosts advertising their landscape Back retain sole ownership.
|
|
3510
|
+
const back = backControl({ away, idle, pendingEnd: this.pendingEnd, hostTrail, place, ticket, kitBack: hostTrail && kitBackNeeded() });
|
|
3312
3511
|
chrome.showBack(
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
(away || (idle && this.pendingEnd === null)) && (hostTrail ? place !== null && kitBackNeeded() : inGame || Boolean(ticket)),
|
|
3316
|
-
ticket?.title ?? (hostTrail && kitBackNeeded() ? 'Back' : 'Again'),
|
|
3512
|
+
back.show,
|
|
3513
|
+
back.label,
|
|
3317
3514
|
);
|
|
3318
3515
|
const free = idle && place !== null && this.pendingEnd === null && !this.talk.talking() && !this.carded;
|
|
3319
3516
|
const town = free && !inGame;
|
|
@@ -3472,21 +3669,21 @@ class HubSystem {
|
|
|
3472
3669
|
}
|
|
3473
3670
|
|
|
3474
3671
|
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
|
-
}
|
|
3672
|
+
// The player's own HUD over the place's, and its timer's seconds now.
|
|
3673
|
+
const { spec, timer } = hudInputs(Hub.hub, Hub.simNow());
|
|
3482
3674
|
// A place that asks (`hud.clear`, v1.26) has its HUD kept short and its
|
|
3483
3675
|
// labels kept out from under it; any other is drawn as it always was.
|
|
3484
3676
|
if (place?.hud?.clear === true || this.hudClear) {
|
|
3485
3677
|
this.hudClear = place?.hud?.clear === true;
|
|
3486
3678
|
chrome.setHudClear?.(this.hudClear);
|
|
3487
3679
|
}
|
|
3488
|
-
|
|
3680
|
+
// The sim time lets the chrome send the timer as a clock that counts
|
|
3681
|
+
// by itself, sent again only when its base moves.
|
|
3682
|
+
chrome.setHud(idle || this.trip?.phase === 'revealing' ? spec : null, timer, Hub.simNow());
|
|
3489
3683
|
}
|
|
3684
|
+
// A server time correction with nothing else changed still reaches a UI
|
|
3685
|
+
// tree host, whose clocks read the simulation time.
|
|
3686
|
+
syncUiTreeTime();
|
|
3490
3687
|
|
|
3491
3688
|
const cam = scene.three?.camera;
|
|
3492
3689
|
const view = { w: window.innerWidth, h: window.innerHeight };
|
|
@@ -3604,6 +3801,7 @@ class HubSystem {
|
|
|
3604
3801
|
chrome.setPointers?.(pointers.map((point) => offsetWorldPoint(point, view)));
|
|
3605
3802
|
if (cam && idle) {
|
|
3606
3803
|
labels.push(...this.markItems(scene, local, cam, view));
|
|
3804
|
+
labels.push(...roleItems(scene, local, cam, view, Hub.hub.roles, project));
|
|
3607
3805
|
labels.push(...this.idle.labels(scene, local, cam, view, project));
|
|
3608
3806
|
labels.push(...this.say.labels(scene, local, cam, view, project, scene.multiplayer?.net?.selfId?.() ?? null));
|
|
3609
3807
|
}
|
|
@@ -3847,31 +4045,14 @@ class HubSystem {
|
|
|
3847
4045
|
|
|
3848
4046
|
// Reports a player to Castle (`Hub.report`), one at a time.
|
|
3849
4047
|
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
|
-
});
|
|
4048
|
+
reportPerson(person, {
|
|
4049
|
+
report: typeof castleSdk.Hub?.report === 'function' ? (userId) => castleSdk.Hub.report(userId) : null,
|
|
4050
|
+
// `reporting` and `reportOff` are this system's own.
|
|
4051
|
+
gate: this,
|
|
4052
|
+
say: (text) => {
|
|
4053
|
+
this.toast = { text, until: performance.now() + TOAST_MS };
|
|
4054
|
+
},
|
|
4055
|
+
});
|
|
3875
4056
|
}
|
|
3876
4057
|
|
|
3877
4058
|
// The tags the place put over players (`hub.mark`): over this player's own
|
|
@@ -3982,8 +4163,10 @@ class HubSystem {
|
|
|
3982
4163
|
// What players wear hangs on the avatars' nodes and holds shares of the
|
|
3983
4164
|
// hat builds: given back with the runtime.
|
|
3984
4165
|
this.companion?.dispose();
|
|
4166
|
+
this.vehicle?.clear();
|
|
3985
4167
|
this.wear?.clear();
|
|
3986
4168
|
this.earned?.clear();
|
|
4169
|
+
this.roles?.clear();
|
|
3987
4170
|
}
|
|
3988
4171
|
}
|
|
3989
4172
|
|
|
@@ -4031,6 +4214,11 @@ function isCabinet(door) {
|
|
|
4031
4214
|
}
|
|
4032
4215
|
|
|
4033
4216
|
// The scene actor of a door id: the actor whose `HubDoor` names it.
|
|
4217
|
+
// Whether this place's door leads into a House (a player's own, or a friend's).
|
|
4218
|
+
function houseDoor(scene, door) {
|
|
4219
|
+
return Boolean(door) && allActors(scene).some((actor) => actor.components?.HubDoor?.id === door && actor.components.HubDoor.to === 'deck:house');
|
|
4220
|
+
}
|
|
4221
|
+
|
|
4034
4222
|
function doorActor(scene, door) {
|
|
4035
4223
|
if (!door) {
|
|
4036
4224
|
return null;
|