feat(ui): Flows-oprydning — tavle grupperet Ind/Ud efter navn, traktorer: egne+ledige (Vis alle), bygninger: valgte først, uden markør skjult (Vis alle); fix: staldes foderkrybbe (feedingTrough) i stationsopslag og bygningsmarkører — hønsehus (v1.19.0.0)

This commit is contained in:
2026-09-24 19:31:57 +02:00
parent b3d49c4857
commit 99c509ea10
13 changed files with 334 additions and 26 deletions
+41 -1
View File
@@ -167,8 +167,48 @@ local function getLoadStationAtMarker(adEnv, wayPoint, farmId)
return getClosestStation(adEnv, g_currentMission.storageSystem:getLoadingStations(), "loadTriggers", LOAD_TRIGGER_NODE_FIELDS, wayPoint, farmId)
end
-- Staldes foderkrybbe (spec_husbandryFood.feedingTrough, samme tippe-trigger som AutoDrive bruger) står
-- ikke altid i aflæsningsstationens unloadTriggers — hønsehuset har KUN krybben. Opslaget får derfor en
-- proxy pr. krybbe der peger på staldens station (eller en minimal station). Caches i UNLOAD_CACHE_MS.
ADSmartPickup.UNLOAD_CACHE_MS = 1000
local unloadCache = {list = nil, time = -math.huge}
function ADSmartPickup.invalidateUnloadCandidates()
unloadCache.list, unloadCache.time = nil, -math.huge
end
local function getUnloadCandidates()
local now = g_currentMission ~= nil and type(g_currentMission.time) == "number" and g_currentMission.time or nil
if unloadCache.list ~= nil and now ~= nil and (now - unloadCache.time) < ADSmartPickup.UNLOAD_CACHE_MS then
return unloadCache.list
end
local list, byPlaceable = {}, {}
for _, station in pairs(g_currentMission.storageSystem:getUnloadingStations()) do
table.insert(list, station)
if station.owningPlaceable ~= nil and byPlaceable[station.owningPlaceable] == nil then
byPlaceable[station.owningPlaceable] = station
end
end
local placeables = g_currentMission.placeableSystem ~= nil and g_currentMission.placeableSystem.placeables or {}
for _, placeable in pairs(placeables) do
local food = placeable.spec_husbandryFood
local trough = food ~= nil and food.feedingTrough or nil
local node = trough ~= nil and (trough.exactFillRootNode or trough.triggerNode) or nil
if node ~= nil then
local station = byPlaceable[placeable] or {
owningPlaceable = placeable,
-- spillets adgangstjek kalder getOwnerFarmId på stationen
getOwnerFarmId = function() return placeable.getOwnerFarmId ~= nil and placeable:getOwnerFarmId() or placeable.ownerFarmId end,
}
table.insert(list, setmetatable({unloadTriggers = {{exactFillRootNode = node}}}, {__index = station}))
end
end
unloadCache.list, unloadCache.time = list, now or -math.huge
return list
end
local function getUnloadStationAtMarker(adEnv, wayPoint, farmId)
return getClosestStation(adEnv, g_currentMission.storageSystem:getUnloadingStations(), "unloadTriggers", UNLOAD_TRIGGER_NODE_FIELDS, wayPoint, farmId)
return getClosestStation(adEnv, getUnloadCandidates(), "unloadTriggers", UNLOAD_TRIGGER_NODE_FIELDS, wayPoint, farmId)
end
-- Station ved et AutoDrive-waypoint (bruges af runs-controlleren og læs-byttet); nil uden station.