using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ATO_mod_pch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ATO_mod_pch")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7c86a674-d42a-4931-a5cc-103cb2fc2136")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ATO_mod_pch;
[BepInPlugin("me.pxh1998.plugin.ato", "ATO_mod_pch", "1.0.0")]
public class ATO_mod_pch : BaseUnityPlugin
{
public static Harmony Harmony = new Harmony("me.pxh1998.plugin.ftk");
public static ATO_mod_pch Instance;
public static bool isNpcCard = false;
public static string heroClass = string.Empty;
public Hero GetRandomHero(Hero[] arr)
{
Random random = new Random();
int num = random.Next(arr.Length - 1);
return arr[num];
}
private void Awake()
{
Harmony.PatchAll();
Debug.Log((object)("Hello, world! " + Application.unityVersion));
Instance = this;
}
private void Start()
{
}
private void Update()
{
KeyboardShortcut val = default(KeyboardShortcut);
((KeyboardShortcut)(ref val))..ctor((KeyCode)290, Array.Empty<KeyCode>());
if (((KeyboardShortcut)(ref val)).IsDown())
{
Debug.Log((object)"当你看到这条消息时,表示按下了F9");
}
}
private void OnDestroy()
{
}
}
[HarmonyPatch(typeof(Character), "GetEnergyTurn")]
public class Character_GetEnergyTurn_Patch
{
[HarmonyPrefix]
public static bool Character_GetEnergyTurn_Prefix(Character __instance, ref int __result)
{
int num = __instance.GetAuraStatModifiers(__instance.EnergyTurn, (CharacterStat)3) + __instance.GetItemStatModifiers((CharacterStat)4);
if (num < 0)
{
num = 0;
}
__result = num;
return false;
}
}
[HarmonyPatch(typeof(CardData), "SetTarget")]
public class CardData_SetTarget_Patch_Pre
{
[HarmonyPrefix]
public static bool CardData_SetTarget_Patch_Prefix()
{
return true;
}
}
[HarmonyPatch(typeof(MatchManager), "GetCardData")]
public class MatchManager_GetCardData_Patch_Post
{
[HarmonyPostfix]
public static void MatchManager_GetCardData_Patch_Postfix(Globals __instance, ref CardData __result)
{
}
}
[HarmonyPatch(typeof(Globals), "GetCardData")]
public class Globals_GetCardData_Patch_Post
{
[HarmonyPostfix]
public static void Globals_GetCardData_Patch_Postfix(Globals __instance, ref CardData __result)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__result != (Object)null)
{
string text = Enum.GetName(typeof(CardClass), __result.CardClass).ToLower();
if ((Object)(object)__result.ItemEnchantment != (Object)null && text != "monster" && __result.ItemEnchantment.DestroyAfterUses >= 3)
{
__result.ItemEnchantment.DestroyAfterUses = 77;
}
if ((Object)(object)__result.ItemEnchantment != (Object)null && text != "monster" && __result.ItemEnchantment.DestroyAfterUses < 3 && __result.ItemEnchantment.DestroyAfterUses > 0)
{
__result.ItemEnchantment.DestroyAfterUses = 0;
__result.ItemEnchantment.TimesPerTurn = 3;
}
if ((Object)(object)__result.ItemEnchantment != (Object)null && text != "monster" && (__result.ItemEnchantment.DestroyStartOfTurn || (__result.ItemEnchantment.DestroyEndOfTurn && __result.ItemEnchantment.DestroyAfterUses == 0)))
{
__result.ItemEnchantment.DestroyEndOfTurn = false;
__result.ItemEnchantment.DestroyStartOfTurn = false;
}
if (ATO_mod_pch.isNpcCard)
{
Debug.Log((object)("[Globals][GetCardData]卡牌target : " + __result.Target));
__result.Playable = true;
}
}
}
}
[HarmonyPatch(typeof(CardItem), "SetCard")]
public class CardItem_SetCard_Patch
{
[HarmonyPostfix]
public static void CardItem_SetCard_Patch_Postfix(ref CardItem __instance)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Invalid comparison between Unknown and I4
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Invalid comparison between Unknown and I4
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Invalid comparison between Unknown and I4
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Invalid comparison between Unknown and I4
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Invalid comparison between Unknown and I4
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: Invalid comparison between Unknown and I4
//IL_0528: Unknown result type (might be due to invalid IL or missing references)
//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0668: Unknown result type (might be due to invalid IL or missing references)
//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0628: Unknown result type (might be due to invalid IL or missing references)
//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0568: Unknown result type (might be due to invalid IL or missing references)
//IL_0732: Unknown result type (might be due to invalid IL or missing references)
//IL_073f: Unknown result type (might be due to invalid IL or missing references)
//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
//IL_0a73: Unknown result type (might be due to invalid IL or missing references)
//IL_094d: Unknown result type (might be due to invalid IL or missing references)
//IL_0a01: Unknown result type (might be due to invalid IL or missing references)
//IL_0899: Unknown result type (might be due to invalid IL or missing references)
//IL_0a3a: Unknown result type (might be due to invalid IL or missing references)
//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0989: Unknown result type (might be due to invalid IL or missing references)
//IL_0911: Unknown result type (might be due to invalid IL or missing references)
Traverse val = Traverse.Create((object)__instance);
CardData cardData = val.Field("cardData").GetValue<CardData>();
Hero value = val.Field("theHero").GetValue<Hero>();
TMP_Text value2 = val.Field("typeTextTM").GetValue<TMP_Text>();
TMP_Text value3 = val.Field("requireTextTM").GetValue<TMP_Text>();
TMP_Text value4 = val.Field("targetTextTM").GetValue<TMP_Text>();
if (!((Object)(object)cardData != (Object)null))
{
return;
}
if ((Object)(object)value3 != (Object)null)
{
}
if (value != null && (int)cardData.CardClass == 5)
{
string target = cardData.Target;
cardData.Target = target.Replace("英雄", "怪物");
cardData.Playable = true;
if ((Object)(object)value4 != (Object)null)
{
target = value4.text;
value4.text = target.Replace("英雄", "怪物");
}
}
HeroClass val2;
if ((Object)(object)value4 != (Object)null && !ATO_mod_pch.isNpcCard)
{
Debug.Log((object)("[SetCard.targetTextTM]测试文本: " + value4.text));
if (value != null)
{
string[] obj = new string[10]
{
"[SetCard.targetTextTM]测试文本: ",
value4.text,
" 角色: ",
((Character)value).ClassName,
" 英雄名字: ",
((Character)value).SourceName,
" 英雄职业: ",
null,
null,
null
};
val2 = ((Character)value).HeroData.HeroClass;
obj[7] = ((object)(HeroClass)(ref val2)).ToString();
obj[8] = " 稀有度: ";
CardRarity cardRarity = cardData.CardRarity;
obj[9] = ((object)(CardRarity)(ref cardRarity)).ToString();
Debug.Log((object)string.Concat(obj));
string[] obj2 = new string[8] { "[SetCard.addTagFromHero]测试文本: 英雄职业: ", null, null, null, null, null, null, null };
val2 = ((Character)value).HeroData.HeroClass;
obj2[1] = ((object)(HeroClass)(ref val2)).ToString();
obj2[2] = " 英雄副职业: ";
val2 = ((Character)value).HeroData.HeroSubClass.HeroClassSecondary;
obj2[3] = ((object)(HeroClass)(ref val2)).ToString();
obj2[4] = " 英雄ID: ";
obj2[5] = ((Character)value).Id;
obj2[6] = " 英雄名字: ";
obj2[7] = ((Character)value).SourceName;
Debug.Log((object)string.Concat(obj2));
}
}
if (value != null && (Object)(object)cardData.ItemEnchantment != (Object)null && (int)cardData.CardClass == 5 && (int)cardData.ItemEnchantment.ItemTarget == 10)
{
cardData.ItemEnchantment.ItemTarget = (ItemTarget)8;
Debug.Log((object)("[SetCard.cardData.ItemEnchantment.ItemTarget]测试文本 卡牌: " + cardData.Id));
}
if (value != null && (int)cardData.CardClass == 5)
{
cardData.Playable = true;
addEnergyCostFromRarity(value, ref cardData);
__instance.DrawEnergyCost(true);
}
if (value != null && (int)cardData.CardClass == 5)
{
addTagFromHero(value, ref cardData);
val2 = ((Character)value).HeroData.HeroClass;
string? text = ((object)(HeroClass)(ref val2)).ToString();
val2 = ((Character)value).HeroData.HeroSubClass.HeroClassSecondary;
Debug.Log((object)("[SetCard.addTagFromHero]测试文本: 英雄职业: " + text + " 英雄副职业: " + ((object)(HeroClass)(ref val2)).ToString()));
((Component)__instance.typeText).gameObject.SetActive(true);
}
string text2 = Enum.GetName(typeof(CardType), cardData.CardType).ToLower();
if ((int)cardData.CardType != 0 && (int)cardData.CardClass != 8)
{
StringBuilder stringBuilder = new StringBuilder();
switch (text2)
{
default:
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2>{0}</size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "cold_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#00FFFF>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "fire_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=red>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "lightning_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#FFFF66>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "mind_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#FF66B2>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "shadow_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#000000>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "holy_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#FFFF99>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "curse_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#B266FF>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
case "healing_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#00FF00>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), cardData.CardType), "")));
break;
}
if (cardData.CardTypeAux.Length != 0)
{
CardType[] cardTypeAux = cardData.CardTypeAux;
foreach (CardType val3 in cardTypeAux)
{
switch (Enum.GetName(typeof(CardType), val3).ToLower())
{
default:
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2>{0}</size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "cold_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#00FFFF>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "fire_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=red>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "lightning_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#FFFF66>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "mind_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#FF66B2>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "shadow_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#000000>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "holy_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#FFFF99>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "curse_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#B266FF>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
case "healing_spell":
stringBuilder.Append(string.Format(" <size=-.2>[</size><size=-.2><color=#00FF00>{0}</color></size> <size=-.2>]</size>", Texts.Instance.GetText(Enum.GetName(typeof(CardType), val3), "")));
break;
}
}
}
if (stringBuilder != null && (Object)(object)value2 != (Object)null)
{
value2.text = stringBuilder.ToString();
((Component)__instance.typeTextImage).gameObject.SetActive(true);
}
}
else
{
value2.text = "";
}
}
public static void addEnergyCostFromRarity(Hero theHero, ref CardData cardData)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected I4, but got Unknown
if ((int)cardData.CardType == 28)
{
return;
}
CardRarity cardRarity = cardData.CardRarity;
CardRarity val = cardRarity;
switch ((int)val)
{
case 0:
cardData.EnergyCost = 0;
cardData.EnergyCostOriginal = 0;
break;
case 1:
cardData.EnergyCost = 1;
cardData.EnergyCostOriginal = 1;
if (cardData.Vanish)
{
cardData.EnergyCost = 0;
cardData.EnergyCostOriginal = 0;
}
break;
case 2:
cardData.EnergyCost = 1;
cardData.EnergyCostOriginal = 1;
break;
case 3:
cardData.EnergyCost = 2;
cardData.EnergyCostOriginal = 2;
break;
case 4:
cardData.EnergyCost = 3;
cardData.EnergyCostOriginal = 3;
break;
}
}
public static void addTagFromHero(Hero theHero, ref CardData cardData)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Invalid comparison between Unknown and I4
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Expected I4, but got Unknown
if ((int)cardData.CardType == 28)
{
return;
}
bool flag = false;
if (((Character)theHero).Id.Contains("warden"))
{
flag = true;
cardData.CardType = (CardType)1;
cardData.CardTypeAux = (CardType[])(object)new CardType[3];
cardData.CardTypeAux[0] = (CardType)19;
cardData.CardTypeAux[1] = (CardType)4;
cardData.CardTypeAux[2] = (CardType)16;
}
else if (((Character)theHero).Id.Contains("minstrel"))
{
flag = true;
cardData.CardType = (CardType)2;
cardData.CardTypeAux = (CardType[])(object)new CardType[4];
cardData.CardTypeAux[0] = (CardType)19;
cardData.CardTypeAux[1] = (CardType)14;
cardData.CardTypeAux[2] = (CardType)15;
cardData.CardTypeAux[3] = (CardType)20;
}
else if (((Character)theHero).Id.Contains("warlock"))
{
flag = true;
cardData.CardType = (CardType)20;
cardData.CardTypeAux = (CardType[])(object)new CardType[4];
cardData.CardTypeAux[0] = (CardType)6;
cardData.CardTypeAux[1] = (CardType)9;
cardData.CardTypeAux[2] = (CardType)11;
cardData.CardTypeAux[3] = (CardType)13;
}
else if (((Character)theHero).Id.Contains("alchemist"))
{
flag = true;
cardData.CardType = (CardType)12;
cardData.CardTypeAux = (CardType[])(object)new CardType[4];
cardData.CardTypeAux[0] = (CardType)20;
cardData.CardTypeAux[1] = (CardType)4;
cardData.CardTypeAux[2] = (CardType)16;
cardData.CardTypeAux[3] = (CardType)30;
}
if (!flag && (int)((Character)theHero).HeroData.HeroSubClass.HeroClassSecondary == 6)
{
HeroClass heroClass = ((Character)theHero).HeroData.HeroClass;
HeroClass val = heroClass;
switch ((int)val)
{
case 0:
cardData.CardType = (CardType)1;
cardData.CardTypeAux = (CardType[])(object)new CardType[3];
cardData.CardTypeAux[0] = (CardType)19;
cardData.CardTypeAux[1] = (CardType)4;
cardData.CardTypeAux[2] = (CardType)16;
break;
case 3:
cardData.CardType = (CardType)2;
cardData.CardTypeAux = (CardType[])(object)new CardType[3];
cardData.CardTypeAux[0] = (CardType)19;
cardData.CardTypeAux[1] = (CardType)14;
cardData.CardTypeAux[2] = (CardType)16;
break;
case 1:
cardData.CardType = (CardType)20;
cardData.CardTypeAux = (CardType[])(object)new CardType[4];
cardData.CardTypeAux[0] = (CardType)6;
cardData.CardTypeAux[1] = (CardType)5;
cardData.CardTypeAux[2] = (CardType)7;
cardData.CardTypeAux[3] = (CardType)13;
break;
case 2:
cardData.CardType = (CardType)12;
cardData.CardTypeAux = (CardType[])(object)new CardType[4];
cardData.CardTypeAux[0] = (CardType)20;
cardData.CardTypeAux[1] = (CardType)4;
cardData.CardTypeAux[2] = (CardType)16;
cardData.CardTypeAux[3] = (CardType)10;
break;
}
}
}
}
[HarmonyPatch(typeof(Globals), "GetItemData")]
public class Globals_GetItemData_Patch_Pre
{
[HarmonyPrefix]
public static bool Globals_GetItemData_Patch_Prefix(Globals __instance, string id, ref ItemData __result)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Invalid comparison between Unknown and I4
Traverse val = Traverse.Create((object)__instance);
Dictionary<string, ItemData> value = val.Field("_ItemDataSource").GetValue<Dictionary<string, ItemData>>();
if (value != null && value.ContainsKey(id))
{
__result = value[id];
if ((Object)(object)__instance.GetCardData(__result.Id, false) != (Object)null && (int)__instance.GetCardData(__result.Id, false).CardClass != 5 && __result.IsEnchantment)
{
__result.DestroyEndOfTurn = false;
__result.DestroyStartOfTurn = false;
}
return false;
}
__result = null;
return false;
}
}
[HarmonyPatch(typeof(ItemCombatIcon), "SetTimesExecuted")]
public class ItemCombatIcon_SetTimesExecuted_Patch
{
[HarmonyPrefix]
public static bool ItemCombatIcon_SetTimesExecuted_Prefix(ref ItemCombatIcon __instance, int times, bool doAnim = true)
{
return true;
}
}
[HarmonyPatch(typeof(CharacterItem), "KillCharacterCO")]
public class CharacterItem_KillCharacterCO_Patch
{
[HarmonyPostfix]
public static void CharacterItem_KillCharacterCO_Patch_Postfix(CharacterItem __instance)
{
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Invalid comparison between Unknown and I4
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 方法触发");
if (!((Object)(object)__instance != (Object)null))
{
return;
}
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 判断1触发");
MatchManager instance = MatchManager.Instance;
Traverse val = Traverse.Create((object)instance);
Traverse val2 = Traverse.Create((object)__instance);
int value = val.Field("heroActive").GetValue<int>();
Hero[] value2 = val.Field("TeamHero").GetValue<Hero[]>();
List<string>[] value3 = val.Field("HeroHand").GetValue<List<string>[]>();
bool value4 = val2.Field("isHero").GetValue<bool>();
NPC value5 = val2.Field("_npc").GetValue<NPC>();
Random random = new Random();
Random random2 = new Random();
if (value4 || ((Character)value5).Alive || value5 == null)
{
return;
}
bool flag = true;
int count = ((Character)value5).Cards.Count;
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 判断2触发");
for (int i = 0; i < 4; i++)
{
Hero hero = MatchManager.Instance.GetHero(i);
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 判断3触发");
if (hero == null || value == -1)
{
continue;
}
Debug.Log((object)("CharacterItem_KillCharacterCO_Patch_Postfix 判断4触发 heroActive: " + value));
if (!((Character)hero).Alive || hero != value2[value])
{
continue;
}
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 英雄回合击杀触发");
flag = false;
val.Field("theHero").SetValue((object)hero);
ATO_mod_pch.heroClass = ((Character)hero).ClassName;
if (count <= 0)
{
continue;
}
ATO_mod_pch.isNpcCard = true;
int index = random.Next(0, count);
for (int j = 0; j < count; j++)
{
if ((int)Globals.Instance.GetCardData(((Character)value5).Cards[j], false).CardType == 28 || (Object)(object)Globals.Instance.GetCardData(((Character)value5).Cards[j], false).ItemEnchantment != (Object)null)
{
index = j;
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 怪物有附魔卡触发");
}
}
AtOManager.Instance.AddCardToHero(value, ((Character)value5).Cards[index]);
AtOManager.Instance.SideBarRefreshCards(value);
if (value3[value].Count <= 0)
{
MatchManager.Instance.GenerateNewCard(1, MatchManager.Instance.CreateCardInDictionary(((Character)value5).Cards[index], "", false), true, (CardPlace)1, (CardData)null, (CardData)null, i, true, 0);
Debug.Log((object)("CharacterItem_KillCharacterCO_Patch_Postfix 英雄回合抽牌前击杀触发. 击杀时英雄手牌为: " + value3[value].Count));
}
else
{
MatchManager.Instance.GenerateNewCard(1, MatchManager.Instance.CreateCardInDictionary(((Character)value5).Cards[index], "", false), true, (CardPlace)5, (CardData)null, (CardData)null, i, true, 0);
}
ATO_mod_pch.heroClass = string.Empty;
ATO_mod_pch.isNpcCard = false;
Debug.Log((object)("给英雄单位发牌: " + ((Character)value5).Cards[index] + ", 敌人卡牌数量: " + count + "给与英雄怪物的第几张牌: " + index + " 当前行动的英雄: " + ((Character)hero).Id));
}
if (flag && count > 0)
{
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 非----英雄回合击杀触发");
int num = random2.Next(0, value2.Length);
Hero hero2 = MatchManager.Instance.GetHero(num);
ATO_mod_pch.isNpcCard = true;
int index = random.Next(0, count);
AtOManager.Instance.AddCardToHero(num, ((Character)value5).Cards[index]);
AtOManager.Instance.SideBarRefreshCards(num);
MatchManager.Instance.GenerateNewCard(1, MatchManager.Instance.CreateCardInDictionary(((Character)value5).Cards[index], "", false), true, (CardPlace)1, (CardData)null, (CardData)null, num, true, 0);
ATO_mod_pch.heroClass = string.Empty;
ATO_mod_pch.isNpcCard = false;
Debug.Log((object)("给英雄单位发牌: " + ((Character)value5).Cards[index] + ", 敌人卡牌数量: " + count + " 获得卡牌的英雄: " + ((Character)hero2).Id));
}
if (value5.NPCIsBoss() && count > 0)
{
Debug.Log((object)"CharacterItem_KillCharacterCO_Patch_Postfix 击杀Boss触发");
int num = random2.Next(0, value2.Length);
Hero hero3 = MatchManager.Instance.GetHero(num);
ATO_mod_pch.isNpcCard = true;
int index = random.Next(0, count);
AtOManager.Instance.AddCardToHero(num, ((Character)value5).Cards[index]);
AtOManager.Instance.SideBarRefreshCards(num);
MatchManager.Instance.GenerateNewCard(1, MatchManager.Instance.CreateCardInDictionary(((Character)value5).Cards[index], "", false), true, (CardPlace)1, (CardData)null, (CardData)null, num, true, 0);
ATO_mod_pch.heroClass = string.Empty;
ATO_mod_pch.isNpcCard = false;
Debug.Log((object)("给英雄单位发牌: " + ((Character)value5).Cards[index] + ", 敌人卡牌数量: " + count + " 获得卡牌的英雄: " + ((Character)hero3).Id));
}
}
}