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
|
@@ -23,6 +23,7 @@ import * as Cabinets from './cabinets.js';
|
|
|
23
23
|
import * as Grab from './grab.js';
|
|
24
24
|
import * as Act from './act.js';
|
|
25
25
|
import * as Idle from './idle.js';
|
|
26
|
+
import * as Vehicle from './vehicle.js';
|
|
26
27
|
import * as Decor from './decor.js';
|
|
27
28
|
import * as Actions from './actions.js';
|
|
28
29
|
import * as Invites from './invites.js';
|
|
@@ -37,11 +38,12 @@ import * as Manifest from './manifest.js';
|
|
|
37
38
|
import { setLabel, wireLabel } from './labels.js';
|
|
38
39
|
import { makeNpcs } from './npcs.js';
|
|
39
40
|
import * as Party from './party.js';
|
|
40
|
-
import { bodySize, standingY } from './standing.js';
|
|
41
|
+
import { bodySize, boundingRadius, footprintHas as poseFootprintHas, solids, standingY } from './standing.js';
|
|
41
42
|
import * as Place from './place.js';
|
|
42
43
|
import * as Say from './say.js';
|
|
43
44
|
import * as Ballot from './ballot.js';
|
|
44
45
|
import * as Wear from './wear.js';
|
|
46
|
+
import * as Role from './role.js';
|
|
45
47
|
import * as Earned from './earned.js';
|
|
46
48
|
import * as Analytics from './analytics.js';
|
|
47
49
|
import * as DoorAnalytics from './doorAnalytics.js';
|
|
@@ -75,6 +77,8 @@ const PAD_REFRESH_MS = 20000;
|
|
|
75
77
|
// step off its pad (`hub.pad` says who stands there); a deck that never
|
|
76
78
|
// reports the pad gets this long instead.
|
|
77
79
|
const SHUT_HOLD_MS = 60000;
|
|
80
|
+
// What a pad says to a player whose app has no door trips (v1.156).
|
|
81
|
+
const NO_TRIPS_LABEL = 'Update Castle to play';
|
|
78
82
|
// How often a place re-reads its doors' boards.
|
|
79
83
|
const BOARD_EVERY_MS = 60000;
|
|
80
84
|
// A weekly Cup clock is refreshed with its board once a minute. Two missed
|
|
@@ -366,6 +370,10 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
366
370
|
hello(h, player, data);
|
|
367
371
|
return;
|
|
368
372
|
}
|
|
373
|
+
if (data?.k === 'hub-no-trips') {
|
|
374
|
+
noTrips(h, session, player);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
369
377
|
// A reset check is in flight. Old client actions must not recreate the
|
|
370
378
|
// player's deleted progress before the deck has reloaded it.
|
|
371
379
|
if (h.players.get(player?.playerId)?.progressReading) { return; }
|
|
@@ -441,10 +449,15 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
441
449
|
Grab.message(h, player?.playerId, data);
|
|
442
450
|
return;
|
|
443
451
|
}
|
|
452
|
+
if (data?.k === 'hub-horn' && h.cars) {Vehicle.horn(h, player?.playerId); return;}
|
|
444
453
|
if (data?.k === 'hub-emote') {
|
|
445
454
|
Idle.emoteMessage(h, player?.playerId, data);
|
|
446
455
|
return;
|
|
447
456
|
}
|
|
457
|
+
if (h.place.idle?.expression && data?.k === 'hub-sit-here') {
|
|
458
|
+
Idle.sitHereMessage(h, placeAt, player?.playerId);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
448
461
|
if (data?.k === 'hub-sit') {
|
|
449
462
|
Idle.sitMessage(h, placeAt, player?.playerId, data);
|
|
450
463
|
return;
|
|
@@ -466,6 +479,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
466
479
|
const dt = h.lastPlaceAt === null ? 0 : Math.min(0.25, (sim.timeMs - h.lastPlaceAt) / 1000);
|
|
467
480
|
h.lastPlaceAt = sim.timeMs;
|
|
468
481
|
reconcile(h);
|
|
482
|
+
if (Role.used(h)) { Role.prune(h); }
|
|
469
483
|
Friends.tick(h, friendUserIdOf);
|
|
470
484
|
// v1.28: a try-on on a player who went before saying hello goes too.
|
|
471
485
|
if (Wear.tryOnUsed(h)) {
|
|
@@ -479,6 +493,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
479
493
|
readResults(h);
|
|
480
494
|
arrivals(h);
|
|
481
495
|
if (h.place.visibility === true) {notifyVisibility(h);}
|
|
496
|
+
Vehicle.tick(h, (id, at, face) => placeAt(h, id, at, face));
|
|
482
497
|
enforceHolds(h);
|
|
483
498
|
enforceSettle(h);
|
|
484
499
|
Idle.tick(h);
|
|
@@ -526,6 +541,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
526
541
|
Ballot.send(h, ballotDeps(h));
|
|
527
542
|
}
|
|
528
543
|
Actors.applyTunes(h, h.engine?.maxSpeed?.() ?? 12);
|
|
544
|
+
Vehicle.tick(h, (id, at, face) => placeAt(h, id, at, face));
|
|
529
545
|
sendLabelOverrides(h);
|
|
530
546
|
Vis.send(h);
|
|
531
547
|
sendAvatarOverrides(h);
|
|
@@ -542,6 +558,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
542
558
|
if (Wear.tryOnUsed(h)) {
|
|
543
559
|
Wear.sendTryOverrides(h, blockedPairs(h));
|
|
544
560
|
}
|
|
561
|
+
if (Role.used(h)) { Role.sendOverrides(h, blockedPairs(h)); }
|
|
545
562
|
// Cabinet cards (v1.7): nothing in a place with no classic door.
|
|
546
563
|
Cabinets.send(h, (playerId) => namesOf(h, blockedPairs(h)?.get(playerId) ?? []));
|
|
547
564
|
notifyResumes(h, false, resumeDeferred);
|
|
@@ -591,6 +608,21 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
591
608
|
},
|
|
592
609
|
} : {}),
|
|
593
610
|
|
|
611
|
+
// A client back from an away whose frames the host dropped asks for the
|
|
612
|
+
// world again (the real-time kit's `resync`), always granted: the client
|
|
613
|
+
// holds its cover until that WORLD comes. An arrived player's Act prompts
|
|
614
|
+
// go again too, as a dropped frame may have carried them; sync sends only
|
|
615
|
+
// changes, so they would never come back.
|
|
616
|
+
resync(session, player) {
|
|
617
|
+
const id = player?.playerId, entry = h.players.get(id);
|
|
618
|
+
if (h.manifest.act === true && entry?.arrived && !entry.ended && !h.actDeparting?.has(id) && !h.resumeDeparting?.has(id) &&
|
|
619
|
+
session?.players.some((p) => p.playerId === id)) {
|
|
620
|
+
Act.replay(h, id);
|
|
621
|
+
}
|
|
622
|
+
return true;
|
|
623
|
+
},
|
|
624
|
+
|
|
625
|
+
allowPlayerPose: (id) => !Vehicle.riding(h, id),
|
|
594
626
|
shutdown: () => shutdown(h),
|
|
595
627
|
|
|
596
628
|
join() {
|
|
@@ -618,10 +650,12 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
618
650
|
spawnTemplates: Actors.templatesOf(h),
|
|
619
651
|
// v1.6, only in a place that turns idle play on.
|
|
620
652
|
...Idle.fields(h),
|
|
653
|
+
...Vehicle.fields(h),
|
|
621
654
|
// v1.27, only once the place keeps an object for a player.
|
|
622
655
|
...(h.keptFor.size > 0 ? { hubKept: Grab.keptOf(h) } : {}),
|
|
623
656
|
// v1.28, only while the place shows a try-on on someone.
|
|
624
657
|
...(h.trying.size > 0 ? tryingForJoin(h) : {}),
|
|
658
|
+
...(h.roles.size > 0 ? rolesForJoin(h) : {}),
|
|
625
659
|
// v1.33, only a town of a deck with `hub.stuck`.
|
|
626
660
|
...(stuckHere(h) ? { hubStuck: { to: arrivalName(h), ...(hasUnstick(h) ? { hook: true } : {}) } } : {}),
|
|
627
661
|
};
|
|
@@ -655,6 +689,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
655
689
|
for (const [field, value] of Object.entries(Idle.fields(h))) {
|
|
656
690
|
latch(h, field, value, out);
|
|
657
691
|
}
|
|
692
|
+
if (h.cars?.size || h.sent.has('hubCars')) {latch(h, 'hubCars', Vehicle.fields(h).hubCars ?? {}, out);}
|
|
658
693
|
// v1.27 `hub.keepFor`: nothing until something is kept, then each change.
|
|
659
694
|
if (h.keptFor.size > 0 || h.sent.has('hubKept')) {
|
|
660
695
|
latch(h, 'hubKept', Grab.keptOf(h), out);
|
|
@@ -663,6 +698,7 @@ export function layer(castleJson, deckHooks, placeHooks, sceneExists, sceneGroun
|
|
|
663
698
|
if (h.trying.size > 0 || h.sent.has('hubTry')) {
|
|
664
699
|
latchTrying(h, out);
|
|
665
700
|
}
|
|
701
|
+
if (h.roles.size > 0 || h.sent.has('hubRole')) { latchRoles(h, out); }
|
|
666
702
|
return Object.keys(out).length ? out : null;
|
|
667
703
|
},
|
|
668
704
|
|
|
@@ -823,6 +859,10 @@ function newState(manifest, savedDeckId) {
|
|
|
823
859
|
pads: new Map(),
|
|
824
860
|
// playerId -> { door, at }: the door that last stayed shut for them
|
|
825
861
|
shut: new Map(),
|
|
862
|
+
// v1.156: players whose app cannot go through a door (no `hub.go`), and
|
|
863
|
+
// the door whose pad tells such a player so: playerId -> { door, actor }
|
|
864
|
+
noTrips: new Set(),
|
|
865
|
+
noTripsLabel: new Map(),
|
|
826
866
|
// door id -> who the deck last said stands on its pad (`hub.pad`)
|
|
827
867
|
padDoors: new Map(),
|
|
828
868
|
// door id -> its board from ghost, and when the boards were last read
|
|
@@ -867,6 +907,7 @@ function newState(manifest, savedDeckId) {
|
|
|
867
907
|
...Grab.newGrabState(),
|
|
868
908
|
// what players wear on their avatars (`wear.js`, v1.4)
|
|
869
909
|
...Wear.newWearState(),
|
|
910
|
+
...Role.newRoleState(),
|
|
870
911
|
// earned items players show (`earned.js`, v1.53)
|
|
871
912
|
...Earned.newEarnedState(),
|
|
872
913
|
// emotes, seats and sounds (`idle.js`, v1.6)
|
|
@@ -961,6 +1002,7 @@ function makeContext(h) {
|
|
|
961
1002
|
station: (id, spec) => Observe.station(h, id, spec),
|
|
962
1003
|
dwell: (playerId, id) => Observe.dwell(h, playerId, id),
|
|
963
1004
|
hold(playerId, at, facingDeg) {
|
|
1005
|
+
if (Vehicle.riding(h, playerId)) {Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));}
|
|
964
1006
|
const body = h.sim?.players.get(playerId);
|
|
965
1007
|
if (!body) {
|
|
966
1008
|
return;
|
|
@@ -972,6 +1014,8 @@ function makeContext(h) {
|
|
|
972
1014
|
placeAt(h, playerId, point, facing);
|
|
973
1015
|
},
|
|
974
1016
|
release(playerId) {
|
|
1017
|
+
if (Vehicle.riding(h, playerId)) {Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));}
|
|
1018
|
+
if (h.held.get(playerId)?.ground) {Idle.stand(h, playerId);}
|
|
975
1019
|
h.held.delete(playerId);
|
|
976
1020
|
},
|
|
977
1021
|
setHud(spec, playerId) {
|
|
@@ -1020,6 +1064,8 @@ function makeContext(h) {
|
|
|
1020
1064
|
friendBests: (key, options) => friendBests(h, key, options, userIdOf),
|
|
1021
1065
|
wear: (playerId, spec) => wear(h, playerId, spec),
|
|
1022
1066
|
tryOn: (playerId, spec) => Wear.tryOn(h, playerId, spec),
|
|
1067
|
+
role: (playerId, spec) => Role.role(h, playerId, spec),
|
|
1068
|
+
roleOf: (playerId) => Role.roleOf(h, playerId),
|
|
1023
1069
|
wearing: (playerId) => Wear.wearing(h, playerId),
|
|
1024
1070
|
unlock: (playerId, itemId) => {
|
|
1025
1071
|
const entry = h.players.get(playerId);
|
|
@@ -1034,6 +1080,9 @@ function makeContext(h) {
|
|
|
1034
1080
|
unlocksOf: (userIds) => Earned.unlocksOf(platformHub(h), userIds, (err) => refused(h, 'unlocks', err), h),
|
|
1035
1081
|
earned: (playerId) => Earned.earnedOf(h, playerId),
|
|
1036
1082
|
tune: (playerId, spec) => Actors.tune(h, playerId, spec),
|
|
1083
|
+
drive: (id, car, at) => Vehicle.drive(h, id, car, at, (pid, point, face) => placeAt(h, pid, point, face)),
|
|
1084
|
+
ride: (id, driver, seat) => Vehicle.ride(h, id, driver, seat, (pid, point, face) => placeAt(h, pid, point, face)),
|
|
1085
|
+
vehicle: (id) => Vehicle.vehicle(h, id),
|
|
1037
1086
|
spawn: (fromActorId, at) => Actors.spawn(h, fromActorId, at, h.engine),
|
|
1038
1087
|
pose: (actorId) => Actors.pose(h, actorId),
|
|
1039
1088
|
reset: (actorId, at) => Actors.reset(h, actorId, at, h.engine),
|
|
@@ -1041,12 +1090,16 @@ function makeContext(h) {
|
|
|
1041
1090
|
// `to` limits the words to those players; for them they replace the
|
|
1042
1091
|
// label everyone else sees until they expire or are cleared the same way.
|
|
1043
1092
|
label: (actorId, text, options) => setLabel(h, isSceneActor(h, actorId) ? actorId : null, text, options, false),
|
|
1093
|
+
// v1.156: whether this player's app cannot go through doors (no `hub.go`);
|
|
1094
|
+
// a deck counting its own pads leaves them out, as `hub.pad` does.
|
|
1095
|
+
noTrips: (playerId) => h.noTrips.has(playerId),
|
|
1044
1096
|
npc: (actorId) => h.npcs.handle(actorId),
|
|
1045
1097
|
npcs: () => h.npcs.list(),
|
|
1046
1098
|
preferNpc: (playerId, npcId) => h.npcs.prefer(playerId, npcId),
|
|
1047
1099
|
result: (playerId, value) => report(h, playerId, value),
|
|
1048
1100
|
drop: (playerId) => Grab.drop(h, playerId),
|
|
1049
1101
|
emote: (playerId, id) => Idle.emote(h, playerId, id),
|
|
1102
|
+
...(h.place.idle?.expression ? { emotesFor: (playerId, ids) => Idle.emotesFor(h, playerId, ids) } : {}),
|
|
1050
1103
|
seat: (playerId) => Idle.seat(h, playerId),
|
|
1051
1104
|
sound: (actorId, file, options) => Idle.sound(h, actorId, file, options),
|
|
1052
1105
|
danceIdle: (actorId, options) => Idle.danceIdle(h, actorId, options),
|
|
@@ -1088,6 +1141,7 @@ function platformHub(h) {
|
|
|
1088
1141
|
// the host has hub ops, the door is ghost's arrival and the result and avatar
|
|
1089
1142
|
// are read from ghost (`readResults`). The hello's avatar and colour are
|
|
1090
1143
|
// provisional until that read; colours also work with the manifest opt-in.
|
|
1144
|
+
// Optional `device` is the packed device class for arrival analytics only.
|
|
1091
1145
|
function queuedResumeHello(h, playerId, known, data, synthetic, signUp, invitedAfresh) {
|
|
1092
1146
|
if (!known?.arrived || signUp || invitedAfresh || h.resumeDeparting?.has(playerId) ||
|
|
1093
1147
|
typeof h.hooks.resume !== 'function') {
|
|
@@ -1240,7 +1294,9 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1240
1294
|
// holds none of the cabinet cards it was sent (v1.7).
|
|
1241
1295
|
if (data.again !== true) {
|
|
1242
1296
|
replaySent(h, player.playerId, data.resume === true);
|
|
1297
|
+
Idle.joinedAfresh(h, player.playerId, data.resume === true);
|
|
1243
1298
|
if (h.manifest.act === true) {Act.replay(h, player.playerId);}
|
|
1299
|
+
h.vehicleDeparting?.delete(player.playerId);
|
|
1244
1300
|
h.npcs.replayPreferred(player.playerId, data.resume === true);
|
|
1245
1301
|
Shot.joinedAfresh(h, player.playerId);
|
|
1246
1302
|
Vis.joinedAfresh(h, player.playerId, userIdOf(h, player.playerId));
|
|
@@ -1264,6 +1320,7 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1264
1320
|
Friends.resend(h, player.playerId);
|
|
1265
1321
|
// v1.28: nothing in a place that never sent a try-on to one player alone.
|
|
1266
1322
|
Wear.joinedAfresh(h, player.playerId);
|
|
1323
|
+
if (Role.used(h) || h.roleAloneUsed) { Role.joinedAfresh(h, player.playerId); }
|
|
1267
1324
|
// v1.53: likewise its earned items alone, only where someone has one.
|
|
1268
1325
|
if (Earned.used(h)) {
|
|
1269
1326
|
Earned.joinedAfresh(h, player.playerId);
|
|
@@ -1312,6 +1369,7 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1312
1369
|
read: progressState.readLifetime?.phase ?? (continuedProgress ? (known?.read === 'reading' ? 'want' : known?.read) : null) ?? (hub ? 'want' : 'done'),
|
|
1313
1370
|
progressVersion: progressState.version,
|
|
1314
1371
|
progressState,
|
|
1372
|
+
...(known?.device !== undefined ? { device: known.device } : {}),
|
|
1315
1373
|
...(h.progressEnabled ? { progressReading: Boolean(progressState.locks.size || accountProgressBlocked(h, progressUser) || (!resumeBeforeProgressRead && progressUser && canReadProgress(h) && typeof h.session?.storage?.playthrough === 'function')) } : {}),
|
|
1316
1374
|
...(resumeBeforeProgressRead ? { progressRefreshPending: true } : {}),
|
|
1317
1375
|
hello: true,
|
|
@@ -1339,6 +1397,7 @@ function hello(h, player, data, synthetic = false) {
|
|
|
1339
1397
|
...(last?.ended === true || known?.endAgain === true ? { endAgain: true } : {}),
|
|
1340
1398
|
...(resumes && known?.arrived && known.ended && data.resume === true ? { endReplayPending: true } : {}),
|
|
1341
1399
|
};
|
|
1400
|
+
if (Number.isSafeInteger(data.device) && data.device > 0 && data.device < 2 ** 29) {entry.device = data.device;}
|
|
1342
1401
|
if (signedUp) {
|
|
1343
1402
|
signUp.avatarRev = entry.avatarRev;
|
|
1344
1403
|
signUp.colorRev = entry.colorRev;
|
|
@@ -1482,6 +1541,7 @@ async function refreshProgress(h, playerId) {
|
|
|
1482
1541
|
delete current.endAgain;
|
|
1483
1542
|
delete current.endReplayPending;
|
|
1484
1543
|
Wear.forget(h, id);
|
|
1544
|
+
Role.forget(h, id);
|
|
1485
1545
|
Earned.forget(h, id);
|
|
1486
1546
|
h.npcs.leave(id);
|
|
1487
1547
|
h.hudMe.delete(id);
|
|
@@ -1671,6 +1731,7 @@ function reconcile(h) {
|
|
|
1671
1731
|
}
|
|
1672
1732
|
}
|
|
1673
1733
|
}
|
|
1734
|
+
if (h.place.analytics === true) {Analytics.observe(h);}
|
|
1674
1735
|
greetLate(h);
|
|
1675
1736
|
}
|
|
1676
1737
|
|
|
@@ -1808,7 +1869,7 @@ function prepareResume(h, playerId, greet = true) {
|
|
|
1808
1869
|
const present = body && h.session?.players.some((p) => p.playerId === playerId);
|
|
1809
1870
|
const returning = present && (kept.awayAt !== undefined || body !== kept.body);
|
|
1810
1871
|
if (!present) {
|
|
1811
|
-
if (kept.awayAt === undefined && h.poseStore && !h.resumeDeparting.has(playerId)) {
|
|
1872
|
+
if (kept.awayAt === undefined && h.poseStore && !h.resumeDeparting.has(playerId) && !h.players.get(playerId)?.ended) {
|
|
1812
1873
|
void h.poseStore.end(h.players.get(playerId)?.userId, kept, Date.now(), playerId);
|
|
1813
1874
|
}
|
|
1814
1875
|
kept.awayAt ??= Date.now();
|
|
@@ -1854,7 +1915,7 @@ function prepareResume(h, playerId, greet = true) {
|
|
|
1854
1915
|
h.players.get(playerId)?.userId !== h.session.hub.owner) {
|
|
1855
1916
|
placeGroup(h, [playerId]);
|
|
1856
1917
|
} else {
|
|
1857
|
-
|
|
1918
|
+
restorePose(h, playerId, kept.at, kept.facing);
|
|
1858
1919
|
}
|
|
1859
1920
|
if (h.poseStore) { void h.poseStore.take(h.players.get(playerId)?.userId, playerId); }
|
|
1860
1921
|
settle(h, playerId);
|
|
@@ -2108,6 +2169,7 @@ function restartRetainedAsFresh(h, player, entry, data, synthetic) {
|
|
|
2108
2169
|
}
|
|
2109
2170
|
|
|
2110
2171
|
function forget(h, playerId) {
|
|
2172
|
+
h.vehicleDeparting?.delete(playerId);
|
|
2111
2173
|
h.padOccupancy?.selected.delete(playerId);
|
|
2112
2174
|
const entry = h.players.get(playerId);
|
|
2113
2175
|
// resumeKept may be the only remaining pose after the body disappears.
|
|
@@ -2131,6 +2193,7 @@ function forget(h, playerId) {
|
|
|
2131
2193
|
console.warn(`[hub] leave hook failed: ${err?.message ?? err}`);
|
|
2132
2194
|
}
|
|
2133
2195
|
}
|
|
2196
|
+
Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
|
|
2134
2197
|
DoorAnalytics.finish(h, playerId, 3);
|
|
2135
2198
|
if (h.arrivalPoses) {
|
|
2136
2199
|
h.arrivalPoses.leave(playerId, entry?.userId, entry?.arrived === true && !entry.ended && !poseDeparting);
|
|
@@ -2177,8 +2240,11 @@ function forget(h, playerId) {
|
|
|
2177
2240
|
h.sentAvMe.delete(playerId);
|
|
2178
2241
|
h.marks.delete(playerId);
|
|
2179
2242
|
Wear.forget(h, playerId);
|
|
2243
|
+
Role.forget(h, playerId);
|
|
2180
2244
|
Earned.forget(h, playerId);
|
|
2181
2245
|
h.shut.delete(playerId);
|
|
2246
|
+
h.noTrips.delete(playerId);
|
|
2247
|
+
h.noTripsLabel.delete(playerId);
|
|
2182
2248
|
h.jumpAt.delete(playerId);
|
|
2183
2249
|
h.whereAt.delete(playerId);
|
|
2184
2250
|
h.unstuckAt?.delete(playerId);
|
|
@@ -2223,7 +2289,7 @@ async function shutdown(h) {
|
|
|
2223
2289
|
}
|
|
2224
2290
|
for (const playerId of [...h.players.keys()]) {
|
|
2225
2291
|
const kept = h.resumeKept?.get(playerId);
|
|
2226
|
-
if (h.poseStore && kept && kept.awayAt === undefined && !h.resumeDeparting?.has(playerId)) {
|
|
2292
|
+
if (h.poseStore && kept && kept.awayAt === undefined && !h.resumeDeparting?.has(playerId) && !h.players.get(playerId)?.ended) {
|
|
2227
2293
|
void h.poseStore.end(h.players.get(playerId)?.userId, kept, Date.now(), playerId);
|
|
2228
2294
|
}
|
|
2229
2295
|
forget(h, playerId);
|
|
@@ -2231,6 +2297,7 @@ async function shutdown(h) {
|
|
|
2231
2297
|
if (Wear.tryOnUsed(h)) {
|
|
2232
2298
|
Wear.endTries(h);
|
|
2233
2299
|
}
|
|
2300
|
+
Role.end(h);
|
|
2234
2301
|
let timer = null;
|
|
2235
2302
|
await Promise.race([
|
|
2236
2303
|
Promise.resolve()
|
|
@@ -2322,6 +2389,7 @@ function arrivals(h) {
|
|
|
2322
2389
|
playerId,
|
|
2323
2390
|
username: usernameOf(h, playerId),
|
|
2324
2391
|
userId: entry.userId,
|
|
2392
|
+
device: entry.device ?? 0,
|
|
2325
2393
|
...(h.place.anonymousEntry === true ? { identityUserId: entry.identityUserId ?? null } : {}),
|
|
2326
2394
|
...(entry.signUp ? { signedUpFrom: entry.signUp.carry.playerId } : {}),
|
|
2327
2395
|
from: entry.from,
|
|
@@ -2362,7 +2430,7 @@ function arrivals(h) {
|
|
|
2362
2430
|
const pose = entry?.arrivalPose;
|
|
2363
2431
|
if (entry) {delete entry.arrivalPose;}
|
|
2364
2432
|
if (pose && pose.userId === arrivalPoseUserId(h, playerId) && !entry?.ended && !entry?.near && !h.resumeDeparting.has(playerId)) {
|
|
2365
|
-
|
|
2433
|
+
restorePose(h, playerId, pose.at, pose.facing);
|
|
2366
2434
|
settle(h, playerId);
|
|
2367
2435
|
}
|
|
2368
2436
|
}
|
|
@@ -2373,8 +2441,11 @@ function arrivals(h) {
|
|
|
2373
2441
|
const entry = h.players.get(playerId);
|
|
2374
2442
|
if (houseResume(h) && h.session?.hub?.owner && entry?.userId !== h.session.hub.owner) {delete entry.coldPose;}
|
|
2375
2443
|
if (entry?.coldPose && entry.invited && entry.near) {delete entry.coldPose;}
|
|
2444
|
+
// A player ghost placed through a door (a House's Back, a host's trip)
|
|
2445
|
+
// arrives at that door, not where an earlier visit was left standing.
|
|
2446
|
+
if (entry?.coldPose && platformHub(h)?.arrival(playerId)?.doorId) {delete entry.coldPose;}
|
|
2376
2447
|
if (entry?.coldPose) {
|
|
2377
|
-
|
|
2448
|
+
restorePose(h, playerId, entry.coldPose.at, entry.coldPose.facing);
|
|
2378
2449
|
settle(h, playerId);
|
|
2379
2450
|
delete entry.coldPose;
|
|
2380
2451
|
}
|
|
@@ -2439,14 +2510,93 @@ function placeGroup(h, playerIds) {
|
|
|
2439
2510
|
}
|
|
2440
2511
|
// Facing f looks along (sin f, cos f); the row runs across it.
|
|
2441
2512
|
const across = { x: Math.cos(facing), z: -Math.sin(facing) };
|
|
2513
|
+
const radius = bodySize(h)?.radius ?? BODY_RADIUS_M;
|
|
2514
|
+
const occupied = othersAt(h, playerIds);
|
|
2442
2515
|
const n = playerIds.length;
|
|
2443
|
-
playerIds.
|
|
2516
|
+
const slots = playerIds.map((_, i) => {
|
|
2444
2517
|
const offset = (i - (n - 1) / 2) * arrival.spread;
|
|
2445
|
-
|
|
2446
|
-
|
|
2518
|
+
return { x: t.x + across.x * offset, y: Math.max(t.y ?? 1, 1.2), z: t.z + across.z * offset };
|
|
2519
|
+
});
|
|
2520
|
+
// Where earlier members of this batch were put, and which of them moved: a
|
|
2521
|
+
// moved member may sit on a later authored slot, which must then move too.
|
|
2522
|
+
const assigned = [];
|
|
2523
|
+
const moved = [];
|
|
2524
|
+
playerIds.forEach((playerId, i) => {
|
|
2525
|
+
const at = slots[i];
|
|
2526
|
+
// A lone door visitor may find the owner still at the arrival (a House
|
|
2527
|
+
// visit from People carries no `near`), and two solid bodies on one spot
|
|
2528
|
+
// wedge. Only authored-floor places step off an occupied slot: a town or
|
|
2529
|
+
// ground-backed game keeps the spawn WORLD already showed (Oct 17, the
|
|
2530
|
+
// ring's later correction glided a joiner 1.1 m), and empty rows keep
|
|
2531
|
+
// their authored placement.
|
|
2532
|
+
const alternate = h.noGround === true && [...occupied, ...moved].some((p) => Math.hypot(p.x - at.x, p.z - at.z) < 2 * radius)
|
|
2533
|
+
? freeArrivalSlot(h, at, across, Math.max(arrival.spread, 2 * radius + 0.1), radius, [...occupied, ...assigned, ...slots.slice(i + 1)], true) : null;
|
|
2534
|
+
const spot = alternate ?? { ...at, y: standingY(h, at) };
|
|
2535
|
+
assigned.push(spot);
|
|
2536
|
+
if (alternate) {moved.push(alternate);}
|
|
2537
|
+
placeAt(h, playerId, spot, facing);
|
|
2447
2538
|
});
|
|
2448
2539
|
}
|
|
2449
2540
|
|
|
2541
|
+
// Every other body in the place where it stands now, arrived or not: a body
|
|
2542
|
+
// waiting for its group or held is as solid as one that arrived.
|
|
2543
|
+
function othersAt(h, except) {
|
|
2544
|
+
return [...h.sim.players.entries()].filter(([id]) => !except.includes(id)).map(([, body]) => body.at);
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
// A stored pose (an arrival pose, a durable resumePose, a retained visit)
|
|
2548
|
+
// puts a returning player back where they stood, but someone may stand there
|
|
2549
|
+
// now. On an authored-floor place one closer than two radii steps off along
|
|
2550
|
+
// the row across their facing, else takes the arrival (Oct 19 QA: a guest's
|
|
2551
|
+
// stored House pose was restored 0.42 m from the owner, and they wedged).
|
|
2552
|
+
function restorePose(h, playerId, at, facing) {
|
|
2553
|
+
const radius = bodySize(h)?.radius ?? BODY_RADIUS_M;
|
|
2554
|
+
const others = othersAt(h, [playerId]);
|
|
2555
|
+
if (h.noGround !== true || !others.some((p) => Math.hypot(p.x - at.x, p.z - at.z) < 2 * radius)) {
|
|
2556
|
+
moveBody(h, playerId, at, facing);
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
const across = { x: Math.cos(facing ?? 0), z: -Math.sin(facing ?? 0) };
|
|
2560
|
+
const spot = freeArrivalSlot(h, at, across, 2 * radius + 0.1, radius, others, true);
|
|
2561
|
+
if (spot) {
|
|
2562
|
+
moveBody(h, playerId, spot, facing);
|
|
2563
|
+
} else {
|
|
2564
|
+
placeGroup(h, [playerId]);
|
|
2565
|
+
}
|
|
2566
|
+
// A hold the player kept across the drop would put them back on the
|
|
2567
|
+
// occupied spot next tick: it follows them to where they now stand.
|
|
2568
|
+
const hold = h.held.get(playerId);
|
|
2569
|
+
const now = h.sim.players.get(playerId)?.at;
|
|
2570
|
+
if (hold && now) {
|
|
2571
|
+
h.held.set(playerId, { ...hold, at: { ...now }, facing: h.sim.players.get(playerId).facing });
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
// `around`: when the row has no free slot, also try the eight compass
|
|
2576
|
+
// directions at the same steps (a narrow floor may run across the row).
|
|
2577
|
+
function freeArrivalSlot(h, at, across, step, radius, occupied, around = false) {
|
|
2578
|
+
// The legacy envelope intersects authored floors under shorter players.
|
|
2579
|
+
const size = (h.noGround === true ? bodySize(h) : null) ?? { radius: BODY_RADIUS_M, halfHeight: BODY_HALF_M };
|
|
2580
|
+
const dirs = [[across.x, across.z], [-across.x, -across.z]];
|
|
2581
|
+
if (around) {
|
|
2582
|
+
for (let i = 0; i < 8; i += 1) {dirs.push([Math.cos(i * Math.PI / 4), Math.sin(i * Math.PI / 4)]);}
|
|
2583
|
+
}
|
|
2584
|
+
for (const [rows, from] of around ? [[2, 0], [dirs.length, 2]] : [[2, 0]]) {
|
|
2585
|
+
for (let k = 1; k <= 6; k += 1) {
|
|
2586
|
+
for (let d = from; d < rows; d += 1) {
|
|
2587
|
+
const [dx, dz] = dirs[d];
|
|
2588
|
+
const candidate = { x: at.x + dx * k * step, y: at.y, z: at.z + dz * k * step };
|
|
2589
|
+
candidate.y = standingY(h, candidate);
|
|
2590
|
+
if (!occupied.some((p) => Math.hypot(p.x - candidate.x, p.z - candidate.z) < 2 * radius) &&
|
|
2591
|
+
spotClear(h, candidate, size) && padAt(h, candidate, radius) === null) {
|
|
2592
|
+
return candidate;
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
return null;
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2450
2600
|
// A player who jumped to a friend stands beside them, facing them, when the
|
|
2451
2601
|
// friend is in this session, a block hides neither from the other, and a spot
|
|
2452
2602
|
// beside them is clear (no solid actor there; on a scene with no ground, a
|
|
@@ -2495,7 +2645,9 @@ function placeBeside(h, playerId, otherId, used = new Map()) {
|
|
|
2495
2645
|
[-Math.sin(f), -Math.cos(f)],
|
|
2496
2646
|
[Math.sin(f), Math.cos(f)],
|
|
2497
2647
|
];
|
|
2498
|
-
|
|
2648
|
+
// On an authored floor a spot keeps clear of every other body too, not only
|
|
2649
|
+
// of this batch's spots: two solid bodies closer than two radii wedge.
|
|
2650
|
+
const taken = [...(used.get(otherId) ?? []), ...(h.noGround === true ? othersAt(h, [playerId]) : [])];
|
|
2499
2651
|
// Never on or at the edge of a door's pad, theirs included (v1.19): a pad
|
|
2500
2652
|
// takes whoever stands on it into its game, and nobody goes into a game
|
|
2501
2653
|
// they did not choose. Beside a friend on a pad is a step or two further
|
|
@@ -2505,8 +2657,7 @@ function placeBeside(h, playerId, otherId, used = new Map()) {
|
|
|
2505
2657
|
.map(([dx, dz]) => ({ x: other.at.x + dx * NEAR_STEP_M * step, y: other.at.y, z: other.at.z + dz * NEAR_STEP_M * step }))
|
|
2506
2658
|
.find((at) => !taken.some((t) => Math.hypot(t.x - at.x, t.z - at.z) < 2 * size.radius) && spotClear(h, at, size) && padAt(h, at, size.radius) === null);
|
|
2507
2659
|
if (spot) {
|
|
2508
|
-
|
|
2509
|
-
used.set(otherId, taken);
|
|
2660
|
+
used.set(otherId, [...(used.get(otherId) ?? []), spot]);
|
|
2510
2661
|
placeAt(h, playerId, spot, Math.atan2(other.at.x - spot.x, other.at.z - spot.z));
|
|
2511
2662
|
return true;
|
|
2512
2663
|
}
|
|
@@ -2527,45 +2678,28 @@ function padAt(h, at, margin) {
|
|
|
2527
2678
|
return null;
|
|
2528
2679
|
}
|
|
2529
2680
|
|
|
2530
|
-
// Whether a standing body fits at `at`: no solid
|
|
2531
|
-
//
|
|
2681
|
+
// Whether a standing body fits at `at`: no solid overlaps it -- a scene actor
|
|
2682
|
+
// or a spawned copy (a House's placed furniture), at its live pose -- and on
|
|
2683
|
+
// a scene with no ground (`fallY`) a solid's top is under its feet.
|
|
2532
2684
|
function spotClear(h, at, { radius, halfHeight }) {
|
|
2533
2685
|
let supported = h.noGround !== true;
|
|
2534
|
-
for (const
|
|
2535
|
-
|
|
2536
|
-
const
|
|
2537
|
-
const
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
}
|
|
2542
|
-
const half = shape.kind === 'sphere' ? (shape.radius ?? 0.5) : (shape.height ?? 1) / 2;
|
|
2543
|
-
const top = (t.y ?? 0) + half;
|
|
2544
|
-
const bottom = (t.y ?? 0) - half;
|
|
2545
|
-
const inside = footprintHas(shape, t, at, radius);
|
|
2686
|
+
for (const { shape, pose } of solids(h)) {
|
|
2687
|
+
// A tilted solid is judged by its enclosing sphere, as standingY does.
|
|
2688
|
+
const bound = pose.upright ? null : boundingRadius(shape);
|
|
2689
|
+
const half = bound ?? (shape.kind === 'sphere' ? (shape.radius ?? 0.5) : (shape.height ?? 1) / 2);
|
|
2690
|
+
const top = pose.y + half;
|
|
2691
|
+
const bottom = pose.y - half;
|
|
2692
|
+
const inside = bound === null ? poseFootprintHas(shape, pose, at, radius) : !(bound > 0) || Math.hypot(at.x - pose.x, at.z - pose.z) <= bound + radius;
|
|
2546
2693
|
if (inside && top > at.y - halfHeight + 0.05 && bottom < at.y + halfHeight) {
|
|
2547
2694
|
return false;
|
|
2548
2695
|
}
|
|
2549
|
-
if (!supported &&
|
|
2696
|
+
if (!supported && bound === null && poseFootprintHas(shape, pose, at, 0) && Math.abs(top - (at.y - halfHeight)) < 0.6) {
|
|
2550
2697
|
supported = true;
|
|
2551
2698
|
}
|
|
2552
2699
|
}
|
|
2553
2700
|
return supported;
|
|
2554
2701
|
}
|
|
2555
2702
|
|
|
2556
|
-
// Whether a point lies within a shape's footprint, grown by `pad`.
|
|
2557
|
-
function footprintHas(shape, t, at, pad) {
|
|
2558
|
-
const dx = at.x - t.x;
|
|
2559
|
-
const dz = at.z - t.z;
|
|
2560
|
-
if (shape.kind === 'box') {
|
|
2561
|
-
const r = ((t.rotationY ?? 0) * Math.PI) / 180;
|
|
2562
|
-
const lx = dx * Math.cos(r) - dz * Math.sin(r);
|
|
2563
|
-
const lz = dx * Math.sin(r) + dz * Math.cos(r);
|
|
2564
|
-
return Math.abs(lx) <= (shape.width ?? 1) / 2 + pad && Math.abs(lz) <= (shape.depth ?? 1) / 2 + pad;
|
|
2565
|
-
}
|
|
2566
|
-
return Math.hypot(dx, dz) <= (shape.radius ?? 0.5) + pad;
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
2703
|
// Move a body. One placed before the joiner's WORLD snapshot is where that
|
|
2570
2704
|
// snapshot starts them; a later one reaches the client as a clamp.
|
|
2571
2705
|
function placeAt(h, playerId, at, facing) {
|
|
@@ -2738,6 +2872,7 @@ function report(h, playerId, value) {
|
|
|
2738
2872
|
}
|
|
2739
2873
|
|
|
2740
2874
|
function end(h, playerId, why) {
|
|
2875
|
+
Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
|
|
2741
2876
|
if (h.place.analyticsRounds !== 'authored') {DoorAnalytics.finish(h, playerId);}
|
|
2742
2877
|
const entry = h.players.get(playerId);
|
|
2743
2878
|
if (entry) {
|
|
@@ -2747,6 +2882,14 @@ function end(h, playerId, why) {
|
|
|
2747
2882
|
entry.endWhy = why;
|
|
2748
2883
|
}
|
|
2749
2884
|
}
|
|
2885
|
+
// A visit the place ended is over, like a kit trip (sendGo): a drop on the
|
|
2886
|
+
// way out keeps no durable pose to come back to. A House front-door leave
|
|
2887
|
+
// was stored on the door and restored there, which ended the next visit at
|
|
2888
|
+
// once (Oct 19 QA). Result places that resume (v1.72) keep their end.
|
|
2889
|
+
if (h.poseStore) {
|
|
2890
|
+
h.resumeDeparting?.add(playerId);
|
|
2891
|
+
void h.poseStore.clear(entry?.userId, playerId);
|
|
2892
|
+
}
|
|
2750
2893
|
h.held.delete(playerId);
|
|
2751
2894
|
Shot.stopHolding(h, playerId);
|
|
2752
2895
|
h.session?.send(playerId, { k: 'hub-end', why });
|
|
@@ -2846,7 +2989,7 @@ function houseVisit(h, player, data) {
|
|
|
2846
2989
|
Idle.stand(h, playerId);
|
|
2847
2990
|
}
|
|
2848
2991
|
if (!door || h.held.has(playerId) || now - (h.jumpAt.get(playerId) ?? 0) < JUMP_EVERY_MS ||
|
|
2849
|
-
|
|
2992
|
+
cannotGo(h, playerId, door.id) || !membersOf(h, [playerId]).size) {
|
|
2850
2993
|
return;
|
|
2851
2994
|
}
|
|
2852
2995
|
h.jumpAt.set(playerId, now);
|
|
@@ -3262,6 +3405,8 @@ function deckDoorPlace(h, props, deck) {
|
|
|
3262
3405
|
// All outgoing travel paths retire the lease after sending the command.
|
|
3263
3406
|
function sendGo(h, playerId, msg) {
|
|
3264
3407
|
if (h.session?.send) {
|
|
3408
|
+
Vehicle.forget(h, playerId, (id, point, face) => placeAt(h, id, point, face));
|
|
3409
|
+
if (h.cars) {(h.vehicleDeparting ??= new Set()).add(playerId);}
|
|
3265
3410
|
h.session.send(playerId, msg);
|
|
3266
3411
|
Shot.stopHolding(h, playerId);
|
|
3267
3412
|
// An explicit kit trip ends the visit rather than retaining it for a drop.
|
|
@@ -3278,7 +3423,7 @@ function sendGo(h, playerId, msg) {
|
|
|
3278
3423
|
// join). In dev the destination is a named session whose key names the place;
|
|
3279
3424
|
// the door table makes this a host command and the instance ghost's.
|
|
3280
3425
|
function go(h, door, playerIds, { instance } = {}) {
|
|
3281
|
-
const going = (playerIds ?? []).filter((playerId) => !
|
|
3426
|
+
const going = (playerIds ?? []).filter((playerId) => !cannotGo(h, playerId, door));
|
|
3282
3427
|
if (going.length < (playerIds ?? []).length) {
|
|
3283
3428
|
if (!going.length) {
|
|
3284
3429
|
return null;
|
|
@@ -3458,12 +3603,13 @@ function gather(h, door, playerIds) {
|
|
|
3458
3603
|
unshut(h, playerId);
|
|
3459
3604
|
}
|
|
3460
3605
|
}
|
|
3606
|
+
noTripsLabels(h, door, on);
|
|
3461
3607
|
const hub = platformHub(h);
|
|
3462
3608
|
// Ghost holds no pad for a cabinet (v1.7): it is not a pad door.
|
|
3463
3609
|
if (!hub || Cabinets.isClassic(h, door) || Cabinets.cabinetDoorIds(h).has(door) || isLayerDoor(h, door)) {
|
|
3464
3610
|
return;
|
|
3465
3611
|
}
|
|
3466
|
-
const users = travelersOf(h, [...on].filter((playerId) => !
|
|
3612
|
+
const users = travelersOf(h, [...on].filter((playerId) => !cannotGo(h, playerId, door)));
|
|
3467
3613
|
const members = [...users.keys()].sort();
|
|
3468
3614
|
let pad = h.pads.get(door);
|
|
3469
3615
|
if (pad?.firing) {
|
|
@@ -3514,6 +3660,8 @@ function doorShut(h, player, data) {
|
|
|
3514
3660
|
}
|
|
3515
3661
|
h.resumeDeparting?.delete(playerId);
|
|
3516
3662
|
h.actDeparting?.delete(playerId);
|
|
3663
|
+
// A failed trip lets them drive and ride again (v1.160).
|
|
3664
|
+
h.vehicleDeparting?.delete(playerId);
|
|
3517
3665
|
unshut(h, playerId);
|
|
3518
3666
|
if (h.padDoors.has(found.id) && !h.padDoors.get(found.id).has(playerId)) {
|
|
3519
3667
|
// Already stepped off while the trip was failing.
|
|
@@ -3536,6 +3684,56 @@ function isShut(h, playerId, door) {
|
|
|
3536
3684
|
return false;
|
|
3537
3685
|
}
|
|
3538
3686
|
|
|
3687
|
+
// v1.156: the client's word that its app has no `hub.go` (released iOS Castle
|
|
3688
|
+
// 1.150 and 1.151 have no hub commands at all), so no door can take this
|
|
3689
|
+
// player anywhere: they are left out of every pad and `hub.go` here for as
|
|
3690
|
+
// long as they stay, rather than counting toward a countdown whose trip their
|
|
3691
|
+
// app turns back. A pad they stand on tells them, to them alone. A connected
|
|
3692
|
+
// player's own word only; it can only ever take its sender out.
|
|
3693
|
+
function noTrips(h, session, player) {
|
|
3694
|
+
const playerId = player?.playerId;
|
|
3695
|
+
if (!playerId || !session?.players.some((p) => p.playerId === playerId) || h.noTrips.has(playerId)) {
|
|
3696
|
+
return;
|
|
3697
|
+
}
|
|
3698
|
+
h.noTrips.add(playerId);
|
|
3699
|
+
console.log(`[hub] ${playerId}'s app has no door trips`);
|
|
3700
|
+
}
|
|
3701
|
+
|
|
3702
|
+
// Whether a door must leave this player out: their app cannot go through
|
|
3703
|
+
// doors, or this one stayed shut for them.
|
|
3704
|
+
function cannotGo(h, playerId, door) {
|
|
3705
|
+
return h.noTrips.has(playerId) || isShut(h, playerId, door);
|
|
3706
|
+
}
|
|
3707
|
+
|
|
3708
|
+
// The private 'Update Castle to play' on a door, for each player without door
|
|
3709
|
+
// trips that the deck says stands on its pad; cleared when they step off.
|
|
3710
|
+
function noTripsLabels(h, door, on) {
|
|
3711
|
+
if (!h.noTrips.size && !h.noTripsLabel.size) {
|
|
3712
|
+
return;
|
|
3713
|
+
}
|
|
3714
|
+
for (const [playerId, entry] of h.noTripsLabel) {
|
|
3715
|
+
if (entry.door === door && !on.has(playerId)) {
|
|
3716
|
+
h.noTripsLabel.delete(playerId);
|
|
3717
|
+
setLabel(h, entry.actor, null, { to: [playerId] }, false);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
for (const playerId of on) {
|
|
3721
|
+
if (!h.noTrips.has(playerId) || h.noTripsLabel.get(playerId)?.door === door) {
|
|
3722
|
+
continue;
|
|
3723
|
+
}
|
|
3724
|
+
const found = doors(h).find((d) => d.id === door);
|
|
3725
|
+
if (!found) {
|
|
3726
|
+
return;
|
|
3727
|
+
}
|
|
3728
|
+
const was = h.noTripsLabel.get(playerId);
|
|
3729
|
+
if (was) {
|
|
3730
|
+
setLabel(h, was.actor, null, { to: [playerId] }, false);
|
|
3731
|
+
}
|
|
3732
|
+
h.noTripsLabel.set(playerId, { door, actor: found.actor });
|
|
3733
|
+
setLabel(h, found.actor, NO_TRIPS_LABEL, { to: [playerId], style: 'sign' }, false);
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3539
3737
|
function unshut(h, playerId) {
|
|
3540
3738
|
const entry = h.shut.get(playerId);
|
|
3541
3739
|
if (entry) {
|
|
@@ -3590,11 +3788,16 @@ function padFired(h, door, pad, users, fired) {
|
|
|
3590
3788
|
}
|
|
3591
3789
|
const found = doors(h).find((d) => d.id === door);
|
|
3592
3790
|
const group = Array.isArray(fired) ? fired : [];
|
|
3593
|
-
// The group is ghost's; anyone of it still here goes, on the pad now or not
|
|
3791
|
+
// The group is ghost's; anyone of it still here goes, on the pad now or not,
|
|
3792
|
+
// but a player whose app has turned out to have no door trips since (v1.156).
|
|
3594
3793
|
const here = travelersOf(h, h.session?.players.map((p) => p.playerId));
|
|
3595
|
-
|
|
3596
|
-
for (const userId of group) {
|
|
3794
|
+
const going = (userId) => {
|
|
3597
3795
|
const playerId = users.get(userId) ?? here.get(userId);
|
|
3796
|
+
return playerId && !h.noTrips.has(playerId) ? playerId : null;
|
|
3797
|
+
};
|
|
3798
|
+
tellWent(h, group.map(going).filter(Boolean), door);
|
|
3799
|
+
for (const userId of group) {
|
|
3800
|
+
const playerId = going(userId);
|
|
3598
3801
|
if (playerId) {
|
|
3599
3802
|
sendGo(h, playerId, {
|
|
3600
3803
|
k: 'hub-go',
|
|
@@ -4472,3 +4675,15 @@ function identityUserIdOf(h, playerId) {
|
|
|
4472
4675
|
function usernameOf(h, playerId) {
|
|
4473
4676
|
return h.session?.players.find((p) => p.playerId === playerId)?.username ?? 'player';
|
|
4474
4677
|
}
|
|
4678
|
+
|
|
4679
|
+
// Roles (v1.157) use try-on's whole-block latch: never-called places have
|
|
4680
|
+
// no key; the last role sends one empty delta, and snapshots omit empties.
|
|
4681
|
+
function rolesForJoin(h) {
|
|
4682
|
+
const roles = Role.rolesOf(h, blockedPairs(h));
|
|
4683
|
+
return Object.keys(roles).length ? { hubRole: roles } : {};
|
|
4684
|
+
}
|
|
4685
|
+
|
|
4686
|
+
function latchRoles(h, out) {
|
|
4687
|
+
const roles = Role.rolesOf(h, blockedPairs(h));
|
|
4688
|
+
if (Object.keys(roles).length || h.sent.has('hubRole')) { latch(h, 'hubRole', roles, out); }
|
|
4689
|
+
}
|