fix(kobling): ankomst måles fra nærmeste led i sættet — bakker AD med vogn, ender vognen på markøren og traktoren et vognslæb væk (stoppedAway ved Bredal) (v1.47.4.0)
This commit is contained in:
@@ -142,10 +142,19 @@ end
|
||||
local function vehicleState(adEnv, vehicle, markerId)
|
||||
local module = stateModule(vehicle)
|
||||
local wayPoint = adEnv.ADGraphManager:getWayPointById(markerId)
|
||||
-- nærmeste led i sættet: bakker AD med vogn, er det vognen der ender på markøren, ikke traktoren
|
||||
-- (in-game 28/9: vognen stod på Bredal, traktoren et vognslæb væk -> "stoppedAway")
|
||||
local distance = math.huge
|
||||
if wayPoint ~= nil and vehicle.rootNode ~= nil then
|
||||
local x, _, z = getWorldTranslation(vehicle.rootNode)
|
||||
distance = math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2)
|
||||
local parts = {vehicle}
|
||||
if vehicle.getChildVehicles ~= nil then
|
||||
local ok, children = pcall(vehicle.getChildVehicles, vehicle)
|
||||
if ok and children ~= nil then parts = children end
|
||||
end
|
||||
for _, part in pairs(parts) do
|
||||
if wayPoint ~= nil and part.rootNode ~= nil then
|
||||
local x, _, z = getWorldTranslation(part.rootNode)
|
||||
distance = math.min(distance, math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2))
|
||||
end
|
||||
end
|
||||
return {
|
||||
adActive = module ~= nil and module:isActive(),
|
||||
|
||||
Reference in New Issue
Block a user