36 lines
1.7 KiB
Lua
36 lines
1.7 KiB
Lua
-- Read only the active CW player's rules and current node's penalty row.
|
|
-- No new sessions, scene loaders, game actions or assembly scans.
|
|
do
|
|
local state=_G.__gacCwSettlementRules1 or {};_G.__gacCwSettlementRules1=state
|
|
if state.done then return end
|
|
local log=function(v)CS.UnityEngine.Debug.Log('[GAC_CW_SETTLEMENT_RULE] '..tostring(v))end
|
|
local ok,err=pcall(function()
|
|
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
|
|
local session=CS.RPG.Client.GlobalVars.s_ModuleManager.GridFightModule.CurGameSession
|
|
if not session then return end
|
|
if not state.initialized then
|
|
local fields=session:GetType():GetFields(flags)
|
|
for i=0,math.min(fields.Length-1,63)do
|
|
local f=fields[i];local name=f.FieldType.FullName
|
|
if name=='RPG.Client.GridFightPlayer'then
|
|
local player=f:GetValue(session);if player then state.rules=player:GetVictoryRules();state.index=0;log('VICTORY_COUNT '..state.rules.Count)end
|
|
elseif name=='RPG.Client.GridFightStage'then
|
|
local stage=f:GetValue(session);local node=stage and stage.CurNode
|
|
if node then
|
|
local row=node:GetType():GetProperty('_PenaltyRuleConfigRow',flags):GetValue(node,nil)
|
|
if row then log('PENALTY_JSON '..CS.Newtonsoft.Json.JsonConvert.SerializeObject(row))end
|
|
end
|
|
end
|
|
end
|
|
state.initialized=true
|
|
end
|
|
if state.rules then
|
|
for _=1,2 do
|
|
if state.index>=state.rules.Count then log('END');state.done=true;return end
|
|
log('VICTORY_JSON '..CS.Newtonsoft.Json.JsonConvert.SerializeObject(state.rules[state.index]));state.index=state.index+1
|
|
end
|
|
else log('NO_PLAYER_RULES');state.done=true end
|
|
end)
|
|
if not ok then log('ERROR '..tostring(err));state.done=true end
|
|
end
|