@shipload/sdk 1.0.0-next.60 → 1.0.0-next.62

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipload/sdk",
3
3
  "description": "SDKs for Shipload",
4
- "version": "1.0.0-next.60",
4
+ "version": "1.0.0-next.62",
5
5
  "homepage": "https://github.com/shipload/toolkit/tree/master/packages/sdk",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,21 +1,4 @@
1
- import {
2
- ITEM_BATTERY_T1,
3
- ITEM_BUILDER_T1,
4
- ITEM_CRAFTER_T1,
5
- ITEM_ENGINE_T1,
6
- ITEM_ENGINE_T2,
7
- ITEM_GATHERER_T1,
8
- ITEM_GATHERER_T2,
9
- ITEM_GENERATOR_T1,
10
- ITEM_GENERATOR_T2,
11
- ITEM_HAULER_T1,
12
- ITEM_HAULER_T2,
13
- ITEM_LAUNCHER_T1,
14
- ITEM_LOADER_T1,
15
- ITEM_STORAGE_T1,
16
- ITEM_WARP_T1,
17
- } from '../data/item-ids'
18
- import {getItem} from '../data/catalog'
1
+ import {getItem, tryGetItem} from '../data/catalog'
19
2
  import type {EntitySlot} from '../data/recipes-runtime'
20
3
 
21
4
  export const MODULE_ANY = 0
@@ -54,36 +37,8 @@ export function moduleAccepts(slotType: number, moduleType: number): boolean {
54
37
  }
55
38
 
56
39
  export function getModuleCapabilityType(itemId: number): number {
57
- switch (itemId) {
58
- case ITEM_ENGINE_T1:
59
- case ITEM_ENGINE_T2:
60
- return MODULE_ENGINE
61
- case ITEM_GENERATOR_T1:
62
- case ITEM_GENERATOR_T2:
63
- return MODULE_GENERATOR
64
- case ITEM_GATHERER_T1:
65
- case ITEM_GATHERER_T2:
66
- return MODULE_GATHERER
67
- case ITEM_LOADER_T1:
68
- return MODULE_LOADER
69
- case ITEM_CRAFTER_T1:
70
- return MODULE_CRAFTER
71
- case ITEM_BUILDER_T1:
72
- return MODULE_BUILDER
73
- case ITEM_STORAGE_T1:
74
- return MODULE_STORAGE
75
- case ITEM_HAULER_T1:
76
- case ITEM_HAULER_T2:
77
- return MODULE_HAULER
78
- case ITEM_WARP_T1:
79
- return MODULE_WARP
80
- case ITEM_BATTERY_T1:
81
- return MODULE_BATTERY
82
- case ITEM_LAUNCHER_T1:
83
- return MODULE_LAUNCHER
84
- default:
85
- return 0xff
86
- }
40
+ const item = tryGetItem(itemId)
41
+ return item?.type === 'module' && item.moduleType ? moduleSlotTypeToCode(item.moduleType) : 0xff
87
42
  }
88
43
 
89
44
  export function isModuleItem(itemId: number): boolean {
@@ -32,12 +32,16 @@ for (const raw of items as any[]) {
32
32
  export const itemIds = Array.from(itemsById.keys())
33
33
 
34
34
  export function getItem(itemId: UInt16Type): Item {
35
- const id = UInt16.from(itemId).toNumber()
36
- const item = itemsById.get(id)
37
- if (!item) throw new Error(`Unknown item id: ${id}`)
35
+ const item = tryGetItem(itemId)
36
+ if (!item) throw new Error(`Unknown item id: ${UInt16.from(itemId).toNumber()}`)
38
37
  return item
39
38
  }
40
39
 
40
+ export function tryGetItem(itemId: UInt16Type): Item | undefined {
41
+ const id = UInt16.from(itemId).toNumber()
42
+ return itemsById.get(id)
43
+ }
44
+
41
45
  export function getItems(): Item[] {
42
46
  return Array.from(itemsById.values())
43
47
  }
@@ -46,7 +46,7 @@ export const itemAbbreviations: Record<number, string> = {
46
46
  10200: 'CT',
47
47
  10201: 'SH',
48
48
  10202: 'WH',
49
- 20001: 'PL',
50
- 20002: 'FR',
51
- 20200: 'CT',
49
+ 11001: 'PL',
50
+ 11002: 'FR',
51
+ 11200: 'CT',
52
52
  }
@@ -335,12 +335,12 @@
335
335
  "baseHullmass": 4000000
336
336
  },
337
337
  {
338
- "entityItemId": 20200,
338
+ "entityItemId": 11200,
339
339
  "slots": [],
340
340
  "baseHullmass": 100000
341
341
  },
342
342
  {
343
- "entityItemId": 20212,
343
+ "entityItemId": 11212,
344
344
  "slots": [
345
345
  {
346
346
  "type": "generator",
@@ -361,7 +361,7 @@
361
361
  "baseHullmass": 5920000
362
362
  },
363
363
  {
364
- "entityItemId": 20213,
364
+ "entityItemId": 11213,
365
365
  "slots": [
366
366
  {
367
367
  "type": "generator",
@@ -387,7 +387,7 @@
387
387
  "baseHullmass": 7360000
388
388
  },
389
389
  {
390
- "entityItemId": 20214,
390
+ "entityItemId": 11214,
391
391
  "slots": [
392
392
  {
393
393
  "type": "generator",
@@ -88,25 +88,27 @@ export const ITEM_WRIGHT_T1A_PACKED = 10213
88
88
  export const ITEM_TUG_T1A_PACKED = 10214
89
89
  export const ITEM_PORTER_T1A_PACKED = 10215
90
90
  export const ITEM_SMITH_T1A_PACKED = 10218
91
- export const ITEM_PLATE_T2 = 20001
92
- export const ITEM_FRAME_T2 = 20002
93
- export const ITEM_PLASMA_CELL_T2 = 20003
94
- export const ITEM_RESONATOR_T2 = 20004
95
- export const ITEM_BEAM_T2 = 20005
96
- export const ITEM_SENSOR_T2 = 20006
97
- export const ITEM_POLYMER_T2 = 20007
98
- export const ITEM_CERAMIC_T2 = 20008
99
- export const ITEM_REACTOR_T2 = 20009
100
- export const ITEM_RESIN_T2 = 20010
101
- export const ITEM_ENGINE_T2 = 20100
102
- export const ITEM_GENERATOR_T2 = 20101
103
- export const ITEM_GATHERER_T2 = 20102
104
- export const ITEM_LOADER_T2 = 20103
105
- export const ITEM_CRAFTER_T2 = 20104
106
- export const ITEM_HAULER_T2 = 20106
107
- export const ITEM_WARP_T2 = 20107
108
- export const ITEM_BUILDER_T2 = 20110
109
- export const ITEM_CONTAINER_T2_PACKED = 20200
110
- export const ITEM_PROSPECTOR_T2A_PACKED = 20212
111
- export const ITEM_PROSPECTOR_T2B_PACKED = 20213
112
- export const ITEM_DREDGER_T2A_PACKED = 20214
91
+ export const ITEM_PLATE_T2 = 11001
92
+ export const ITEM_FRAME_T2 = 11002
93
+ export const ITEM_PLASMA_CELL_T2 = 11003
94
+ export const ITEM_RESONATOR_T2 = 11004
95
+ export const ITEM_BEAM_T2 = 11005
96
+ export const ITEM_SENSOR_T2 = 11006
97
+ export const ITEM_POLYMER_T2 = 11007
98
+ export const ITEM_CERAMIC_T2 = 11008
99
+ export const ITEM_REACTOR_T2 = 11009
100
+ export const ITEM_RESIN_T2 = 11010
101
+ export const ITEM_ENGINE_T2 = 11100
102
+ export const ITEM_GENERATOR_T2 = 11101
103
+ export const ITEM_GATHERER_T2 = 11102
104
+ export const ITEM_LOADER_T2 = 11103
105
+ export const ITEM_CRAFTER_T2 = 11104
106
+ export const ITEM_STORAGE_T2 = 11105
107
+ export const ITEM_HAULER_T2 = 11106
108
+ export const ITEM_WARP_T2 = 11107
109
+ export const ITEM_BATTERY_T2 = 11108
110
+ export const ITEM_BUILDER_T2 = 11110
111
+ export const ITEM_CONTAINER_T2_PACKED = 11200
112
+ export const ITEM_PROSPECTOR_T2A_PACKED = 11212
113
+ export const ITEM_PROSPECTOR_T2B_PACKED = 11213
114
+ export const ITEM_DREDGER_T2A_PACKED = 11214
@@ -536,7 +536,7 @@
536
536
  },
537
537
  {
538
538
  "id": 10208,
539
- "mass": 1900000,
539
+ "mass": 4800000,
540
540
  "type": "entity",
541
541
  "tier": 1
542
542
  },
@@ -589,141 +589,155 @@
589
589
  "tier": 1
590
590
  },
591
591
  {
592
- "id": 20001,
592
+ "id": 11001,
593
593
  "mass": 4800,
594
594
  "type": "component",
595
595
  "tier": 2
596
596
  },
597
597
  {
598
- "id": 20002,
598
+ "id": 11002,
599
599
  "mass": 4800,
600
600
  "type": "component",
601
601
  "tier": 2
602
602
  },
603
603
  {
604
- "id": 20003,
604
+ "id": 11003,
605
605
  "mass": 4800,
606
606
  "type": "component",
607
607
  "tier": 2
608
608
  },
609
609
  {
610
- "id": 20004,
610
+ "id": 11004,
611
611
  "mass": 4800,
612
612
  "type": "component",
613
613
  "tier": 2
614
614
  },
615
615
  {
616
- "id": 20005,
616
+ "id": 11005,
617
617
  "mass": 4800,
618
618
  "type": "component",
619
619
  "tier": 2
620
620
  },
621
621
  {
622
- "id": 20006,
622
+ "id": 11006,
623
623
  "mass": 4800,
624
624
  "type": "component",
625
625
  "tier": 2
626
626
  },
627
627
  {
628
- "id": 20007,
628
+ "id": 11007,
629
629
  "mass": 4800,
630
630
  "type": "component",
631
631
  "tier": 2
632
632
  },
633
633
  {
634
- "id": 20008,
634
+ "id": 11008,
635
635
  "mass": 4800,
636
636
  "type": "component",
637
637
  "tier": 2
638
638
  },
639
639
  {
640
- "id": 20009,
640
+ "id": 11009,
641
641
  "mass": 4800,
642
642
  "type": "component",
643
643
  "tier": 2
644
644
  },
645
645
  {
646
- "id": 20010,
646
+ "id": 11010,
647
647
  "mass": 4800,
648
648
  "type": "component",
649
649
  "tier": 2
650
650
  },
651
651
  {
652
- "id": 20100,
652
+ "id": 11100,
653
653
  "mass": 1536000,
654
654
  "type": "module",
655
655
  "tier": 2,
656
656
  "subtype": "engine"
657
657
  },
658
658
  {
659
- "id": 20101,
659
+ "id": 11101,
660
660
  "mass": 1536000,
661
661
  "type": "module",
662
662
  "tier": 2,
663
663
  "subtype": "generator"
664
664
  },
665
665
  {
666
- "id": 20102,
666
+ "id": 11102,
667
667
  "mass": 1536000,
668
668
  "type": "module",
669
669
  "tier": 2,
670
670
  "subtype": "gatherer"
671
671
  },
672
672
  {
673
- "id": 20103,
673
+ "id": 11103,
674
674
  "mass": 1536000,
675
675
  "type": "module",
676
676
  "tier": 2,
677
677
  "subtype": "loader"
678
678
  },
679
679
  {
680
- "id": 20104,
680
+ "id": 11104,
681
681
  "mass": 1536000,
682
682
  "type": "module",
683
683
  "tier": 2,
684
684
  "subtype": "crafter"
685
685
  },
686
686
  {
687
- "id": 20106,
687
+ "id": 11105,
688
+ "mass": 1536000,
689
+ "type": "module",
690
+ "tier": 2,
691
+ "subtype": "storage"
692
+ },
693
+ {
694
+ "id": 11106,
688
695
  "mass": 1536000,
689
696
  "type": "module",
690
697
  "tier": 2,
691
698
  "subtype": "hauler"
692
699
  },
693
700
  {
694
- "id": 20107,
701
+ "id": 11107,
695
702
  "mass": 1536000,
696
703
  "type": "module",
697
704
  "tier": 2,
698
705
  "subtype": "warp"
699
706
  },
700
707
  {
701
- "id": 20110,
708
+ "id": 11108,
709
+ "mass": 1536000,
710
+ "type": "module",
711
+ "tier": 2,
712
+ "subtype": "battery"
713
+ },
714
+ {
715
+ "id": 11110,
702
716
  "mass": 1536000,
703
717
  "type": "module",
704
718
  "tier": 2,
705
719
  "subtype": "builder"
706
720
  },
707
721
  {
708
- "id": 20200,
722
+ "id": 11200,
709
723
  "mass": 3100000,
710
724
  "type": "entity",
711
725
  "tier": 2
712
726
  },
713
727
  {
714
- "id": 20212,
728
+ "id": 11212,
715
729
  "mass": 4320000,
716
730
  "type": "entity",
717
731
  "tier": 2
718
732
  },
719
733
  {
720
- "id": 20213,
734
+ "id": 11213,
721
735
  "mass": 5760000,
722
736
  "type": "entity",
723
737
  "tier": 2
724
738
  },
725
739
  {
726
- "id": 20214,
740
+ "id": 11214,
727
741
  "mass": 5760000,
728
742
  "type": "entity",
729
743
  "tier": 2
@@ -157,7 +157,7 @@
157
157
  "displayLabel": ""
158
158
  },
159
159
  {
160
- "itemId": 20200,
160
+ "itemId": 11200,
161
161
  "kind": "container",
162
162
  "displayLabel": ""
163
163
  },
@@ -177,17 +177,17 @@
177
177
  "displayLabel": ""
178
178
  },
179
179
  {
180
- "itemId": 20212,
180
+ "itemId": 11212,
181
181
  "kind": "ship",
182
182
  "displayLabel": "Prospector"
183
183
  },
184
184
  {
185
- "itemId": 20213,
185
+ "itemId": 11213,
186
186
  "kind": "ship",
187
187
  "displayLabel": "Prospector"
188
188
  },
189
189
  {
190
- "itemId": 20214,
190
+ "itemId": 11214,
191
191
  "kind": "ship",
192
192
  "displayLabel": "Dredger"
193
193
  }
@@ -328,101 +328,112 @@ export const itemMetadata: Record<number, ItemMetadata> = {
328
328
  },
329
329
 
330
330
  // === Components (T2) ===
331
- 20001: {
331
+ 11001: {
332
332
  name: 'Plate',
333
333
  description: 'Advanced structural plating reinforced with tier 2 ore.',
334
334
  color: '#9BADB8',
335
335
  },
336
- 20002: {
336
+ 11002: {
337
337
  name: 'Frame',
338
338
  description:
339
339
  'Advanced composite framing reinforced with tier 2 regolith and biomass polymer.',
340
340
  color: '#C4A57B',
341
341
  },
342
- 20003: {
342
+ 11003: {
343
343
  name: 'Plasma Cell',
344
344
  description: 'Advanced high-energy gaseous storage cell reinforced with tier 2 gas.',
345
345
  color: '#E86344',
346
346
  },
347
- 20004: {
347
+ 11004: {
348
348
  name: 'Resonator',
349
349
  description: 'Advanced crystalline resonance lattice reinforced with tier 2 crystal.',
350
350
  color: '#4ADBFF',
351
351
  },
352
- 20005: {
352
+ 11005: {
353
353
  name: 'Beam',
354
354
  description: 'Advanced heavy-duty structural beam reinforced with tier 2 ore.',
355
355
  color: '#7B8D9E',
356
356
  },
357
- 20006: {
357
+ 11006: {
358
358
  name: 'Sensor',
359
359
  description: 'Advanced crystal-lattice sensing element reinforced with tier 2 crystal.',
360
360
  color: '#4ADBFF',
361
361
  },
362
- 20007: {
362
+ 11007: {
363
363
  name: 'Polymer',
364
364
  description: 'Advanced pliable biomass-derived polymer reinforced with tier 2 biomass.',
365
365
  color: '#5A8B3E',
366
366
  },
367
- 20008: {
367
+ 11008: {
368
368
  name: 'Ceramic',
369
369
  description: 'Advanced hardened ceramic reinforced with tier 2 regolith.',
370
370
  color: '#C4A57B',
371
371
  },
372
- 20009: {
372
+ 11009: {
373
373
  name: 'Reactor',
374
374
  description: 'Advanced gas-pressurized reaction vessel reinforced with tier 2 gas.',
375
375
  color: '#B877FF',
376
376
  },
377
- 20010: {
377
+ 11010: {
378
378
  name: 'Resin',
379
379
  description: 'Advanced saturated organic binder reinforced with tier 2 biomass.',
380
380
  color: '#5A8B3E',
381
381
  },
382
382
 
383
383
  // === Modules (T2) ===
384
- 20100: {
384
+ 11100: {
385
385
  name: 'Engine',
386
386
  description: 'Advanced propulsion system. Reinforced thrust chambers for higher velocity.',
387
387
  color: '#E86344',
388
388
  },
389
- 20101: {
389
+ 11101: {
390
390
  name: 'Power Core',
391
391
  description:
392
392
  'Advanced energy system. Higher-density crystal matrix for increased energy throughput.',
393
393
  color: '#4ADBFF',
394
394
  },
395
- 20102: {
395
+ 11102: {
396
396
  name: 'Limpet Bay',
397
397
  description: 'Advanced gathering system. Reinforced probes and conduits for deeper yield.',
398
398
  color: '#7B8D9E',
399
399
  },
400
- 20103: {
400
+ 11103: {
401
401
  name: 'Shuttle Bay',
402
402
  description:
403
403
  'Advanced cargo handling system. Reinforced articulated arms for greater loading throughput.',
404
404
  color: '#5A8B3E',
405
405
  },
406
- 20104: {
406
+ 11104: {
407
407
  name: 'Fabricator',
408
408
  description:
409
409
  'Advanced crafting system. Higher-grade reaction chambers for faster processing.',
410
410
  color: '#B877FF',
411
411
  },
412
+ 11105: {
413
+ name: 'Cargo Hold',
414
+ description: 'Advanced cargo storage. Reinforced tier 2 holds carry more mass.',
415
+ color: '#8B7355',
416
+ },
412
417
 
413
- 20106: {
418
+ 11106: {
414
419
  name: 'Tractor Beam',
415
420
  description:
416
421
  'Advanced haul beam projector reinforced with tier 2 components for greater towing capacity.',
417
422
  color: '#4ADBFF',
418
423
  },
419
- 20107: {
424
+ 11107: {
420
425
  name: 'Warp Drive',
421
426
  description:
422
427
  'Advanced warp system. Reinforced field coils project the hull across greater distances.',
423
428
  color: '#9be4ff',
424
429
  },
425
- 20110: {
430
+ 11108: {
431
+ name: 'Battery Bank',
432
+ description:
433
+ 'Advanced battery bank. Higher-density cells store more charge from the power core.',
434
+ color: '#4ADBFF',
435
+ },
436
+ 11110: {
426
437
  name: 'Assembly Arm',
427
438
  description:
428
439
  'Advanced construction system. Reinforced manipulator arms for faster build and upgrade work.',
@@ -430,23 +441,23 @@ export const itemMetadata: Record<number, ItemMetadata> = {
430
441
  },
431
442
 
432
443
  // === Entities (packed, T2) ===
433
- 20200: {
444
+ 11200: {
434
445
  name: 'Container',
435
446
  description: 'Advanced cargo container with improved capacity formulas.',
436
447
  color: '#9BADB8',
437
448
  },
438
- 20212: {
449
+ 11212: {
439
450
  name: 'Prospector',
440
451
  description: 'The tier 2 Prospector. The same three systems, ready for tier 2 modules.',
441
452
  color: '#4AE898',
442
453
  },
443
- 20213: {
454
+ 11213: {
444
455
  name: 'Prospector',
445
456
  description:
446
457
  'A tier 2 Prospector with an auxiliary system for extra power, mobility, or endurance.',
447
458
  color: '#4AE898',
448
459
  },
449
- 20214: {
460
+ 11214: {
450
461
  name: 'Dredger',
451
462
  description:
452
463
  'A gathering ship that stores what it digs. Its limpet bay works alongside a cargo hold.',
@@ -474,9 +485,9 @@ export const entityMetadata: Record<number, EntityMetadata> = {
474
485
  moduleSlotLabels: ['Fabricator', 'Fabricator', 'Fabricator', 'Fabricator', 'Fabricator'],
475
486
  },
476
487
  10209: {moduleSlotLabels: ['Power Core', 'Assembly Arm']},
477
- 20212: {moduleSlotLabels: ['Power Core', 'Engine', 'Limpet Bay']},
478
- 20213: {moduleSlotLabels: ['Power Core', 'Engine', 'Auxiliary System', 'Limpet Bay']},
479
- 20214: {moduleSlotLabels: ['Power Core', 'Engine', 'Limpet Bay', 'Cargo Hold']},
488
+ 11212: {moduleSlotLabels: ['Power Core', 'Engine', 'Limpet Bay']},
489
+ 11213: {moduleSlotLabels: ['Power Core', 'Engine', 'Auxiliary System', 'Limpet Bay']},
490
+ 11214: {moduleSlotLabels: ['Power Core', 'Engine', 'Limpet Bay', 'Cargo Hold']},
480
491
  }
481
492
 
482
493
  for (const item of items as Array<{id: number}>) {