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

33 lines
2.1 KiB
Lua

-- IDs are injected from the current revision's captured role configuration.
-- Read config rows only, four traits per heartbeat, never during Battle.
do local function capture()
local s=_G.__gacCwTraitRows1 or {index=1};_G.__gacCwTraitRows1=s
if s.done then return end
local ids=_G.__gacCwTraitCaptureIDs
if type(ids)~='table'or #ids>256 then error('bounded captured trait ID plan required')end
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
local manager=CS.RPG.Client.GlobalVars.s_GamePhaseManager
local phase=manager and typeof(CS.RPG.Client.GamePhaseManager):GetField('_CurrentPhase',flags):GetValue(manager)
if not phase or typeof(CS.RPG.Client.BattleGamePhase):IsInstanceOfType(phase)then return end
local module=CS.RPG.Client.GlobalVars.s_ModuleManager.GridFightModule
local log=function(x)CS.UnityEngine.Debug.Log('[GAC_CW_TRAIT_ROWS] '..tostring(x))end
local function rows(label,obj)
local fs=obj:GetType():GetFields(flags)
for i=0,math.min(fs.Length-1,47)do local f=fs[i]
if not f.IsStatic and f.FieldType.FullName:find('Row$')then local row=f:GetValue(obj);if row then local encoded=CS.Newtonsoft.Json.JsonConvert.SerializeObject(row);if #encoded>32768 then error('trait row bound')end;log(label..' '..encoded)end end
end
end
for _=1,4 do
if s.index>#ids then s.done=true;log('END');return end
local id=ids[s.index];s.index=s.index+1
local config=module:GetTraitConfig(id)
if config then
rows('BASE',config)
local f=config:GetType():GetField('_layerConfigs',flags);local layers=f and f:GetValue(config)
if layers then if layers.Count>32 then error('trait layer bound')end;for i=0,layers.Count-1 do rows('LAYER',layers[i])end end
local effects=config.TraitEffectList
if effects then for i=0,math.min(effects.Length-1,15)do local effect=module:GetTraitEffectConfig(effects[i]);if effect then rows('EFFECT',effect)end end end
else log('MISSING '..id)end
end
end;local ok,e=pcall(capture);if not ok then _G.__gacCwTraitRows1={done=true};CS.UnityEngine.Debug.Log('[GAC_CW_TRAIT_ROWS] ERROR '..tostring(e))end end