dredless 1.0.0 → 1.1.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/README.md +11 -12
- package/dist/browser/dredless.global.js +241 -34
- package/dist/browser/dredless.global.js.map +3 -3
- package/docs/PROTOCOL.md +5 -0
- package/docs/README.md +1 -0
- package/docs/WORLD_STATE.md +71 -0
- package/package.json +1 -1
- package/src/client/domains/index.js +34 -0
- package/src/index.d.ts +107 -1
- package/src/state/model/decoder.js +129 -39
- package/src/state/model/index.d.ts +7 -0
- package/src/state/model/state.js +53 -4
- package/src/state/world/index.d.ts +6 -0
- package/src/state/world/state.js +5 -0
package/src/state/model/state.js
CHANGED
|
@@ -62,7 +62,11 @@ const {
|
|
|
62
62
|
summarizeCommsStation,
|
|
63
63
|
summarizeHealth,
|
|
64
64
|
summarizeBot,
|
|
65
|
-
|
|
65
|
+
summarizeProjectile,
|
|
66
|
+
summarizeCombatBeams,
|
|
67
|
+
summarizeBall,
|
|
68
|
+
summarizeRcd,
|
|
69
|
+
summarizeRecycler,
|
|
66
70
|
botClassFromState,
|
|
67
71
|
isCowardBossState,
|
|
68
72
|
isOrangeFoolBotState,
|
|
@@ -268,6 +272,11 @@ export class ModelState {
|
|
|
268
272
|
blocks: includeBlocks ? this.#derivedBlocks().slice() : undefined,
|
|
269
273
|
transforms: derived.transforms.slice(),
|
|
270
274
|
players: derived.players.slice(),
|
|
275
|
+
projectiles: derived.specialEntities.projectiles.slice(),
|
|
276
|
+
bots: derived.specialEntities.bots.slice(),
|
|
277
|
+
rcds: derived.specialEntities.rcds.slice(),
|
|
278
|
+
balls: derived.specialEntities.balls.slice(),
|
|
279
|
+
recyclers: derived.specialEntities.recyclers.slice(),
|
|
271
280
|
shipControls: derived.shipControls.slice(),
|
|
272
281
|
machines: this.#machinesSnapshot(derived.machines),
|
|
273
282
|
tables: includeTables ? this.tablesSnapshot() : derived.tableSummaries.slice()
|
|
@@ -298,6 +307,26 @@ export class ModelState {
|
|
|
298
307
|
return this.#derivedState().players.slice();
|
|
299
308
|
}
|
|
300
309
|
|
|
310
|
+
projectiles() {
|
|
311
|
+
return this.#derivedState().specialEntities.projectiles.slice();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
bots() {
|
|
315
|
+
return this.#derivedState().specialEntities.bots.slice();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
rcds() {
|
|
319
|
+
return this.#derivedState().specialEntities.rcds.slice();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
balls() {
|
|
323
|
+
return this.#derivedState().specialEntities.balls.slice();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
recyclers() {
|
|
327
|
+
return this.#derivedState().specialEntities.recyclers.slice();
|
|
328
|
+
}
|
|
329
|
+
|
|
301
330
|
shipControls() {
|
|
302
331
|
return this.#derivedState().shipControls.slice();
|
|
303
332
|
}
|
|
@@ -699,6 +728,7 @@ export class ModelState {
|
|
|
699
728
|
doors: [],
|
|
700
729
|
expandoBoxes: []
|
|
701
730
|
};
|
|
731
|
+
const specialEntities = {projectiles: [], bots: [], rcds: [], balls: [], recyclers: []};
|
|
702
732
|
const players = [];
|
|
703
733
|
const shipControls = [];
|
|
704
734
|
const transforms = [];
|
|
@@ -728,6 +758,11 @@ export class ModelState {
|
|
|
728
758
|
if (contents.spawnPoint) machines.spawnPoints.push(contents.spawnPoint);
|
|
729
759
|
if (contents.door) machines.doors.push(contents.door);
|
|
730
760
|
if (contents.expandoBox) machines.expandoBoxes.push(contents.expandoBox);
|
|
761
|
+
if (contents.projectile) specialEntities.projectiles.push(contents.projectile);
|
|
762
|
+
if (contents.bot) specialEntities.bots.push(contents.bot);
|
|
763
|
+
if (contents.rcd) specialEntities.rcds.push(contents.rcd);
|
|
764
|
+
if (contents.ball) specialEntities.balls.push(contents.ball);
|
|
765
|
+
if (contents.recycler) specialEntities.recyclers.push(contents.recycler);
|
|
731
766
|
if (contents.player) players.push(contents.player);
|
|
732
767
|
if (contents.shipControl) shipControls.push(contents.shipControl);
|
|
733
768
|
}
|
|
@@ -735,6 +770,7 @@ export class ModelState {
|
|
|
735
770
|
derived.entities = entities;
|
|
736
771
|
derived.transforms = transforms;
|
|
737
772
|
derived.players = players;
|
|
773
|
+
derived.specialEntities = specialEntities;
|
|
738
774
|
derived.shipControls = shipControls;
|
|
739
775
|
derived.machines = machines;
|
|
740
776
|
derived.summariesDirty = false;
|
|
@@ -817,6 +853,11 @@ export class ModelState {
|
|
|
817
853
|
const itemHolder = summarizeItemHolder(entityId, itemHolderRecord);
|
|
818
854
|
const isExpandoBox = typeId === EXPANDO_BOX_TYPE_ID || markerTypeId === EXPANDO_BOX_TYPE_ID;
|
|
819
855
|
const health = summarizeHealth(entityId, healthRecord);
|
|
856
|
+
const projectile = summarizeProjectile(entityId, rec(24));
|
|
857
|
+
const combatBeams = summarizeCombatBeams(entityId, rec(15));
|
|
858
|
+
const ball = summarizeBall(entityId, rec(17), health, rec(2));
|
|
859
|
+
const rcd = summarizeRcd(entityId, rec(59), itemHolderRecord);
|
|
860
|
+
const recycler = this.isOverworld === false ? summarizeRecycler(entityId, rec(23), itemHolderRecord) : null;
|
|
820
861
|
const fabricator = summarizeFabricator(entityId, fabricatorRecord, itemHolderRecord, typeRecord);
|
|
821
862
|
const cargoEjector = summarizeCargoEjector(entityId, typeId, cargoEjectorRecord);
|
|
822
863
|
const cannon = summarizeCannon(entityId, cannonRecord, typeId, transformRecord);
|
|
@@ -854,10 +895,10 @@ export class ModelState {
|
|
|
854
895
|
const hugeThruster = this.isOverworld
|
|
855
896
|
? summarizeHugeThruster(entityId, hugeThrusterRecord, crateSizeRecord)
|
|
856
897
|
: null;
|
|
857
|
-
const itemCrate = this.isOverworld && !rec(2) && !rec(18) && health && crateSizeRecord
|
|
898
|
+
const itemCrate = this.isOverworld && !rec(2) && !rec(18) && !combatBeams && !projectile && !ball && !rcd && health && crateSizeRecord
|
|
858
899
|
? summarizeItemCrate(entityId, crateSizeRecord, crateItemRecord, healthRecord)
|
|
859
900
|
: null;
|
|
860
|
-
const bot = this.isOverworld
|
|
901
|
+
const bot = (this.isOverworld || rec(18) || combatBeams) && !projectile && !ball && !rcd
|
|
861
902
|
? summarizeBot(entityId, {
|
|
862
903
|
health,
|
|
863
904
|
table2Record: rec(2),
|
|
@@ -865,7 +906,7 @@ export class ModelState {
|
|
|
865
906
|
combatRecord: rec(18),
|
|
866
907
|
motionRecord: crateItemRecord,
|
|
867
908
|
table10Record: rec(10),
|
|
868
|
-
|
|
909
|
+
beamRecord: rec(15),
|
|
869
910
|
itemCrate,
|
|
870
911
|
player,
|
|
871
912
|
shipControl
|
|
@@ -879,6 +920,7 @@ export class ModelState {
|
|
|
879
920
|
flags: [transformRecord.q33, transformRecord.q34, transformRecord.q35].filter((value) => value != null)
|
|
880
921
|
} : null;
|
|
881
922
|
const contents = mergeContents({
|
|
923
|
+
projectile, combatBeams, ball, rcd, recycler,
|
|
882
924
|
itemHolder, expandoBox, hoverOutline, itemCrate, mapMarker, dockingSpring,
|
|
883
925
|
hugeThruster, blueprintPreview, health, bot, fabricator, cargoEjector,
|
|
884
926
|
cannon, thruster, pusher, pusherBeam, launcher, loader, cargoHatch,
|
|
@@ -913,6 +955,7 @@ export class ModelState {
|
|
|
913
955
|
});
|
|
914
956
|
const typeName = entityNameFromType(typeId);
|
|
915
957
|
const category = entityCategory({
|
|
958
|
+
projectile, ball, rcd, recycler,
|
|
916
959
|
typeId,
|
|
917
960
|
markerTypeId,
|
|
918
961
|
looseItemMarker,
|
|
@@ -948,6 +991,7 @@ export class ModelState {
|
|
|
948
991
|
markerTypeId,
|
|
949
992
|
markerTypeName,
|
|
950
993
|
label: entityLabel({
|
|
994
|
+
projectile, ball, rcd, recycler,
|
|
951
995
|
category,
|
|
952
996
|
typeId,
|
|
953
997
|
typeName,
|
|
@@ -981,6 +1025,11 @@ export class ModelState {
|
|
|
981
1025
|
isOverworld: this.isOverworld
|
|
982
1026
|
}),
|
|
983
1027
|
kind: [
|
|
1028
|
+
projectile ? "projectile" : null,
|
|
1029
|
+
combatBeams ? "combat_beams" : null,
|
|
1030
|
+
ball ? "ball" : null,
|
|
1031
|
+
rcd ? "rcd" : null,
|
|
1032
|
+
recycler ? "recycler" : null,
|
|
984
1033
|
transform ? "transform" : null,
|
|
985
1034
|
dynamicBody ? "dynamic_body" : null,
|
|
986
1035
|
itemHolder ? "item_holder" : null,
|
|
@@ -10,6 +10,12 @@ export {
|
|
|
10
10
|
type WorldSnapshot,
|
|
11
11
|
type WorldUpdate,
|
|
12
12
|
type CommsBubbleSummary,
|
|
13
|
+
type ProjectileSummary,
|
|
14
|
+
type BotCombatSummary,
|
|
15
|
+
type CombatBeamsSummary,
|
|
16
|
+
type RcdSummary,
|
|
17
|
+
type BallSummary,
|
|
18
|
+
type RecyclerSummary,
|
|
13
19
|
type ModelRecord,
|
|
14
20
|
type ModelSnapshot,
|
|
15
21
|
type TransformSummary,
|
package/src/state/world/state.js
CHANGED
|
@@ -260,6 +260,11 @@ export class WorldState {
|
|
|
260
260
|
transforms: model.transforms,
|
|
261
261
|
machines: model.machines,
|
|
262
262
|
players: model.players,
|
|
263
|
+
projectiles: model.projectiles,
|
|
264
|
+
bots: model.bots,
|
|
265
|
+
rcds: model.rcds,
|
|
266
|
+
balls: model.balls,
|
|
267
|
+
recyclers: model.recyclers,
|
|
263
268
|
shipControls: model.shipControls,
|
|
264
269
|
commsBubbles: this.commsBubbles.slice(),
|
|
265
270
|
tiles: includeTiles ? [...this.tiles.values()] : undefined
|