Files
GaCy-GO/tools/cw_active_table_rows.lua
T
2026-10-28 18:54:43 +07:00

71 lines
4.1 KiB
Lua

-- One-shot, read-only Beta Client lookup for the active CW route/stage rows.
-- IDs passed to these lookups come from the active GridFightStage objects.
do
local state = _G.__gacCwActiveTableRows1 or { done = false }
_G.__gacCwActiveTableRows1 = state
if not state.done then
local lines = {}
local function add(s) if #lines < 24 then lines[#lines + 1] = tostring(s) end end
local function getField(obj, name, flags)
if not obj then return nil end
local fs = obj:GetType():GetFields(flags)
for i = 0, math.min(fs.Length - 1, 95) do
if fs[i].Name == name then return fs[i]:GetValue(obj) end
end
end
local function row(name, id, getter)
local ok, value = pcall(getter)
if not ok then add('ROW_ERROR ' .. name .. ' id=' .. tostring(id) .. ' ' .. tostring(value)); return end
if not value then add('ROW_EMPTY ' .. name .. ' id=' .. tostring(id)); return end
local encodedOK, encoded = pcall(function() return CS.Newtonsoft.Json.JsonConvert.SerializeObject(value) end)
if encodedOK and #tostring(encoded) <= 20000 then
add('ROW ' .. name .. ' id=' .. tostring(id) .. ' ' .. tostring(encoded))
elseif encodedOK then
add('ROW_TOO_LARGE ' .. name .. ' id=' .. tostring(id) .. ' chars=' .. tostring(#tostring(encoded)))
else
add('ROW_SERIALIZE_ERROR ' .. name .. ' id=' .. tostring(id) .. ' ' .. tostring(encoded))
end
end
local ok, err = pcall(function()
local flags = CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags), 60)
local session = CS.RPG.Client.GlobalVars.s_ModuleManager.GridFightModule.CurGameSession
if not session then add('NO_SESSION'); return end
local stage
local fs = session:GetType():GetFields(flags)
for i = 0, math.min(fs.Length - 1, 79) do
if fs[i].FieldType.FullName == 'RPG.Client.GridFightStage' then stage = fs[i]:GetValue(session); break end
end
if not stage or not stage.CurNode then add('NO_ACTIVE_NODE'); return end
local node = stage.CurNode
local stageID, routeID = node.StageID, stage.RouteID
local battle = getField(node, '_BattleNodeInfo', flags)
local battleAuxA = getField(battle, 'INGNOGNLFBC', flags)
local battleAuxB = getField(battle, 'LFGIGDPIGJE', flags)
add('RUN route=' .. tostring(routeID) .. ' section=' .. tostring(stage.SectionID) ..
' stage=' .. tostring(stageID) .. ' level=' .. tostring(stage.CurMonsterLevel) ..
' battle_aux=' .. tostring(battleAuxA) .. ',' .. tostring(battleAuxB))
local routeNode = getField(node, '_RouteNode', flags)
local nodeParam = getField(node, '_NodeParam', flags)
local nodeInfo = getField(node, '_NodeInfo', flags)
local displayRow = getField(node, '_DisplayRow', flags)
local routeDisplay = getField(routeNode, 'NMABHKCOLCM', flags)
local routeID = stage.RouteID
row('StageExcelTable', stageID, function() return CS.RPG.GameCore.StageExcelTable.GetData(stageID) end)
row('GridFightStageRouteConfigExcelTable', routeID, function() return CS.RPG.GameCore.GridFightStageRouteConfigExcelTable.GetData(routeID) end)
row('GridFightEnemyDifficultyLvConfigExcelTable(candidate_aux_b)', battleAuxB, function() return CS.RPG.GameCore.GridFightEnemyDifficultyLvConfigExcelTable.GetData(battleAuxB) end)
for label, obj in pairs({nodeParam = nodeParam, nodeInfo = nodeInfo, displayRow = displayRow, routeNode = routeNode, routeDisplay = routeDisplay}) do
if obj then
local encodedOK, encoded = pcall(function() return CS.Newtonsoft.Json.JsonConvert.SerializeObject(obj) end)
if encodedOK and #tostring(encoded) <= 12000 then add('OBJECT ' .. label .. ' ' .. tostring(encoded))
else add('OBJECT ' .. label .. ' TYPE=' .. tostring(obj:GetType().FullName) .. ' serialize=' .. tostring(encoded)) end
else
add('OBJECT ' .. label .. ' nil')
end
end
end)
if not ok then add('ERROR ' .. tostring(err)) end
CS.UnityEngine.Debug.Log('[GAC_CW_ACTIVE_TABLE_ROWS]\n' .. table.concat(lines, '\n'))
state.done = true
end
end