59 lines
3.0 KiB
Lua
59 lines
3.0 KiB
Lua
-- Capture initialized default/OtherRoles wrappers only, after the user's round.
|
|||
|
|
-- Keep outside scripts until capture is requested. Never create roles or alter stars.
|
||
|
|
-- A BattleGamePhase pauses all table work; queue construction handles four
|
||
|
|
-- handbook family per heartbeat, then encoding handles at most two roles.
|
||
|
|
do
|
||
|
|
_G.__gacCwVariants2=_G.__gacCwVariants2 or {family=0,index=1,queue={}}
|
||
|
|
local s=_G.__gacCwVariants2
|
||
|
|
if not s.done then
|
||
|
|
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
|
||
|
|
local phaseField=typeof(CS.RPG.Client.GamePhaseManager):GetField('_CurrentPhase',flags)
|
||
|
|
local manager=CS.RPG.Client.GlobalVars.s_GamePhaseManager
|
||
|
|
local phase=manager and phaseField:GetValue(manager)
|
||
|
|
local log=function(v)CS.UnityEngine.Debug.Log('[GAC_CW_ROLE_VARIANTS] '..tostring(v))end
|
||
|
|
if not phase or typeof(CS.RPG.Client.BattleGamePhase):IsInstanceOfType(phase)then
|
||
|
|
if not s.paused then log('WAIT phase='..tostring(phase and phase:GetType().FullName));s.paused=true end
|
||
|
|
return
|
||
|
|
end
|
||
|
|
if s.paused then log('RESUME');s.paused=false end
|
||
|
|
local ok,err=pcall(function()
|
||
|
|
if not s.families then
|
||
|
|
s.families=CS.RPG.Client.GlobalVars.s_ModuleManager.GridFightModule:GetHandBookAllRoleConfig()
|
||
|
|
if s.families.Count>1024 then error('Handbook family count exceeds capture bound')end
|
||
|
|
log('QUEUE families='..s.families.Count)
|
||
|
|
end
|
||
|
|
if s.family<s.families.Count then
|
||
|
|
for batch=1,4 do
|
||
|
|
if s.family>=s.families.Count then break end
|
||
|
|
local family=s.families[s.family]
|
||
|
|
s.queue[#s.queue+1]={role=family.DefaultRole,parent=family.ID,origin='DefaultRole'}
|
||
|
|
local others=family.OtherRoles
|
||
|
|
if others then
|
||
|
|
if others.Count>32 then error('Handbook variant count exceeds capture bound')end
|
||
|
|
for i=0,others.Count-1 do s.queue[#s.queue+1]={role=others[i],parent=family.ID,origin='OtherRoles'}end
|
||
|
|
end
|
||
|
|
s.family=s.family+1
|
||
|
|
end
|
||
|
|
return
|
||
|
|
end
|
||
|
|
if not s.begun then s.begun=true;log('BEGIN count='..#s.queue)end
|
||
|
|
for n=1,2 do
|
||
|
|
local entry=s.queue[s.index]
|
||
|
|
if not entry then s.done=true;log('END');s.queue=nil;return end
|
||
|
|
local role=entry.role
|
||
|
|
local config=role.RoleConfig
|
||
|
|
local row=config:GetType():GetField('_Row',flags):GetValue(config)
|
||
|
|
local starConfig=role.StarConfig
|
||
|
|
local starRow=starConfig:GetType():GetField('_Row',flags):GetValue(starConfig)
|
||
|
|
local servantRow=starConfig:GetType():GetField('_ServantStarRow',flags):GetValue(starConfig)
|
||
|
|
local text='ROW {"ParentID":'..entry.parent..',"Origin":"'..entry.origin..'","Config":'..CS.Newtonsoft.Json.JsonConvert.SerializeObject(row)
|
||
|
|
..',"Price":'..config.Price..',"MaxStar":'..config.MaxStar..',"Star":'..role.Star..',"SellPrice":'..role.SellPrice
|
||
|
|
..',"StarConfig":'..CS.Newtonsoft.Json.JsonConvert.SerializeObject(starRow)..',"ServantStarConfig":'..CS.Newtonsoft.Json.JsonConvert.SerializeObject(servantRow)..'}'
|
||
|
|
if #text>65536 then error('Role variant row exceeds output bound')end
|
||
|
|
log(text)
|
||
|
|
s.index=s.index+1
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
if not ok then log('ERROR '..tostring(err));s.done=true;s.queue=nil end
|
||
|
|
end
|
||
|
|
end
|