@shipload/sdk 1.0.0-next.20 → 1.0.0-next.22
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 +25 -1
- package/lib/shipload.js +186 -22
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +186 -23
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/index-module.ts +4 -0
- package/src/managers/construction-types.ts +21 -0
- package/src/managers/construction.ts +159 -15
- package/src/managers/index.ts +2 -0
- package/src/scheduling/energy.ts +41 -0
- package/src/scheduling/projection.ts +10 -11
package/lib/shipload.d.ts
CHANGED
|
@@ -2898,10 +2898,15 @@ interface SourceEntityRef {
|
|
|
2898
2898
|
relevantCargo: SourceCargoStack[];
|
|
2899
2899
|
}
|
|
2900
2900
|
interface SourceCargoStack {
|
|
2901
|
+
key: string;
|
|
2902
|
+
rowId: UInt64;
|
|
2901
2903
|
itemId: number;
|
|
2902
2904
|
item: Item;
|
|
2905
|
+
stats: UInt64;
|
|
2906
|
+
modules: Types.module_entry[];
|
|
2903
2907
|
available: number;
|
|
2904
2908
|
plotNeeds: number;
|
|
2909
|
+
reserved: number;
|
|
2905
2910
|
}
|
|
2906
2911
|
interface FinalizerEntityRef {
|
|
2907
2912
|
entityId: UInt64;
|
|
@@ -2910,6 +2915,20 @@ interface FinalizerEntityRef {
|
|
|
2910
2915
|
crafterSpeed: number;
|
|
2911
2916
|
estimatedDuration: UInt32;
|
|
2912
2917
|
}
|
|
2918
|
+
interface InboundTransfer {
|
|
2919
|
+
sourceEntityId: UInt64;
|
|
2920
|
+
sourceEntityType: Name;
|
|
2921
|
+
sourceName: string;
|
|
2922
|
+
itemId: number;
|
|
2923
|
+
quantity: number;
|
|
2924
|
+
etaSeconds: number;
|
|
2925
|
+
}
|
|
2926
|
+
interface Reservation {
|
|
2927
|
+
targetEntityId: UInt64;
|
|
2928
|
+
targetEntityType: Name;
|
|
2929
|
+
itemId: number;
|
|
2930
|
+
quantity: number;
|
|
2931
|
+
}
|
|
2913
2932
|
|
|
2914
2933
|
interface PlotProgressInputRow {
|
|
2915
2934
|
itemId: number;
|
|
@@ -2935,6 +2954,9 @@ declare class ConstructionManager extends BaseManager {
|
|
|
2935
2954
|
unreachable: SourceEntityRef[];
|
|
2936
2955
|
};
|
|
2937
2956
|
eligibleFinalizers(target: BuildableTarget, entities: Types.entity_info[]): FinalizerEntityRef[];
|
|
2957
|
+
inboundTransfersTo(plotId: UInt64, entities: Types.entity_info[], now: Date): InboundTransfer[];
|
|
2958
|
+
inboundTransfersByTarget(entities: Types.entity_info[], now: Date): Map<string, InboundTransfer[]>;
|
|
2959
|
+
reservationsFrom(sourceEntityId: UInt64, entities: Types.entity_info[]): Reservation[];
|
|
2938
2960
|
estimateFinalizeDuration(target: BuildableTarget, crafterSpeed: number): UInt32;
|
|
2939
2961
|
static isConstructionKind(kind: string): boolean;
|
|
2940
2962
|
}
|
|
@@ -3176,6 +3198,8 @@ interface TaskCargoChange {
|
|
|
3176
3198
|
}
|
|
3177
3199
|
declare function taskCargoChanges(task: Types.task): TaskCargoChange[];
|
|
3178
3200
|
|
|
3201
|
+
declare function energyAtTime(entity: Projectable, now: Date): number;
|
|
3202
|
+
|
|
3179
3203
|
interface Entity {
|
|
3180
3204
|
id: UInt64;
|
|
3181
3205
|
type: Name;
|
|
@@ -3825,4 +3849,4 @@ type gatherer_stats = Types.gatherer_stats;
|
|
|
3825
3849
|
type location_static = Types.location_static;
|
|
3826
3850
|
type location_derived = Types.location_derived;
|
|
3827
3851
|
|
|
3828
|
-
export { ALL_ENTITY_TYPES, ATOMICASSETS_ACCOUNT, AckMessage, ActionsManager, AnyEntity, AtomicAssetRow, AtomicAttributeType, AtomicSchemaRow, BASE_ORBITAL_MASS, BLEND_INPUTS_MUST_MATCH, BLEND_REQUIRES_MULTIPLE, BLEND_STAT_LESS_NOT_SUPPORTED, BoundingBox, BoundsDeltaMessage, BoundsSubscriptionHandle, BuildMethod, BuildState, BuildableTarget, CANCEL_CONTAINS_GROUPED_TASK, CANCEL_PAIRED_HAS_PENDING, CAP_DEMOLISH, CAP_MODULES, CAP_UNDEPLOY, CAP_WRAP, CATEGORY_LABELS, COMMIT_ALREADY_SET, COMMIT_CANNOT_MATCH, COMMIT_NOT_SET, COMPANY_NOT_FOUND, COMPONENT_TIER_PREFIXES, CONTAINER_NOT_FOUND, CONTAINER_Z, CRAFT_ENERGY_DIVISOR, CRAFT_EXCEEDS_ENERGY_CAPACITY, CRAFT_NOT_ENOUGH_ENERGY, CapabilityAttribute, CapabilityInput, CargoData, CargoMassInfo, CargoStack, CategoryIconShape, CategoryInfo, CategoryStacks, ClientMessage, ComputedCapabilities, ConnectionState, ConstructionManager, Container, ContainerEntity, Coordinates, CoordinatesType, CraftedItemCategory, CrafterCapability, DEPLOY_ENTITY_HAS_SCHEDULE, DEPTH_THRESHOLD_T1, DEPTH_THRESHOLD_T2, DEPTH_THRESHOLD_T3, DEPTH_THRESHOLD_T4, DEPTH_THRESHOLD_T5, DESTINATION_CAPACITY_EXCEEDED, DecodedAtomicAsset, DerivedStratum, DescribeOptions, Distance, ENTITY_ALREADY_THERE, ENTITY_CAPACITY_EXCEEDED, ENTITY_CARGO_NOT_LOADED, ENTITY_CARGO_NOT_OWNED, ENTITY_CONTAINER, ENTITY_EXTRACTOR, ENTITY_FACTORY, ENTITY_INVALID_CARGO, ENTITY_INVALID_DESTINATION, ENTITY_INVALID_TRAVEL_DURATION, ENTITY_NEXUS, ENTITY_NOT_ENOUGH_ENERGY, ENTITY_NOT_ENOUGH_ENERGY_CAPACITY, ENTITY_NO_CRAFTER, ENTITY_SHIP, ENTITY_WAREHOUSE, EPOCH_NON_ZERO, EPOCH_NOT_READY, ERROR_SYSTEM_ALREADY_INITIALIZED, ERROR_SYSTEM_DISABLED, ERROR_SYSTEM_NOT_INITIALIZED, EffectiveReserveInput, EnergyCapability, EntitiesManager, Entity$1 as Entity, EntityCapabilities, EntityClass, EntityInfo, EntityInstance, EntityInventory, EntityLayout, EntityRefInput, EntitySlot, EntityState, EntityStateInput, EntitySubscriptionHandle, EntityTypeName, EpochInfo, EpochsManager, ErrorMessage, EstimateTravelTimeOptions, EstimatedTravelTime, EventCatchupCompleteMessage, EventMessage, Extractor, Factory, FetchAssetsOptions, FinalizerCapability, FinalizerEntityRef, FloatPosition, GAME_NOT_FOUND, GAME_SEED_NOT_SET, GATHERER_DEPTH_MAX_TIER, GATHERER_DEPTH_TABLE, GATHER_EXCEEDS_ENERGY_CAPACITY, GATHER_NOT_ENOUGH_ENERGY, GROUP_DUPLICATE_ENTITY, GROUP_EMPTY, GROUP_ENTITY_NOT_MOVABLE, GROUP_HAUL_CAPACITY_EXCEEDED, GROUP_NOT_FOUND, GROUP_NOT_SAME_LOCATION, GROUP_NOT_SAME_OWNER, GROUP_NO_THRUST, GameState, GathererCapability, GathererDepthParams, HasCapacity, HasCargo, HasCargomass, HasScheduleAndLocation, INSUFFICIENT_BALANCE, INSUFFICIENT_ITEM_QUANTITY, INSUFFICIENT_ITEM_SUPPLY, INVALID_AMOUNT, ITEM_BATTERY_T1, ITEM_BEAM, ITEM_BIOMASS_T1, ITEM_BIOMASS_T10, ITEM_BIOMASS_T2, ITEM_BIOMASS_T3, ITEM_BIOMASS_T4, ITEM_BIOMASS_T5, ITEM_BIOMASS_T6, ITEM_BIOMASS_T7, ITEM_BIOMASS_T8, ITEM_BIOMASS_T9, ITEM_CERAMIC, ITEM_CONTAINER_T1_PACKED, ITEM_CONTAINER_T2_PACKED, ITEM_CRAFTER_T1, ITEM_CRYSTAL_T1, ITEM_CRYSTAL_T10, ITEM_CRYSTAL_T2, ITEM_CRYSTAL_T3, ITEM_CRYSTAL_T4, ITEM_CRYSTAL_T5, ITEM_CRYSTAL_T6, ITEM_CRYSTAL_T7, ITEM_CRYSTAL_T8, ITEM_CRYSTAL_T9, ITEM_DOES_NOT_EXIST, ITEM_EMITTER, ITEM_ENGINE_T1, ITEM_EXTRACTOR_T1_PACKED, ITEM_FACTORY_T1_PACKED, ITEM_FRAME, ITEM_FRAME_T2, ITEM_GAS_T1, ITEM_GAS_T10, ITEM_GAS_T2, ITEM_GAS_T3, ITEM_GAS_T4, ITEM_GAS_T5, ITEM_GAS_T6, ITEM_GAS_T7, ITEM_GAS_T8, ITEM_GAS_T9, ITEM_GATHERER_T1, ITEM_GENERATOR_T1, ITEM_HAULER_T1, ITEM_LOADER_T1, ITEM_NOT_AVAILABLE_AT_LOCATION, ITEM_NOT_DEPLOYABLE, ITEM_NOT_PACKED_ENTITY, ITEM_ORE_T1, ITEM_ORE_T10, ITEM_ORE_T2, ITEM_ORE_T3, ITEM_ORE_T4, ITEM_ORE_T5, ITEM_ORE_T6, ITEM_ORE_T7, ITEM_ORE_T8, ITEM_ORE_T9, ITEM_PLASMA_CELL, ITEM_PLATE, ITEM_PLATE_T2, ITEM_POLYMER, ITEM_REACTOR, ITEM_REGOLITH_T1, ITEM_REGOLITH_T10, ITEM_REGOLITH_T2, ITEM_REGOLITH_T3, ITEM_REGOLITH_T4, ITEM_REGOLITH_T5, ITEM_REGOLITH_T6, ITEM_REGOLITH_T7, ITEM_REGOLITH_T8, ITEM_REGOLITH_T9, ITEM_RESONATOR, ITEM_SENSOR, ITEM_SHIP_T1_PACKED, ITEM_STORAGE_T1, ITEM_TYPE_COMPONENT, ITEM_TYPE_ENTITY, ITEM_TYPE_MODULE, ITEM_TYPE_RESOURCE, ITEM_WAREHOUSE_T1_PACKED, ITEM_WARP_T1, ImmutableEntry, ImmutableModuleSlot, InstalledModule, InventoryAccessor, Item, ItemType, KindMeta, LOCATION_MAX_DEPTH, LOCATION_MIN_DEPTH, LoadTimeBreakdown, LoaderCapability, Location, LocationStratum, LocationType, LocationsManager, MAX_ORBITAL_ALTITUDE, MIN_ORBITAL_ALTITUDE, MIN_TRANSFER_DISTANCE, MODULE_ANY, MODULE_BATTERY, MODULE_CARGO_NOT_FOUND, MODULE_CRAFTER, MODULE_ENGINE, MODULE_ENTITY_BUSY, MODULE_GATHERER, MODULE_GENERATOR, MODULE_HAULER, MODULE_LAUNCHER, MODULE_LOADER, MODULE_NOT_MODULE, MODULE_SLOT_EMPTY, MODULE_SLOT_INVALID, MODULE_SLOT_OCCUPIED, MODULE_STORAGE, MODULE_TIER_PREFIXES, MODULE_TYPE_MISMATCH, MODULE_WARP, MassCapability, MintAssetParams, ModuleDescription, ModuleEntry, ModuleType, MovementCapability, index as NFT, NFTCargoItem, NFTCommonBase, NFTInstalledModule, NFTModuleSlot, NO_SCHEDULE, NamedStats, Nexus, NftConfigForItem, NftManager, OwnerSubscriptionHandle, PLANETARY_STRUCTURE_Z, PLANET_SUBTYPE_GAS_GIANT, PLANET_SUBTYPE_ICY, PLANET_SUBTYPE_INDUSTRIAL, PLANET_SUBTYPE_OCEAN, PLANET_SUBTYPE_ROCKY, PLANET_SUBTYPE_TERRESTRIAL, PLAYER_ALREADY_JOINED, PLAYER_NOT_FOUND, PLAYER_NOT_JOINED, PRECISION, PackedModule, PackedModuleInput, PingMessage, PlanetSubtypeInfo, platform as PlatformContract, Types$1 as PlatformTypes, Player, PlayerStateInput, PlayersManager, PongMessage, Projectable, ProjectableSnapshot, ProjectedEntity, ProjectionOptions, RECIPE_INPUTS_EXCESS, RECIPE_INPUTS_INSUFFICIENT, RECIPE_INPUTS_INVALID, RECIPE_INPUTS_MIXED, RECIPE_NOT_FOUND, REQUIRES_MORE_THAN_ONE, REQUIRES_POSITIVE_VALUE, RESERVE_TIERS, RESOLVE_COUNT_EXCEEDS_COMPLETED, RESOURCE_TIER_ADJECTIVES, RawData, Recipe, RecipeInput, RecipeSlotInput, RenderDescriptionOptions, ReserveTier, ResolvedAttributeGroup, ResolvedItem, ResolvedItemStat, ResolvedItemType, ResolvedModuleSlot, ResourceCategory, ResourceStats, SHIPLOAD_COLLECTION, SHIP_ALREADY_TRAVELING, SHIP_CANNOT_BUY_TRAVELING, SHIP_CANNOT_CANCEL_TASK, SHIP_CANNOT_UPDATE_TRAVELING, SHIP_NOT_ARRIVED, SHIP_NOT_FOUND, SHIP_NOT_IDLE, SHIP_NOT_OWNED, SHIP_NO_COMPLETED_TASKS, SHIP_NO_TASKS_TO_CANCEL, SLOT_FORMULAS, ScheduleAccessor, ScheduleCapability, ScheduleData, Scheduleable, SchemaField, server as ServerContract, ServerMessage, Types as ServerTypes, Ship, ShipEntity, ShipLike, Shipload, SlotConsumer, SlotConsumerKind, SnapshotMessage, SourceCargoStack, SourceEntityRef, StackInput, StatDefinition, StatMapping, StatSlot, StorageCapability, StratumInfo, SubscribeEntityMessage, SubscribeEventsMessage, SubscribeMessage, SubscriptionEntityType, SubscriptionsManager, SubscriptionsOptions, TIER_ROLL_MAX, TRAVEL_MAX_DURATION, TaskCancelable, TaskCargoChange, TaskCargoDirection, TaskType, TemplateMeta, TextSpan, TierRange, TransferEntity, UnsubscribeEntityMessage, UnsubscribeEventsMessage, UnsubscribeMessage, UpdateBoundsMessage, UpdateMessage, WAREHOUSE_ALREADY_AT_LOCATION, WAREHOUSE_NOT_FOUND, WARP_HAS_CARGO, WARP_HAS_SCHEDULE, WARP_NOT_FULL_ENERGY, WARP_NO_CAPABILITY, WARP_OUT_OF_RANGE, Warehouse, WarehouseEntity, WebSocketConnection, WebSocketConnectionOptions, WireCoordinates, WireEntity, YIELD_FRACTION_DEEP, YIELD_FRACTION_SHALLOW, allBuildableItems, allPlotBuildableItems, availableBuildMethods, availableCapacity$1 as availableCapacity, availableCapacityFromMass, baseName, blendCargoStacks, blendComponentStacks, blendCrossGroup, blendStacks, buildComponentImmutable, buildEntityDescription, buildEntityImmutable, buildImmutableData, buildMintAssetAction, buildModuleImmutable, buildResourceImmutable, calcCargoItemMass, calcCargoMass, calcEnergyUsage, calcLoadDuration, calcStacksMass, calc_acceleration, calc_craft_duration, calc_craft_energy, calc_energyusage, calc_flighttime, calc_gather_duration, calc_gather_energy, calc_gather_rate, calc_loader_acceleration, calc_loader_flighttime, calc_orbital_altitude, calc_rechargetime, calc_ship_acceleration, calc_ship_flighttime, calc_ship_mass, calc_ship_rechargetime, calc_transfer_duration, calculateFlightTime, calculateLoadTimeBreakdown, calculateRefuelingTime, calculateTransferTime, canMove, capabilityAttributes, capabilityNames, capsHasCrafter, capsHasGatherer, capsHasHauler, capsHasLoaders, capsHasMass, capsHasMovement, capsHasStorage, cargoItem, cargoItemToStack, cargoRef, cargoUtils, cargo_item, categoryColors, categoryFromIndex, categoryIconShapes, categoryIcons, categoryLabel, categoryLabelFromIndex, componentIcon, computeBaseCapacity, computeBaseCapacityShip, computeBaseCapacityWarehouse, computeBaseHullmass, computeComponentStats, computeContainerCapabilities, computeContainerT2Capabilities, computeCraftedOutputStats, computeCrafterCapabilities, computeCrafterDrain, computeCrafterSpeed, computeEngineCapabilities, computeEngineDrain, computeEngineThrust, computeEntityCapabilities, computeEntityStats, computeGathererCapabilities, computeGathererDepth, computeGathererDrain, computeGathererYield, computeGeneratorCap, computeGeneratorCapabilities, computeGeneratorRech, computeHaulPenalty, computeHaulerCapabilities, computeHaulerCapacity, computeHaulerDrain$1 as computeHaulerDrain, computeHaulerEfficiency, computeInputMass, computeLoaderCapabilities, computeLoaderMass, computeLoaderThrust, computeNftImageUrl, computeShipHullCapabilities, computeStorageCapabilities, computeWarehouseHullCapabilities, computeWarpCapabilities, computeWarpRange, coordsToLocationId, createInventoryAccessor, createProjectedEntity, createScheduleAccessor, decodeAtomicAsset, decodeCraftedItemStats, decodeStat, decodeStats, Shipload as default, deriveLocation, deriveLocationSize, deriveLocationStatic, deriveResourceStats, deriveStatMappings, deriveStrata, deriveStratum, describeItem, describeModule, describeModuleForItem, describeModuleForSlot, deserializeAsset, deserializeAtomicData, deserializeComponent, deserializeEntity, deserializeModule, deserializeResource, displayName, distanceBetweenCoordinates, distanceBetweenPoints, easeFlightProgress, encodeGatheredCargoStats, encodeStats, energyPercent, energy_stats, entityDisplayName, entity_row, estimateDealTravelTime, estimateTravelTime, fetchAtomicAssetsForOwner, fetchAtomicSchemas, filterByBuildMethod, findNearbyPlanets, flightSpeedFactor, formatLocation, formatMass, formatMassDelta, formatMassScaled, formatModuleLine, formatTier, gathererDepthForTier, gatherer_stats, getCapabilityAttributes, getCategoryInfo, getComponents, getCurrentEpoch, getDepthThreshold, getDestinationLocation, getEffectiveReserve, getEligibleResources, getEntityClass, getEntityItems, getEntityLayout, getEpochInfo, getFlightOrigin, getInterpolatedPosition, getItem, getItems, getKindMeta, getLocationCandidates, getLocationProfile, getLocationType, getLocationTypeName, getModuleCapabilityType, getModules, getPackedEntityType, getPlanetSubtype, getPlanetSubtypes, getPositionAt, getRecipe, getResourceTier, getResourceWeight, getResources, getStatDefinitions, getStatMappings, getStatMappingsForCapability, getStatMappingsForStat, getStatName, getSystemName, getTemplateMeta, hasEnergy, hasEnergyForDistance, hasGatherer, hasLoaders, hasMass, hasSchedule, hasSpace$1 as hasSpace, hasSpaceForMass, hasStorage, hasSystem, hash, hash512, interpolateFlightPosition, isBuildable, isContainer, isCraftedItem, isExtractor, isFactory, isFull$1 as isFull, isFullFromMass, isGatherableLocation, isInvertedAttribute, isLocationBuildable, isModuleItem, isNexus, isPlot, isPlotBuildable, isRelatedItem, isShip, isSubscriptionsDebugEnabled, isWarehouse, itemAbbreviations, itemCategory, itemIds, itemOffset, itemTier, itemTypeCode, kindCan, lerp, loader_stats, location_derived, location_static, makeEntity, mapEntity, maxTravelDistance, mergeStacks, moduleAccepts, moduleDisplayName, moduleIcon, moduleSlotTypeToCode, movement_stats, needsRecharge, parseWireEntity, projectEntity, projectEntityAt, projectFromCurrentState, projectFromCurrentStateAt, readCommonBase, removeFromStacks, renderDescription, resolveItem, resolveItemCategory, resolveStats, rollTier, rollWithinTier, rotation, schedule, setSubscriptionsDebug, stackKey, stackToCargoItem, stacksEqual, task, taskCargoChanges, tierAdjective, tierColors, tierOfReserve, toLocation, typeLabel, validateSchedule, yieldThresholdAt };
|
|
3852
|
+
export { ALL_ENTITY_TYPES, ATOMICASSETS_ACCOUNT, AckMessage, ActionsManager, AnyEntity, AtomicAssetRow, AtomicAttributeType, AtomicSchemaRow, BASE_ORBITAL_MASS, BLEND_INPUTS_MUST_MATCH, BLEND_REQUIRES_MULTIPLE, BLEND_STAT_LESS_NOT_SUPPORTED, BoundingBox, BoundsDeltaMessage, BoundsSubscriptionHandle, BuildMethod, BuildState, BuildableTarget, CANCEL_CONTAINS_GROUPED_TASK, CANCEL_PAIRED_HAS_PENDING, CAP_DEMOLISH, CAP_MODULES, CAP_UNDEPLOY, CAP_WRAP, CATEGORY_LABELS, COMMIT_ALREADY_SET, COMMIT_CANNOT_MATCH, COMMIT_NOT_SET, COMPANY_NOT_FOUND, COMPONENT_TIER_PREFIXES, CONTAINER_NOT_FOUND, CONTAINER_Z, CRAFT_ENERGY_DIVISOR, CRAFT_EXCEEDS_ENERGY_CAPACITY, CRAFT_NOT_ENOUGH_ENERGY, CapabilityAttribute, CapabilityInput, CargoData, CargoMassInfo, CargoStack, CategoryIconShape, CategoryInfo, CategoryStacks, ClientMessage, ComputedCapabilities, ConnectionState, ConstructionManager, Container, ContainerEntity, Coordinates, CoordinatesType, CraftedItemCategory, CrafterCapability, DEPLOY_ENTITY_HAS_SCHEDULE, DEPTH_THRESHOLD_T1, DEPTH_THRESHOLD_T2, DEPTH_THRESHOLD_T3, DEPTH_THRESHOLD_T4, DEPTH_THRESHOLD_T5, DESTINATION_CAPACITY_EXCEEDED, DecodedAtomicAsset, DerivedStratum, DescribeOptions, Distance, ENTITY_ALREADY_THERE, ENTITY_CAPACITY_EXCEEDED, ENTITY_CARGO_NOT_LOADED, ENTITY_CARGO_NOT_OWNED, ENTITY_CONTAINER, ENTITY_EXTRACTOR, ENTITY_FACTORY, ENTITY_INVALID_CARGO, ENTITY_INVALID_DESTINATION, ENTITY_INVALID_TRAVEL_DURATION, ENTITY_NEXUS, ENTITY_NOT_ENOUGH_ENERGY, ENTITY_NOT_ENOUGH_ENERGY_CAPACITY, ENTITY_NO_CRAFTER, ENTITY_SHIP, ENTITY_WAREHOUSE, EPOCH_NON_ZERO, EPOCH_NOT_READY, ERROR_SYSTEM_ALREADY_INITIALIZED, ERROR_SYSTEM_DISABLED, ERROR_SYSTEM_NOT_INITIALIZED, EffectiveReserveInput, EnergyCapability, EntitiesManager, Entity$1 as Entity, EntityCapabilities, EntityClass, EntityInfo, EntityInstance, EntityInventory, EntityLayout, EntityRefInput, EntitySlot, EntityState, EntityStateInput, EntitySubscriptionHandle, EntityTypeName, EpochInfo, EpochsManager, ErrorMessage, EstimateTravelTimeOptions, EstimatedTravelTime, EventCatchupCompleteMessage, EventMessage, Extractor, Factory, FetchAssetsOptions, FinalizerCapability, FinalizerEntityRef, FloatPosition, GAME_NOT_FOUND, GAME_SEED_NOT_SET, GATHERER_DEPTH_MAX_TIER, GATHERER_DEPTH_TABLE, GATHER_EXCEEDS_ENERGY_CAPACITY, GATHER_NOT_ENOUGH_ENERGY, GROUP_DUPLICATE_ENTITY, GROUP_EMPTY, GROUP_ENTITY_NOT_MOVABLE, GROUP_HAUL_CAPACITY_EXCEEDED, GROUP_NOT_FOUND, GROUP_NOT_SAME_LOCATION, GROUP_NOT_SAME_OWNER, GROUP_NO_THRUST, GameState, GathererCapability, GathererDepthParams, HasCapacity, HasCargo, HasCargomass, HasScheduleAndLocation, INSUFFICIENT_BALANCE, INSUFFICIENT_ITEM_QUANTITY, INSUFFICIENT_ITEM_SUPPLY, INVALID_AMOUNT, ITEM_BATTERY_T1, ITEM_BEAM, ITEM_BIOMASS_T1, ITEM_BIOMASS_T10, ITEM_BIOMASS_T2, ITEM_BIOMASS_T3, ITEM_BIOMASS_T4, ITEM_BIOMASS_T5, ITEM_BIOMASS_T6, ITEM_BIOMASS_T7, ITEM_BIOMASS_T8, ITEM_BIOMASS_T9, ITEM_CERAMIC, ITEM_CONTAINER_T1_PACKED, ITEM_CONTAINER_T2_PACKED, ITEM_CRAFTER_T1, ITEM_CRYSTAL_T1, ITEM_CRYSTAL_T10, ITEM_CRYSTAL_T2, ITEM_CRYSTAL_T3, ITEM_CRYSTAL_T4, ITEM_CRYSTAL_T5, ITEM_CRYSTAL_T6, ITEM_CRYSTAL_T7, ITEM_CRYSTAL_T8, ITEM_CRYSTAL_T9, ITEM_DOES_NOT_EXIST, ITEM_EMITTER, ITEM_ENGINE_T1, ITEM_EXTRACTOR_T1_PACKED, ITEM_FACTORY_T1_PACKED, ITEM_FRAME, ITEM_FRAME_T2, ITEM_GAS_T1, ITEM_GAS_T10, ITEM_GAS_T2, ITEM_GAS_T3, ITEM_GAS_T4, ITEM_GAS_T5, ITEM_GAS_T6, ITEM_GAS_T7, ITEM_GAS_T8, ITEM_GAS_T9, ITEM_GATHERER_T1, ITEM_GENERATOR_T1, ITEM_HAULER_T1, ITEM_LOADER_T1, ITEM_NOT_AVAILABLE_AT_LOCATION, ITEM_NOT_DEPLOYABLE, ITEM_NOT_PACKED_ENTITY, ITEM_ORE_T1, ITEM_ORE_T10, ITEM_ORE_T2, ITEM_ORE_T3, ITEM_ORE_T4, ITEM_ORE_T5, ITEM_ORE_T6, ITEM_ORE_T7, ITEM_ORE_T8, ITEM_ORE_T9, ITEM_PLASMA_CELL, ITEM_PLATE, ITEM_PLATE_T2, ITEM_POLYMER, ITEM_REACTOR, ITEM_REGOLITH_T1, ITEM_REGOLITH_T10, ITEM_REGOLITH_T2, ITEM_REGOLITH_T3, ITEM_REGOLITH_T4, ITEM_REGOLITH_T5, ITEM_REGOLITH_T6, ITEM_REGOLITH_T7, ITEM_REGOLITH_T8, ITEM_REGOLITH_T9, ITEM_RESONATOR, ITEM_SENSOR, ITEM_SHIP_T1_PACKED, ITEM_STORAGE_T1, ITEM_TYPE_COMPONENT, ITEM_TYPE_ENTITY, ITEM_TYPE_MODULE, ITEM_TYPE_RESOURCE, ITEM_WAREHOUSE_T1_PACKED, ITEM_WARP_T1, ImmutableEntry, ImmutableModuleSlot, InboundTransfer, InstalledModule, InventoryAccessor, Item, ItemType, KindMeta, LOCATION_MAX_DEPTH, LOCATION_MIN_DEPTH, LoadTimeBreakdown, LoaderCapability, Location, LocationStratum, LocationType, LocationsManager, MAX_ORBITAL_ALTITUDE, MIN_ORBITAL_ALTITUDE, MIN_TRANSFER_DISTANCE, MODULE_ANY, MODULE_BATTERY, MODULE_CARGO_NOT_FOUND, MODULE_CRAFTER, MODULE_ENGINE, MODULE_ENTITY_BUSY, MODULE_GATHERER, MODULE_GENERATOR, MODULE_HAULER, MODULE_LAUNCHER, MODULE_LOADER, MODULE_NOT_MODULE, MODULE_SLOT_EMPTY, MODULE_SLOT_INVALID, MODULE_SLOT_OCCUPIED, MODULE_STORAGE, MODULE_TIER_PREFIXES, MODULE_TYPE_MISMATCH, MODULE_WARP, MassCapability, MintAssetParams, ModuleDescription, ModuleEntry, ModuleType, MovementCapability, index as NFT, NFTCargoItem, NFTCommonBase, NFTInstalledModule, NFTModuleSlot, NO_SCHEDULE, NamedStats, Nexus, NftConfigForItem, NftManager, OwnerSubscriptionHandle, PLANETARY_STRUCTURE_Z, PLANET_SUBTYPE_GAS_GIANT, PLANET_SUBTYPE_ICY, PLANET_SUBTYPE_INDUSTRIAL, PLANET_SUBTYPE_OCEAN, PLANET_SUBTYPE_ROCKY, PLANET_SUBTYPE_TERRESTRIAL, PLAYER_ALREADY_JOINED, PLAYER_NOT_FOUND, PLAYER_NOT_JOINED, PRECISION, PackedModule, PackedModuleInput, PingMessage, PlanetSubtypeInfo, platform as PlatformContract, Types$1 as PlatformTypes, Player, PlayerStateInput, PlayersManager, PongMessage, Projectable, ProjectableSnapshot, ProjectedEntity, ProjectionOptions, RECIPE_INPUTS_EXCESS, RECIPE_INPUTS_INSUFFICIENT, RECIPE_INPUTS_INVALID, RECIPE_INPUTS_MIXED, RECIPE_NOT_FOUND, REQUIRES_MORE_THAN_ONE, REQUIRES_POSITIVE_VALUE, RESERVE_TIERS, RESOLVE_COUNT_EXCEEDS_COMPLETED, RESOURCE_TIER_ADJECTIVES, RawData, Recipe, RecipeInput, RecipeSlotInput, RenderDescriptionOptions, Reservation, ReserveTier, ResolvedAttributeGroup, ResolvedItem, ResolvedItemStat, ResolvedItemType, ResolvedModuleSlot, ResourceCategory, ResourceStats, SHIPLOAD_COLLECTION, SHIP_ALREADY_TRAVELING, SHIP_CANNOT_BUY_TRAVELING, SHIP_CANNOT_CANCEL_TASK, SHIP_CANNOT_UPDATE_TRAVELING, SHIP_NOT_ARRIVED, SHIP_NOT_FOUND, SHIP_NOT_IDLE, SHIP_NOT_OWNED, SHIP_NO_COMPLETED_TASKS, SHIP_NO_TASKS_TO_CANCEL, SLOT_FORMULAS, ScheduleAccessor, ScheduleCapability, ScheduleData, Scheduleable, SchemaField, server as ServerContract, ServerMessage, Types as ServerTypes, Ship, ShipEntity, ShipLike, Shipload, SlotConsumer, SlotConsumerKind, SnapshotMessage, SourceCargoStack, SourceEntityRef, StackInput, StatDefinition, StatMapping, StatSlot, StorageCapability, StratumInfo, SubscribeEntityMessage, SubscribeEventsMessage, SubscribeMessage, SubscriptionEntityType, SubscriptionsManager, SubscriptionsOptions, TIER_ROLL_MAX, TRAVEL_MAX_DURATION, TaskCancelable, TaskCargoChange, TaskCargoDirection, TaskType, TemplateMeta, TextSpan, TierRange, TransferEntity, UnsubscribeEntityMessage, UnsubscribeEventsMessage, UnsubscribeMessage, UpdateBoundsMessage, UpdateMessage, WAREHOUSE_ALREADY_AT_LOCATION, WAREHOUSE_NOT_FOUND, WARP_HAS_CARGO, WARP_HAS_SCHEDULE, WARP_NOT_FULL_ENERGY, WARP_NO_CAPABILITY, WARP_OUT_OF_RANGE, Warehouse, WarehouseEntity, WebSocketConnection, WebSocketConnectionOptions, WireCoordinates, WireEntity, YIELD_FRACTION_DEEP, YIELD_FRACTION_SHALLOW, allBuildableItems, allPlotBuildableItems, availableBuildMethods, availableCapacity$1 as availableCapacity, availableCapacityFromMass, baseName, blendCargoStacks, blendComponentStacks, blendCrossGroup, blendStacks, buildComponentImmutable, buildEntityDescription, buildEntityImmutable, buildImmutableData, buildMintAssetAction, buildModuleImmutable, buildResourceImmutable, calcCargoItemMass, calcCargoMass, calcEnergyUsage, calcLoadDuration, calcStacksMass, calc_acceleration, calc_craft_duration, calc_craft_energy, calc_energyusage, calc_flighttime, calc_gather_duration, calc_gather_energy, calc_gather_rate, calc_loader_acceleration, calc_loader_flighttime, calc_orbital_altitude, calc_rechargetime, calc_ship_acceleration, calc_ship_flighttime, calc_ship_mass, calc_ship_rechargetime, calc_transfer_duration, calculateFlightTime, calculateLoadTimeBreakdown, calculateRefuelingTime, calculateTransferTime, canMove, capabilityAttributes, capabilityNames, capsHasCrafter, capsHasGatherer, capsHasHauler, capsHasLoaders, capsHasMass, capsHasMovement, capsHasStorage, cargoItem, cargoItemToStack, cargoRef, cargoUtils, cargo_item, categoryColors, categoryFromIndex, categoryIconShapes, categoryIcons, categoryLabel, categoryLabelFromIndex, componentIcon, computeBaseCapacity, computeBaseCapacityShip, computeBaseCapacityWarehouse, computeBaseHullmass, computeComponentStats, computeContainerCapabilities, computeContainerT2Capabilities, computeCraftedOutputStats, computeCrafterCapabilities, computeCrafterDrain, computeCrafterSpeed, computeEngineCapabilities, computeEngineDrain, computeEngineThrust, computeEntityCapabilities, computeEntityStats, computeGathererCapabilities, computeGathererDepth, computeGathererDrain, computeGathererYield, computeGeneratorCap, computeGeneratorCapabilities, computeGeneratorRech, computeHaulPenalty, computeHaulerCapabilities, computeHaulerCapacity, computeHaulerDrain$1 as computeHaulerDrain, computeHaulerEfficiency, computeInputMass, computeLoaderCapabilities, computeLoaderMass, computeLoaderThrust, computeNftImageUrl, computeShipHullCapabilities, computeStorageCapabilities, computeWarehouseHullCapabilities, computeWarpCapabilities, computeWarpRange, coordsToLocationId, createInventoryAccessor, createProjectedEntity, createScheduleAccessor, decodeAtomicAsset, decodeCraftedItemStats, decodeStat, decodeStats, Shipload as default, deriveLocation, deriveLocationSize, deriveLocationStatic, deriveResourceStats, deriveStatMappings, deriveStrata, deriveStratum, describeItem, describeModule, describeModuleForItem, describeModuleForSlot, deserializeAsset, deserializeAtomicData, deserializeComponent, deserializeEntity, deserializeModule, deserializeResource, displayName, distanceBetweenCoordinates, distanceBetweenPoints, easeFlightProgress, encodeGatheredCargoStats, encodeStats, energyAtTime, energyPercent, energy_stats, entityDisplayName, entity_row, estimateDealTravelTime, estimateTravelTime, fetchAtomicAssetsForOwner, fetchAtomicSchemas, filterByBuildMethod, findNearbyPlanets, flightSpeedFactor, formatLocation, formatMass, formatMassDelta, formatMassScaled, formatModuleLine, formatTier, gathererDepthForTier, gatherer_stats, getCapabilityAttributes, getCategoryInfo, getComponents, getCurrentEpoch, getDepthThreshold, getDestinationLocation, getEffectiveReserve, getEligibleResources, getEntityClass, getEntityItems, getEntityLayout, getEpochInfo, getFlightOrigin, getInterpolatedPosition, getItem, getItems, getKindMeta, getLocationCandidates, getLocationProfile, getLocationType, getLocationTypeName, getModuleCapabilityType, getModules, getPackedEntityType, getPlanetSubtype, getPlanetSubtypes, getPositionAt, getRecipe, getResourceTier, getResourceWeight, getResources, getStatDefinitions, getStatMappings, getStatMappingsForCapability, getStatMappingsForStat, getStatName, getSystemName, getTemplateMeta, hasEnergy, hasEnergyForDistance, hasGatherer, hasLoaders, hasMass, hasSchedule, hasSpace$1 as hasSpace, hasSpaceForMass, hasStorage, hasSystem, hash, hash512, interpolateFlightPosition, isBuildable, isContainer, isCraftedItem, isExtractor, isFactory, isFull$1 as isFull, isFullFromMass, isGatherableLocation, isInvertedAttribute, isLocationBuildable, isModuleItem, isNexus, isPlot, isPlotBuildable, isRelatedItem, isShip, isSubscriptionsDebugEnabled, isWarehouse, itemAbbreviations, itemCategory, itemIds, itemOffset, itemTier, itemTypeCode, kindCan, lerp, loader_stats, location_derived, location_static, makeEntity, mapEntity, maxTravelDistance, mergeStacks, moduleAccepts, moduleDisplayName, moduleIcon, moduleSlotTypeToCode, movement_stats, needsRecharge, parseWireEntity, projectEntity, projectEntityAt, projectFromCurrentState, projectFromCurrentStateAt, readCommonBase, removeFromStacks, renderDescription, resolveItem, resolveItemCategory, resolveStats, rollTier, rollWithinTier, rotation, schedule, setSubscriptionsDebug, stackKey, stackToCargoItem, stacksEqual, task, taskCargoChanges, tierAdjective, tierColors, tierOfReserve, toLocation, typeLabel, validateSchedule, yieldThresholdAt };
|
package/lib/shipload.js
CHANGED
|
@@ -10730,6 +10730,72 @@ class ConstructionManager extends BaseManager {
|
|
|
10730
10730
|
}
|
|
10731
10731
|
return out.sort((a, b) => a.estimatedDuration.value - b.estimatedDuration.value);
|
|
10732
10732
|
}
|
|
10733
|
+
inboundTransfersTo(plotId, entities, now) {
|
|
10734
|
+
return this.inboundTransfersByTarget(entities, now).get(plotId.toString()) ?? [];
|
|
10735
|
+
}
|
|
10736
|
+
inboundTransfersByTarget(entities, now) {
|
|
10737
|
+
const buckets = new Map();
|
|
10738
|
+
const nowMs = now.getTime();
|
|
10739
|
+
for (const entity of entities) {
|
|
10740
|
+
const schedule = entity.schedule;
|
|
10741
|
+
if (!schedule)
|
|
10742
|
+
continue;
|
|
10743
|
+
const entityIdStr = entity.id.toString();
|
|
10744
|
+
const sourceName = entity.entity_name || entityIdStr;
|
|
10745
|
+
const startedMs = schedule.started.toDate().getTime();
|
|
10746
|
+
let cumulativeSec = 0;
|
|
10747
|
+
for (const task of schedule.tasks) {
|
|
10748
|
+
cumulativeSec += task.duration.toNumber();
|
|
10749
|
+
if (!isTransferTask(task))
|
|
10750
|
+
continue;
|
|
10751
|
+
if (!task.entitytarget)
|
|
10752
|
+
continue;
|
|
10753
|
+
const projectedEndMs = startedMs + cumulativeSec * 1000;
|
|
10754
|
+
if (projectedEndMs < nowMs)
|
|
10755
|
+
continue;
|
|
10756
|
+
const targetIdStr = task.entitytarget.entity_id.toString();
|
|
10757
|
+
const etaSeconds = Math.max(0, Math.round((projectedEndMs - nowMs) / 1000));
|
|
10758
|
+
let perTarget = buckets.get(targetIdStr);
|
|
10759
|
+
if (!perTarget) {
|
|
10760
|
+
perTarget = new Map();
|
|
10761
|
+
buckets.set(targetIdStr, perTarget);
|
|
10762
|
+
}
|
|
10763
|
+
for (const c of task.cargo) {
|
|
10764
|
+
const itemId = c.item_id.toNumber();
|
|
10765
|
+
const quantity = c.quantity.toNumber();
|
|
10766
|
+
if (quantity === 0)
|
|
10767
|
+
continue;
|
|
10768
|
+
const key = `${entityIdStr}#${itemId}`;
|
|
10769
|
+
const existing = perTarget.get(key);
|
|
10770
|
+
if (existing) {
|
|
10771
|
+
existing.quantity += quantity;
|
|
10772
|
+
existing.etaSeconds = Math.min(existing.etaSeconds, etaSeconds);
|
|
10773
|
+
}
|
|
10774
|
+
else {
|
|
10775
|
+
perTarget.set(key, {
|
|
10776
|
+
sourceEntityId: entity.id,
|
|
10777
|
+
sourceEntityType: entity.type,
|
|
10778
|
+
sourceName,
|
|
10779
|
+
itemId,
|
|
10780
|
+
quantity,
|
|
10781
|
+
etaSeconds,
|
|
10782
|
+
});
|
|
10783
|
+
}
|
|
10784
|
+
}
|
|
10785
|
+
}
|
|
10786
|
+
}
|
|
10787
|
+
const out = new Map();
|
|
10788
|
+
for (const [targetId, perTarget] of buckets) {
|
|
10789
|
+
out.set(targetId, Array.from(perTarget.values()));
|
|
10790
|
+
}
|
|
10791
|
+
return out;
|
|
10792
|
+
}
|
|
10793
|
+
reservationsFrom(sourceEntityId, entities) {
|
|
10794
|
+
const source = entities.find((e) => e.id.equals(sourceEntityId));
|
|
10795
|
+
if (!source)
|
|
10796
|
+
return [];
|
|
10797
|
+
return reservationsOf(source);
|
|
10798
|
+
}
|
|
10733
10799
|
estimateFinalizeDuration(target, crafterSpeed) {
|
|
10734
10800
|
return calc_craft_duration(crafterSpeed, target.progress.massRequired);
|
|
10735
10801
|
}
|
|
@@ -10740,26 +10806,49 @@ class ConstructionManager extends BaseManager {
|
|
|
10740
10806
|
function coordsEqual(a, b) {
|
|
10741
10807
|
return a.x.equals(b.x) && a.y.equals(b.y);
|
|
10742
10808
|
}
|
|
10743
|
-
function
|
|
10744
|
-
const
|
|
10809
|
+
function moduleKey(module) {
|
|
10810
|
+
const installed = module.installed;
|
|
10811
|
+
if (!installed)
|
|
10812
|
+
return `${module.type.toNumber()}:empty`;
|
|
10813
|
+
return `${module.type.toNumber()}:${installed.item_id.toNumber()}:${installed.stats.toString()}`;
|
|
10814
|
+
}
|
|
10815
|
+
function sourceStackKey(cargo) {
|
|
10816
|
+
return `${cargo.item_id.toNumber()}#${cargo.stats.toString()}#${(cargo.modules ?? [])
|
|
10817
|
+
.map(moduleKey)
|
|
10818
|
+
.join(',')}`;
|
|
10819
|
+
}
|
|
10820
|
+
function matchRelevantCargo(entity, target, cargo, reservedByItem) {
|
|
10821
|
+
const needsByItemId = new Map(target.progress.rows.filter((row) => row.missing > 0).map((row) => [row.itemId, row]));
|
|
10822
|
+
const remainingReserved = new Map(reservedByItem);
|
|
10823
|
+
const out = [];
|
|
10745
10824
|
for (const c of cargo) {
|
|
10746
10825
|
if (!c.entity_id.equals(entity.id))
|
|
10747
10826
|
continue;
|
|
10748
|
-
const
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
if (
|
|
10827
|
+
const itemId = c.item_id.toNumber();
|
|
10828
|
+
const need = needsByItemId.get(itemId);
|
|
10829
|
+
if (!need)
|
|
10830
|
+
continue;
|
|
10831
|
+
const gross = c.quantity.toNumber();
|
|
10832
|
+
if (gross === 0)
|
|
10754
10833
|
continue;
|
|
10755
|
-
const
|
|
10834
|
+
const reservedRemaining = remainingReserved.get(itemId) ?? 0;
|
|
10835
|
+
const reserved = Math.min(gross, reservedRemaining);
|
|
10836
|
+
const available = gross - reserved;
|
|
10837
|
+
if (reserved > 0) {
|
|
10838
|
+
remainingReserved.set(itemId, reservedRemaining - reserved);
|
|
10839
|
+
}
|
|
10756
10840
|
if (available === 0)
|
|
10757
10841
|
continue;
|
|
10758
10842
|
out.push({
|
|
10759
|
-
|
|
10760
|
-
|
|
10843
|
+
key: sourceStackKey(c),
|
|
10844
|
+
rowId: c.id,
|
|
10845
|
+
itemId,
|
|
10846
|
+
item: getItem(itemId),
|
|
10847
|
+
stats: c.stats,
|
|
10848
|
+
modules: c.modules ?? [],
|
|
10761
10849
|
available,
|
|
10762
|
-
plotNeeds:
|
|
10850
|
+
plotNeeds: need.missing,
|
|
10851
|
+
reserved,
|
|
10763
10852
|
});
|
|
10764
10853
|
}
|
|
10765
10854
|
return out;
|
|
@@ -10774,7 +10863,8 @@ function partitionSources(target, entities, cargo) {
|
|
|
10774
10863
|
continue;
|
|
10775
10864
|
if (!coordsEqual(entity.coordinates, target.coordinates))
|
|
10776
10865
|
continue;
|
|
10777
|
-
const
|
|
10866
|
+
const reserved = reservedByItemFor(entity);
|
|
10867
|
+
const relevant = matchRelevantCargo(entity, target, cargo, reserved);
|
|
10778
10868
|
if (relevant.length === 0)
|
|
10779
10869
|
continue;
|
|
10780
10870
|
const loaderCount = entity.loaders?.quantity.toNumber() ?? 0;
|
|
@@ -10794,6 +10884,50 @@ function partitionSources(target, entities, cargo) {
|
|
|
10794
10884
|
}
|
|
10795
10885
|
return { eligible, unreachable };
|
|
10796
10886
|
}
|
|
10887
|
+
function isTransferTask(task) {
|
|
10888
|
+
const type = task.type.toNumber();
|
|
10889
|
+
return type === exports.TaskType.LOAD || type === exports.TaskType.UNLOAD;
|
|
10890
|
+
}
|
|
10891
|
+
function reservationsOf(source) {
|
|
10892
|
+
if (!source.schedule)
|
|
10893
|
+
return [];
|
|
10894
|
+
const out = new Map();
|
|
10895
|
+
for (const task of source.schedule.tasks) {
|
|
10896
|
+
if (!isTransferTask(task))
|
|
10897
|
+
continue;
|
|
10898
|
+
if (!task.entitytarget)
|
|
10899
|
+
continue;
|
|
10900
|
+
const targetType = task.entitytarget.entity_type;
|
|
10901
|
+
const targetId = task.entitytarget.entity_id;
|
|
10902
|
+
for (const c of task.cargo) {
|
|
10903
|
+
const itemId = c.item_id.toNumber();
|
|
10904
|
+
const quantity = c.quantity.toNumber();
|
|
10905
|
+
if (quantity === 0)
|
|
10906
|
+
continue;
|
|
10907
|
+
const key = `${targetId.toString()}#${itemId}`;
|
|
10908
|
+
const existing = out.get(key);
|
|
10909
|
+
if (existing) {
|
|
10910
|
+
existing.quantity += quantity;
|
|
10911
|
+
}
|
|
10912
|
+
else {
|
|
10913
|
+
out.set(key, {
|
|
10914
|
+
targetEntityId: targetId,
|
|
10915
|
+
targetEntityType: targetType,
|
|
10916
|
+
itemId,
|
|
10917
|
+
quantity,
|
|
10918
|
+
});
|
|
10919
|
+
}
|
|
10920
|
+
}
|
|
10921
|
+
}
|
|
10922
|
+
return Array.from(out.values());
|
|
10923
|
+
}
|
|
10924
|
+
function reservedByItemFor(source) {
|
|
10925
|
+
const out = new Map();
|
|
10926
|
+
for (const r of reservationsOf(source)) {
|
|
10927
|
+
out.set(r.itemId, (out.get(r.itemId) ?? 0) + r.quantity);
|
|
10928
|
+
}
|
|
10929
|
+
return out;
|
|
10930
|
+
}
|
|
10797
10931
|
|
|
10798
10932
|
function totalCargoMass(cargo) {
|
|
10799
10933
|
return cargo.reduce((sum, c) => {
|
|
@@ -11102,25 +11236,20 @@ function applyRechargeTask(projected, _task, options) {
|
|
|
11102
11236
|
}
|
|
11103
11237
|
}
|
|
11104
11238
|
function applyFlightTask(projected, task, options) {
|
|
11105
|
-
if (!task.coordinates
|
|
11239
|
+
if (!task.coordinates)
|
|
11106
11240
|
return;
|
|
11107
|
-
const origin = projected.location;
|
|
11108
11241
|
const destination = Coordinates.from(task.coordinates);
|
|
11109
|
-
const distance = distanceBetweenCoordinates(origin, task.coordinates);
|
|
11110
|
-
const energyUsage = distance.dividing(PRECISION$1).multiplying(projected.engines.drain);
|
|
11111
11242
|
if (options.complete) {
|
|
11112
|
-
projected
|
|
11113
|
-
? antelope.UInt16.from(projected.energy.subtracting(energyUsage))
|
|
11114
|
-
: antelope.UInt16.from(0);
|
|
11243
|
+
applyEnergyCost(projected, task);
|
|
11115
11244
|
projected.location = destination;
|
|
11116
11245
|
}
|
|
11117
11246
|
else if (options.progress !== undefined) {
|
|
11118
|
-
const interpolated = lerp$1(
|
|
11247
|
+
const interpolated = lerp$1(projected.location, destination, options.progress);
|
|
11119
11248
|
projected.location = Coordinates.from({
|
|
11120
11249
|
x: Math.round(interpolated.x),
|
|
11121
11250
|
y: Math.round(interpolated.y),
|
|
11122
11251
|
});
|
|
11123
|
-
const partialEnergy = antelope.UInt64.from(Math.floor(Number(
|
|
11252
|
+
const partialEnergy = antelope.UInt64.from(Math.floor(Number(task.energy_cost ?? 0) * options.progress));
|
|
11124
11253
|
projected.energy = projected.energy.gt(partialEnergy)
|
|
11125
11254
|
? antelope.UInt16.from(projected.energy.subtracting(partialEnergy))
|
|
11126
11255
|
: antelope.UInt16.from(0);
|
|
@@ -11179,6 +11308,7 @@ function applyTask(projected, task) {
|
|
|
11179
11308
|
applyRechargeTask(projected, task, { complete: true });
|
|
11180
11309
|
break;
|
|
11181
11310
|
case exports.TaskType.TRAVEL:
|
|
11311
|
+
case exports.TaskType.WARP:
|
|
11182
11312
|
applyFlightTask(projected, task, { complete: true });
|
|
11183
11313
|
break;
|
|
11184
11314
|
case exports.TaskType.LOAD:
|
|
@@ -11331,6 +11461,7 @@ function projectEntityAt(entity, now) {
|
|
|
11331
11461
|
applyRechargeTask(projected, task, { complete: taskComplete, progress });
|
|
11332
11462
|
break;
|
|
11333
11463
|
case exports.TaskType.TRAVEL:
|
|
11464
|
+
case exports.TaskType.WARP:
|
|
11334
11465
|
applyFlightTask(projected, task, { complete: taskComplete, progress });
|
|
11335
11466
|
break;
|
|
11336
11467
|
case exports.TaskType.LOAD:
|
|
@@ -11397,6 +11528,38 @@ function taskCargoChanges(task) {
|
|
|
11397
11528
|
}
|
|
11398
11529
|
}
|
|
11399
11530
|
|
|
11531
|
+
function energyAtTime(entity, now) {
|
|
11532
|
+
const projected = createProjectedEntity(entity);
|
|
11533
|
+
const capacity = projected.generator ? Number(projected.generator.capacity) : undefined;
|
|
11534
|
+
const clamp = (value) => {
|
|
11535
|
+
const floored = Math.max(0, value);
|
|
11536
|
+
return capacity !== undefined ? Math.min(capacity, floored) : floored;
|
|
11537
|
+
};
|
|
11538
|
+
let running = Number(projected.energy);
|
|
11539
|
+
const tasks = entity.schedule?.tasks;
|
|
11540
|
+
if (!tasks || tasks.length === 0)
|
|
11541
|
+
return clamp(running);
|
|
11542
|
+
const activeIndex = currentTaskIndex(entity, now);
|
|
11543
|
+
const activeProgress = currentTaskProgressFloat(entity, now);
|
|
11544
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
11545
|
+
const complete = isTaskComplete(entity, i, now);
|
|
11546
|
+
if (!complete && i !== activeIndex)
|
|
11547
|
+
break;
|
|
11548
|
+
const fraction = complete ? 1 : activeProgress;
|
|
11549
|
+
if (tasks[i].type.toNumber() === exports.TaskType.RECHARGE) {
|
|
11550
|
+
if (capacity !== undefined) {
|
|
11551
|
+
running = complete ? capacity : running + (capacity - running) * fraction;
|
|
11552
|
+
}
|
|
11553
|
+
}
|
|
11554
|
+
else {
|
|
11555
|
+
const cost = Number(tasks[i].energy_cost ?? 0);
|
|
11556
|
+
running -= cost * fraction;
|
|
11557
|
+
}
|
|
11558
|
+
running = clamp(running);
|
|
11559
|
+
}
|
|
11560
|
+
return clamp(running);
|
|
11561
|
+
}
|
|
11562
|
+
|
|
11400
11563
|
function canMove(e) {
|
|
11401
11564
|
return 'engines' in e && 'generator' in e && 'energy' in e;
|
|
11402
11565
|
}
|
|
@@ -13474,6 +13637,7 @@ exports.distanceBetweenPoints = distanceBetweenPoints;
|
|
|
13474
13637
|
exports.easeFlightProgress = easeFlightProgress;
|
|
13475
13638
|
exports.encodeGatheredCargoStats = encodeGatheredCargoStats;
|
|
13476
13639
|
exports.encodeStats = encodeStats;
|
|
13640
|
+
exports.energyAtTime = energyAtTime;
|
|
13477
13641
|
exports.energyPercent = energyPercent;
|
|
13478
13642
|
exports.entityDisplayName = entityDisplayName;
|
|
13479
13643
|
exports.estimateDealTravelTime = estimateDealTravelTime;
|