57 lines
3.0 KiB
Lua
57 lines
3.0 KiB
Lua
-- Temporary single-banner proof. Uses initialized Standard pool state and
|
|
-- native grouping. Caller supplies one resource-backed banner in a separate
|
|
-- generated prelude; no IDs or asset paths are invented here.
|
|
do
|
|
local function run()
|
|
if _G.__gacCloneRegistration1 then return end
|
|
local banner=_G.__GAC_SINGLE_BANNER_PROOF
|
|
if not banner then return end
|
|
local m=CS.RPG.Client.GlobalVars.s_ModuleManager.GachaModule
|
|
local pools=m and m:GetSortedGachaPoolDatas()
|
|
if not pools or pools.Count==0 then return end
|
|
_G.__gacCloneRegistration1=true
|
|
local log=function(v)CS.UnityEngine.Debug.Log('[GAC_GACHA_CLONE_REGISTER] '..tostring(v))end
|
|
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
|
|
local invoke=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),0)
|
|
local empty=CS.System.Array.CreateInstance(typeof(CS.System.Object),0)
|
|
local clone=typeof(CS.System.Object):GetMethod('MemberwiseClone',flags)
|
|
local template=nil
|
|
for i=0,pools.Count-1 do
|
|
if pools[i].GachaID==banner.gacha_id then log('ALREADY_PRESENT');return end
|
|
if pools[i]:GetType().FullName=='RPG.Client.StandardGachaPoolData'then template=pools[i]end
|
|
end
|
|
if not template then error('initialized Standard template absent')end
|
|
local pool=clone:Invoke(template,invoke,nil,empty,nil)
|
|
local row=clone:Invoke(template.Row,invoke,nil,empty,nil)
|
|
row.GachaID=banner.gacha_id
|
|
local base=template:GetType().BaseType
|
|
base:GetField('<Row>k__BackingField',flags):SetValue(pool,row)
|
|
pool.SingleDrawData=clone:Invoke(template.SingleDrawData,invoke,nil,empty,nil)
|
|
pool.MultiDrawData=clone:Invoke(template.MultiDrawData,invoke,nil,empty,nil)
|
|
local t=m:GetType()
|
|
local list=t:GetField('_GachaPoolDatasThisVersion',flags):GetValue(m)
|
|
local groups=t:GetField('_GachaGroupDataDict',flags):GetValue(m)
|
|
local before={};local it=groups.Keys:GetEnumerator()
|
|
while it:MoveNext()do before[tostring(it.Current)]=true end
|
|
it:Dispose()
|
|
local count=list.Count
|
|
local ok,err=pcall(function()
|
|
list:Add(pool)
|
|
local args=CS.System.Array.CreateInstance(typeof(CS.System.Object),1);args[0]=pool
|
|
t:GetMethod('_AddGachaPoolDataToGroupDict',flags):Invoke(m,invoke,nil,args,nil)
|
|
if m:GetGachaPoolData(banner.gacha_id)~=pool then error('pool lookup did not retain clone')end
|
|
log('REGISTERED pool='..pool.GachaID..' concrete='..pool:GetType().FullName..' pools='..m:GetSortedGachaPoolDatas().Count..' groups='..m:GetSortedGachaGroupDatas().Count)
|
|
_G.__GAC_REGISTERED_BANNER_PROOF={pool=pool,banner=banner}
|
|
end)
|
|
if not ok then
|
|
list:Remove(pool)
|
|
local remove={};local iter=groups.Keys:GetEnumerator()
|
|
while iter:MoveNext()do if not before[tostring(iter.Current)]then remove[#remove+1]=iter.Current end end
|
|
iter:Dispose();for _,id in ipairs(remove)do groups:Remove(id)end
|
|
log('ROLLED_BACK list='..list.Count..' original='..count..' ERROR '..tostring(err))
|
|
end
|
|
end
|
|
local ok,e=pcall(run)
|
|
if not ok then _G.__gacCloneRegistration1=true;CS.UnityEngine.Debug.Log('[GAC_GACHA_CLONE_REGISTER] ERROR '..tostring(e))end
|
|
end
|