feat: udkørsel "Lever også til" (fodring med samme vogn) + låst traktor og vogn til flowet
This commit is contained in:
@@ -109,6 +109,30 @@ function SmartPickupFrame:flowStoreContext(adEnv, preview, farmId)
|
||||
return result
|
||||
end
|
||||
|
||||
-- "Lever også til" (udkørsel): bygninger med aflæsningsmarkør, der tager mindst én af kildernes varer — ikke kilderne
|
||||
-- selv. Valgte bygninger vises altid (kan fravælges).
|
||||
function SmartPickupFrame:flowFeedContext(adEnv, draft, products, farmId)
|
||||
local chosen, sources = idSet(draft.feedBuildingIds), idSet(draft.sourceBuildingIds)
|
||||
local fillTypes = {}
|
||||
for _, product in ipairs(products or {}) do
|
||||
local index = g_fillTypeManager:getFillTypeIndexByName(tostring(product.name))
|
||||
if index ~= nil then table.insert(fillTypes, index) end
|
||||
end
|
||||
local result = {}
|
||||
for _, building in ipairs(ADBuildings.list(adEnv, farmId)) do
|
||||
local fits = false
|
||||
if building.unloadMarker ~= nil and not sources[building.id] and (building.kind == "factory" or building.kind == "husbandry") then
|
||||
for _, fillType in ipairs(fillTypes) do
|
||||
if ADOutbound.feedLevel(building, fillType, farmId) ~= nil then fits = true break end
|
||||
end
|
||||
end
|
||||
if fits or chosen[building.id] then
|
||||
table.insert(result, {id = building.id, name = tostring(building.name), text = trim(self:describeBuilding(building, "unload"))})
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- Varer (fillType-indeks) flowet kører med: udkørsel = valgte produkter, forsyning = valgte/målets varer.
|
||||
-- Tom liste = ukendt endnu (ingen mål valgt) -> enhver vogn med last-enheder tæller.
|
||||
local function flowFillTypes(adEnv, preview)
|
||||
@@ -241,6 +265,8 @@ function SmartPickupFrame:flowGuideContext(adEnv, draft)
|
||||
unused and self.i18n:getText("spu_guide_flow_unusedSuffix") or "")})
|
||||
end
|
||||
context.storeBuildings = self:flowStoreContext(adEnv, preview, farmId)
|
||||
local okFeed, feedBuildings = pcall(self.flowFeedContext, self, adEnv, draft, context.products, farmId)
|
||||
context.feedBuildings = okFeed and feedBuildings or {}
|
||||
else
|
||||
for _, fillType in ipairs(ADRunsController.getTargetAcceptedFillTypes(adEnv, preview)) do
|
||||
table.insert(context.fillTypes, {name = fillType.name, title = tostring(fillType.title)})
|
||||
|
||||
Reference in New Issue
Block a user