getNodesFromPathDist
Definition
-- @/lua/ge/map.lua:2602
local function getNodesFromPathDist(path, dist)
-- finds and returns nodes and an xnorm based on distance along path
local mapNodes = map.nodes
if not mapNodes or not path or not path[2] then return end
local pathCount = #path
dist = dist or huge
for i = 1, pathCount - 1 do
local n1, n2 = path[i], path[i + 1]
if mapNodes[n1] and mapNodes[n2] then
local length = mapNodes[n1].pos:distance(mapNodes[n2].pos)
if dist > length then
dist = dist - length
else
return n1, n2, clamp(dist / (length + 1e-30), 0, 1)
end
end
end
return path[pathCount - 1], path[pathCount], 1
end
Callers
@/lua/ge/extensions/core/multiSpawn.lua
local n1, n2, xnorm = map.getNodesFromPathDist(path, dist)
local p1, p2 = mapNodes[n1].pos, mapNodes[n2].pos