fix: stald-siloer regnes ikke som marksiloer (v1.62.146)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
ADFields = {}
|
||||
|
||||
ADFields.FIELD_SILO_DISTANCE = 150
|
||||
ADFields.STABLE_SILO_M = 80 -- standard når ADSettings ikke er indlæst (ellers "stableSiloRange")
|
||||
ADFields.MARKER_MAX_DISTANCE = 400
|
||||
ADFields.cache = {}
|
||||
ADFields.order = {}
|
||||
@@ -727,13 +728,33 @@ function ADFields.getInfo(id)
|
||||
return ADFields.cache[id]
|
||||
end
|
||||
|
||||
-- Stald-silo: en silo inden for stableSiloRange (ADSettings, standard 80 m) af en stald i bygningslisten. Den er
|
||||
-- staldens eget lager (forsyningen henter dér), ikke en marksilo — også når den står op ad en mark.
|
||||
function ADFields.isStableSilo(building, buildings)
|
||||
if building == nil or building.kind ~= "silo" or building.placeable == nil or building.placeable.rootNode == nil then return false end
|
||||
local okS, sx, _, sz = pcall(getWorldTranslation, building.placeable.rootNode)
|
||||
if not okS or sx == nil then return false end
|
||||
local range = ADSettings ~= nil and ADSettings.get("stableSiloRange", building.id) or ADFields.STABLE_SILO_M
|
||||
for _, other in ipairs(buildings or {}) do
|
||||
local node = other.kind == "husbandry" and other.placeable ~= nil and other.placeable.rootNode or nil
|
||||
if node ~= nil then
|
||||
local okH, hx, _, hz = pcall(getWorldTranslation, node)
|
||||
if okH and hx ~= nil and (hx - sx) ^ 2 + (hz - sz) ^ 2 <= range ^ 2 then return true end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Siloer tæt på markens polygon (eller centrum): mellemlagre, som et udkørselsflow skal tømme hjem.
|
||||
-- Stald-siloer (ADFields.isStableSilo) tælles ikke med: de hører til stalden, ikke marken.
|
||||
function ADFields.fieldSilos(adEnv, farmId, info)
|
||||
local result = {}
|
||||
if ADBuildings == nil or info == nil or info.x == nil then return result end
|
||||
local anchors = #info.verts > 0 and info.verts or {{x = info.x, z = info.z}}
|
||||
for _, building in ipairs(ADBuildings.list(adEnv, farmId)) do
|
||||
local buildings = ADBuildings.list(adEnv, farmId)
|
||||
for _, building in ipairs(buildings) do
|
||||
local node = building.kind == "silo" and building.placeable ~= nil and building.placeable.rootNode or nil
|
||||
if node ~= nil and ADFields.isStableSilo(building, buildings) then node = nil end
|
||||
if node ~= nil then
|
||||
local bx, _, bz = getWorldTranslation(node)
|
||||
for _, anchor in ipairs(anchors) do
|
||||
|
||||
@@ -142,7 +142,9 @@ function ADNames.autoName(adEnv, buildings)
|
||||
if existing[building.id] == nil then
|
||||
local x, z = position(building.placeable)
|
||||
local nearest = nil
|
||||
if x ~= nil and building.kind == "silo" then
|
||||
-- stald-siloer får ikke marknavn ("F12 marksilo"), selv om de står ved en mark: de hører til stalden
|
||||
local isStableSilo = building.kind == "silo" and ADFields ~= nil and ADFields.isStableSilo ~= nil and ADFields.isStableSilo(building, buildings)
|
||||
if x ~= nil and building.kind == "silo" and not isStableSilo then
|
||||
for _, field in ipairs(fields) do
|
||||
local distance = math.sqrt((field.x - x) ^ 2 + (field.z - z) ^ 2)
|
||||
if nearest == nil or distance < nearest.distance then nearest = {name = field.name, distance = distance} end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.145.0</version>
|
||||
<version>1.62.146.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user