dredless 1.1.4 → 1.2.1
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/browser/dredless.global.js +23 -13
- package/dist/browser/dredless.global.js.map +2 -2
- package/docs/MACHINES.md +5 -0
- package/package.json +1 -1
- package/src/index.d.ts +11 -2
- package/src/state/model/decoder.js +22 -5
- package/src/state/model/reader.js +4 -1
- package/src/state/model/state.js +5 -9
package/docs/MACHINES.md
CHANGED
|
@@ -349,3 +349,8 @@ name have been removed. Raw encoded values remain in `.state.state` (`q40` for
|
|
|
349
349
|
the indicator, `q56` for resources).
|
|
350
350
|
|
|
351
351
|
Summary progress, counts, health, occupancy, and raw model records vary by component; use the component's [declared summary](../src/index.d.ts) rather than assuming all machines share a progress scale or health convention.
|
|
352
|
+
|
|
353
|
+
Cargo ejector rendering state uses table 49 `q20 / 100` for `progress`,
|
|
354
|
+
`q24` for the signed `direction` offset, `q28 / 100` for `extension`, and
|
|
355
|
+
`q33` for `noMount`. `active` reports a nonzero cycle or extension; it is
|
|
356
|
+
not the mount flag. The summary also exposes the raw `state`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dredless",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A fully-featured and from-scratch headless drednot.io client implementation written in pure js.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/certainhuman/dredless#readme",
|
package/src/index.d.ts
CHANGED
|
@@ -1567,8 +1567,15 @@ export interface CargoEjectorSummary {
|
|
|
1567
1567
|
entity: number;
|
|
1568
1568
|
typeId: number;
|
|
1569
1569
|
typeName: string | null;
|
|
1570
|
-
|
|
1571
|
-
|
|
1570
|
+
/** Animation cycle in renderer units (q20 / 100). */
|
|
1571
|
+
progress: number;
|
|
1572
|
+
/** Signed lateral offset used by the ejector arm. */
|
|
1573
|
+
direction: number;
|
|
1574
|
+
extension: number;
|
|
1575
|
+
noMount: boolean;
|
|
1576
|
+
/** Whether the cycle or arm extension is nonzero; not a replicated flag. */
|
|
1577
|
+
active: boolean;
|
|
1578
|
+
state: ModelRecord;
|
|
1572
1579
|
}
|
|
1573
1580
|
|
|
1574
1581
|
export interface EntityContentsSummary {
|
|
@@ -2378,6 +2385,8 @@ export interface PlayerSummary {
|
|
|
2378
2385
|
cheats: { noclip: boolean; sandboxBuild: boolean };
|
|
2379
2386
|
/** Shared item effect flag, including active rocket/hover pack exhaust. */
|
|
2380
2387
|
itemEffectActive: boolean;
|
|
2388
|
+
/** Current world velocity from motion table 4, in world units per second. */
|
|
2389
|
+
velocity: { x: number; y: number } | null;
|
|
2381
2390
|
animation: PlayerAnimationSummary;
|
|
2382
2391
|
appearance: PlayerAppearanceSummary | null;
|
|
2383
2392
|
actionPreview: PlayerActionPreviewSummary | null;
|
|
@@ -74,7 +74,7 @@ export function peekStreamInt(reader) {
|
|
|
74
74
|
result += (byte & 0x7f) * (2 ** shift);
|
|
75
75
|
if ((byte & 0x80) === 0) {
|
|
76
76
|
return {
|
|
77
|
-
value:
|
|
77
|
+
value: result % 2 === 0 ? result / 2 : -Math.floor(result / 2),
|
|
78
78
|
offset
|
|
79
79
|
};
|
|
80
80
|
}
|
|
@@ -655,12 +655,21 @@ export function summarizeFabricator(entity, record, itemHolderRecord = null, typ
|
|
|
655
655
|
|
|
656
656
|
export function summarizeCargoEjector(entity, typeId, record) {
|
|
657
657
|
if (typeId !== 223) return null;
|
|
658
|
+
// Official DTS -> component sync (1014): q20/100 is the cycle,
|
|
659
|
+
// q24 is the signed lateral offset, q28/100 is arm extension, and
|
|
660
|
+
// q33 suppresses the hull mount. The flag is not an active bit.
|
|
661
|
+
const progress = numberOrNull(record?.q20, 100) ?? 0;
|
|
662
|
+
const extension = numberOrNull(record?.q28, 100) ?? 0;
|
|
658
663
|
return {
|
|
659
664
|
entity,
|
|
660
665
|
typeId,
|
|
661
666
|
typeName: entityNameFromType(typeId),
|
|
662
|
-
progress
|
|
663
|
-
|
|
667
|
+
progress,
|
|
668
|
+
direction: record?.q24 ?? 0,
|
|
669
|
+
extension,
|
|
670
|
+
noMount: Boolean(record?.q33),
|
|
671
|
+
active: progress > 0 || extension > 0,
|
|
672
|
+
state: cloneRecord(record)
|
|
664
673
|
};
|
|
665
674
|
}
|
|
666
675
|
|
|
@@ -1083,7 +1092,9 @@ export function summarizeShipControl(entity, record) {
|
|
|
1083
1092
|
tankValues
|
|
1084
1093
|
},
|
|
1085
1094
|
warp: warpTicks == null ? null : {
|
|
1086
|
-
|
|
1095
|
+
// Native ship status uses the positive warp timer (q84 / 20).
|
|
1096
|
+
// q28 is thrust Y and does not indicate a warp state.
|
|
1097
|
+
active: warpTicks > 0,
|
|
1087
1098
|
ticks: warpTicks,
|
|
1088
1099
|
elapsedSeconds: warpElapsedSeconds,
|
|
1089
1100
|
durationSeconds: warpDurationSeconds,
|
|
@@ -1483,7 +1494,7 @@ function summarizePlayerAppearance(record, player) {
|
|
|
1483
1494
|
};
|
|
1484
1495
|
}
|
|
1485
1496
|
|
|
1486
|
-
export function summarizePlayer(entity, record, previewRecord = null, blueprintItems = [], appearanceRecord = null, localPlayerEntity = null) {
|
|
1497
|
+
export function summarizePlayer(entity, record, previewRecord = null, blueprintItems = [], appearanceRecord = null, localPlayerEntity = null, motionRecord = null) {
|
|
1487
1498
|
if (!record) return null;
|
|
1488
1499
|
const rawHeldItemId = record.q28 == null ? null : Number(record.q28);
|
|
1489
1500
|
const heldItemId = Number.isFinite(rawHeldItemId) && rawHeldItemId !== 0 ? rawHeldItemId : null;
|
|
@@ -1511,6 +1522,12 @@ export function summarizePlayer(entity, record, previewRecord = null, blueprintI
|
|
|
1511
1522
|
sandboxBuild: Boolean(record.q108)
|
|
1512
1523
|
},
|
|
1513
1524
|
itemEffectActive: Boolean(record.q111),
|
|
1525
|
+
// Official motion component sync (1013): q20 is metadata;
|
|
1526
|
+
// q24/q28 are world velocity, quantized in twentieths.
|
|
1527
|
+
velocity: motionRecord ? {
|
|
1528
|
+
x: (motionRecord.q24 ?? 0) / 20,
|
|
1529
|
+
y: (motionRecord.q28 ?? 0) / 20
|
|
1530
|
+
} : null,
|
|
1514
1531
|
animation: {
|
|
1515
1532
|
facing: record.q20 ?? 1,
|
|
1516
1533
|
orientation: record.q24 ?? 0,
|
|
@@ -29,7 +29,10 @@ export class ModelReader {
|
|
|
29
29
|
|
|
30
30
|
readStreamInt() {
|
|
31
31
|
const raw = this.readUnsigned();
|
|
32
|
-
|
|
32
|
+
// The client uses sign/magnitude varints, including entity-ID deltas.
|
|
33
|
+
// Odd 2*n+1 decodes to -n (not the zigzag value -n-1).
|
|
34
|
+
const magnitude = Math.floor(raw / 2);
|
|
35
|
+
return raw % 2 === 0 ? magnitude : -magnitude;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
readFieldDelta() {
|
package/src/state/model/state.js
CHANGED
|
@@ -878,7 +878,7 @@ export class ModelState {
|
|
|
878
878
|
const shieldGenerator = typeId === 256 ? summarizeShieldGenerator(entityId, shieldRecord, itemHolderRecord, shieldGeneratorBoostRecord) : null;
|
|
879
879
|
const shieldProjector = typeId === 257 ? summarizeShieldProjector(entityId, shieldProjectorRecord) : null;
|
|
880
880
|
const blueprintPreview = summarizeBlueprintPreview(entityId, blueprintPreviewRecord, transformRecord);
|
|
881
|
-
const player = summarizePlayer(entityId, playerRecord, rec(14), this.#blueprintPreviewItems(), rec(56), this.#localPlayerEntity);
|
|
881
|
+
const player = summarizePlayer(entityId, playerRecord, rec(14), this.#blueprintPreviewItems(), rec(56), this.#localPlayerEntity, rec(4));
|
|
882
882
|
const shipControl = summarizeShipControl(entityId, shipControlRecord);
|
|
883
883
|
const helm = summarizeHelm(entityId, typeId, this.#helmOccupied.get(entityId));
|
|
884
884
|
const commsStation = summarizeCommsStation(entityId, typeId, commsStationRecord, this.#commsStationOccupied.get(entityId));
|
|
@@ -1107,14 +1107,10 @@ export class ModelState {
|
|
|
1107
1107
|
if (delta === 0) break;
|
|
1108
1108
|
entity += delta;
|
|
1109
1109
|
removals.push(entity);
|
|
1110
|
-
//
|
|
1111
|
-
//
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
for (const tableId of known) this.tables.get(tableId)?.delete(entity);
|
|
1115
|
-
} else {
|
|
1116
|
-
for (const records of this.tables.values()) records.delete(entity);
|
|
1117
|
-
}
|
|
1110
|
+
// The derived membership index describes the previous apply(), so it
|
|
1111
|
+
// can miss component tables added earlier in this same packet (or
|
|
1112
|
+
// in a partially decoded section). A removal must clear every table.
|
|
1113
|
+
for (const records of this.tables.values()) records.delete(entity);
|
|
1118
1114
|
this.#helmOccupied.delete(entity);
|
|
1119
1115
|
this.#commsStationOccupied.delete(entity);
|
|
1120
1116
|
this.#navigationUnitAutoWarp.delete(entity);
|