fix: udkørsels-kilde bruger bygningens tildelte læssemarkør før løst opslag (Kostald 1 Milk Collection) — 1.62.280
This commit is contained in:
@@ -174,6 +174,15 @@ function ADSources.identifyUncached(adEnv, wayPointId, farmId)
|
||||
if placeable ~= nil and placeable.spec_objectStorage == nil then
|
||||
return {kind = "storage", placeable = placeable, station = station, wayPointId = wayPointId, name = getPlaceableName(placeable, markerName)}
|
||||
end
|
||||
-- markøren er en bygnings tildelte læssemarkør (Bygninger-listen): brug den bygning, også når en anden
|
||||
-- læssestation står nærmere (in-game 17/10: "Milk Collection" ved Kostald 1 — Silo 3 stod nærmere end mælketanken)
|
||||
if placeable == nil then
|
||||
local assigned = ADSources.assignedBuilding(adEnv, wayPointId, farmId)
|
||||
if assigned ~= nil then
|
||||
assigned.name = getPlaceableName(assigned.placeable, markerName)
|
||||
return assigned
|
||||
end
|
||||
end
|
||||
-- Det strenge opslag (trigger bag næsen) passer til silorækker; en mælketank eller fabrik ligger
|
||||
-- ofte ved siden af markøren. Løst opslag inden for 40 m — men aldrig for siloer.
|
||||
-- stald med egne pallespawnere (hønsehus: æg) — markøren står ved spawneren, ingen læssestation
|
||||
@@ -211,6 +220,47 @@ function ADSources.identifyUncached(adEnv, wayPointId, farmId)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Stald/fabrik/lager hvis tildelte læssemarkør er wayPointId -> {kind, placeable, station, wayPointId} | nil.
|
||||
-- Siloer og objektlagre springes over (de har deres egne, strenge regler), og stalde med pallespawnere (hønsehus,
|
||||
-- fårestald) beholder den gamle vej — en station dér ville skjule pallevarerne. Stationen er den af bygningens
|
||||
-- læssestationer hvis trigger står nærmest markøren (en stald har ofte en til mælk og en til gylle).
|
||||
local ASSIGNED_KINDS = {husbandry = "husbandry", factory = "factory", storage = "storage"}
|
||||
|
||||
local function nearestOwnedStation(placeable, wayPoint)
|
||||
local storage = g_currentMission ~= nil and g_currentMission.storageSystem or nil
|
||||
local best, bestDistance = nil, math.huge
|
||||
for _, station in pairs(storage ~= nil and storage:getLoadingStations() or {}) do
|
||||
if station.owningPlaceable == placeable then
|
||||
local distance = math.huge
|
||||
for _, trigger in pairs(station.loadTriggers or {}) do
|
||||
local x, z = getNodePosition(trigger.triggerNode)
|
||||
if x ~= nil then distance = math.min(distance, distance2(wayPoint.x, wayPoint.z, x, z)) end
|
||||
end
|
||||
if best == nil or distance < bestDistance then best, bestDistance = station, distance end
|
||||
end
|
||||
end
|
||||
return best
|
||||
end
|
||||
|
||||
function ADSources.assignedBuilding(adEnv, wayPointId, farmId)
|
||||
if ADBuildings == nil or ADBuildings.byMarker == nil then return nil end
|
||||
local wayPoint = adEnv.ADGraphManager:getWayPointById(wayPointId)
|
||||
if wayPoint == nil then return nil end
|
||||
local ok, building = pcall(ADBuildings.byMarker, adEnv, farmId, wayPointId, "load")
|
||||
if not ok or building == nil or building.placeable == nil then return nil end
|
||||
local kind = ASSIGNED_KINDS[building.kind]
|
||||
if kind == nil then return nil end
|
||||
local placeable = building.placeable
|
||||
if kind == "husbandry" and getHusbandryPalletSpawners(placeable) ~= nil then return nil end
|
||||
local production = getProductionPoint(placeable)
|
||||
local station = kind == "factory" and production ~= nil and production.loadingStation or nil
|
||||
station = station or nearestOwnedStation(placeable, wayPoint)
|
||||
if station == nil then
|
||||
Logging.info("ADSmartPickup: markør %s hører til '%s', men bygningen har ingen læssestation", tostring(wayPointId), tostring(building.name))
|
||||
end
|
||||
return {kind = kind, placeable = placeable, station = station, wayPointId = wayPointId}
|
||||
end
|
||||
|
||||
-- Til advarslen "kilde-markør X er ikke …": hvad opslaget faktisk ser ved markøren.
|
||||
function ADSources.explainMarker(adEnv, wayPointId, farmId)
|
||||
local wayPoint = adEnv.ADGraphManager:getWayPointById(wayPointId)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.279.0</version>
|
||||
<version>1.62.280.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user