@shipload/sdk 1.0.0-next.41 → 1.0.0-next.43
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/scan.d.ts +19 -1
- package/lib/scan.js +54 -28
- package/lib/scan.js.map +1 -1
- package/lib/scan.m.js +52 -29
- package/lib/scan.m.js.map +1 -1
- package/lib/shipload.d.ts +98 -1
- package/lib/shipload.js +297 -165
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +286 -166
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/data/capabilities.ts +8 -0
- package/src/data/recipes.json +1 -143
- package/src/derivation/capabilities.test.ts +4 -4
- package/src/derivation/capabilities.ts +1 -1
- package/src/derivation/capability-mappings.ts +49 -4
- package/src/derivation/recipe-usage.test.ts +8 -9
- package/src/derivation/wormhole.ts +5 -0
- package/src/index-module.ts +19 -2
- package/src/managers/actions.ts +17 -0
- package/src/managers/entities.ts +9 -0
- package/src/managers/index.ts +1 -0
- package/src/managers/players.ts +25 -0
- package/src/nft/buildImmutableData.ts +2 -2
- package/src/scan/index.ts +93 -29
- package/src/scan/scan-wasm.base64.ts +1 -1
- package/src/scheduling/unwrap.test.ts +60 -0
- package/src/scheduling/unwrap.ts +187 -0
- package/src/travel/route-planner.ts +82 -1
package/lib/shipload.js
CHANGED
|
@@ -3690,7 +3690,7 @@ var recipes = [
|
|
|
3690
3690
|
quantity: 300
|
|
3691
3691
|
},
|
|
3692
3692
|
{
|
|
3693
|
-
itemId:
|
|
3693
|
+
itemId: 10010,
|
|
3694
3694
|
quantity: 300
|
|
3695
3695
|
}
|
|
3696
3696
|
],
|
|
@@ -4206,149 +4206,6 @@ var recipes = [
|
|
|
4206
4206
|
],
|
|
4207
4207
|
blendWeights: [
|
|
4208
4208
|
]
|
|
4209
|
-
},
|
|
4210
|
-
{
|
|
4211
|
-
outputItemId: 20001,
|
|
4212
|
-
outputMass: 500,
|
|
4213
|
-
inputs: [
|
|
4214
|
-
{
|
|
4215
|
-
itemId: 10001,
|
|
4216
|
-
quantity: 200
|
|
4217
|
-
},
|
|
4218
|
-
{
|
|
4219
|
-
itemId: 102,
|
|
4220
|
-
quantity: 15
|
|
4221
|
-
}
|
|
4222
|
-
],
|
|
4223
|
-
statSlots: [
|
|
4224
|
-
{
|
|
4225
|
-
sources: [
|
|
4226
|
-
{
|
|
4227
|
-
inputIndex: 0,
|
|
4228
|
-
statIndex: 0
|
|
4229
|
-
},
|
|
4230
|
-
{
|
|
4231
|
-
inputIndex: 1,
|
|
4232
|
-
statIndex: 0
|
|
4233
|
-
}
|
|
4234
|
-
]
|
|
4235
|
-
},
|
|
4236
|
-
{
|
|
4237
|
-
sources: [
|
|
4238
|
-
{
|
|
4239
|
-
inputIndex: 0,
|
|
4240
|
-
statIndex: 1
|
|
4241
|
-
},
|
|
4242
|
-
{
|
|
4243
|
-
inputIndex: 1,
|
|
4244
|
-
statIndex: 2
|
|
4245
|
-
}
|
|
4246
|
-
]
|
|
4247
|
-
}
|
|
4248
|
-
],
|
|
4249
|
-
blendWeights: [
|
|
4250
|
-
1,
|
|
4251
|
-
1
|
|
4252
|
-
]
|
|
4253
|
-
},
|
|
4254
|
-
{
|
|
4255
|
-
outputItemId: 20002,
|
|
4256
|
-
outputMass: 300,
|
|
4257
|
-
inputs: [
|
|
4258
|
-
{
|
|
4259
|
-
itemId: 10002,
|
|
4260
|
-
quantity: 200
|
|
4261
|
-
},
|
|
4262
|
-
{
|
|
4263
|
-
itemId: 402,
|
|
4264
|
-
quantity: 10
|
|
4265
|
-
},
|
|
4266
|
-
{
|
|
4267
|
-
itemId: 502,
|
|
4268
|
-
quantity: 20
|
|
4269
|
-
}
|
|
4270
|
-
],
|
|
4271
|
-
statSlots: [
|
|
4272
|
-
{
|
|
4273
|
-
sources: [
|
|
4274
|
-
{
|
|
4275
|
-
inputIndex: 0,
|
|
4276
|
-
statIndex: 0
|
|
4277
|
-
},
|
|
4278
|
-
{
|
|
4279
|
-
inputIndex: 1,
|
|
4280
|
-
statIndex: 1
|
|
4281
|
-
}
|
|
4282
|
-
]
|
|
4283
|
-
},
|
|
4284
|
-
{
|
|
4285
|
-
sources: [
|
|
4286
|
-
{
|
|
4287
|
-
inputIndex: 0,
|
|
4288
|
-
statIndex: 1
|
|
4289
|
-
},
|
|
4290
|
-
{
|
|
4291
|
-
inputIndex: 2,
|
|
4292
|
-
statIndex: 2
|
|
4293
|
-
}
|
|
4294
|
-
]
|
|
4295
|
-
}
|
|
4296
|
-
],
|
|
4297
|
-
blendWeights: [
|
|
4298
|
-
1,
|
|
4299
|
-
1,
|
|
4300
|
-
1
|
|
4301
|
-
]
|
|
4302
|
-
},
|
|
4303
|
-
{
|
|
4304
|
-
outputItemId: 20200,
|
|
4305
|
-
outputMass: 80000,
|
|
4306
|
-
inputs: [
|
|
4307
|
-
{
|
|
4308
|
-
itemId: 20001,
|
|
4309
|
-
quantity: 600
|
|
4310
|
-
},
|
|
4311
|
-
{
|
|
4312
|
-
itemId: 20002,
|
|
4313
|
-
quantity: 200
|
|
4314
|
-
}
|
|
4315
|
-
],
|
|
4316
|
-
statSlots: [
|
|
4317
|
-
{
|
|
4318
|
-
sources: [
|
|
4319
|
-
{
|
|
4320
|
-
inputIndex: 0,
|
|
4321
|
-
statIndex: 0
|
|
4322
|
-
}
|
|
4323
|
-
]
|
|
4324
|
-
},
|
|
4325
|
-
{
|
|
4326
|
-
sources: [
|
|
4327
|
-
{
|
|
4328
|
-
inputIndex: 0,
|
|
4329
|
-
statIndex: 1
|
|
4330
|
-
}
|
|
4331
|
-
]
|
|
4332
|
-
},
|
|
4333
|
-
{
|
|
4334
|
-
sources: [
|
|
4335
|
-
{
|
|
4336
|
-
inputIndex: 1,
|
|
4337
|
-
statIndex: 0
|
|
4338
|
-
}
|
|
4339
|
-
]
|
|
4340
|
-
},
|
|
4341
|
-
{
|
|
4342
|
-
sources: [
|
|
4343
|
-
{
|
|
4344
|
-
inputIndex: 1,
|
|
4345
|
-
statIndex: 1
|
|
4346
|
-
}
|
|
4347
|
-
]
|
|
4348
|
-
}
|
|
4349
|
-
],
|
|
4350
|
-
blendWeights: [
|
|
4351
|
-
]
|
|
4352
4209
|
}
|
|
4353
4210
|
];
|
|
4354
4211
|
|
|
@@ -5606,6 +5463,21 @@ function deriveLocationSize(loc) {
|
|
|
5606
5463
|
return Math.floor(LOCATION_MIN_DEPTH + curved * range);
|
|
5607
5464
|
}
|
|
5608
5465
|
|
|
5466
|
+
const COORD_MIN = -2147483648;
|
|
5467
|
+
const COORD_MAX = 2147483647;
|
|
5468
|
+
const COORD_OFFSET = 2147485000;
|
|
5469
|
+
const SECTOR_DIV = 100000000;
|
|
5470
|
+
const REGION_DIV = 10000;
|
|
5471
|
+
const SECTORS_PER_AXIS = 43;
|
|
5472
|
+
const REGION_PER_AXIS = 10000;
|
|
5473
|
+
const LOCAL_HALF = 5000;
|
|
5474
|
+
const LOCAL_MIN = -5000;
|
|
5475
|
+
const LOCAL_MAX = 4999;
|
|
5476
|
+
const SECTOR_COUNT = SECTORS_PER_AXIS * SECTORS_PER_AXIS;
|
|
5477
|
+
const REGION_COUNT = REGION_PER_AXIS * REGION_PER_AXIS;
|
|
5478
|
+
const SECTOR_FEISTEL = { n: SECTOR_COUNT, halfBits: 6, label: 'sector' };
|
|
5479
|
+
const REGION_FEISTEL = { n: REGION_COUNT, halfBits: 14, label: 'region' };
|
|
5480
|
+
|
|
5609
5481
|
const WH = {
|
|
5610
5482
|
RSIZE: 75,
|
|
5611
5483
|
ZONE: 16384,
|
|
@@ -5672,6 +5544,9 @@ function endpointInRegion(seed, R, key) {
|
|
|
5672
5544
|
function dist$1(a, b) {
|
|
5673
5545
|
return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
|
|
5674
5546
|
}
|
|
5547
|
+
function inBounds(c) {
|
|
5548
|
+
return c.x >= COORD_MIN && c.x <= COORD_MAX && c.y >= COORD_MIN && c.y <= COORD_MAX;
|
|
5549
|
+
}
|
|
5675
5550
|
function wormholeOfRegion(seed, R) {
|
|
5676
5551
|
const P = partnerRegion(seed, R);
|
|
5677
5552
|
if (P.rx === R.rx && P.ry === R.ry)
|
|
@@ -5681,6 +5556,8 @@ function wormholeOfRegion(seed, R) {
|
|
|
5681
5556
|
return null;
|
|
5682
5557
|
const A = endpointInRegion(seed, R, key);
|
|
5683
5558
|
const B = endpointInRegion(seed, P, key);
|
|
5559
|
+
if (!inBounds(A) || !inBounds(B))
|
|
5560
|
+
return null;
|
|
5684
5561
|
if (dist$1(A, B) < WH.MIN_REACH)
|
|
5685
5562
|
return null;
|
|
5686
5563
|
return { A, B };
|
|
@@ -9316,6 +9193,14 @@ class EntitiesManager extends BaseManager {
|
|
|
9316
9193
|
const entities = result;
|
|
9317
9194
|
return entities.map((e) => new Entity(e));
|
|
9318
9195
|
}
|
|
9196
|
+
async getAllEntities(kind) {
|
|
9197
|
+
const rows = await this.server.table('entity').all();
|
|
9198
|
+
if (!kind) {
|
|
9199
|
+
return rows;
|
|
9200
|
+
}
|
|
9201
|
+
const wanted = antelope.Name.from(kind);
|
|
9202
|
+
return rows.filter((row) => wanted.equals(row.kind));
|
|
9203
|
+
}
|
|
9319
9204
|
async getSummaries(owner, kind) {
|
|
9320
9205
|
const ownerName = this.resolveOwner(owner);
|
|
9321
9206
|
const result = await this.server.readonly('getsummaries', {
|
|
@@ -9349,6 +9234,24 @@ class PlayersManager extends BaseManager {
|
|
|
9349
9234
|
}
|
|
9350
9235
|
return new Player(playerRow);
|
|
9351
9236
|
}
|
|
9237
|
+
async getPlayers() {
|
|
9238
|
+
const rows = await this.server.table('player').all();
|
|
9239
|
+
return rows.map((row) => new Player(row));
|
|
9240
|
+
}
|
|
9241
|
+
async getRoster() {
|
|
9242
|
+
const [players, companies] = await Promise.all([
|
|
9243
|
+
this.server.table('player').all(),
|
|
9244
|
+
this.platform.table('company').all(),
|
|
9245
|
+
]);
|
|
9246
|
+
const companyNames = new Map();
|
|
9247
|
+
for (const company of companies) {
|
|
9248
|
+
companyNames.set(company.account.toString(), company.name);
|
|
9249
|
+
}
|
|
9250
|
+
return players.map((player) => ({
|
|
9251
|
+
owner: player.owner,
|
|
9252
|
+
company: companyNames.get(player.owner.toString()),
|
|
9253
|
+
}));
|
|
9254
|
+
}
|
|
9352
9255
|
}
|
|
9353
9256
|
|
|
9354
9257
|
const RESERVE_TIERS = {
|
|
@@ -9999,21 +9902,6 @@ class LocationsManager extends BaseManager {
|
|
|
9999
9902
|
}
|
|
10000
9903
|
}
|
|
10001
9904
|
|
|
10002
|
-
const COORD_MIN = -2147483648;
|
|
10003
|
-
const COORD_MAX = 2147483647;
|
|
10004
|
-
const COORD_OFFSET = 2147485000;
|
|
10005
|
-
const SECTOR_DIV = 100000000;
|
|
10006
|
-
const REGION_DIV = 10000;
|
|
10007
|
-
const SECTORS_PER_AXIS = 43;
|
|
10008
|
-
const REGION_PER_AXIS = 10000;
|
|
10009
|
-
const LOCAL_HALF = 5000;
|
|
10010
|
-
const LOCAL_MIN = -5000;
|
|
10011
|
-
const LOCAL_MAX = 4999;
|
|
10012
|
-
const SECTOR_COUNT = SECTORS_PER_AXIS * SECTORS_PER_AXIS;
|
|
10013
|
-
const REGION_COUNT = REGION_PER_AXIS * REGION_PER_AXIS;
|
|
10014
|
-
const SECTOR_FEISTEL = { n: SECTOR_COUNT, halfBits: 6, label: 'sector' };
|
|
10015
|
-
const REGION_FEISTEL = { n: REGION_COUNT, halfBits: 14, label: 'region' };
|
|
10016
|
-
|
|
10017
9905
|
const ROUNDS = 4;
|
|
10018
9906
|
const keyCache = new Map();
|
|
10019
9907
|
function deriveRoundKeys(seed, label) {
|
|
@@ -12581,6 +12469,19 @@ class ActionsManager extends BaseManager {
|
|
|
12581
12469
|
},
|
|
12582
12470
|
}, ATOMICASSETS_ABI);
|
|
12583
12471
|
}
|
|
12472
|
+
sendAsset(owner, recipient, assetId, memo = '') {
|
|
12473
|
+
return antelope.Action.from({
|
|
12474
|
+
account: this.atomicAssetsAccount,
|
|
12475
|
+
name: 'transfer',
|
|
12476
|
+
authorization: [{ actor: antelope.Name.from(owner), permission: 'active' }],
|
|
12477
|
+
data: {
|
|
12478
|
+
from: antelope.Name.from(owner),
|
|
12479
|
+
to: antelope.Name.from(recipient),
|
|
12480
|
+
asset_ids: [antelope.UInt64.from(assetId)],
|
|
12481
|
+
memo,
|
|
12482
|
+
},
|
|
12483
|
+
}, ATOMICASSETS_ABI);
|
|
12484
|
+
}
|
|
12584
12485
|
unwrapCargoTx(owner, assetId, hostId) {
|
|
12585
12486
|
return [this.transferForUnwrap(owner, assetId), this.placecargo(owner, hostId, assetId)];
|
|
12586
12487
|
}
|
|
@@ -13549,7 +13450,7 @@ function gathererDepthForTier(tol, tier) {
|
|
|
13549
13450
|
}
|
|
13550
13451
|
function computeGathererCapabilities(stats, tier) {
|
|
13551
13452
|
const str = stats.strength;
|
|
13552
|
-
const con = stats.
|
|
13453
|
+
const con = stats.saturation;
|
|
13553
13454
|
const tol = stats.tolerance;
|
|
13554
13455
|
return {
|
|
13555
13456
|
yield: 200 + str,
|
|
@@ -14547,8 +14448,23 @@ function reconstruct(cameFrom, origin, dest) {
|
|
|
14547
14448
|
const waypoints = path.slice(1);
|
|
14548
14449
|
return { ok: true, waypoints, legs: waypoints.length, totalDistance };
|
|
14549
14450
|
}
|
|
14451
|
+
let scanProvider = null;
|
|
14452
|
+
const graphCache = new Map();
|
|
14453
|
+
function setScanProvider(provider) {
|
|
14454
|
+
scanProvider = provider;
|
|
14455
|
+
graphCache.clear();
|
|
14456
|
+
}
|
|
14550
14457
|
function sdkSystemGraph(seed) {
|
|
14551
14458
|
const s = antelope.Checksum256.from(seed);
|
|
14459
|
+
const seedHex = s.toString();
|
|
14460
|
+
const cached = graphCache.get(seedHex);
|
|
14461
|
+
if (cached)
|
|
14462
|
+
return cached;
|
|
14463
|
+
const graph = scanProvider ? wasmSystemGraph(s, seedHex, scanProvider) : jsSystemGraph(s);
|
|
14464
|
+
graphCache.set(seedHex, graph);
|
|
14465
|
+
return graph;
|
|
14466
|
+
}
|
|
14467
|
+
function jsSystemGraph(s) {
|
|
14552
14468
|
return {
|
|
14553
14469
|
hasSystem: (c) => hasSystem(s, { x: c.x, y: c.y }) || wormholeAt(s, c.x, c.y) !== null,
|
|
14554
14470
|
nearby: (c, reachTiles) => {
|
|
@@ -14573,6 +14489,57 @@ function sdkSystemGraph(seed) {
|
|
|
14573
14489
|
},
|
|
14574
14490
|
};
|
|
14575
14491
|
}
|
|
14492
|
+
const SCAN_BUCKET = 48;
|
|
14493
|
+
function wasmSystemGraph(s, seedHex, scan) {
|
|
14494
|
+
const bucketCache = new Map();
|
|
14495
|
+
const bucketSystems = (bx, by) => {
|
|
14496
|
+
const k = `${bx},${by}`;
|
|
14497
|
+
let v = bucketCache.get(k);
|
|
14498
|
+
if (v === undefined) {
|
|
14499
|
+
const xMin = bx * SCAN_BUCKET;
|
|
14500
|
+
const yMin = by * SCAN_BUCKET;
|
|
14501
|
+
v = scan
|
|
14502
|
+
.systemsInBox(seedHex, xMin, yMin, xMin + SCAN_BUCKET - 1, yMin + SCAN_BUCKET - 1)
|
|
14503
|
+
.map((cell) => ({ x: cell.x, y: cell.y }));
|
|
14504
|
+
bucketCache.set(k, v);
|
|
14505
|
+
}
|
|
14506
|
+
return v;
|
|
14507
|
+
};
|
|
14508
|
+
return {
|
|
14509
|
+
hasSystem: (c) => scan.getLocationType(seedHex, c.x, c.y) !== 0 || wormholeAt(s, c.x, c.y) !== null,
|
|
14510
|
+
nearby: (c, reachTiles) => {
|
|
14511
|
+
const r = Math.floor(reachTiles);
|
|
14512
|
+
const seen = new Set([`${c.x},${c.y}`]);
|
|
14513
|
+
const out = [];
|
|
14514
|
+
const bx0 = Math.floor((c.x - r) / SCAN_BUCKET);
|
|
14515
|
+
const bx1 = Math.floor((c.x + r) / SCAN_BUCKET);
|
|
14516
|
+
const by0 = Math.floor((c.y - r) / SCAN_BUCKET);
|
|
14517
|
+
const by1 = Math.floor((c.y + r) / SCAN_BUCKET);
|
|
14518
|
+
for (let bx = bx0; bx <= bx1; bx++) {
|
|
14519
|
+
for (let by = by0; by <= by1; by++) {
|
|
14520
|
+
for (const cell of bucketSystems(bx, by)) {
|
|
14521
|
+
const dist = Math.hypot(cell.x - c.x, cell.y - c.y);
|
|
14522
|
+
if (dist > reachTiles)
|
|
14523
|
+
continue;
|
|
14524
|
+
const k = `${cell.x},${cell.y}`;
|
|
14525
|
+
if (seen.has(k))
|
|
14526
|
+
continue;
|
|
14527
|
+
seen.add(k);
|
|
14528
|
+
out.push({ coord: { x: cell.x, y: cell.y }, dist });
|
|
14529
|
+
}
|
|
14530
|
+
}
|
|
14531
|
+
}
|
|
14532
|
+
for (const coord of nearbyWormholes(s, c.x, c.y, reachTiles)) {
|
|
14533
|
+
const k = `${coord.x},${coord.y}`;
|
|
14534
|
+
if (seen.has(k))
|
|
14535
|
+
continue;
|
|
14536
|
+
seen.add(k);
|
|
14537
|
+
out.push({ coord, dist: Math.hypot(coord.x - c.x, coord.y - c.y) });
|
|
14538
|
+
}
|
|
14539
|
+
return out;
|
|
14540
|
+
},
|
|
14541
|
+
};
|
|
14542
|
+
}
|
|
14576
14543
|
|
|
14577
14544
|
function computePerLegReach(s, haulCount = 0) {
|
|
14578
14545
|
const capacity = s.generator?.capacity;
|
|
@@ -15612,6 +15579,117 @@ function cancelEligibility(entity, laneKey, fromTaskIndex, input) {
|
|
|
15612
15579
|
return { ok: true, range, effects };
|
|
15613
15580
|
}
|
|
15614
15581
|
|
|
15582
|
+
const NFT_TRANSIT_THRUST = 400;
|
|
15583
|
+
function derivedLoaders(lanes) {
|
|
15584
|
+
if (!lanes || lanes.length === 0)
|
|
15585
|
+
return null;
|
|
15586
|
+
let totalMass = 0;
|
|
15587
|
+
let totalThrust = 0;
|
|
15588
|
+
for (const l of lanes) {
|
|
15589
|
+
totalMass += Number(l.mass);
|
|
15590
|
+
totalThrust += Number(l.thrust);
|
|
15591
|
+
}
|
|
15592
|
+
const count = lanes.length;
|
|
15593
|
+
return {
|
|
15594
|
+
mass: Math.floor(totalMass / count),
|
|
15595
|
+
thrust: Math.min(totalThrust, 65535),
|
|
15596
|
+
quantity: count,
|
|
15597
|
+
};
|
|
15598
|
+
}
|
|
15599
|
+
function acceleration(thrust, mass) {
|
|
15600
|
+
if (mass <= 0)
|
|
15601
|
+
return 0;
|
|
15602
|
+
return (thrust / mass) * PRECISION$1;
|
|
15603
|
+
}
|
|
15604
|
+
function flightTime(distance, accel) {
|
|
15605
|
+
if (accel <= 0 || distance <= 0)
|
|
15606
|
+
return 0;
|
|
15607
|
+
return Math.floor(2 * Math.sqrt(distance / accel));
|
|
15608
|
+
}
|
|
15609
|
+
function distance2d(ax, ay, bx, by) {
|
|
15610
|
+
const dx = ax - bx;
|
|
15611
|
+
const dy = ay - by;
|
|
15612
|
+
return Math.floor(Math.sqrt(dx * dx + dy * dy) * PRECISION$1);
|
|
15613
|
+
}
|
|
15614
|
+
function unwrapTransitDuration(itemMass, origin, dest) {
|
|
15615
|
+
if (itemMass <= 0)
|
|
15616
|
+
return 0;
|
|
15617
|
+
return flightTime(distance2d(origin.x, origin.y, dest.x, dest.y), acceleration(NFT_TRANSIT_THRUST, itemMass));
|
|
15618
|
+
}
|
|
15619
|
+
function unwrapLoadDuration(loaders, itemMass, destZ) {
|
|
15620
|
+
if (!loaders || itemMass <= 0)
|
|
15621
|
+
return 0;
|
|
15622
|
+
const total = itemMass + loaders.mass;
|
|
15623
|
+
const flight = flightTime(destZ, acceleration(loaders.thrust, total));
|
|
15624
|
+
return Math.floor(flight / loaders.quantity);
|
|
15625
|
+
}
|
|
15626
|
+
function estimateUnwrapDuration(dest, item) {
|
|
15627
|
+
const itemMass = Number(calcCargoItemMass({
|
|
15628
|
+
item_id: item.itemId,
|
|
15629
|
+
quantity: item.quantity,
|
|
15630
|
+
modules: item.modules,
|
|
15631
|
+
}));
|
|
15632
|
+
const loaders = derivedLoaders(dest.loader_lanes);
|
|
15633
|
+
const dz = Number(dest.coordinates.z ?? 0);
|
|
15634
|
+
const load = unwrapLoadDuration(loaders, itemMass, dz);
|
|
15635
|
+
const transit = unwrapTransitDuration(itemMass, { x: item.originX, y: item.originY }, {
|
|
15636
|
+
x: Number(dest.coordinates.x),
|
|
15637
|
+
y: Number(dest.coordinates.y),
|
|
15638
|
+
});
|
|
15639
|
+
return load + transit;
|
|
15640
|
+
}
|
|
15641
|
+
const INCOMING_HOLD_KINDS = new Set([2, 3, 5]);
|
|
15642
|
+
function incomingHoldMass(holds) {
|
|
15643
|
+
if (!holds)
|
|
15644
|
+
return 0;
|
|
15645
|
+
let total = 0;
|
|
15646
|
+
for (const h of holds) {
|
|
15647
|
+
if (INCOMING_HOLD_KINDS.has(Number(h.kind)))
|
|
15648
|
+
total += Number(h.incoming_mass);
|
|
15649
|
+
}
|
|
15650
|
+
return total;
|
|
15651
|
+
}
|
|
15652
|
+
function cargoListMass(items) {
|
|
15653
|
+
let m = 0;
|
|
15654
|
+
for (const it of items)
|
|
15655
|
+
m += Number(calcCargoItemMass(it));
|
|
15656
|
+
return m;
|
|
15657
|
+
}
|
|
15658
|
+
function projectedPeakCargomass(entity, at, addMass, removeMass = 0) {
|
|
15659
|
+
const events = [];
|
|
15660
|
+
for (const ordered of orderedTasks(entity)) {
|
|
15661
|
+
const eff = taskCargoEffect(ordered.task);
|
|
15662
|
+
const delta = cargoListMass(eff.added) - cargoListMass(eff.removed);
|
|
15663
|
+
events.push({ t: ordered.completesAt.getTime(), delta });
|
|
15664
|
+
}
|
|
15665
|
+
events.push({ t: at.getTime(), delta: addMass - removeMass });
|
|
15666
|
+
events.sort((a, b) => (a.t !== b.t ? a.t - b.t : b.delta - a.delta));
|
|
15667
|
+
let running = Number(entity.cargomass);
|
|
15668
|
+
let peak = running;
|
|
15669
|
+
for (const e of events) {
|
|
15670
|
+
running += e.delta;
|
|
15671
|
+
if (running < 0)
|
|
15672
|
+
running = 0;
|
|
15673
|
+
if (running > peak)
|
|
15674
|
+
peak = running;
|
|
15675
|
+
}
|
|
15676
|
+
return Math.min(peak, 4294967295);
|
|
15677
|
+
}
|
|
15678
|
+
function receiveFits(dest, item, now) {
|
|
15679
|
+
const capacity = Number(dest.capacity ?? 0);
|
|
15680
|
+
if (capacity <= 0)
|
|
15681
|
+
return false;
|
|
15682
|
+
const itemMass = Number(calcCargoItemMass({
|
|
15683
|
+
item_id: item.itemId,
|
|
15684
|
+
quantity: item.quantity,
|
|
15685
|
+
modules: item.modules,
|
|
15686
|
+
}));
|
|
15687
|
+
const duration = estimateUnwrapDuration(dest, item);
|
|
15688
|
+
const candidateCompletes = candidateLaneCompletesAt(dest, LANE_MOBILITY, duration, now);
|
|
15689
|
+
const peak = projectedPeakCargomass(dest, candidateCompletes, itemMass + incomingHoldMass(dest.holds));
|
|
15690
|
+
return peak <= capacity;
|
|
15691
|
+
}
|
|
15692
|
+
|
|
15615
15693
|
function maxCraftable(entity, recipe, crafterSpeed, now) {
|
|
15616
15694
|
if (recipe.inputs.length === 0)
|
|
15617
15695
|
return 0;
|
|
@@ -16055,6 +16133,10 @@ function traceToRawCategoryStat(recipe, source, visited = new Set()) {
|
|
|
16055
16133
|
nextVisited.add(input.itemId);
|
|
16056
16134
|
return traceToRawCategoryStat(subRecipe, subSource, nextVisited);
|
|
16057
16135
|
}
|
|
16136
|
+
function sourceLabelForOutput(itemId) {
|
|
16137
|
+
const item = getItem(itemId);
|
|
16138
|
+
return item.type === 'entity' ? 'Hull' : item.name;
|
|
16139
|
+
}
|
|
16058
16140
|
let cached;
|
|
16059
16141
|
function deriveStatMappings() {
|
|
16060
16142
|
if (cached)
|
|
@@ -16066,16 +16148,17 @@ function deriveStatMappings() {
|
|
|
16066
16148
|
const recipe = getRecipe(itemId);
|
|
16067
16149
|
if (!recipe)
|
|
16068
16150
|
continue;
|
|
16151
|
+
const source = sourceLabelForOutput(itemId);
|
|
16069
16152
|
for (const [slotIdxStr, consumer] of Object.entries(slots)) {
|
|
16070
16153
|
const slotIdx = Number(slotIdxStr);
|
|
16071
16154
|
const slot = recipe.statSlots[slotIdx];
|
|
16072
16155
|
if (!slot)
|
|
16073
16156
|
continue;
|
|
16074
|
-
for (const
|
|
16075
|
-
const stat = traceToRawCategoryStat(recipe,
|
|
16157
|
+
for (const src of slot.sources) {
|
|
16158
|
+
const stat = traceToRawCategoryStat(recipe, src);
|
|
16076
16159
|
if (!stat)
|
|
16077
16160
|
continue;
|
|
16078
|
-
const key = `${stat.label}|${consumer.capability}|${consumer.attribute}`;
|
|
16161
|
+
const key = `${stat.label}|${consumer.capability}|${consumer.attribute}|${source}`;
|
|
16079
16162
|
if (seen.has(key))
|
|
16080
16163
|
continue;
|
|
16081
16164
|
seen.add(key);
|
|
@@ -16083,6 +16166,7 @@ function deriveStatMappings() {
|
|
|
16083
16166
|
stat: stat.label,
|
|
16084
16167
|
capability: consumer.capability,
|
|
16085
16168
|
attribute: consumer.attribute,
|
|
16169
|
+
source,
|
|
16086
16170
|
});
|
|
16087
16171
|
}
|
|
16088
16172
|
}
|
|
@@ -16099,6 +16183,42 @@ function getStatMappingsForStat(stat) {
|
|
|
16099
16183
|
function getStatMappingsForCapability(capability) {
|
|
16100
16184
|
return deriveStatMappings().filter((m) => m.capability === capability);
|
|
16101
16185
|
}
|
|
16186
|
+
function getProducersForAttribute(capability, attribute) {
|
|
16187
|
+
const seen = new Set();
|
|
16188
|
+
const out = [];
|
|
16189
|
+
for (const m of deriveStatMappings()) {
|
|
16190
|
+
if (m.capability !== capability || m.attribute !== attribute)
|
|
16191
|
+
continue;
|
|
16192
|
+
if (seen.has(m.source))
|
|
16193
|
+
continue;
|
|
16194
|
+
seen.add(m.source);
|
|
16195
|
+
out.push(m.source);
|
|
16196
|
+
}
|
|
16197
|
+
return out;
|
|
16198
|
+
}
|
|
16199
|
+
function getCapabilityAttributeRows() {
|
|
16200
|
+
const rows = [];
|
|
16201
|
+
for (const ca of capabilityAttributes) {
|
|
16202
|
+
const producers = getProducersForAttribute(ca.capability, ca.attribute);
|
|
16203
|
+
if (producers.length === 0) {
|
|
16204
|
+
rows.push({
|
|
16205
|
+
capability: ca.capability,
|
|
16206
|
+
attribute: ca.attribute,
|
|
16207
|
+
description: ca.description,
|
|
16208
|
+
});
|
|
16209
|
+
continue;
|
|
16210
|
+
}
|
|
16211
|
+
for (const source of producers) {
|
|
16212
|
+
rows.push({
|
|
16213
|
+
capability: ca.capability,
|
|
16214
|
+
attribute: ca.attribute,
|
|
16215
|
+
description: ca.description,
|
|
16216
|
+
source,
|
|
16217
|
+
});
|
|
16218
|
+
}
|
|
16219
|
+
}
|
|
16220
|
+
return rows;
|
|
16221
|
+
}
|
|
16102
16222
|
|
|
16103
16223
|
function getAllRecipes() {
|
|
16104
16224
|
return recipes;
|
|
@@ -16803,8 +16923,8 @@ function buildModuleImmutable(itemId, quantity, stats, originX, originY) {
|
|
|
16803
16923
|
const ref = decodeStat(stats, 3);
|
|
16804
16924
|
base.push({ first: 'strength', second: ['uint16', str] });
|
|
16805
16925
|
base.push({ first: 'tolerance', second: ['uint16', tol] });
|
|
16806
|
-
base.push({ first: '
|
|
16807
|
-
base.push({ first: '
|
|
16926
|
+
base.push({ first: 'saturation', second: ['uint16', con] });
|
|
16927
|
+
base.push({ first: 'plasticity', second: ['uint16', ref] });
|
|
16808
16928
|
base.push({ first: 'yield', second: ['uint16', computeGathererYield(str)] });
|
|
16809
16929
|
base.push({ first: 'drain', second: ['uint16', computeGathererDrain(con)] });
|
|
16810
16930
|
base.push({ first: 'depth', second: ['uint16', computeGathererDepth(tol, item.tier)] });
|
|
@@ -17523,6 +17643,7 @@ exports.deriveResourceStats = deriveResourceStats;
|
|
|
17523
17643
|
exports.deriveStatMappings = deriveStatMappings;
|
|
17524
17644
|
exports.deriveStrata = deriveStrata;
|
|
17525
17645
|
exports.deriveStratum = deriveStratum;
|
|
17646
|
+
exports.derivedLoaders = derivedLoaders;
|
|
17526
17647
|
exports.describeItem = describeItem;
|
|
17527
17648
|
exports.describeModule = describeModule;
|
|
17528
17649
|
exports.describeModuleForItem = describeModuleForItem;
|
|
@@ -17548,6 +17669,7 @@ exports.energyPercent = energyPercent;
|
|
|
17548
17669
|
exports.entityDisplayName = entityDisplayName;
|
|
17549
17670
|
exports.estimateDealTravelTime = estimateDealTravelTime;
|
|
17550
17671
|
exports.estimateTravelTime = estimateTravelTime;
|
|
17672
|
+
exports.estimateUnwrapDuration = estimateUnwrapDuration;
|
|
17551
17673
|
exports.feistel = feistel;
|
|
17552
17674
|
exports.feistelInv = feistelInv;
|
|
17553
17675
|
exports.fetchAtomicAssetsForOwner = fetchAtomicAssetsForOwner;
|
|
@@ -17563,6 +17685,7 @@ exports.formatModuleLine = formatModuleLine;
|
|
|
17563
17685
|
exports.formatTier = formatTier;
|
|
17564
17686
|
exports.gathererDepthForTier = gathererDepthForTier;
|
|
17565
17687
|
exports.getAllRecipes = getAllRecipes;
|
|
17688
|
+
exports.getCapabilityAttributeRows = getCapabilityAttributeRows;
|
|
17566
17689
|
exports.getCapabilityAttributes = getCapabilityAttributes;
|
|
17567
17690
|
exports.getCategoryInfo = getCategoryInfo;
|
|
17568
17691
|
exports.getComponentDemand = getComponentDemand;
|
|
@@ -17592,6 +17715,7 @@ exports.getPackedEntityType = getPackedEntityType;
|
|
|
17592
17715
|
exports.getPlanetSubtype = getPlanetSubtype;
|
|
17593
17716
|
exports.getPlanetSubtypes = getPlanetSubtypes;
|
|
17594
17717
|
exports.getPositionAt = getPositionAt;
|
|
17718
|
+
exports.getProducersForAttribute = getProducersForAttribute;
|
|
17595
17719
|
exports.getRecipe = getRecipe;
|
|
17596
17720
|
exports.getRecipeConsumers = getRecipeConsumers;
|
|
17597
17721
|
exports.getResourceDemand = getResourceDemand;
|
|
@@ -17617,6 +17741,7 @@ exports.hasStorage = hasStorage;
|
|
|
17617
17741
|
exports.hasSystem = hasSystem;
|
|
17618
17742
|
exports.hash = hash;
|
|
17619
17743
|
exports.hash512 = hash512;
|
|
17744
|
+
exports.incomingHoldMass = incomingHoldMass;
|
|
17620
17745
|
exports.interpolateFlightPosition = interpolateFlightPosition;
|
|
17621
17746
|
exports.isBuildable = isBuildable;
|
|
17622
17747
|
exports.isContainer = isContainer;
|
|
@@ -17655,6 +17780,7 @@ exports.moduleAccepts = moduleAccepts;
|
|
|
17655
17780
|
exports.moduleDisplayName = moduleDisplayName;
|
|
17656
17781
|
exports.moduleIcon = moduleIcon;
|
|
17657
17782
|
exports.moduleSlotTypeToCode = moduleSlotTypeToCode;
|
|
17783
|
+
exports.nearbyWormholes = nearbyWormholes;
|
|
17658
17784
|
exports.needsRecharge = needsRecharge;
|
|
17659
17785
|
exports.normalizeDisplayName = normalizeDisplayName;
|
|
17660
17786
|
exports.parseWireEntity = parseWireEntity;
|
|
@@ -17666,8 +17792,10 @@ exports.projectEntity = projectEntity;
|
|
|
17666
17792
|
exports.projectEntityAt = projectEntityAt;
|
|
17667
17793
|
exports.projectRemainingAt = projectRemainingAt;
|
|
17668
17794
|
exports.projectedCargoAvailableAt = projectedCargoAvailableAt;
|
|
17795
|
+
exports.projectedPeakCargomass = projectedPeakCargomass;
|
|
17669
17796
|
exports.rawScheduleEnd = rawScheduleEnd;
|
|
17670
17797
|
exports.readCommonBase = readCommonBase;
|
|
17798
|
+
exports.receiveFits = receiveFits;
|
|
17671
17799
|
exports.regionOf = regionOf;
|
|
17672
17800
|
exports.removeFromStacks = removeFromStacks;
|
|
17673
17801
|
exports.renderDescription = renderDescription;
|
|
@@ -17687,7 +17815,9 @@ exports.rotation = rotation;
|
|
|
17687
17815
|
exports.schedule = schedule;
|
|
17688
17816
|
exports.sdkSystemGraph = sdkSystemGraph;
|
|
17689
17817
|
exports.selectGatherLane = selectGatherLane;
|
|
17818
|
+
exports.setScanProvider = setScanProvider;
|
|
17690
17819
|
exports.setSubscriptionsDebug = setSubscriptionsDebug;
|
|
17820
|
+
exports.sourceLabelForOutput = sourceLabelForOutput;
|
|
17691
17821
|
exports.stackKey = stackKey;
|
|
17692
17822
|
exports.stackToCargoItem = stackToCargoItem;
|
|
17693
17823
|
exports.stacksEqual = stacksEqual;
|
|
@@ -17702,6 +17832,8 @@ exports.tierColors = tierColors;
|
|
|
17702
17832
|
exports.tierOfReserve = tierOfReserve;
|
|
17703
17833
|
exports.toLocation = toLocation;
|
|
17704
17834
|
exports.typeLabel = typeLabel;
|
|
17835
|
+
exports.unwrapLoadDuration = unwrapLoadDuration;
|
|
17836
|
+
exports.unwrapTransitDuration = unwrapTransitDuration;
|
|
17705
17837
|
exports.validateDisplayName = validateDisplayName;
|
|
17706
17838
|
exports.validateSchedule = validateSchedule;
|
|
17707
17839
|
exports.workerLaneKey = workerLaneKey;
|