34 lines
1.8 KiB
Lua
34 lines
1.8 KiB
Lua
-- Read named Excel tables from the assembly that owns the captured Row type.
|
|
-- At most sixteen plain configuration rows per heartbeat; no graph loads.
|
|
do
|
|
local names={'GridFightStageRouteConfigExcelTable'}
|
|
_G.__gacCwExcelExport1=_G.__gacCwExcelExport1 or {table=1,count=0}
|
|
local state=_G.__gacCwExcelExport1
|
|
if state.table<=#names then
|
|
local function log(v)CS.UnityEngine.Debug.Log('[GAC_CW_EXCEL] '..tostring(v))end
|
|
local ok,err=pcall(function()
|
|
if not state.iterator then
|
|
local assembly=typeof(CS.RPG.GameCore.GridFightRoleConfigRow).Assembly
|
|
local t=assembly:GetType('RPG.GameCore.'..names[state.table])
|
|
if not t then error('Named table missing from Row assembly')end
|
|
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
|
|
local getter=t:GetProperty('dataDict',flags):GetGetMethod(true)
|
|
local rows=getter:Invoke(nil,CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),0),nil,CS.System.Array.CreateInstance(typeof(CS.System.Object),0),nil)
|
|
if rows.Count>20000 then error('Table exceeds capture bound')end
|
|
state.iterator=rows:GetEnumerator();state.expected=rows.Count;state.count=0
|
|
log('BEGIN '..names[state.table]..' count='..rows.Count)
|
|
end
|
|
for i=1,16 do
|
|
if not state.iterator:MoveNext()then
|
|
if state.count~=state.expected then error('Table changed during capture')end
|
|
log('END '..names[state.table]..' count='..state.count)
|
|
state.iterator=nil;state.table=state.table+1;return
|
|
end
|
|
log('ROW '..names[state.table]..' '..CS.Newtonsoft.Json.JsonConvert.SerializeObject(state.iterator.Current.Value))
|
|
state.count=state.count+1
|
|
end
|
|
end)
|
|
if not ok then log('ERROR '..names[state.table]..' '..tostring(err));state.iterator=nil;state.table=state.table+1 end
|
|
end
|
|
end
|