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

24 lines
1.4 KiB
Lua

-- Caller supplies ItemIDs from the captured rank rows. Read five item rows per
-- non-battle heartbeat, never mutating inventory or scanning other tables.
do local function capture()
local s=_G.__GacRankItemCapture1 or {i=1};_G.__GacRankItemCapture1=s
if s.done then return end
local ids=_G.__GAC_RANK_ITEM_IDS
if type(ids)~='table' or #ids==0 or #ids>64 then error('item IDs missing or outside bound')end
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
local mgr=CS.RPG.Client.GlobalVars.s_GamePhaseManager
local phase=mgr and typeof(CS.RPG.Client.GamePhaseManager):GetField('_CurrentPhase',flags):GetValue(mgr)
if not phase or typeof(CS.RPG.Client.BattleGamePhase):IsInstanceOfType(phase)then return end
for n=1,5 do
local id=ids[s.i];if not id then s.done=true;CS.UnityEngine.Debug.Log('[GAC_RANK_ITEM] END');return end
s.i=s.i+1
local item=CS.RPG.Client.ItemHelper.GetItem(id)
if not item or not item.Row then CS.UnityEngine.Debug.Log('[GAC_RANK_ITEM] MISSING '..id)
else
local row=CS.Newtonsoft.Json.JsonConvert.SerializeObject(item.Row)
if #row>16384 then error('item row size bound')end
CS.UnityEngine.Debug.Log('[GAC_RANK_ITEM] ROW {"requested_id":'..id..',"row":'..row..'}')
end
end
end local ok,e=pcall(capture);if not ok then _G.__GacRankItemCapture1={done=true};CS.UnityEngine.Debug.Log('[GAC_RANK_ITEM] ERROR '..tostring(e))end end