feat(lagre): faner pr. bygningstype (Fabrikker/Siloer/Stalde/Palleskure), kolonner tilpasset rækkebredden, statistik tæller kun kørende produktioner × tidsjustering (v1.16.0.0)
This commit is contained in:
@@ -632,10 +632,29 @@ local function addRate(rates, fillType, field, liters)
|
||||
rates[fillType][field] = rates[fillType][field] + liters
|
||||
end
|
||||
|
||||
-- Statistik: kun produktioner der kører NU. "Ønsket" (tændt eller mangler input) bruges til reserve og
|
||||
-- forsyning, men ville her tælle stillestående fabrikker med fuld hastighed — fx fermenteringssiloer
|
||||
-- med 200.000 cyklusser i timen gav hundreder af millioner liter pr. døgn.
|
||||
local function isProductionRunning(productionPoint, production)
|
||||
local status = ProductionPoint ~= nil and ProductionPoint.PROD_STATUS ~= nil and ProductionPoint.PROD_STATUS.RUNNING or nil
|
||||
if status ~= nil and production.status ~= nil then
|
||||
return production.status == status
|
||||
end
|
||||
return isProductionWanted(productionPoint, production)
|
||||
end
|
||||
|
||||
-- Spillets rater gælder pr. måned (én 24-timers dag pr. måned); faktisk pr. døgn = rate × timeAdjustment
|
||||
-- (1 / dage pr. periode).
|
||||
local function getTimeAdjustment()
|
||||
local environment = g_currentMission ~= nil and g_currentMission.environment or nil
|
||||
local value = environment ~= nil and tonumber(environment.timeAdjustment) or nil
|
||||
return value ~= nil and value > 0 and value or 1
|
||||
end
|
||||
|
||||
local function addFactoryRates(rates, placeable)
|
||||
local productionPoint = getProductionPoint(placeable)
|
||||
for _, production in ipairs(productionPoint ~= nil and productionPoint.productions or {}) do
|
||||
if isProductionWanted(productionPoint, production) then
|
||||
if isProductionRunning(productionPoint, production) then
|
||||
local perDay = (production.cyclesPerMinute or ((production.cyclesPerHour or 0) / 60)) * 1440
|
||||
for _, input in ipairs(production.inputs or {}) do addRate(rates, input.type, "consumption", (input.amount or 0) * perDay) end
|
||||
for _, output in ipairs(production.outputs or {}) do addRate(rates, output.type, "production", (output.amount or 0) * perDay) end
|
||||
@@ -732,6 +751,10 @@ function ADSources.getFarmRates(adEnv, farmId)
|
||||
end
|
||||
end
|
||||
end
|
||||
local adjustment = getTimeAdjustment()
|
||||
for _, rate in pairs(rates) do
|
||||
rate.consumption, rate.production = rate.consumption * adjustment, rate.production * adjustment
|
||||
end
|
||||
return rates
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user