castle-web-cli 0.4.255 → 0.4.257
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +1 -0
- package/dist/agent-failures.js +9 -0
- package/dist/agent.d.ts +3 -0
- package/dist/agent.js +43 -10
- package/dist/devSessionChild.js +8 -1
- package/dist/devSessionServer.d.ts +7 -0
- package/dist/devSessionServer.js +12 -5
- package/dist/hostFeatureCheck.d.ts +23 -0
- package/dist/hostFeatureCheck.js +70 -0
- package/dist/init.js +1 -1
- package/dist/platformDoc.d.ts +1 -0
- package/dist/platformDoc.js +19 -3
- package/dist/retryNotice.d.ts +3 -0
- package/dist/retryNotice.js +39 -0
- package/dist/save-deck.js +2 -0
- package/dist/shell/assets/index-CO225dl5.js +454 -0
- package/dist/shell/assets/{index-MVLfNYd9.css → index-D_8-R2mm.css} +1 -1
- package/dist/shell/index.html +2 -2
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +14 -0
- package/kits/base/sdk/server/platformHandle.d.ts +2 -0
- package/kits/base/sdk/server/wrapper.d.ts +4 -0
- package/kits/base/sdk/server/wrapper.js +29 -1
- package/kits/hub-game/code/client/chrome.js +80 -28
- package/kits/hub-game/code/client/crowdNames.js +3 -2
- package/kits/hub-game/code/client/hudTree.js +7 -3
- package/kits/hub-game/code/client/nameTagLayout.js +46 -0
- package/kits/hub-game/code/client/role.js +4 -2
- package/kits/hub-game/code/client/safeLayout.js +1 -0
- package/kits/hub-game/code/client/worldLabels.js +54 -8
- package/kits/hub-game/code/systems/hub.js +90 -12
- package/kits/hub-game/scripts/fixtures/hud-surface.json +63 -63
- package/kits/hub-game/scripts/fixtures/talk-surface.json +4 -4
- package/kits/hub-game/scripts/test-actions-client.mjs +13 -3
- package/kits/hub-game/scripts/test-disguise-client.mjs +1 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +16 -10
- package/kits/hub-game/scripts/test-hud-defects-dom.mjs +59 -0
- package/kits/hub-game/scripts/test-hud-surface.mjs +31 -4
- package/kits/hub-game/scripts/test-placement-cache.mjs +87 -0
- package/kits/hub-game/scripts/test-quality.mjs +1 -1
- package/kits/hub-game/scripts/test-role-client.mjs +82 -6
- package/kits/hub-game/scripts/test-talk-surface.mjs +3 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +81 -0
- package/kits/turn-based/castle.json +1 -1
- package/package.json +2 -2
- package/dist/shell/assets/index-Bec6LpAv.js +0 -454
|
@@ -49,6 +49,7 @@ import { padCuesEnabled } from '../client/padCues.js';
|
|
|
49
49
|
import { readPadArrival } from '../client/padCueArrival.js';
|
|
50
50
|
import { makePadReadability } from '../client/padReadability.js';
|
|
51
51
|
import { crowdNamesFor, layoutCrowdNames, readableSpriteBox, spriteBox } from '../client/crowdNames.js';
|
|
52
|
+
import { projectNameTag } from '../client/nameTagLayout.js';
|
|
52
53
|
import { doorPoint } from '../client/doorFrame.js';
|
|
53
54
|
import * as Avatar from '../client/avatar.js';
|
|
54
55
|
import * as Celebrate from '../client/celebrate.js';
|
|
@@ -451,12 +452,13 @@ class HubSystem {
|
|
|
451
452
|
if (geometry.resized) {
|
|
452
453
|
(this.crowdNameScales ??= new Map()).set(sprite, geometry.resized);
|
|
453
454
|
}
|
|
455
|
+
const box = this.playerNameBox(sprite, cam, this.nameTagFrame?.view ?? frame.view) ?? geometry.box;
|
|
454
456
|
candidates.push({
|
|
455
457
|
id: String(playerId),
|
|
456
458
|
friend: Boolean(friendIds && userId && friendIds.has(String(userId))),
|
|
457
459
|
distance: frame.local ? Math.hypot(at.x - frame.local.x, at.z - frame.local.z) : Infinity,
|
|
458
460
|
at,
|
|
459
|
-
box
|
|
461
|
+
box,
|
|
460
462
|
});
|
|
461
463
|
sprites.set(String(playerId), sprite);
|
|
462
464
|
}
|
|
@@ -508,6 +510,44 @@ class HubSystem {
|
|
|
508
510
|
}
|
|
509
511
|
}
|
|
510
512
|
|
|
513
|
+
playerNameBox(sprite, cam, view) {
|
|
514
|
+
if (!cam.matrixWorldInverse || !cam.projectionMatrix) {return null;}
|
|
515
|
+
const area = view.world ?? (this.nameTagArea ??= { left: 0, top: 0 });
|
|
516
|
+
if (!view.world) {
|
|
517
|
+
area.right = area.width = view.w;
|
|
518
|
+
area.bottom = area.height = view.h;
|
|
519
|
+
}
|
|
520
|
+
this.nameTagGeometry ??= new WeakMap();
|
|
521
|
+
let box = this.nameTagGeometry.get(sprite);
|
|
522
|
+
if (!box) {this.nameTagGeometry.set(sprite, box = {});}
|
|
523
|
+
return projectNameTag(sprite, cam, area, this.nameTagPoint ??= cam.position.clone(), box);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// Multiplayer has now moved the tags, and the town/crowd passes have
|
|
527
|
+
// settled their visibility and scale. Use the pose that is about to draw.
|
|
528
|
+
finishNameLabels(scene) {
|
|
529
|
+
const frame = this.nameTagFrame;
|
|
530
|
+
const cam = scene.three?.camera;
|
|
531
|
+
const tags = scene.multiplayer?.avatars?.tags;
|
|
532
|
+
if (frame?.scene !== scene || !cam || !tags?.size) {return;}
|
|
533
|
+
const boxes = (this.nameTagBoxes ??= new Map());
|
|
534
|
+
boxes.clear();
|
|
535
|
+
for (const [id, tag] of tags) {
|
|
536
|
+
const sprite = tag?.sprite;
|
|
537
|
+
if (id === 'self' || !sprite?.visible || sprite.material?.visible === false || !(sprite.material?.opacity > 0)) {continue;}
|
|
538
|
+
const box = this.playerNameBox(sprite, cam, frame.view);
|
|
539
|
+
if (box) {boxes.set(String(id), box);}
|
|
540
|
+
}
|
|
541
|
+
if (!frame.idle) {return;}
|
|
542
|
+
const local = scene.actorWith('Player');
|
|
543
|
+
this.chrome.syncRoleLabels?.(this.markItems(scene, local, cam, frame.view), null, true, 'mark:');
|
|
544
|
+
if (Hub.hub.roles.size && scene.data?.engine?.hubCrowdNames !== true) {
|
|
545
|
+
this.chrome.syncRoleLabels?.(roleItems(scene, local, cam, frame.view, Hub.hub.roles, project));
|
|
546
|
+
}
|
|
547
|
+
this.chrome.setWorldNameTags?.(boxes);
|
|
548
|
+
this.worldNameTagsSent = true;
|
|
549
|
+
}
|
|
550
|
+
|
|
511
551
|
invalidateCrowdNames(scene) {
|
|
512
552
|
// Without current geometry and authorization E cannot associate a name
|
|
513
553
|
// or count with an avatar. Remove all visit-local decisions and finish
|
|
@@ -537,6 +577,7 @@ class HubSystem {
|
|
|
537
577
|
|
|
538
578
|
afterBehaviors(scene, dt) {
|
|
539
579
|
// Snapshot layout before any of this frame's chrome setters write DOM.
|
|
580
|
+
this.nameTagFrame = null;
|
|
540
581
|
const canvas = scene.three?.renderer?.domElement;
|
|
541
582
|
this.frameCanvas = this.chrome?.beginLayoutFrame?.(canvas) ?? canvas?.getBoundingClientRect?.();
|
|
542
583
|
this.act?.beginLayoutFrame?.();
|
|
@@ -894,7 +935,9 @@ class HubSystem {
|
|
|
894
935
|
this.ballot.frame(this.carded ? cardFor(mp.net ?? null) : null, Hub.hub.place?.ballot?.lines ?? [], mp.net?.selfId?.() ?? null, Hub.simNow(), box ? box.bottom : 0);
|
|
895
936
|
}
|
|
896
937
|
this.chrome.safeSurface?.('ballot', this.ballot?.surface?.());
|
|
897
|
-
|
|
938
|
+
// Crowd selection needs the ordinary label boxes before it picks names.
|
|
939
|
+
// Other places do the DOM pass once, after multiplayer moves the tags.
|
|
940
|
+
if (this.lateFor !== scene || !this.nameTagFrame || scene.data?.engine?.hubCrowdNames === true) {this.chrome.flushWorldLabels?.();}
|
|
898
941
|
this.reportLoad(mp);
|
|
899
942
|
this.measure(scene, mp, now);
|
|
900
943
|
if (this.lateFor !== scene) {this.endLayoutFrame();}
|
|
@@ -1056,8 +1099,13 @@ class HubSystem {
|
|
|
1056
1099
|
this.applyVisibility(s);
|
|
1057
1100
|
this.applyWear(s);
|
|
1058
1101
|
this.applyCars(s);
|
|
1102
|
+
s.three?.camera?.updateWorldMatrix?.(true, false);
|
|
1059
1103
|
this.fadeNames(s);
|
|
1060
1104
|
this.applyDisguise(s);
|
|
1105
|
+
if (this.nameTagFrame?.scene === s) {
|
|
1106
|
+
this.finishNameLabels(s);
|
|
1107
|
+
this.chrome.flushWorldLabels?.();
|
|
1108
|
+
}
|
|
1061
1109
|
},
|
|
1062
1110
|
});
|
|
1063
1111
|
// Device tiers run as a system of their own, registered only in a deck
|
|
@@ -4081,10 +4129,20 @@ class HubSystem {
|
|
|
4081
4129
|
if (canvas?.width > 0 && canvas.height > 0) {view.world = canvas;}
|
|
4082
4130
|
}
|
|
4083
4131
|
chrome.setWorldViewport?.(view.world ?? null);
|
|
4132
|
+
// Last frame's names stop counting; a place that never had any is not told.
|
|
4133
|
+
if (this.worldNameTagsSent) {
|
|
4134
|
+
chrome.setWorldNameTags?.(null);
|
|
4135
|
+
this.worldNameTagsSent = false;
|
|
4136
|
+
}
|
|
4137
|
+
const canvas = this.frameCanvas;
|
|
4138
|
+
this.nameTagFrame = { scene, idle, view: !view.world && canvas?.width > 0 && canvas.height > 0 ? { ...view, world: canvas } : view };
|
|
4084
4139
|
const labels = [];
|
|
4085
4140
|
const padOccupancy = scene.data?.engine?.hubPadOccupancy === true;
|
|
4086
4141
|
const crowdNames = scene.data?.engine?.hubCrowdNames === true;
|
|
4087
|
-
|
|
4142
|
+
// Label depths and the late name-tag pass must use the same camera pose.
|
|
4143
|
+
if (typeof cam?.updateWorldMatrix === 'function') {
|
|
4144
|
+
cam.updateWorldMatrix(true, false);
|
|
4145
|
+
} else if (cam?.parent === null && cam.matrixWorldAutoUpdate === true) {
|
|
4088
4146
|
cam.updateMatrixWorld();
|
|
4089
4147
|
}
|
|
4090
4148
|
let worldLabelCount = 0;
|
|
@@ -4148,11 +4206,12 @@ class HubSystem {
|
|
|
4148
4206
|
const box = labelBox(screen.x, screen.y, chrome.measureLabel(label.text, speech, npc, pad), npc, view, chrome.hudClearBox?.() ?? null, chrome.hudPromptBox?.() ?? null);
|
|
4149
4207
|
if (!box) {continue;}
|
|
4150
4208
|
const item = chromeItem(id, label.text, speech, npc, box, opacity);
|
|
4209
|
+
item.depth = screen.depth;
|
|
4151
4210
|
if (Hub.deck.quality) {item.actorId = id;}
|
|
4152
4211
|
if (pad) {item.padOccupancy = true;}
|
|
4153
4212
|
labels.push(item);
|
|
4154
4213
|
} else {
|
|
4155
|
-
labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity });
|
|
4214
|
+
labels.push({ id, x: screen.x, y: screen.y, depth: screen.depth, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity });
|
|
4156
4215
|
}
|
|
4157
4216
|
}
|
|
4158
4217
|
}
|
|
@@ -4168,11 +4227,11 @@ class HubSystem {
|
|
|
4168
4227
|
for (const { id, at, label } of placed) {
|
|
4169
4228
|
if (!party.has(id) || labels.some((item) => (item.actorId ?? item.id) === id)) {continue;}
|
|
4170
4229
|
const screen = project(cam, at.x, at.y + 1.6, at.z, view);
|
|
4171
|
-
if (screen) {labels.push({ id, x: screen.x, y: screen.y, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity: 1 });}
|
|
4230
|
+
if (screen) {labels.push({ id, x: screen.x, y: screen.y, depth: screen.depth, text: label.text, speech: label.style === 'speech', npc: label.npc === true, opacity: 1 });}
|
|
4172
4231
|
}
|
|
4173
4232
|
// v1.168: marks and role labels count under the same cap; a culled
|
|
4174
4233
|
// bystander's are dropped. Drawn later, after the world labels.
|
|
4175
|
-
const tags = qualityTags(scene, local, this.markItems(scene, local, cam, view), roleItems(scene, local, cam, view, Hub.hub.roles, project));
|
|
4234
|
+
const tags = qualityTags(scene, local, this.markItems(scene, local, cam, view, false), roleItems(scene, local, cam, view, Hub.hub.roles, project));
|
|
4176
4235
|
qualityTagItems = splitTags(capWorldLabels(labels, placed, lt, quality.labels, party, tags), labels, tags);
|
|
4177
4236
|
}
|
|
4178
4237
|
}
|
|
@@ -4196,7 +4255,7 @@ class HubSystem {
|
|
|
4196
4255
|
chrome.setPointers?.(pointers.map((point) => offsetWorldPoint(point, view)));
|
|
4197
4256
|
if (cam && idle) {
|
|
4198
4257
|
if (qualityTagItems) {labels.push(...qualityTagItems);} else {
|
|
4199
|
-
labels.push(...this.markItems(scene, local, cam, view));
|
|
4258
|
+
labels.push(...this.markItems(scene, local, cam, view, false));
|
|
4200
4259
|
labels.push(...roleItems(scene, local, cam, view, Hub.hub.roles, project));
|
|
4201
4260
|
}
|
|
4202
4261
|
labels.push(...this.idle.labels(scene, local, cam, view, project));
|
|
@@ -4412,13 +4471,14 @@ class HubSystem {
|
|
|
4412
4471
|
const screen = candidates.has(id) ? project(cam, at.x, at.y + 1.6, at.z, view) : null;
|
|
4413
4472
|
const box = screen ? labelBox(screen.x, screen.y, chrome.measureLabel(label.text, speech, npc, pad), npc, view, hud, prompt) : null;
|
|
4414
4473
|
items.push({ id, kind, pick, d: candidates.has(id) ? Math.hypot(at.x - lt.x, at.z - lt.z) : Infinity, mine: Object.hasOwn(mine, id), box });
|
|
4415
|
-
drawn.set(id, { text: label.text, speech, npc, box, pad });
|
|
4474
|
+
drawn.set(id, { text: label.text, speech, npc, box, pad, depth: screen?.depth });
|
|
4416
4475
|
}
|
|
4417
4476
|
const out = [];
|
|
4418
4477
|
for (const [id, opacity] of (defaults ? relevantLabels(state, items, view, now) : near(state, items, view, now))) {
|
|
4419
4478
|
const d = drawn.get(id);
|
|
4420
4479
|
if (!d?.box) {continue;}
|
|
4421
4480
|
const item = chromeItem(id, d.text, d.speech, d.npc, d.box, opacity);
|
|
4481
|
+
item.depth = d.depth;
|
|
4422
4482
|
if (Hub.deck.quality) {
|
|
4423
4483
|
item.actorId = id;
|
|
4424
4484
|
// Admission by the near-label rule grants the exemption, regardless
|
|
@@ -4464,7 +4524,7 @@ class HubSystem {
|
|
|
4464
4524
|
|
|
4465
4525
|
// The tags the place put over players (`hub.mark`): over this player's own
|
|
4466
4526
|
// body and over each other player's avatar, above the name tag.
|
|
4467
|
-
markItems(scene, local, cam, view) {
|
|
4527
|
+
markItems(scene, local, cam, view, namesReady = true) {
|
|
4468
4528
|
const mp = scene.multiplayer;
|
|
4469
4529
|
const self = mp?.net?.selfId?.() ?? null;
|
|
4470
4530
|
const out = [];
|
|
@@ -4472,9 +4532,27 @@ class HubSystem {
|
|
|
4472
4532
|
if (disguiseTags(self, playerId)) {continue;}
|
|
4473
4533
|
const actorId = playerId === self ? local?.id : mp?.avatars?.actors?.get(playerId);
|
|
4474
4534
|
const at = actorId ? scene.getActor(actorId)?.components.Transform : null;
|
|
4475
|
-
|
|
4535
|
+
if (!at) {continue;}
|
|
4536
|
+
const tag = namesReady && playerId !== self ? mp?.avatars?.tags?.get(playerId)?.sprite : null;
|
|
4537
|
+
if (tag && (!tag.visible || tag.material?.visible === false || !(tag.material?.opacity > 0))) {continue;}
|
|
4538
|
+
// The kit hides this player's own name; the own mark sits where that
|
|
4539
|
+
// name would be drawn, not a fixed 1.95 m up (which floats far above
|
|
4540
|
+
// the head on a phone and, turned, under the HUD where the world layout
|
|
4541
|
+
// drops it). The point comes from this frame's body at multiplayer-3d's
|
|
4542
|
+
// own-tag height (`showSelf` passes no `tagHeight`: nameTags.js
|
|
4543
|
+
// HEIGHT_ABOVE), so a sprite multiplayer stopped placing (a vehicle
|
|
4544
|
+
// passenger skips the report) cannot hold the mark at an old pose; the
|
|
4545
|
+
// sprite gives only its drawn size.
|
|
4546
|
+
const own = playerId === self ? mp?.avatars?.tags?.get('self')?.sprite : null;
|
|
4547
|
+
const up = cam.matrixWorld?.elements;
|
|
4548
|
+
const half = (tag ?? own) && up ? Math.abs((tag ?? own).scale.y) / 2 : 0;
|
|
4549
|
+
const p = tag?.position ?? (playerId === self ? { x: at.x, y: at.y + 1.25, z: at.z } : null);
|
|
4550
|
+
const screen = p && up
|
|
4551
|
+
? project(cam, p.x + up[4] * half, p.y + up[5] * half, p.z + up[6] * half, view)
|
|
4552
|
+
: project(cam, at.x, at.y + 1.95, at.z, view);
|
|
4476
4553
|
if (screen) {
|
|
4477
|
-
out.push({ id: `mark:${playerId}`, x: screen.x, y: screen.y, text: mark.text || '●', color: mark.color
|
|
4554
|
+
out.push({ id: `mark:${playerId}`, x: screen.x, y: screen.y - (p && up ? 4 : 0), text: mark.text || '●', color: mark.color,
|
|
4555
|
+
opacity: tag?.material?.opacity ?? 1, ...(playerId === self ? { own: true } : {}) });
|
|
4478
4556
|
}
|
|
4479
4557
|
}
|
|
4480
4558
|
return out;
|
|
@@ -4734,7 +4812,7 @@ function project(cam, x, y, z, view) {
|
|
|
4734
4812
|
if (v.z > 1 || v.z < -1) {
|
|
4735
4813
|
return null;
|
|
4736
4814
|
}
|
|
4737
|
-
return mapWorldPoint({ x: ((v.x + 1) / 2) * view.w, y: ((1 - v.y) / 2) * view.h }, view);
|
|
4815
|
+
return mapWorldPoint({ x: ((v.x + 1) / 2) * view.w, y: ((1 - v.y) / 2) * view.h, depth: v.z }, view);
|
|
4738
4816
|
}
|
|
4739
4817
|
|
|
4740
4818
|
function statsWanted() {
|