refactor: eksponér stations- og niveau-opslag til runs-controller
This commit is contained in:
@@ -51,7 +51,7 @@ local function getAutoDriveEnv()
|
||||
return nil
|
||||
end
|
||||
|
||||
local function getFarmId(vehicle)
|
||||
function ADSmartPickup.getFarmId(vehicle)
|
||||
if vehicle.getOwnerFarmId ~= nil then
|
||||
local farmId = vehicle:getOwnerFarmId()
|
||||
if farmId ~= nil and farmId > 0 then
|
||||
@@ -63,6 +63,7 @@ local function getFarmId(vehicle)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
local getFarmId = ADSmartPickup.getFarmId
|
||||
|
||||
local function getWantedFillTypes(driver)
|
||||
local wanted = {}
|
||||
@@ -148,10 +149,21 @@ local function getUnloadStationAtMarker(adEnv, wayPoint, farmId)
|
||||
return getClosestStation(adEnv, g_currentMission.storageSystem:getUnloadingStations(), "unloadTriggers", UNLOAD_TRIGGER_NODE_FIELDS, wayPoint, farmId)
|
||||
end
|
||||
|
||||
-- Station ved et AutoDrive-waypoint (bruges af runs-controlleren og læs-byttet); nil uden station.
|
||||
function ADSmartPickup.getLoadStationAtWayPointId(adEnv, wayPointId, farmId)
|
||||
local wayPoint = adEnv.ADGraphManager:getWayPointById(wayPointId)
|
||||
return wayPoint ~= nil and getLoadStationAtMarker(adEnv, wayPoint, farmId) or nil
|
||||
end
|
||||
|
||||
function ADSmartPickup.getUnloadStationAtWayPointId(adEnv, wayPointId, farmId)
|
||||
local wayPoint = adEnv.ADGraphManager:getWayPointById(wayPointId)
|
||||
return wayPoint ~= nil and getUnloadStationAtMarker(adEnv, wayPoint, farmId) or nil
|
||||
end
|
||||
|
||||
-- Siloens EGET indhold. Udvidelses-siloer (isExtension) deler lager med naboer
|
||||
-- inden for storageRadius, så stationens niveau er en nabo-sum — eget lager er
|
||||
-- det tal spilleren ser på siloen og giver en præcis "mindst først"-rangering.
|
||||
local function getOwnStorageLevel(station, fillTypes)
|
||||
function ADSmartPickup.getOwnStorageLevel(station, fillTypes)
|
||||
local placeable = station.owningPlaceable
|
||||
local storages = placeable ~= nil and placeable.spec_silo ~= nil and placeable.spec_silo.storages or nil
|
||||
if storages == nil then
|
||||
@@ -165,6 +177,7 @@ local function getOwnStorageLevel(station, fillTypes)
|
||||
end
|
||||
return total
|
||||
end
|
||||
local getOwnStorageLevel = ADSmartPickup.getOwnStorageLevel
|
||||
|
||||
-- Returnerer niveau + om det er siloens eget lager (true) eller kun nabo-lagre (false).
|
||||
local function getStationFillLevel(station, fillTypes, farmId)
|
||||
@@ -358,7 +371,7 @@ local function isFillTypeAccepted(station, husbandry, fillType)
|
||||
end
|
||||
|
||||
-- Niveau + kapacitet for én vare i aflæsningsmålet; nil hvis målet ikke tager varen.
|
||||
local function getTargetLevelAndCapacity(station, fillType, farmId)
|
||||
function ADSmartPickup.getStationLevelAndCapacity(station, fillType, farmId)
|
||||
local husbandry = getHusbandry(station)
|
||||
if not isFillTypeAccepted(station, husbandry, fillType) then
|
||||
return nil
|
||||
@@ -378,6 +391,7 @@ local function getTargetLevelAndCapacity(station, fillType, farmId)
|
||||
end
|
||||
return level, level + freeSpace
|
||||
end
|
||||
local getTargetLevelAndCapacity = ADSmartPickup.getStationLevelAndCapacity
|
||||
|
||||
-- Niveau + kapacitet pr. ingrediens i aflæsningsmålets lager; demand giver forbrug/min.
|
||||
local function getTargetNeeds(station, ingredients, farmId, demand)
|
||||
|
||||
Reference in New Issue
Block a user