fix(markarbejde): slåmarker regnes først klar i fuld højde; afbrudt slåning venter på genvækst i stedet for at klippe græs i mellemhøjde (F90) (v1.34.1.0)
This commit is contained in:
@@ -59,6 +59,24 @@ function ADFields.growthPhase(state, fruit)
|
||||
return "cut"
|
||||
end
|
||||
|
||||
-- Fuldt udvokset stadie for en slåafgrøde: græs er "høstbart" allerede i mellemhøjde (halv ydelse,
|
||||
-- Dakota-græs: greenMiddle 3 < harvestReady 4 < harvestReady2 5), så slåning venter til stadiet efter
|
||||
-- det første høstbare, når afgrøden har flere. nil = ukendte grænser (ingen ekstra krav).
|
||||
function ADFields.primeState(fruit)
|
||||
if fruit == nil then return nil end
|
||||
local minReady = fruit.minHarvestingGrowthState or fruit.minHarvestGrowthState
|
||||
if minReady == nil then return nil end
|
||||
local maxReady = fruit.maxHarvestingGrowthState or fruit.maxHarvestGrowthState or minReady
|
||||
if maxReady > minReady then return minReady + 1 end
|
||||
return minReady
|
||||
end
|
||||
|
||||
-- Tæller punktets klar-pixels? Kun når stadiet (4. værdi fra getFruitArea) er fuldt udvokset.
|
||||
function ADFields.isPrime(growthState, prime)
|
||||
if prime == nil or type(growthState) ~= "number" or growthState <= 0 then return true end
|
||||
return growthState >= prime
|
||||
end
|
||||
|
||||
-- Vokser marken? Fasen vinder; ukendt fase -> der er voksende afgrøde (getFruitArea) og den er ikke klar.
|
||||
function ADFields.isGrowing(phase, anyPixels, readyRatio)
|
||||
if phase ~= nil then return phase == "growing" end
|
||||
@@ -290,7 +308,7 @@ end
|
||||
local function newScan(adEnv, entry)
|
||||
local field, fieldId = entry.field, entry.id
|
||||
local scan = {id = fieldId, queue = {}, head = 1, tail = 0, points = {}, fruitVotes = {},
|
||||
anySum = 0, readySum = 0, soil = {fert = {0, 0}, lime = {0, 0}, plowLevel = {0, 0}, weed = {0, 0}}}
|
||||
anySum = 0, readySum = 0, immatureSum = 0, soil = {fert = {0, 0}, lime = {0, 0}, plowLevel = {0, 0}, weed = {0, 0}}}
|
||||
local info = {id = fieldId, field = field, points = scan.points, verts = {}, mowable = false, readyRatio = 0}
|
||||
scan.info = info
|
||||
-- 1) polygon og kandidatpunkter (centroid + halvvejs mod op til 8 hjørner)
|
||||
@@ -348,14 +366,25 @@ function ADFields.scanPerFruit(scan)
|
||||
local fruitIndex = info.fruitIndex
|
||||
local settings = missionSettings()
|
||||
scan.settings = settings
|
||||
-- slåafgrøder: genvækst i mellemhøjde tæller ikke som klar (in-game 27/9: halvt slået F90 blev
|
||||
-- klippet igen i mellemhøjde)
|
||||
local prime = nil
|
||||
if fruitIndex ~= nil and ADFields.getMowable()[fruitIndex] ~= nil then
|
||||
prime = ADFields.primeState(g_fruitTypeManager:getFruitTypeByIndex(fruitIndex))
|
||||
end
|
||||
for _, point in ipairs(scan.points) do
|
||||
push(scan, function()
|
||||
local x, z = point.x, point.z
|
||||
if fruitIndex ~= nil then
|
||||
local okA, _, anyPixels = pcall(FSDensityMapUtil.getFruitArea, fruitIndex, x - 2, z - 2, x + 2, z, x, z + 2, true, true)
|
||||
if okA and anyPixels then scan.anySum = scan.anySum + anyPixels end
|
||||
local okA, _, anyPixels, _, pointState = pcall(FSDensityMapUtil.getFruitArea, fruitIndex, x - 2, z - 2, x + 2, z, x, z + 2, true, true)
|
||||
if okA and anyPixels then
|
||||
scan.anySum = scan.anySum + anyPixels
|
||||
if not ADFields.isPrime(pointState, prime) then scan.immatureSum = scan.immatureSum + anyPixels end
|
||||
end
|
||||
local okR, _, readyPixels = pcall(FSDensityMapUtil.getFruitArea, fruitIndex, x - 2, z - 2, x + 2, z, x, z + 2, false, false)
|
||||
if okR and readyPixels then scan.readySum = scan.readySum + readyPixels end
|
||||
if okR and readyPixels and ADFields.isPrime(okA and pointState or nil, prime) then
|
||||
scan.readySum = scan.readySum + readyPixels
|
||||
end
|
||||
end
|
||||
end)
|
||||
push(scan, function()
|
||||
@@ -387,6 +416,7 @@ local function finishScan(adEnv, scan)
|
||||
local fruit = nil
|
||||
if info.fruitIndex ~= nil then
|
||||
info.readyRatio = scan.anySum > 0 and scan.readySum / scan.anySum or 0
|
||||
info.immatureRatio = scan.anySum > 0 and scan.immatureSum / scan.anySum or 0
|
||||
info.anyPixels = scan.anySum
|
||||
fruit = g_fruitTypeManager:getFruitTypeByIndex(info.fruitIndex)
|
||||
info.fruitName = fruit ~= nil and fruit.name or nil
|
||||
|
||||
Reference in New Issue
Block a user