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)
|
||||
|
||||
@@ -699,6 +699,17 @@ listener:update(16)
|
||||
FS25_AutoDrive.LoadAtDestinationTask.update(stopperTask, 16)
|
||||
check("L7 greb ryddet når AD stopper", stopperTask.seenRotate, RT_ONLYPICKUP)
|
||||
|
||||
-- ==== E: eksponerede opslag (bruges af runs-controller og læs-bytte) ====
|
||||
local eDriver = buildCowWorld()
|
||||
check("E1 aflæsningsstation ved waypoint", ADSmartPickup.getUnloadStationAtWayPointId(FS25_AutoDrive, 30, 1), unloadStations[1])
|
||||
check("E1 ukendt waypoint -> nil", ADSmartPickup.getUnloadStationAtWayPointId(FS25_AutoDrive, 9999, 1), nil)
|
||||
check("E2 læssestation ved waypoint", ADSmartPickup.getLoadStationAtWayPointId(FS25_AutoDrive, 21, 1), stations[2])
|
||||
local eLevel, eCapacity = ADSmartPickup.getStationLevelAndCapacity(unloadStations[1], TMR, 1)
|
||||
check("E3 niveau i målet", eLevel, 40000)
|
||||
check("E3 kapacitet i målet", eCapacity, 100000)
|
||||
check("E3 vare målet ikke tager -> nil", ADSmartPickup.getStationLevelAndCapacity(unloadStations[1], MILK, 1), nil)
|
||||
check("E3 farmId", ADSmartPickup.getFarmId(eDriver), 1)
|
||||
|
||||
-- L6: samme valg logges kun én gang
|
||||
resetWorld()
|
||||
addMarker(1, "Silo 1", "Siloer", 0, 0); table.insert(stations, makeStation(101, 0, 15, {[SUGARBEET] = 5000}, false, {[SUGARBEET] = 5000}))
|
||||
|
||||
Reference in New Issue
Block a user