@shipload/sdk 1.0.0-next.10 → 1.0.0-next.11

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.
@@ -39,7 +39,7 @@ export type UnsubscribeMessage = {
39
39
  export type SubscribeEntityMessage = {
40
40
  type: 'subscribe_entity'
41
41
  sub_id: string
42
- entity_type: 'ship' | 'warehouse' | 'container'
42
+ entity_type: 'ship' | 'warehouse' | 'container' | 'nexus'
43
43
  entity_id: string
44
44
  }
45
45
 
@@ -80,7 +80,7 @@ export type AckMessage = {
80
80
 
81
81
  export type WireEntity = Record<string, unknown> & {
82
82
  type: number
83
- type_name: 'ship' | 'warehouse' | 'container'
83
+ type_name: 'ship' | 'warehouse' | 'container' | 'nexus'
84
84
  id: string | number
85
85
  owner: string
86
86
  coordinates: WireCoordinates
@@ -3,6 +3,7 @@ import {
3
3
  ITEM_CONTAINER_T1_PACKED,
4
4
  ITEM_CONTAINER_T2_PACKED,
5
5
  ITEM_EXTRACTOR_T1_PACKED,
6
+ ITEM_FACTORY_T1_PACKED,
6
7
  ITEM_SHIP_T1_PACKED,
7
8
  ITEM_WAREHOUSE_T1_PACKED,
8
9
  } from '../data/item-ids'
@@ -10,7 +11,9 @@ import {
10
11
  export const ENTITY_SHIP = Name.from('ship')
11
12
  export const ENTITY_WAREHOUSE = Name.from('warehouse')
12
13
  export const ENTITY_EXTRACTOR = Name.from('extractor')
14
+ export const ENTITY_FACTORY = Name.from('factory')
13
15
  export const ENTITY_CONTAINER = Name.from('container')
16
+ export const ENTITY_NEXUS = Name.from('nexus')
14
17
 
15
18
  export enum EntityClass {
16
19
  OrbitalVessel = 0,
@@ -22,9 +25,11 @@ export function getEntityClass(entityType: Name | EntityTypeName): EntityClass {
22
25
  switch (typeName) {
23
26
  case 'ship':
24
27
  case 'container':
28
+ case 'nexus':
25
29
  return EntityClass.OrbitalVessel
26
30
  case 'warehouse':
27
31
  case 'extractor':
32
+ case 'factory':
28
33
  return EntityClass.PlanetaryStructure
29
34
  default:
30
35
  throw new Error(`Entity type has no class: ${typeName}`)
@@ -42,12 +47,14 @@ export function getPackedEntityType(itemId: number): Name | null {
42
47
  return ENTITY_WAREHOUSE
43
48
  case ITEM_EXTRACTOR_T1_PACKED:
44
49
  return ENTITY_EXTRACTOR
50
+ case ITEM_FACTORY_T1_PACKED:
51
+ return ENTITY_FACTORY
45
52
  default:
46
53
  return null
47
54
  }
48
55
  }
49
56
 
50
- export type EntityTypeName = 'ship' | 'warehouse' | 'extractor' | 'container'
57
+ export type EntityTypeName = 'ship' | 'warehouse' | 'extractor' | 'factory' | 'container' | 'nexus'
51
58
 
52
59
  export interface EntityTraits {
53
60
  typeName: Name
@@ -88,6 +95,16 @@ export const extractorTraits: EntityTraits = {
88
95
  notFoundError: 'extractor not found',
89
96
  }
90
97
 
98
+ export const factoryTraits: EntityTraits = {
99
+ typeName: ENTITY_FACTORY,
100
+ isMovable: false,
101
+ hasEnergy: true,
102
+ hasLoaders: false,
103
+ hasModules: true,
104
+
105
+ notFoundError: 'factory not found',
106
+ }
107
+
91
108
  export const containerTraits: EntityTraits = {
92
109
  typeName: ENTITY_CONTAINER,
93
110
  isMovable: true,
@@ -98,6 +115,16 @@ export const containerTraits: EntityTraits = {
98
115
  notFoundError: 'container not found',
99
116
  }
100
117
 
118
+ export const nexusTraits: EntityTraits = {
119
+ typeName: ENTITY_NEXUS,
120
+ isMovable: false,
121
+ hasEnergy: false,
122
+ hasLoaders: false,
123
+ hasModules: false,
124
+
125
+ notFoundError: 'nexus not found',
126
+ }
127
+
101
128
  export function getEntityTraits(entityType: Name | EntityTypeName): EntityTraits {
102
129
  const typeName = typeof entityType === 'string' ? entityType : entityType.toString()
103
130
 
@@ -108,8 +135,12 @@ export function getEntityTraits(entityType: Name | EntityTypeName): EntityTraits
108
135
  return warehouseTraits
109
136
  case 'extractor':
110
137
  return extractorTraits
138
+ case 'factory':
139
+ return factoryTraits
111
140
  case 'container':
112
141
  return containerTraits
142
+ case 'nexus':
143
+ return nexusTraits
113
144
  default:
114
145
  throw new Error(`Unknown entity type: ${typeName}`)
115
146
  }
@@ -127,6 +158,14 @@ export function isExtractor(entity: {type?: Name}): boolean {
127
158
  return entity.type?.equals(ENTITY_EXTRACTOR) ?? false
128
159
  }
129
160
 
161
+ export function isFactory(entity: {type?: Name}): boolean {
162
+ return entity.type?.equals(ENTITY_FACTORY) ?? false
163
+ }
164
+
130
165
  export function isContainer(entity: {type?: Name}): boolean {
131
166
  return entity.type?.equals(ENTITY_CONTAINER) ?? false
132
167
  }
168
+
169
+ export function isNexus(entity: {type?: Name}): boolean {
170
+ return entity.type?.equals(ENTITY_NEXUS) ?? false
171
+ }