chore(prototype): log lane layout of shared street segments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aa5dfa655f
commit
b6daeaa328
1 file changed
+29
@@ -25,6 +25,34 @@ local function turnaround(edge : EdgeId) : integer
|
||||
return tn.turnaroundEdges[edge.index + 1]
|
||||
end
|
||||
|
||||
local function modes(m : {TransportMode : boolean}) : string
|
||||
local out : {string} = {}
|
||||
for k, v in pairs(m or {}) do
|
||||
if v then table.insert(out, tostring(k)) end
|
||||
end
|
||||
return table.concat(out, ",")
|
||||
end
|
||||
|
||||
-- per street segment: BaseEdge lane layout + TransportNetwork lanes (modes, speed, opposite lane)
|
||||
local function segmentInfo(seg : integer) : string
|
||||
local be = api.engine.getComponent(seg, api.type.ComponentType.BASE_EDGE) as Engine.Component.BaseEdge
|
||||
local tn = api.engine.getComponent(seg, api.type.ComponentType.TRANSPORT_NETWORK) as Engine.Component.TransportNetwork
|
||||
local parts : {string} = {}
|
||||
if be ~= nil then
|
||||
table.insert(parts, string.format("roadType=%s template=%s laneConfigs=%d", tostring(be.roadType), tostring(be.roadTemplate), #be.laneConfigs))
|
||||
for i, lc in ipairs(be.laneConfigs) do
|
||||
table.insert(parts, string.format(" lc%d fwd=%s off=%.1f w=%.1f modes=[%s]", i, tostring(lc.forward), lc.offset, lc.width, modes(lc.transportModes)))
|
||||
end
|
||||
end
|
||||
if tn ~= nil then
|
||||
table.insert(parts, string.format("tnEdges=%d", #tn.edges))
|
||||
for i, e in ipairs(tn.edges) do
|
||||
table.insert(parts, string.format(" tn%d modes=[%s] speedLimit=%.1f curSpeed=%.1f turnaround=%s", i - 1, modes(e.transportModes), e.speedLimit, e.curSpeed, tostring(tn.turnaroundEdges[i])))
|
||||
end
|
||||
end
|
||||
return table.concat(parts, "\n" .. TAG .. " ")
|
||||
end
|
||||
|
||||
local function dump(dt : number)
|
||||
local player = api.engine.util.getPlayer()
|
||||
local vehicles = api.engine.getEntitiesWithComponent(api.type.ComponentType.TRANSPORT_VEHICLE, { requireOwnedByPlayer = player })
|
||||
@@ -53,6 +81,7 @@ local function dump(dt : number)
|
||||
for seg, list in pairs(bySegment) do
|
||||
if #list > 1 then
|
||||
p(string.format("SHARED seg=%d: %s", seg, table.concat(list, " ")))
|
||||
p(" SEGMENT " .. seg .. " " .. segmentInfo(seg))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user