fix: staldes læssemarkører ejes af den stald hvis læssepunkt er nærmest, afgjort på tværs af staldene — 1.62.294
In-game 17/10 efter 293: Hønsehus 2 og 3 valgte begge 'Coop 1 Egg Pickup'. Pre-pass i ADBuildings.build: noteLoadOwner pr. kandidatmarkør, ownedCandidates filtrerer pr. stald (tom -> alle som før). Ingen ændring for andre bygninger.
This commit is contained in:
@@ -576,12 +576,43 @@ local function hasOwnLoadingStation(placeable, loadStations)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Ren: husk markørens ejer = den stald hvis læssepunkt ligger nærmest (17/10: Hønsehus 2 og 3 delte 'Coop 1 Egg Pickup')
|
||||
function ADBuildings.noteLoadOwner(owners, markerId, owner, distance)
|
||||
local current = owners[markerId]
|
||||
if current == nil or distance < current.distance then owners[markerId] = {owner = owner, distance = distance} end
|
||||
end
|
||||
|
||||
-- Ren: kun de kandidater der ejes af owner (ukendte beholdes); bliver listen tom, bruges alle som før.
|
||||
function ADBuildings.ownedCandidates(candidates, owners, owner)
|
||||
if owners == nil then return candidates end
|
||||
local kept = {}
|
||||
for _, candidate in ipairs(candidates or {}) do
|
||||
local entry = owners[candidate.id]
|
||||
if entry == nil or entry.owner == owner then table.insert(kept, candidate) end
|
||||
end
|
||||
return #kept > 0 and kept or candidates
|
||||
end
|
||||
|
||||
local function build(adEnv, farmId)
|
||||
local placeables = g_currentMission ~= nil and g_currentMission.placeableSystem ~= nil and g_currentMission.placeableSystem.placeables or {}
|
||||
local storage = g_currentMission ~= nil and g_currentMission.storageSystem or nil
|
||||
local loadStations = storage ~= nil and storage:getLoadingStations() or {}
|
||||
local unloadStations = storage ~= nil and storage:getUnloadingStations() or {}
|
||||
local result = {}
|
||||
-- stalde: læssemarkørens ejer afgøres på tværs af staldene, før hver stald vælger (nabohusets markør kan stå nærmest)
|
||||
local loadOwner, prepared = {}, {}
|
||||
for _, placeable in pairs(placeables) do
|
||||
if getKind(placeable) == "husbandry" and isOwnedBy(placeable, farmId) then
|
||||
local loadGroups, unloadNodes = collectNodes(placeable, loadStations, unloadStations)
|
||||
local candidatesByGroup = {}
|
||||
for index, nodes in ipairs(loadGroups) do
|
||||
local candidates = markerCandidates(adEnv, nodes)
|
||||
candidatesByGroup[index] = candidates
|
||||
for _, candidate in ipairs(candidates) do ADBuildings.noteLoadOwner(loadOwner, candidate.id, placeable, candidate.distance) end
|
||||
end
|
||||
prepared[placeable] = {loadGroups = loadGroups, unloadNodes = unloadNodes, candidatesByGroup = candidatesByGroup}
|
||||
end
|
||||
end
|
||||
for _, placeable in pairs(placeables) do
|
||||
local kind = getKind(placeable)
|
||||
local isSell = kind == nil and isSellPlaceable(placeable, unloadStations)
|
||||
@@ -592,15 +623,20 @@ local function build(adEnv, farmId)
|
||||
if kind ~= nil and (kind == "sell" or isOwnedBy(placeable, farmId)) then
|
||||
local id = ADBuildings.getId(placeable)
|
||||
if id ~= nil then
|
||||
local loadGroups, unloadNodes = collectNodes(placeable, loadStations, unloadStations)
|
||||
local pre = prepared[placeable]
|
||||
local loadGroups, unloadNodes
|
||||
if pre ~= nil then loadGroups, unloadNodes = pre.loadGroups, pre.unloadNodes
|
||||
else loadGroups, unloadNodes = collectNodes(placeable, loadStations, unloadStations) end
|
||||
local loadMarkers, seen, skipForUnload = {}, {}, {}
|
||||
if kind == "silo" then
|
||||
local marker = siloLoadMarker(adEnv, farmId, placeable, loadStations)
|
||||
if marker ~= nil then table.insert(loadMarkers, marker) end
|
||||
else
|
||||
local unloadBest = markerCandidates(adEnv, unloadNodes)[1]
|
||||
for _, nodes in ipairs(loadGroups) do
|
||||
local candidates = markerCandidates(adEnv, nodes)
|
||||
for index, nodes in ipairs(loadGroups) do
|
||||
local candidates = pre ~= nil and pre.candidatesByGroup[index] or markerCandidates(adEnv, nodes)
|
||||
-- stalde: kun markører der er stalden egen (nærmest dens læssepunkt frem for naboens)
|
||||
if pre ~= nil then candidates = ADBuildings.ownedCandidates(candidates, loadOwner, placeable) end
|
||||
local marker = ADBuildings.pickLoadMarker(candidates, unloadBest, nodes.isSpawner == true, nodes.fillWords)
|
||||
if marker ~= nil and not seen[marker.id] then
|
||||
seen[marker.id] = true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.293.0</version>
|
||||
<version>1.62.294.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user