@shipload/sdk 1.0.0-next.55 → 1.0.0-next.56
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.js +32 -10
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +32 -10
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/managers/construction.ts +41 -10
package/lib/shipload.m.js
CHANGED
|
@@ -17345,23 +17345,28 @@ class ConstructionManager extends BaseManager {
|
|
|
17345
17345
|
}
|
|
17346
17346
|
inboundTransfersByTarget(entities, now) {
|
|
17347
17347
|
const buckets = new Map();
|
|
17348
|
+
const entitiesById = new Map(entities.map((entity) => [entity.id.toString(), entity]));
|
|
17348
17349
|
const nowMs = now.getTime();
|
|
17349
17350
|
for (const entity of entities) {
|
|
17350
|
-
const entityIdStr = entity.id.toString();
|
|
17351
|
-
const sourceName = entity.entity_name || entityIdStr;
|
|
17352
17351
|
for (const lane of getLanes(entity)) {
|
|
17353
17352
|
const startedMs = lane.schedule.started.toDate().getTime();
|
|
17354
17353
|
let cumulativeSec = 0;
|
|
17355
17354
|
for (const task of lane.schedule.tasks) {
|
|
17356
17355
|
cumulativeSec += task.duration.toNumber();
|
|
17357
|
-
if (!
|
|
17356
|
+
if (!isDeliveryTask(task))
|
|
17358
17357
|
continue;
|
|
17359
|
-
|
|
17358
|
+
const target = deliveryTarget(task);
|
|
17359
|
+
if (!target)
|
|
17360
|
+
continue;
|
|
17361
|
+
const source = deliverySource(task, entity, entitiesById);
|
|
17362
|
+
if (!source)
|
|
17360
17363
|
continue;
|
|
17361
17364
|
const projectedEndMs = startedMs + cumulativeSec * 1000;
|
|
17362
17365
|
if (projectedEndMs < nowMs)
|
|
17363
17366
|
continue;
|
|
17364
|
-
const targetIdStr =
|
|
17367
|
+
const targetIdStr = target.entity_id.toString();
|
|
17368
|
+
const sourceIdStr = source.id.toString();
|
|
17369
|
+
const sourceName = source.entity_name || sourceIdStr;
|
|
17365
17370
|
const etaSeconds = Math.max(0, Math.round((projectedEndMs - nowMs) / 1000));
|
|
17366
17371
|
let perTarget = buckets.get(targetIdStr);
|
|
17367
17372
|
if (!perTarget) {
|
|
@@ -17373,7 +17378,7 @@ class ConstructionManager extends BaseManager {
|
|
|
17373
17378
|
const quantity = c.quantity.toNumber();
|
|
17374
17379
|
if (quantity === 0)
|
|
17375
17380
|
continue;
|
|
17376
|
-
const key = `${
|
|
17381
|
+
const key = `${sourceIdStr}#${itemId}`;
|
|
17377
17382
|
const existing = perTarget.get(key);
|
|
17378
17383
|
if (existing) {
|
|
17379
17384
|
existing.quantity += quantity;
|
|
@@ -17381,8 +17386,8 @@ class ConstructionManager extends BaseManager {
|
|
|
17381
17386
|
}
|
|
17382
17387
|
else {
|
|
17383
17388
|
perTarget.set(key, {
|
|
17384
|
-
sourceEntityId:
|
|
17385
|
-
sourceEntityType:
|
|
17389
|
+
sourceEntityId: source.id,
|
|
17390
|
+
sourceEntityType: source.type,
|
|
17386
17391
|
sourceName,
|
|
17387
17392
|
itemId,
|
|
17388
17393
|
quantity,
|
|
@@ -17575,7 +17580,24 @@ function partitionSources(target, entities, cargo) {
|
|
|
17575
17580
|
}
|
|
17576
17581
|
return { eligible, unreachable };
|
|
17577
17582
|
}
|
|
17578
|
-
function
|
|
17583
|
+
function isDeliveryTask(task) {
|
|
17584
|
+
const type = task.type.toNumber();
|
|
17585
|
+
return type === TaskType.UNLOAD || type === TaskType.SHUTTLE;
|
|
17586
|
+
}
|
|
17587
|
+
function deliveryTarget(task) {
|
|
17588
|
+
if (task.type.toNumber() === TaskType.SHUTTLE) {
|
|
17589
|
+
return task.couplings.find((coupling) => coupling.kind.toNumber() === HoldKind.PUSH)
|
|
17590
|
+
?.counterpart;
|
|
17591
|
+
}
|
|
17592
|
+
return task.couplings[0]?.counterpart;
|
|
17593
|
+
}
|
|
17594
|
+
function deliverySource(task, transporter, entitiesById) {
|
|
17595
|
+
if (task.type.toNumber() !== TaskType.SHUTTLE)
|
|
17596
|
+
return transporter;
|
|
17597
|
+
const source = task.couplings.find((coupling) => coupling.kind.toNumber() === HoldKind.PULL)?.counterpart;
|
|
17598
|
+
return source ? entitiesById.get(source.entity_id.toString()) : undefined;
|
|
17599
|
+
}
|
|
17600
|
+
function isReservingPushTask(task) {
|
|
17579
17601
|
return task.type.toNumber() === TaskType.UNLOAD;
|
|
17580
17602
|
}
|
|
17581
17603
|
function isBuildOfPlot(task, plotId) {
|
|
@@ -17586,7 +17608,7 @@ function isBuildOfPlot(task, plotId) {
|
|
|
17586
17608
|
function reservationsOf(source) {
|
|
17587
17609
|
const out = new Map();
|
|
17588
17610
|
for (const task of getTasks(source)) {
|
|
17589
|
-
if (!
|
|
17611
|
+
if (!isReservingPushTask(task))
|
|
17590
17612
|
continue;
|
|
17591
17613
|
if (task.couplings.length === 0)
|
|
17592
17614
|
continue;
|