@shipload/sdk 1.0.0-next.11 → 1.0.0-next.12
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/lib/shipload.d.ts +744 -926
- package/lib/shipload.js +2336 -2752
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +2316 -2726
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/data/kind-registry.json +78 -0
- package/src/data/kind-registry.ts +133 -0
- package/src/derivation/capabilities.ts +397 -0
- package/src/derivation/crafting.ts +1 -1
- package/src/entities/entity.ts +98 -0
- package/src/entities/makers.ts +75 -228
- package/src/index-module.ts +37 -34
- package/src/managers/entities.ts +18 -114
- package/src/managers/index.ts +1 -1
- package/src/nft/atomicdata.ts +2 -0
- package/src/nft/description.ts +1 -1
- package/src/resolution/resolve-item.ts +3 -2
- package/src/subscriptions/manager.ts +2 -5
- package/src/subscriptions/mappers.ts +3 -12
- package/src/testing/catalog-hash.ts +19 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/projection-parity.ts +143 -0
- package/src/types/index.ts +0 -1
- package/src/types.ts +0 -9
- package/src/entities/container.ts +0 -123
- package/src/entities/extractor.ts +0 -144
- package/src/entities/factory.ts +0 -135
- package/src/entities/nexus.ts +0 -29
- package/src/entities/ship-deploy.ts +0 -316
- package/src/entities/ship.ts +0 -221
- package/src/entities/warehouse.ts +0 -136
- package/src/types/entity-traits.ts +0 -171
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {UInt64} from '@wharfkit/antelope'
|
|
2
|
+
import {ServerContract} from '../contracts'
|
|
3
|
+
import {
|
|
4
|
+
CAP_DEMOLISH,
|
|
5
|
+
CAP_MODULES,
|
|
6
|
+
CAP_UNDEPLOY,
|
|
7
|
+
CAP_WRAP,
|
|
8
|
+
type EntityClass,
|
|
9
|
+
getEntityClass,
|
|
10
|
+
kindCan,
|
|
11
|
+
} from '../data/kind-registry'
|
|
12
|
+
import {InventoryAccessor} from './inventory-accessor'
|
|
13
|
+
import {Location} from './location'
|
|
14
|
+
import {ScheduleAccessor} from '../scheduling/accessor'
|
|
15
|
+
import * as schedule from '../scheduling/schedule'
|
|
16
|
+
import type {EntityInventory} from './entity-inventory'
|
|
17
|
+
|
|
18
|
+
export class Entity extends ServerContract.Types.entity_info {
|
|
19
|
+
private _sched?: ScheduleAccessor
|
|
20
|
+
private _inv?: InventoryAccessor
|
|
21
|
+
|
|
22
|
+
get name(): string {
|
|
23
|
+
return this.entity_name
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get location(): Location {
|
|
27
|
+
return Location.from(this.coordinates)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get isIdle(): boolean {
|
|
31
|
+
return this.is_idle
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get sched(): ScheduleAccessor {
|
|
35
|
+
this._sched ??= new ScheduleAccessor(this)
|
|
36
|
+
return this._sched
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get inv(): InventoryAccessor {
|
|
40
|
+
this._inv ??= new InventoryAccessor(this)
|
|
41
|
+
return this._inv
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get inventory(): EntityInventory[] {
|
|
45
|
+
return this.inv.items
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get totalCargoMass(): UInt64 {
|
|
49
|
+
return this.inv.totalMass
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get maxCapacity(): UInt64 {
|
|
53
|
+
return UInt64.from(this.capacity ?? 0)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get availableCapacity(): UInt64 {
|
|
57
|
+
const cargo = this.totalCargoMass
|
|
58
|
+
const max = this.maxCapacity
|
|
59
|
+
return cargo.gte(max) ? UInt64.from(0) : max.subtracting(cargo)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get isFull(): boolean {
|
|
63
|
+
return this.totalCargoMass.gte(this.maxCapacity)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get totalMass(): UInt64 {
|
|
67
|
+
const hull = this.hullmass ? UInt64.from(this.hullmass) : UInt64.from(0)
|
|
68
|
+
return hull.adding(this.totalCargoMass)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get entityClass(): EntityClass {
|
|
72
|
+
return getEntityClass(this.type)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get canWrap(): boolean {
|
|
76
|
+
return kindCan(this.type, CAP_WRAP)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get canUndeploy(): boolean {
|
|
80
|
+
return kindCan(this.type, CAP_UNDEPLOY)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get canDemolish(): boolean {
|
|
84
|
+
return kindCan(this.type, CAP_DEMOLISH)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get canUseModules(): boolean {
|
|
88
|
+
return kindCan(this.type, CAP_MODULES)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
isLoading(now: Date): boolean {
|
|
92
|
+
return schedule.isLoading(this, now)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
isUnloading(now: Date): boolean {
|
|
96
|
+
return schedule.isUnloading(this, now)
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/entities/makers.ts
CHANGED
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
import {Name, UInt16, UInt32, UInt64, UInt8} from '@wharfkit/antelope'
|
|
2
|
+
import type {NameType, UInt64Type} from '@wharfkit/antelope'
|
|
2
3
|
import {ServerContract} from '../contracts'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {Factory, computeFactoryCapabilities, type FactoryStateInput} from './factory'
|
|
9
|
-
import {
|
|
10
|
-
ITEM_EXTRACTOR_T1_PACKED,
|
|
11
|
-
ITEM_FACTORY_T1_PACKED,
|
|
12
|
-
ITEM_SHIP_T1_PACKED,
|
|
13
|
-
ITEM_WAREHOUSE_T1_PACKED,
|
|
14
|
-
} from '../data/item-ids'
|
|
15
|
-
import {getEntityLayout, type EntitySlot} from '../data/recipes-runtime'
|
|
4
|
+
import {Entity} from './entity'
|
|
5
|
+
import {getKindMeta, getTemplateMeta} from '../data/kind-registry'
|
|
6
|
+
import type {EntityTypeName} from '../data/kind-registry'
|
|
7
|
+
import {getEntityLayout} from '../data/recipes-runtime'
|
|
8
|
+
import type {EntitySlot} from '../data/recipes-runtime'
|
|
16
9
|
import {itemMetadata} from '../data/metadata'
|
|
17
10
|
import {getItem} from '../data/catalog'
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
MODULE_STORAGE,
|
|
21
|
-
moduleAccepts,
|
|
22
|
-
moduleSlotTypeToCode,
|
|
23
|
-
} from '../capabilities/modules'
|
|
24
|
-
import {computeShipCapabilities, computeStorageCapabilities} from './ship-deploy'
|
|
11
|
+
import {getModuleCapabilityType, moduleAccepts, moduleSlotTypeToCode} from '../capabilities/modules'
|
|
12
|
+
import {computeEntityCapabilities} from '../derivation/capabilities'
|
|
25
13
|
import type {InstalledModule} from './slot-multiplier'
|
|
26
|
-
|
|
14
|
+
|
|
15
|
+
export interface PackedModuleInput {
|
|
16
|
+
itemId: number
|
|
17
|
+
stats: bigint
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface EntityStateInput {
|
|
21
|
+
id: UInt64Type
|
|
22
|
+
owner: NameType
|
|
23
|
+
name: string
|
|
24
|
+
coordinates: {x: number; y: number; z?: number}
|
|
25
|
+
hullmass?: number
|
|
26
|
+
capacity?: number
|
|
27
|
+
cargomass?: number
|
|
28
|
+
energy?: number
|
|
29
|
+
modules?: PackedModuleInput[]
|
|
30
|
+
schedule?: ServerContract.Types.schedule
|
|
31
|
+
cargo?: ServerContract.Types.cargo_item[]
|
|
32
|
+
}
|
|
27
33
|
|
|
28
34
|
function assignModulesToSlots(
|
|
29
|
-
|
|
35
|
+
slots: EntitySlot[],
|
|
30
36
|
modules: PackedModuleInput[],
|
|
31
37
|
entityLabel: string
|
|
32
38
|
): ServerContract.Types.module_entry[] {
|
|
33
|
-
const layout = getEntityLayout(packedEntityItemId)
|
|
34
|
-
const slots = layout?.slots ?? []
|
|
35
39
|
const result: Array<{type: number; installed?: ServerContract.Types.packed_module}> = slots.map(
|
|
36
40
|
(s) => ({type: moduleSlotTypeToCode(s.type), installed: undefined})
|
|
37
41
|
)
|
|
38
42
|
|
|
39
43
|
for (const mod of modules) {
|
|
40
|
-
const
|
|
41
|
-
const modType = getModuleCapabilityType(itemId)
|
|
44
|
+
const modType = getModuleCapabilityType(mod.itemId)
|
|
42
45
|
const slotIdx = result.findIndex((r) => !r.installed && moduleAccepts(r.type, modType))
|
|
43
46
|
if (slotIdx === -1) {
|
|
44
47
|
let modName: string
|
|
45
48
|
try {
|
|
46
|
-
modName = getItem(itemId).name
|
|
49
|
+
modName = getItem(mod.itemId).name
|
|
47
50
|
} catch {
|
|
48
|
-
modName = itemMetadata[itemId]?.name ?? `item ${itemId}`
|
|
51
|
+
modName = itemMetadata[mod.itemId]?.name ?? `item ${mod.itemId}`
|
|
49
52
|
}
|
|
50
53
|
throw new Error(
|
|
51
54
|
`No compatible slot for module ${modName} (type ${modType}) on ${entityLabel}`
|
|
@@ -71,236 +74,80 @@ function toInstalledModules(entries: ServerContract.Types.module_entry[]): Insta
|
|
|
71
74
|
if (!entry.installed) return
|
|
72
75
|
installed.push({
|
|
73
76
|
slotIndex,
|
|
74
|
-
itemId: Number(
|
|
75
|
-
stats: BigInt(
|
|
77
|
+
itemId: Number(entry.installed.item_id.value),
|
|
78
|
+
stats: BigInt(entry.installed.stats.toString()),
|
|
76
79
|
})
|
|
77
80
|
})
|
|
78
81
|
return installed
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const {capacityBonus} = computeStorageCapabilities(stats, baseCapacity)
|
|
87
|
-
totalBonus += capacityBonus
|
|
88
|
-
}
|
|
89
|
-
return totalBonus
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function deriveShipFromModules(
|
|
93
|
-
moduleEntries: ServerContract.Types.module_entry[],
|
|
94
|
-
layout: EntitySlot[],
|
|
95
|
-
baseCapacity: number
|
|
96
|
-
): {
|
|
97
|
-
capabilities: ReturnType<typeof computeShipCapabilities>
|
|
98
|
-
finalCapacity: number
|
|
99
|
-
} {
|
|
100
|
-
const installed = toInstalledModules(moduleEntries)
|
|
101
|
-
const capabilities = computeShipCapabilities(installed, layout)
|
|
102
|
-
const totalBonus = computeStorageBonus(installed, baseCapacity)
|
|
103
|
-
return {capabilities, finalCapacity: baseCapacity + totalBonus}
|
|
84
|
+
const ZERO_HULL_STATS: Record<string, number> = {
|
|
85
|
+
density: 0,
|
|
86
|
+
strength: 0,
|
|
87
|
+
hardness: 0,
|
|
88
|
+
saturation: 0,
|
|
104
89
|
}
|
|
105
90
|
|
|
106
|
-
export function
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
owner: Name.from(state.owner),
|
|
111
|
-
entity_name: state.name,
|
|
112
|
-
coordinates: ServerContract.Types.coordinates.from(state.coordinates),
|
|
113
|
-
cargomass: UInt32.from(0),
|
|
114
|
-
cargo: state.cargo || [],
|
|
115
|
-
is_idle: !state.schedule,
|
|
116
|
-
current_task_elapsed: UInt32.from(0),
|
|
117
|
-
current_task_remaining: UInt32.from(0),
|
|
118
|
-
pending_tasks: [],
|
|
119
|
-
}
|
|
120
|
-
if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
|
|
121
|
-
if (state.energy !== undefined) info.energy = UInt16.from(state.energy)
|
|
122
|
-
if (state.schedule) info.schedule = state.schedule
|
|
123
|
-
|
|
124
|
-
let moduleEntries: ServerContract.Types.module_entry[] = []
|
|
125
|
-
const shipLayout = getEntityLayout(ITEM_SHIP_T1_PACKED)?.slots ?? []
|
|
126
|
-
if (state.modules && state.modules.length > 0) {
|
|
127
|
-
moduleEntries = assignModulesToSlots(ITEM_SHIP_T1_PACKED, state.modules, 'Ship T1')
|
|
128
|
-
const {capabilities, finalCapacity} = deriveShipFromModules(
|
|
129
|
-
moduleEntries,
|
|
130
|
-
shipLayout,
|
|
131
|
-
state.capacity ?? 0
|
|
132
|
-
)
|
|
133
|
-
if (capabilities.engines) info.engines = capabilities.engines
|
|
134
|
-
if (capabilities.generator) info.generator = capabilities.generator
|
|
135
|
-
if (capabilities.gatherer) info.gatherer = capabilities.gatherer
|
|
136
|
-
if (capabilities.hauler) info.hauler = capabilities.hauler
|
|
137
|
-
if (capabilities.loaders) info.loaders = capabilities.loaders
|
|
138
|
-
if (capabilities.crafter) info.crafter = capabilities.crafter
|
|
139
|
-
if (state.capacity !== undefined) info.capacity = UInt32.from(finalCapacity)
|
|
140
|
-
} else {
|
|
141
|
-
moduleEntries = assignModulesToSlots(ITEM_SHIP_T1_PACKED, [], 'Ship T1')
|
|
142
|
-
if (state.capacity !== undefined) info.capacity = UInt32.from(state.capacity)
|
|
91
|
+
export function makeEntity(packedItemId: number, state: EntityStateInput): Entity {
|
|
92
|
+
const template = getTemplateMeta(packedItemId)
|
|
93
|
+
if (!template) {
|
|
94
|
+
throw new Error(`Unknown packed entity item ID: ${packedItemId}`)
|
|
143
95
|
}
|
|
144
96
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
return new Ship(entityInfo)
|
|
149
|
-
}
|
|
97
|
+
const kind = template.kind.toString() as EntityTypeName
|
|
98
|
+
const layout = getEntityLayout(packedItemId)?.slots ?? []
|
|
99
|
+
const mods = state.modules ?? []
|
|
150
100
|
|
|
151
|
-
export function makeWarehouse(state: WarehouseStateInput): Warehouse {
|
|
152
101
|
const info: Record<string, unknown> = {
|
|
153
|
-
type:
|
|
102
|
+
type: template.kind,
|
|
154
103
|
id: UInt64.from(state.id),
|
|
155
104
|
owner: Name.from(state.owner),
|
|
156
105
|
entity_name: state.name,
|
|
157
106
|
coordinates: ServerContract.Types.coordinates.from(state.coordinates),
|
|
158
|
-
|
|
159
|
-
cargomass: UInt32.from(0),
|
|
107
|
+
cargomass: UInt32.from(state.cargomass ?? 0),
|
|
160
108
|
cargo: state.cargo || [],
|
|
161
109
|
is_idle: !state.schedule,
|
|
162
110
|
current_task_elapsed: UInt32.from(0),
|
|
163
111
|
current_task_remaining: UInt32.from(0),
|
|
164
112
|
pending_tasks: [],
|
|
165
113
|
}
|
|
166
|
-
if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
|
|
167
|
-
if (state.schedule) info.schedule = state.schedule
|
|
168
|
-
|
|
169
|
-
let moduleEntries: ServerContract.Types.module_entry[] = []
|
|
170
|
-
const warehouseLayout = getEntityLayout(ITEM_WAREHOUSE_T1_PACKED)?.slots ?? []
|
|
171
|
-
if (state.modules && state.modules.length > 0) {
|
|
172
|
-
moduleEntries = assignModulesToSlots(
|
|
173
|
-
ITEM_WAREHOUSE_T1_PACKED,
|
|
174
|
-
state.modules,
|
|
175
|
-
'Warehouse T1'
|
|
176
|
-
)
|
|
177
|
-
const installed = toInstalledModules(moduleEntries)
|
|
178
|
-
const capabilities = computeWarehouseCapabilities(installed, warehouseLayout)
|
|
179
|
-
if (capabilities.loaders) info.loaders = capabilities.loaders
|
|
180
|
-
|
|
181
|
-
const totalBonus = computeStorageBonus(installed, state.capacity)
|
|
182
|
-
info.capacity = UInt32.from(state.capacity + totalBonus)
|
|
183
|
-
} else {
|
|
184
|
-
moduleEntries = assignModulesToSlots(ITEM_WAREHOUSE_T1_PACKED, [], 'Warehouse T1')
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
info.modules = moduleEntries
|
|
188
|
-
|
|
189
|
-
const entityInfo = ServerContract.Types.entity_info.from(info)
|
|
190
|
-
return new Warehouse(entityInfo)
|
|
191
|
-
}
|
|
192
114
|
|
|
193
|
-
export function makeExtractor(state: ExtractorStateInput): Extractor {
|
|
194
|
-
const info: Record<string, unknown> = {
|
|
195
|
-
type: Name.from('extractor'),
|
|
196
|
-
id: UInt64.from(state.id),
|
|
197
|
-
owner: Name.from(state.owner),
|
|
198
|
-
entity_name: state.name,
|
|
199
|
-
coordinates: ServerContract.Types.coordinates.from(state.coordinates),
|
|
200
|
-
cargomass: UInt32.from(0),
|
|
201
|
-
cargo: state.cargo || [],
|
|
202
|
-
is_idle: !state.schedule,
|
|
203
|
-
current_task_elapsed: UInt32.from(0),
|
|
204
|
-
current_task_remaining: UInt32.from(0),
|
|
205
|
-
pending_tasks: [],
|
|
206
|
-
}
|
|
207
|
-
if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
|
|
208
115
|
if (state.energy !== undefined) info.energy = UInt16.from(state.energy)
|
|
209
116
|
if (state.schedule) info.schedule = state.schedule
|
|
210
|
-
if (state.capacity !== undefined) info.capacity = UInt32.from(state.capacity)
|
|
211
117
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
state.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
const capabilities = computeExtractorCapabilities(installed, layout)
|
|
221
|
-
if (capabilities.generator) info.generator = capabilities.generator
|
|
222
|
-
if (capabilities.gatherer) info.gatherer = capabilities.gatherer
|
|
223
|
-
}
|
|
118
|
+
if (kind === 'container') {
|
|
119
|
+
info.modules = []
|
|
120
|
+
if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
|
|
121
|
+
if (state.capacity !== undefined) info.capacity = UInt32.from(state.capacity)
|
|
122
|
+
} else {
|
|
123
|
+
const entityLabel = getKindMeta(template.kind)?.defaultLabel ?? kind
|
|
124
|
+
const moduleEntries = assignModulesToSlots(layout, mods, entityLabel)
|
|
125
|
+
info.modules = moduleEntries
|
|
224
126
|
|
|
225
|
-
|
|
127
|
+
const installed = toInstalledModules(moduleEntries)
|
|
128
|
+
const caps = computeEntityCapabilities(ZERO_HULL_STATS, packedItemId, installed, layout)
|
|
226
129
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
130
|
+
if (state.hullmass !== undefined) {
|
|
131
|
+
info.hullmass = UInt32.from(state.hullmass)
|
|
132
|
+
} else if (installed.length > 0) {
|
|
133
|
+
info.hullmass = UInt32.from(caps.hullmass)
|
|
134
|
+
}
|
|
230
135
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
entity_name: state.name,
|
|
237
|
-
coordinates: ServerContract.Types.coordinates.from(state.coordinates),
|
|
238
|
-
cargomass: UInt32.from(0),
|
|
239
|
-
cargo: state.cargo || [],
|
|
240
|
-
is_idle: !state.schedule,
|
|
241
|
-
current_task_elapsed: UInt32.from(0),
|
|
242
|
-
current_task_remaining: UInt32.from(0),
|
|
243
|
-
pending_tasks: [],
|
|
244
|
-
}
|
|
245
|
-
if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
|
|
246
|
-
if (state.energy !== undefined) info.energy = UInt16.from(state.energy)
|
|
247
|
-
if (state.schedule) info.schedule = state.schedule
|
|
248
|
-
if (state.capacity !== undefined) info.capacity = UInt32.from(state.capacity)
|
|
136
|
+
if (state.capacity !== undefined) {
|
|
137
|
+
info.capacity = UInt32.from(state.capacity)
|
|
138
|
+
} else {
|
|
139
|
+
info.capacity = UInt32.from(caps.capacity)
|
|
140
|
+
}
|
|
249
141
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const installed = toInstalledModules(moduleEntries)
|
|
258
|
-
const capabilities = computeFactoryCapabilities(installed, layout)
|
|
259
|
-
if (capabilities.generator) info.generator = capabilities.generator
|
|
260
|
-
if (capabilities.crafter) info.crafter = capabilities.crafter
|
|
142
|
+
if (caps.engines) info.engines = caps.engines
|
|
143
|
+
if (caps.generator) info.generator = caps.generator
|
|
144
|
+
if (caps.gatherer) info.gatherer = caps.gatherer
|
|
145
|
+
if (caps.loaders) info.loaders = caps.loaders
|
|
146
|
+
if (caps.crafter) info.crafter = caps.crafter
|
|
147
|
+
if (caps.hauler) info.hauler = caps.hauler
|
|
148
|
+
if (caps.warp) info.warp = caps.warp
|
|
261
149
|
}
|
|
262
150
|
|
|
263
|
-
info.modules = moduleEntries
|
|
264
|
-
|
|
265
151
|
const entityInfo = ServerContract.Types.entity_info.from(info)
|
|
266
|
-
return new
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export function makeContainer(state: ContainerStateInput): Container {
|
|
270
|
-
const entityInfo = ServerContract.Types.entity_info.from({
|
|
271
|
-
type: Name.from('container'),
|
|
272
|
-
id: UInt64.from(state.id),
|
|
273
|
-
owner: Name.from(state.owner),
|
|
274
|
-
entity_name: state.name,
|
|
275
|
-
coordinates: ServerContract.Types.coordinates.from(state.coordinates),
|
|
276
|
-
hullmass: UInt32.from(state.hullmass),
|
|
277
|
-
capacity: UInt32.from(state.capacity),
|
|
278
|
-
cargomass: UInt32.from(state.cargomass || 0),
|
|
279
|
-
cargo: state.cargo || [],
|
|
280
|
-
modules: [],
|
|
281
|
-
is_idle: !state.schedule,
|
|
282
|
-
current_task_elapsed: UInt32.from(0),
|
|
283
|
-
current_task_remaining: UInt32.from(0),
|
|
284
|
-
pending_tasks: [],
|
|
285
|
-
schedule: state.schedule,
|
|
286
|
-
})
|
|
287
|
-
return new Container(entityInfo)
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export function makeNexus(state: NexusStateInput): Nexus {
|
|
291
|
-
const entityInfo = ServerContract.Types.entity_info.from({
|
|
292
|
-
type: Name.from('nexus'),
|
|
293
|
-
id: UInt64.from(state.id),
|
|
294
|
-
owner: Name.from(state.owner),
|
|
295
|
-
entity_name: state.name,
|
|
296
|
-
coordinates: ServerContract.Types.coordinates.from(state.coordinates),
|
|
297
|
-
cargomass: UInt32.from(0),
|
|
298
|
-
cargo: [],
|
|
299
|
-
modules: [],
|
|
300
|
-
is_idle: true,
|
|
301
|
-
current_task_elapsed: UInt32.from(0),
|
|
302
|
-
current_task_remaining: UInt32.from(0),
|
|
303
|
-
pending_tasks: [],
|
|
304
|
-
})
|
|
305
|
-
return new Nexus(entityInfo)
|
|
152
|
+
return new Entity(entityInfo)
|
|
306
153
|
}
|
package/src/index-module.ts
CHANGED
|
@@ -10,28 +10,19 @@ export {Types as ServerTypes} from './contracts/server'
|
|
|
10
10
|
export {Types as PlatformTypes} from './contracts/platform'
|
|
11
11
|
|
|
12
12
|
import type {ServerContract} from './contracts'
|
|
13
|
+
import type {Entity as EntityType} from './entities/entity'
|
|
13
14
|
|
|
14
15
|
export {Shipload} from './shipload'
|
|
15
|
-
export {
|
|
16
|
-
export type
|
|
17
|
-
export
|
|
18
|
-
export type
|
|
19
|
-
export
|
|
20
|
-
export type
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export {
|
|
24
|
-
export type {
|
|
25
|
-
export {Nexus} from './entities/nexus'
|
|
26
|
-
export type {NexusStateInput} from './entities/nexus'
|
|
27
|
-
export {
|
|
28
|
-
makeShip,
|
|
29
|
-
makeWarehouse,
|
|
30
|
-
makeExtractor,
|
|
31
|
-
makeFactory,
|
|
32
|
-
makeContainer,
|
|
33
|
-
makeNexus,
|
|
34
|
-
} from './entities/makers'
|
|
16
|
+
export {Entity} from './entities/entity'
|
|
17
|
+
export type Ship = EntityType
|
|
18
|
+
export type Warehouse = EntityType
|
|
19
|
+
export type Container = EntityType
|
|
20
|
+
export type Extractor = EntityType
|
|
21
|
+
export type Factory = EntityType
|
|
22
|
+
export type Nexus = EntityType
|
|
23
|
+
export {makeEntity} from './entities/makers'
|
|
24
|
+
export type {EntityStateInput, PackedModuleInput} from './entities/makers'
|
|
25
|
+
export type {InstalledModule} from './entities/slot-multiplier'
|
|
35
26
|
|
|
36
27
|
export type movement_stats = ServerContract.Types.movement_stats
|
|
37
28
|
export type energy_stats = ServerContract.Types.energy_stats
|
|
@@ -57,7 +48,7 @@ export {
|
|
|
57
48
|
EpochsManager,
|
|
58
49
|
ActionsManager,
|
|
59
50
|
} from './managers'
|
|
60
|
-
export type {
|
|
51
|
+
export type {LocationStratum} from './managers'
|
|
61
52
|
export type {EntityRefInput} from './managers/actions'
|
|
62
53
|
|
|
63
54
|
export {
|
|
@@ -203,21 +194,24 @@ export {
|
|
|
203
194
|
ENTITY_EXTRACTOR,
|
|
204
195
|
ENTITY_FACTORY,
|
|
205
196
|
ENTITY_CONTAINER,
|
|
206
|
-
|
|
207
|
-
warehouseTraits,
|
|
208
|
-
extractorTraits,
|
|
209
|
-
factoryTraits,
|
|
210
|
-
containerTraits,
|
|
197
|
+
ENTITY_NEXUS,
|
|
211
198
|
getEntityClass,
|
|
212
199
|
getPackedEntityType,
|
|
213
|
-
|
|
200
|
+
getKindMeta,
|
|
201
|
+
getTemplateMeta,
|
|
202
|
+
kindCan,
|
|
203
|
+
CAP_WRAP,
|
|
204
|
+
CAP_UNDEPLOY,
|
|
205
|
+
CAP_DEMOLISH,
|
|
206
|
+
CAP_MODULES,
|
|
214
207
|
isShip,
|
|
215
208
|
isWarehouse,
|
|
216
209
|
isExtractor,
|
|
217
210
|
isFactory,
|
|
218
211
|
isContainer,
|
|
219
|
-
|
|
220
|
-
|
|
212
|
+
isNexus,
|
|
213
|
+
} from './data/kind-registry'
|
|
214
|
+
export type {EntityTypeName, KindMeta, TemplateMeta} from './data/kind-registry'
|
|
221
215
|
export * from './capabilities'
|
|
222
216
|
|
|
223
217
|
export {
|
|
@@ -274,8 +268,6 @@ export {
|
|
|
274
268
|
} from './derivation/crafting'
|
|
275
269
|
export type {StackInput, CategoryStacks, RecipeSlotInput} from './derivation/crafting'
|
|
276
270
|
|
|
277
|
-
export {computeContainerCapabilities, computeContainerT2Capabilities} from './entities/container'
|
|
278
|
-
|
|
279
271
|
export {
|
|
280
272
|
computeShipHullCapabilities,
|
|
281
273
|
computeEngineCapabilities,
|
|
@@ -286,12 +278,16 @@ export {
|
|
|
286
278
|
computeCrafterCapabilities,
|
|
287
279
|
computeWarehouseHullCapabilities,
|
|
288
280
|
computeStorageCapabilities,
|
|
289
|
-
|
|
281
|
+
computeContainerCapabilities,
|
|
282
|
+
computeContainerT2Capabilities,
|
|
283
|
+
computeWarpCapabilities,
|
|
284
|
+
computeBaseCapacity,
|
|
285
|
+
computeEntityCapabilities,
|
|
290
286
|
GATHERER_DEPTH_TABLE,
|
|
291
287
|
GATHERER_DEPTH_MAX_TIER,
|
|
292
288
|
gathererDepthForTier,
|
|
293
|
-
} from './
|
|
294
|
-
export type {
|
|
289
|
+
} from './derivation/capabilities'
|
|
290
|
+
export type {GathererDepthParams, ComputedCapabilities} from './derivation/capabilities'
|
|
295
291
|
|
|
296
292
|
export {resolveItem} from './resolution/resolve-item'
|
|
297
293
|
export type {
|
|
@@ -373,3 +369,10 @@ export {displayName, describeItem} from './resolution/display-name'
|
|
|
373
369
|
export type {DescribeOptions} from './resolution/display-name'
|
|
374
370
|
|
|
375
371
|
export * from './subscriptions'
|
|
372
|
+
|
|
373
|
+
export {assertProjectionEquals} from './testing/projection-parity'
|
|
374
|
+
export type {
|
|
375
|
+
ContractProjectedState,
|
|
376
|
+
ProjectionComparisonOptions,
|
|
377
|
+
} from './testing/projection-parity'
|
|
378
|
+
export {CATALOG_FILES_REL, computeCatalogHash} from './testing/catalog-hash'
|