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

26 lines
1.7 KiB
Lua

-- Cached config wrappers only, eight entries per heartbeat, paused in Battle.
do local function capture()
local s=_G.__gacCwConfigCache1 or {table=1};_G.__gacCwConfigCache1=s
if s.done then return end
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
local phase=CS.RPG.Client.GlobalVars.s_GamePhaseManager
phase=phase and typeof(CS.RPG.Client.GamePhaseManager):GetField('_CurrentPhase',flags):GetValue(phase)
if not phase or typeof(CS.RPG.Client.BattleGamePhase):IsInstanceOfType(phase)then return end
local names={'GridFightForgeConfigs','EquipItemConfigs','ConsumableItemConfigs','NPCConfigs'}
local log=function(x)CS.UnityEngine.Debug.Log('[GAC_CW_CONFIG_CACHE] '..tostring(x))end
local module=CS.RPG.Client.GlobalVars.s_ModuleManager.GridFightModule
if not s.iterator then
local dict=module[names[s.table]]
if not dict then log('MISSING '..names[s.table]);s.table=s.table+1;return end
if dict.Count>4096 then error('cache bound exceeded')end
s.iterator=dict:GetEnumerator();log('TABLE '..names[s.table]..' count='..dict.Count)
end
for _=1,8 do
if not s.iterator:MoveNext()then s.iterator:Dispose();s.iterator=nil;s.table=s.table+1;if s.table>#names then s.done=true;log('END')end;return end
local entry=s.iterator.Current;local obj=entry.Value;local field=obj:GetType():GetField('_Row',flags)
local row=field and field:GetValue(obj)
if row then local encoded=CS.Newtonsoft.Json.JsonConvert.SerializeObject(row);if #encoded>32768 then error('row bound exceeded')end;log('ROW '..names[s.table]..' '..tostring(entry.Key)..' '..encoded)end
end
end;local ok,e=pcall(capture);if not ok then _G.__gacCwConfigCache1={done=true};CS.UnityEngine.Debug.Log('[GAC_CW_CONFIG_CACHE] ERROR '..tostring(e))end end