@shipload/sdk 1.0.0-next.26 → 1.0.0-next.27
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 +193 -85
- package/lib/shipload.js +775 -378
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +764 -377
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +13 -8
- package/lib/testing.js +38 -23
- package/lib/testing.js.map +1 -1
- package/lib/testing.m.js +38 -23
- package/lib/testing.m.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/craftable.ts +51 -0
- package/src/contracts/server.ts +39 -18
- package/src/data/capabilities.ts +5 -0
- package/src/entities/entity.ts +1 -1
- package/src/entities/makers.ts +14 -5
- package/src/index-module.ts +24 -4
- package/src/managers/actions.ts +10 -1
- package/src/managers/construction.ts +67 -65
- package/src/scheduling/accessor.ts +65 -23
- package/src/scheduling/availability.ts +108 -0
- package/src/scheduling/energy.ts +18 -11
- package/src/scheduling/lane-core.ts +130 -0
- package/src/scheduling/lanes.ts +60 -0
- package/src/scheduling/projection.ts +30 -54
- package/src/scheduling/schedule.ts +236 -121
- package/src/travel/travel.ts +21 -16
- package/src/types/capabilities.ts +1 -0
package/src/travel/travel.ts
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
} from '../types'
|
|
36
36
|
import {getItem} from '../data/catalog'
|
|
37
37
|
import {hasSystem} from '../utils/system'
|
|
38
|
+
import * as scheduleModel from '../scheduling/schedule'
|
|
39
|
+
import type {ScheduleData} from '../scheduling/schedule'
|
|
38
40
|
|
|
39
41
|
export function calc_orbital_altitude(mass: number): number {
|
|
40
42
|
if (mass <= BASE_ORBITAL_MASS) {
|
|
@@ -112,14 +114,15 @@ export function getInterpolatedPosition(
|
|
|
112
114
|
taskIndex: number,
|
|
113
115
|
taskProgress: number
|
|
114
116
|
): FloatPosition {
|
|
115
|
-
|
|
117
|
+
const tasks = mobilityTasks(entity)
|
|
118
|
+
if (tasks.length === 0) {
|
|
116
119
|
return {x: Number(entity.coordinates.x), y: Number(entity.coordinates.y)}
|
|
117
120
|
}
|
|
118
121
|
if (taskIndex < 0) {
|
|
119
|
-
const settled = getFlightOrigin(entity,
|
|
122
|
+
const settled = getFlightOrigin(entity, tasks.length)
|
|
120
123
|
return {x: Number(settled.x), y: Number(settled.y)}
|
|
121
124
|
}
|
|
122
|
-
const task =
|
|
125
|
+
const task = tasks[taskIndex]
|
|
123
126
|
if (!task.type.equals(TaskType.TRAVEL) || !task.coordinates) {
|
|
124
127
|
const origin = getFlightOrigin(entity, taskIndex)
|
|
125
128
|
return {x: Number(origin.x), y: Number(origin.y)}
|
|
@@ -427,20 +430,22 @@ export interface TransferEntity {
|
|
|
427
430
|
}
|
|
428
431
|
}
|
|
429
432
|
|
|
430
|
-
export interface HasScheduleAndLocation {
|
|
433
|
+
export interface HasScheduleAndLocation extends ScheduleData {
|
|
431
434
|
coordinates: ServerContract.ActionParams.Type.coordinates
|
|
432
|
-
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function mobilityTasks(entity: HasScheduleAndLocation): ServerContract.Types.task[] {
|
|
438
|
+
return scheduleModel.mobilityLane(entity)?.schedule.tasks ?? []
|
|
433
439
|
}
|
|
434
440
|
|
|
435
441
|
export function getFlightOrigin(
|
|
436
442
|
entity: HasScheduleAndLocation,
|
|
437
443
|
flightTaskIndex: number
|
|
438
444
|
): ServerContract.ActionParams.Type.coordinates {
|
|
439
|
-
|
|
440
|
-
|
|
445
|
+
const tasks = mobilityTasks(entity)
|
|
441
446
|
let origin = entity.coordinates
|
|
442
|
-
for (let i = 0; i < flightTaskIndex && i <
|
|
443
|
-
const task =
|
|
447
|
+
for (let i = 0; i < flightTaskIndex && i < tasks.length; i++) {
|
|
448
|
+
const task = tasks[i]
|
|
444
449
|
if (task.type.equals(TaskType.TRAVEL) && task.coordinates) {
|
|
445
450
|
origin = task.coordinates
|
|
446
451
|
}
|
|
@@ -451,10 +456,9 @@ export function getFlightOrigin(
|
|
|
451
456
|
export function getDestinationLocation(
|
|
452
457
|
entity: HasScheduleAndLocation
|
|
453
458
|
): ServerContract.ActionParams.Type.coordinates | undefined {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
const task = entity.schedule.tasks[i]
|
|
459
|
+
const tasks = mobilityTasks(entity)
|
|
460
|
+
for (let i = tasks.length - 1; i >= 0; i--) {
|
|
461
|
+
const task = tasks[i]
|
|
458
462
|
if (task.type.equals(TaskType.TRAVEL) && task.coordinates) {
|
|
459
463
|
return task.coordinates
|
|
460
464
|
}
|
|
@@ -468,14 +472,15 @@ export function getPositionAt(
|
|
|
468
472
|
taskIndex: number,
|
|
469
473
|
taskProgress: number
|
|
470
474
|
): ServerContract.ActionParams.Type.coordinates {
|
|
471
|
-
|
|
475
|
+
const tasks = mobilityTasks(entity)
|
|
476
|
+
if (tasks.length === 0) {
|
|
472
477
|
return entity.coordinates
|
|
473
478
|
}
|
|
474
479
|
if (taskIndex < 0) {
|
|
475
|
-
return getFlightOrigin(entity,
|
|
480
|
+
return getFlightOrigin(entity, tasks.length)
|
|
476
481
|
}
|
|
477
482
|
|
|
478
|
-
const task =
|
|
483
|
+
const task = tasks[taskIndex]
|
|
479
484
|
|
|
480
485
|
if (!task.type.equals(TaskType.TRAVEL) || !task.coordinates) {
|
|
481
486
|
return getFlightOrigin(entity, taskIndex)
|