Files
GaCy-GO/tools/scene_metadata_probe.lua
T

75 lines
4.1 KiB
Lua

-- Read-only template. Replace __FLOOR_INPUTS__ with Lua pairs from the
-- installed MapEntrance table, and __CAPTURE_KEY__ with a unique string.
-- Read a bounded batch per heartbeat; never enter a map or alter entities.
do
local key = '__CAPTURE_KEY__'
_G.__gacSceneExports = _G.__gacSceneExports or {}
local progress = _G.__gacSceneExports[key] or 1
local floors = __FLOOR_INPUTS__
local function log(kind, text)
CS.UnityEngine.Debug.Log('[GAC_SCENE_' .. kind .. '] ' .. tostring(text))
end
local function world(group, item)
local yaw = group.RotY * math.pi / 180
return group.PosX + item.PosX * math.cos(yaw) + item.PosZ * math.sin(yaw),
group.PosY + item.PosY,
group.PosZ - item.PosX * math.sin(yaw) + item.PosZ * math.cos(yaw),
group.RotY + item.RotY
end
local function position(kind, prefix, group, item)
local x, y, z, rot = world(group, item)
log(kind, prefix .. ' pos=' .. tostring(x) .. ',' .. tostring(y) .. ',' .. tostring(z) .. ' rot=' .. tostring(rot))
end
local batchSize = 4
for index = progress, math.min(progress + batchSize - 1, #floors) do
local pair = floors[index]
local ok, err = pcall(function()
local path = CS.RPG.Client.MapDef.GetRtFloorInfoPath(pair[1], pair[2])
local floor = CS.RPG.GameCore.GameCoreConfigLoader.LoadRtLevelFloorInfo(path)
if floor == nil then error('missing RuntimeFloor ' .. path) end
local floorID = tostring(pair[2])
log('META', 'FLOOR ' .. tostring(pair[1]) .. ' ' .. floorID
.. ' startGroup=' .. tostring(floor.StartGroupIndex) .. ' anchor=' .. tostring(floor.StartAnchorID)
.. ' count=' .. tostring(floor.GroupInstanceCommonMap.Count))
local iterator = floor.GroupInstanceCommonMap:GetEnumerator()
while iterator:MoveNext() do
local entry = iterator.Current
log('META', 'GROUP ' .. floorID .. ' ' .. tostring(entry.Key)
.. ' side=' .. tostring(entry.Value.LoadSide) .. ' hoyo=' .. tostring(entry.Value.IsHoyoGroup)
.. ' deleted=' .. tostring(entry.Value.IsDelete))
end
log('META', 'END ' .. floorID)
for i = 0, floor.GroupInstanceList.Length - 1 do
local group = floor.GroupInstanceList[i]
local common = floor.GroupInstanceCommonMap[group.ID]
if not group.IsDelete and common ~= nil and not common.IsDelete
and (i == floor.StartGroupIndex or tostring(common.LoadSide):find('Server', 1, true)) then
local data = CS.RPG.GameCore.GameCoreConfigLoader.LoadRtLevelGroupInfo(group.GroupPath)
if data == nil then error('missing RuntimeGroup ' .. tostring(group.GroupPath)) end
if i == floor.StartGroupIndex and data.AnchorList ~= nil then
for j = 0, data.AnchorList.Length - 1 do
local anchor = data.AnchorList[j]
if not anchor.IsDelete and anchor.ID == floor.StartAnchorID then
position('PLACEMENT', 'ANCHOR ' .. floorID .. ' ' .. tostring(anchor.ID), group, anchor)
end
end
end
if data.MonsterList ~= nil then
for j = 0, data.MonsterList.Length - 1 do
local monster = data.MonsterList[j]
if not monster.IsDelete and not monster.IsClientOnly then
position('PLACEMENT', 'MONSTER ' .. floorID .. ' ' .. tostring(group.ID)
.. ' ' .. tostring(monster.ID), group, monster)
end
end
end
end
end
log('PLACEMENT', 'END ' .. floorID)
end)
if not ok then log('META', 'ERROR ' .. tostring(pair[2]) .. ' ' .. tostring(err)) end
progress = index + 1
end
_G.__gacSceneExports[key] = progress
end