dredless 1.4.2 → 1.5.0
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 +417 -245
- package/dist/browser/dredless.global.js.map +4 -4
- package/docs/MACHINES.md +43 -0
- package/docs/MANAGEMENT.md +2 -2
- package/docs/WORLD_STATE.md +25 -0
- package/package.json +1 -1
- package/src/client/core.js +19 -1
- package/src/client/domains/index.js +19 -0
- package/src/data/item-schema.js +18 -2
- package/src/index.d.ts +52 -5
- package/src/index.js +1 -0
- package/src/protocol/codec/ui-integer.js +7 -0
- package/src/protocol/outbound/advanced-expando.js +65 -0
- package/src/protocol/outbound/machine-config.js +1 -6
- package/src/protocol/outbound/ui-config.d.ts +6 -0
- package/src/protocol/outbound/ui-config.js +7 -9
- package/src/state/model/decoder.js +43 -11
- package/src/state/model/state.js +37 -4
- package/src/state/world/state.js +1 -1
package/src/state/model/state.js
CHANGED
|
@@ -128,6 +128,10 @@ const {
|
|
|
128
128
|
} = modelDecoder;
|
|
129
129
|
|
|
130
130
|
export class ModelState {
|
|
131
|
+
#entityRevisions = new Map();
|
|
132
|
+
#entityIds = null;
|
|
133
|
+
#recordRevisions = new WeakMap();
|
|
134
|
+
#revision = 0;
|
|
131
135
|
#localPlayerEntity = null;
|
|
132
136
|
#blueprintItems = null;
|
|
133
137
|
#helmOccupied = new Map();
|
|
@@ -176,6 +180,28 @@ export class ModelState {
|
|
|
176
180
|
return this.table(tableId).get(Number(entityId)) || null;
|
|
177
181
|
}
|
|
178
182
|
|
|
183
|
+
/** Monotonic local revision, independent of the server's generation counter. */
|
|
184
|
+
get revision() { return this.#revision; }
|
|
185
|
+
|
|
186
|
+
/** Live component IDs without creating entity/debug summaries. */
|
|
187
|
+
componentEntityIds() {
|
|
188
|
+
this.#entityIds ??= [...this.#entityRevisions.keys()].sort((a, b) => a - b);
|
|
189
|
+
return this.#entityIds.values();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Latest record mutation for a live entity, or zero after removal. */
|
|
193
|
+
entityRevision(entityId) { return this.#entityRevisions.get(Number(entityId)) ?? 0; }
|
|
194
|
+
|
|
195
|
+
/** Revision of a decoded record, without creating entity/debug summaries. */
|
|
196
|
+
recordRevision(record) { return record ? this.#recordRevisions.get(record) ?? 0 : 0; }
|
|
197
|
+
|
|
198
|
+
/** Stateful navigation destination without constructing derived entity lists. */
|
|
199
|
+
navigationDestination(entityId) {
|
|
200
|
+
const record = this.record(78, entityId);
|
|
201
|
+
return this.#navigationUnitAutoWarp.get(Number(entityId))?.destination
|
|
202
|
+
?? navigationDestinationFromRecord(record);
|
|
203
|
+
}
|
|
204
|
+
|
|
179
205
|
entity(entityId) {
|
|
180
206
|
const id = Number(entityId);
|
|
181
207
|
if (!Number.isFinite(id)) return null;
|
|
@@ -199,6 +225,7 @@ export class ModelState {
|
|
|
199
225
|
}
|
|
200
226
|
|
|
201
227
|
apply(bytes, {full = false} = {}) {
|
|
228
|
+
this.#revision++;
|
|
202
229
|
this.#blueprintItems = null;
|
|
203
230
|
const reader = new ModelReader(bytes);
|
|
204
231
|
const update = {
|
|
@@ -892,7 +919,7 @@ export class ModelState {
|
|
|
892
919
|
const thrusterRecord = rec(50);
|
|
893
920
|
const labelRecord = rec(9);
|
|
894
921
|
const zoneLabelRecord = rec(25);
|
|
895
|
-
const dockingSpringRecord = rec(
|
|
922
|
+
const dockingSpringRecord = rec(22);
|
|
896
923
|
const hugeThrusterRecord = rec(23);
|
|
897
924
|
const bodyStateRecord = rec(1);
|
|
898
925
|
const typeRecord = rec(7);
|
|
@@ -907,7 +934,8 @@ export class ModelState {
|
|
|
907
934
|
const dynamicBody = bodyStateRecord?.q20 === -4;
|
|
908
935
|
const typeId = entityTypeIdFromRecord(typeRecord);
|
|
909
936
|
const itemHolder = summarizeItemHolder(entityId, itemHolderRecord);
|
|
910
|
-
const
|
|
937
|
+
const isAdvancedExpandoBox = typeId === 266 || Boolean(rec(82) || rec(83));
|
|
938
|
+
const isExpandoBox = isAdvancedExpandoBox || typeId === EXPANDO_BOX_TYPE_ID || markerTypeId === EXPANDO_BOX_TYPE_ID;
|
|
911
939
|
const health = summarizeHealth(entityId, healthRecord);
|
|
912
940
|
const projectile = summarizeProjectile(entityId, rec(24));
|
|
913
941
|
const combatBeams = summarizeCombatBeams(entityId, rec(15));
|
|
@@ -944,10 +972,10 @@ export class ModelState {
|
|
|
944
972
|
const door = typeId === 220 ? summarizeDoor(entityId, spawnPointRecord, doorRecord, rec(80)) : null;
|
|
945
973
|
const shipSize = shipControl && this.isOverworld ? summarizeShipSize(entityId, rec(3)) : null;
|
|
946
974
|
const hoverOutline = summarizeHoverOutline(entityId, crateSizeRecord);
|
|
947
|
-
const expandoBox = isExpandoBox ? summarizeExpandoBox(entityId, itemHolderRecord, expandoSizeRecord) : null;
|
|
975
|
+
const expandoBox = isExpandoBox ? summarizeExpandoBox(entityId, itemHolderRecord, expandoSizeRecord, rec(82), rec(83), isAdvancedExpandoBox) : null;
|
|
948
976
|
const mapMarker = this.isOverworld ? summarizeMapMarker(entityId, labelRecord, zoneLabelRecord, crateSizeRecord) : null;
|
|
949
977
|
const dockingSpring = this.isOverworld
|
|
950
|
-
? summarizeDockingSpring(entityId, dockingSpringRecord,
|
|
978
|
+
? summarizeDockingSpring(entityId, dockingSpringRecord, crateSizeRecord)
|
|
951
979
|
: null;
|
|
952
980
|
const hugeThruster = this.isOverworld
|
|
953
981
|
? summarizeHugeThruster(entityId, hugeThrusterRecord, crateSizeRecord)
|
|
@@ -1164,6 +1192,8 @@ export class ModelState {
|
|
|
1164
1192
|
if (delta === 0) break;
|
|
1165
1193
|
entity += delta;
|
|
1166
1194
|
removals.push(entity);
|
|
1195
|
+
this.#entityRevisions.delete(entity);
|
|
1196
|
+
this.#entityIds = null;
|
|
1167
1197
|
// The derived membership index describes the previous apply(), so it
|
|
1168
1198
|
// can miss component tables added earlier in this same packet (or
|
|
1169
1199
|
// in a partially decoded section). A removal must clear every table.
|
|
@@ -1206,6 +1236,9 @@ export class ModelState {
|
|
|
1206
1236
|
if (!records) this.tables.set(tableId, records = new Map());
|
|
1207
1237
|
let record = records.get(entity);
|
|
1208
1238
|
if (!record) records.set(entity, record = {...spec?.defaults});
|
|
1239
|
+
if (!this.#entityRevisions.has(entity)) this.#entityIds = null;
|
|
1240
|
+
this.#entityRevisions.set(entity, this.#revision);
|
|
1241
|
+
this.#recordRevisions.set(record, this.#revision);
|
|
1209
1242
|
record.lastMask = mask;
|
|
1210
1243
|
|
|
1211
1244
|
try {
|
package/src/state/world/state.js
CHANGED
|
@@ -137,7 +137,7 @@ export class WorldState {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
readMeta(packet) {
|
|
140
|
-
this.meta = packet;
|
|
140
|
+
this.meta = {...this.meta, ...packet};
|
|
141
141
|
this.seed = packet.seed ?? this.seed;
|
|
142
142
|
const isOverworld = packet.is_overworld ?? this.isOverworld;
|
|
143
143
|
this.isOverworld = isOverworld == null ? null : Boolean(isOverworld);
|