using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DiskCardGame; using GBC; using HarmonyLib; using InscryptionAPI.Boons; using InscryptionAPI.Card; using InscryptionAPI.CardCosts; using InscryptionAPI.Dialogue; using InscryptionAPI.Helpers; using InscryptionAPI.Helpers.Extensions; using InscryptionCommunityPatch.Card; using InscryptionCommunityPatch.ResourceManagers; using InscryptionCommunityPatch.Tests; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using Pixelplacement; using Pixelplacement.TweenSystem; using Sirenix.Serialization.Utilities; using Sirenix.Utilities; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("InscryptionCommunityPatch")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.23.7.0")] [assembly: AssemblyInformationalVersion("2.23.7+c2c1d85e82ab55ad3b88eceba9182618d37c1e16")] [assembly: AssemblyProduct("InscryptionCommunityPatch")] [assembly: AssemblyTitle("InscryptionCommunityPatch")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.23.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace InscryptionCommunityPatch { [BepInPlugin("community.inscryption.patch", "InscryptionCommunityPatch", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PatchPlugin : BaseUnityPlugin { public const string ModGUID = "community.inscryption.patch"; public const string ModName = "InscryptionCommunityPatch"; public const string ModVer = "1.0.0"; internal static PatchPlugin Instance; internal static ConfigEntry configEnergy; internal static ConfigEntry configDrone; internal static ConfigEntry configMox; internal static ConfigEntry configDroneMox; internal static ConfigEntry configShowSquirrelTribeOnCards; internal static ConfigEntry configAct3Bones; internal static ConfigEntry configCostMask; internal static ConfigEntry configResetEyes; internal static ConfigEntry undeadCatEmission; internal static ConfigEntry rightAct2Cost; internal static ConfigEntry act2CostRender; internal static ConfigEntry act2VanillaStyle; internal static ConfigEntry doubleStackSplit; internal static ConfigEntry act2StackIconType; internal static ConfigEntry configMergeOnBottom; internal static ConfigEntry configRemovePatches; internal static ConfigEntry configSmallPricetags; internal static ConfigEntry configMovePricetags; internal static ConfigEntry configTestState; internal static ConfigEntry configFullDebug; internal static ConfigEntry configDefaultDrone; internal static ConfigEntry act2TutorCenterRows; internal static ManualLogSource Logger; private readonly Harmony HarmonyInstance = new Harmony("community.inscryption.patch"); private void OnEnable() { Logger = ((BaseUnityPlugin)this).Logger; HarmonyInstance.PatchAll(typeof(PatchPlugin).Assembly); SceneManager.sceneLoaded += OnSceneLoaded; if (configTestState.Value) { ExecuteCommunityPatchTests.PrepareForTests(); TestCost.Init(); } CommunityArtPatches.PatchCommunityArt(); } private void OnDisable() { HarmonyInstance.UnpatchSelf(); } private void Awake() { Instance = this; configEnergy = ((BaseUnityPlugin)this).Config.Bind("Energy", "Energy Refresh", true, "Max energy increases and energy refreshes at end of turn"); configDrone = ((BaseUnityPlugin)this).Config.Bind("Energy", "Energy Drone", false, "Drone is visible to display energy (requires Energy Refresh)"); configDefaultDrone = ((BaseUnityPlugin)this).Config.Bind("Energy", "Default Drone", false, "Drone uses the vanilla model instead of being attached to the scales (requires Energy Drone)"); configMox = ((BaseUnityPlugin)this).Config.Bind("Mox", "Mox Refresh", true, "Mox refreshes at end of battle"); configDroneMox = ((BaseUnityPlugin)this).Config.Bind("Mox", "Mox Drone", false, "Drone displays mox (requires Energy Drone and Mox Refresh)"); configAct3Bones = ((BaseUnityPlugin)this).Config.Bind("Bones", "Act 3 Bones", false, "Force bones displayer to be active in Act 3"); configShowSquirrelTribeOnCards = ((BaseUnityPlugin)this).Config.Bind("Tribes", "Show Squirrel Tribe", false, "Shows the Squirrel tribe icon on cards"); act2CostRender = ((BaseUnityPlugin)this).Config.Bind("Card Costs", "GBC Cost render", true, "GBC Cards are able to display custom costs and hybrid costs through the API."); rightAct2Cost = ((BaseUnityPlugin)this).Config.Bind("Card Costs", "GBC Cost On Right", true, "GBC Cards display their costs on the top-right corner. If false, display on the top-left corner"); act2VanillaStyle = ((BaseUnityPlugin)this).Config.Bind("Card Costs", "GBC Vanilla Render", false, "GBC cards use vanilla sprites when rendering multiple and custom costs."); configMergeOnBottom = ((BaseUnityPlugin)this).Config.Bind("Sigil Display", "Merge_On_Botom", false, "Makes it so if enabled, merged sigils will display on the bottom of the card instead of on the artwork. In extreme cases, this can cause some visual bugs."); configRemovePatches = ((BaseUnityPlugin)this).Config.Bind("Sigil Display", "Remove_Patches", false, "Makes it so if enabled, merged sigils will not have a patch behind them anymore and will instead be glowing yellow (only works with Merge_On_Bottom)."); doubleStackSplit = ((BaseUnityPlugin)this).Config.Bind("Sigil Display", "Vanilla Stacking", false, "If enabled, cards with only two visible sigils will display each separately even if they can stack."); configSmallPricetags = ((BaseUnityPlugin)this).Config.Bind("Act 1", "Smaller Pricetags", false, "If enabled, the price tags placed on cards while buying from the Trapper will be scaled down."); configMovePricetags = ((BaseUnityPlugin)this).Config.Bind("Act 1", "Move Pricetags", false, "If enabled, the price tags placed on cards while buying from the Trapper will be moved to the right."); act2StackIconType = ((BaseUnityPlugin)this).Config.Bind("Sigil Display", "Act 2 Sigil icon type", true, "If true, stacking icons are a cream outline with a black center. If false, stacking icons are a black outline with a cream center. Act 2"); act2TutorCenterRows = ((BaseUnityPlugin)this).Config.Bind("Act 2", "Centred Hoarder UI", true, "If true, centres displayed cards in each row during the Hoarder selection sequence."); configFullDebug = ((BaseUnityPlugin)this).Config.Bind("General", "Full Debug", true, "If true, displays all debug logs in the console."); configTestState = ((BaseUnityPlugin)this).Config.Bind("General", "Test Mode", false, "Puts the game into test mode. This will cause (among potentially other things) a new run to spawn a number of cards into your opening deck that will demonstrate card behaviors."); configResetEyes = ((BaseUnityPlugin)this).Config.Bind("Act 1", "Reset Red Eyes", false, "Resets Leshy's eyes to normal if they were turned red due to a boss fight's grizzly bear sequence."); configCostMask = ((BaseUnityPlugin)this).Config.Bind("Act 1", "Render Costs Above Emission", true, "Applies a mask to card emissions that prevents them from covering play costs when rendering in-game."); undeadCatEmission = ((BaseUnityPlugin)this).Config.Bind("General", "Undead Cat Emission", false, "If true, Undead Cat will have a forced red emission."); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { EnergyDrone.TryEnableEnergy(((Scene)(ref scene)).name); } } } namespace InscryptionCommunityPatch.Tests { public class SacrificeSquirrels : BoonBehaviour { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SacrificeSquirrels <>4__this; public PlayableCard otherCard; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown int num = <>1__state; SacrificeSquirrels sacrificeSquirrels = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = ((BoonBehaviour)sacrificeSquirrels).PlayBoonAnimation(); <>1__state = 1; return true; case 1: <>1__state = -1; otherCard.TemporaryMods.Add(new CardModificationInfo((Ability)14)); ((Card)otherCard).RenderCard(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public override bool RespondsToOtherCardResolve(PlayableCard otherCard) { return ((Object)((Card)otherCard).Info).name.ToLowerInvariant().Equals("squirrel"); } [IteratorStateMachine(typeof(d__1))] public override IEnumerator OnOtherCardResolve(PlayableCard otherCard) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this, otherCard = otherCard }; } } [HarmonyPatch] public static class ExecuteCommunityPatchTests { public static Type TestBoon; public static void PrepareForTests() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) AbilityExtensions.AbilityByID((IEnumerable)AbilityManager.BaseGameAbilities, (Ability)15).Info.canStack = true; AbilityExtensions.AbilityByID((IEnumerable)AbilityManager.BaseGameAbilities, (Ability)34).Info.canStack = true; AbilityExtensions.AbilityByID((IEnumerable)AbilityManager.BaseGameAbilities, (Ability)29).Info.canStack = true; TestBoon = BoonManager.New("community.inscryption.patch", "Sacrificial Squirrels", typeof(SacrificeSquirrels), "Squirrels are super OP now", (Texture)(object)Resources.Load("art/cards/abilityicons/ability_drawcopyondeath"), (Texture)(object)Resources.Load("art/cards/boons/boonportraits/boon_startinggoat"), false, true, true); } [HarmonyPatch(typeof(AscensionSaveData), "NewRun")] [HarmonyPostfix] private static void StartRunInTestMode(ref AscensionSaveData __instance) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) if (!PatchPlugin.configTestState.Value) { return; } List list = new List { (Ability)15, (Ability)83, (Ability)6, (Ability)1, (Ability)3, (Ability)4, (Ability)100, (Ability)23, (Ability)2 }; for (int i = 2; i < 4; i++) { CardInfo cardByName = CardLoader.GetCardByName("Rabbit"); CardModificationInfo val = new CardModificationInfo(); val.abilities = new List(list.Take(i)); cardByName.mods.Add(val); CardModificationInfo val2 = new CardModificationInfo(); val2.abilities = new List { list[i - 1] }; val2.fromCardMerge = true; cardByName.mods.Add(val2); ((CardCollectionInfo)__instance.currentRun.playerDeck).AddCard(cardByName); } for (int j = 1; j <= 2; j++) { CardInfo cardByName2 = CardLoader.GetCardByName("Rabbit"); CardModificationInfo val3 = new CardModificationInfo(); val3.abilities = new List(); for (int k = 0; k < j; k++) { val3.abilities.Add((Ability)15); val3.abilities.Add((Ability)34); val3.abilities.Add((Ability)29); val3.abilities.Add((Ability)2); } cardByName2.mods.Add(val3); ((CardCollectionInfo)__instance.currentRun.playerDeck).AddCard(cardByName2); } __instance.currentRun.playerDeck.AddBoon(TestBoon); } } public class TestCost : CustomCardCost { [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int cardCost; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (cardCost > 0) { <>2__current = Singleton.Instance.SpendEnergy(cardCost); <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public override string CostName => "TestCost"; public static void Init() { PatchPlugin.Logger.LogDebug((object)"Adding TestCost"); CardCostManager.SetFoundAtChoiceNodes(CardCostManager.SetCanBePlayedByTurn2WithHand(CardCostManager.SetCostTier(CardCostManager.Register("cyantist.inscryption.api", "TestCost", typeof(TestCost), (Func)Texture3D, (Func)TexturePixel), (Func)CostTier), (Func, bool>)CanBePlayed), true, (Texture)(object)TextureHelper.GetImageAsTexture("testCost.png", typeof(TestCost).Assembly, (FilterMode)0)); } public static int CostTier(int amount) { return Mathf.FloorToInt((float)amount / 2f); } public static bool CanBePlayed(int amount, CardInfo card, List hand) { return amount <= 2; } public static Texture2D Texture3D(int cardCost, CardInfo cardInfo, PlayableCard playableCard) { return ReverseColours(TextureHelper.GetImageAsTexture($"energy_cost_{Mathf.Min(7, cardCost)}.png", typeof(PatchPlugin).Assembly, (FilterMode)0)); } public static Texture2D TexturePixel(int cardCost, CardInfo info, PlayableCard playableCard) { return ReverseColours(Part2CardCostRender.CombineIconAndCount(cardCost, TextureHelper.GetImageAsTexture("pixel_energy.png", typeof(PatchPlugin).Assembly, (FilterMode)0))); } private static Texture2D ReverseColours(Texture2D texToReverse) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); for (int i = 0; i < ((Texture)texToReverse).width; i++) { for (int j = 0; j < ((Texture)texToReverse).height; j++) { Color pixel = texToReverse.GetPixel(i, j); Color.RGBToHSV(pixel, ref num, ref num2, ref num3); Color val = Color.HSVToRGB((num + 0.5f) % 1f, (num2 + 0.5f) % 1f, (num3 + 0.5f) % 1f); val.a = pixel.a; texToReverse.SetPixel(i, j, val); } } texToReverse.Apply(); return texToReverse; } public override bool CostSatisfied(int cardCost, PlayableCard card) { return cardCost <= Singleton.Instance.PlayerEnergy - card.EnergyCost; } public override string CostUnsatisfiedHint(int cardCost, PlayableCard card) { return "Eat your greens aby. " + ((Card)card).Info.DisplayedNameLocalized; } [IteratorStateMachine(typeof(d__10))] public override IEnumerator OnPlayed(int cardCost, PlayableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { cardCost = cardCost }; } } } namespace InscryptionCommunityPatch.Sequencers { [HarmonyPatch] internal class BuyPeltsSmallTags { [HarmonyPostfix] [HarmonyPatch(typeof(BuyPeltsSequencer), "AddPricetagToCard")] private static void ReducePricetagSize(SelectableCard card) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (!PatchPlugin.configSmallPricetags.Value && !PatchPlugin.configMovePricetags.Value) { return; } Transform val = ((Component)card).transform.Find("pricetag"); if (!((Object)(object)val == (Object)null)) { if (PatchPlugin.configSmallPricetags.Value) { val.localScale = new Vector3(0.75f, 1f, 0.75f); } if (PatchPlugin.configMovePricetags.Value) { val.localPosition = new Vector3(val.localPosition.x * -1f, val.localPosition.y, val.localPosition.z); } } } } [HarmonyPatch] internal static class ChoiceNodePatch { [HarmonyPostfix] [HarmonyPatch(typeof(CardSingleChoicesSequencer), "GetCardbackTexture")] private static void CardSingleChoicesSequencer_GetCardbackTexture(ref Texture __result, CardChoice choice) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 ResourceType resourceType = choice.resourceType; if ((int)resourceType != 3) { if ((int)resourceType == 4) { __result = (Texture)(object)TextureHelper.GetImageAsTexture(MoxTextureName(choice.resourceAmount), typeof(ChoiceNodePatch).Assembly, (FilterMode)0); } } else { __result = (Texture)(object)TextureHelper.GetImageAsTexture("energyCost.png", typeof(ChoiceNodePatch).Assembly, (FilterMode)0); } } public static string MoxTextureName(int index) { return "moxCost" + index switch { 1 => "Green", 2 => "Orange", 3 => "Blue", _ => "", } + ".png"; } } [HarmonyPatch] internal class CardStatBoostSequencerPatch { [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardStatBoostSequencer instance; public bool attackMod; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (instance.GetValidCards(attackMod).Count == 0) { if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)"Player has no cards that can be boosted at the campfire."); } <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } goto IL_00d4; case 1: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("You have no creatures to warm.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 3; return true; case 3: <>1__state = -1; goto IL_00d4; case 4: { <>1__state = -1; return false; } IL_00d4: <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 4; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string name_DisplayClass = "DiskCardGame.CardStatBoostSequencer+<>c__DisplayClass12_0 <>8__1"; private const string name_AttackMod = "System.Boolean attackMod"; private const string name_ViewInstance = "DiskCardGame.ViewManager get_Instance()"; private const string name_GetValidCards = "System.Collections.Generic.List`1[DiskCardGame.CardInfo] GetValidCards(Boolean)"; private const string name_DestroyCard = "Void DestroyCard()"; private static MethodBase TargetMethod() { return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(CardStatBoostSequencer), "StatBoostSequence", (Type[])null, (Type[])null)); } private static object Transpiler(IEnumerable instructions) { //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Expected O, but got Unknown //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown List list = new List(instructions); int num = -1; int num2 = -1; object obj = null; object obj2 = null; object obj3 = null; object obj4 = null; CodeInstruction item = null; for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldfld && list[i].operand.ToString() == "DiskCardGame.CardStatBoostSequencer+<>c__DisplayClass12_0 <>8__1" && obj == null) { obj = list[i].operand; } else if (list[i].opcode == OpCodes.Ldfld && list[i].operand.ToString() == "System.Boolean attackMod" && obj2 == null) { obj2 = list[i].operand; } else if (list[i].opcode == OpCodes.Callvirt && list[i].operand.ToString() == "System.Collections.Generic.List`1[DiskCardGame.CardInfo] GetValidCards(Boolean)" && obj3 == null) { obj3 = list[i].operand; obj4 = list[i + 1].operand; } else if (list[i].opcode == OpCodes.Ldc_I4_7) { num = i - 6; } else if (list[i].opcode == OpCodes.Call && list[i].operand.ToString() == "DiskCardGame.ViewManager get_Instance()" && list[i + 1].opcode == OpCodes.Ldc_I4_1 && list[i + 3].opcode == OpCodes.Ldc_I4_0) { num2 = i + 6; } else if (list[i].opcode == OpCodes.Callvirt && list[i].operand.ToString() == "Void DestroyCard()") { item = new CodeInstruction(list[i + 1]); } if (num != -1 && num2 != -1) { MethodBase methodBase = AccessTools.Method(typeof(CardStatBoostSequencerPatch), "NewStatBoostSequence", new Type[2] { typeof(CardStatBoostSequencer), typeof(bool) }, (Type[])null); list.RemoveAt(num2); list.RemoveAt(num2); list.Insert(num2, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(num2 + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num2 + 2, new CodeInstruction(OpCodes.Ldfld, obj)); list.Insert(num2 + 3, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(num2 + 4, new CodeInstruction(OpCodes.Callvirt, (object)methodBase)); list.Insert(num, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 2, new CodeInstruction(OpCodes.Ldfld, obj)); list.Insert(num + 3, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(num + 4, new CodeInstruction(OpCodes.Callvirt, obj3)); list.Insert(num + 5, new CodeInstruction(OpCodes.Callvirt, obj4)); list.Insert(num + 6, item); list[num + 6].opcode = OpCodes.Brfalse_S; break; } } return list; } [IteratorStateMachine(typeof(d__7))] private static IEnumerator NewStatBoostSequence(CardStatBoostSequencer instance, bool attackMod) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { instance = instance, attackMod = attackMod }; } } [HarmonyPatch] internal class LeshyResetRedEyes { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TurnManager __instance; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; if (!PatchPlugin.configResetEyes.Value || !SaveManager.SaveFile.IsPart1 || (Object)(object)__instance.opponent == (Object)null) { <>2__current = enumerator; <>1__state = 1; return true; } bool flag = false; Opponent opponent = __instance.opponent; ProspectorBossOpponent val = (ProspectorBossOpponent)(object)((opponent is ProspectorBossOpponent) ? opponent : null); if (val != null) { flag = ((Part1BossOpponent)val).HasGrizzlyGlitchPhase(int.MinValue); } else { Opponent opponent2 = __instance.opponent; AnglerBossOpponent val2 = (AnglerBossOpponent)(object)((opponent2 is AnglerBossOpponent) ? opponent2 : null); if (val2 != null) { flag = ((Part1BossOpponent)val2).HasGrizzlyGlitchPhase(0); } else { Opponent opponent3 = __instance.opponent; TrapperTraderBossOpponent val3 = (TrapperTraderBossOpponent)(object)((opponent3 is TrapperTraderBossOpponent) ? opponent3 : null); if (val3 != null) { flag = ((Part1BossOpponent)val3).HasGrizzlyGlitchPhase(1); } } } if (flag) { LeshyAnimationController instance = LeshyAnimationController.Instance; if (instance != null) { instance.ResetEyesTexture(); } } <>2__current = enumerator; <>1__state = 2; return true; } case 1: <>1__state = -1; return false; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyPostfix] [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] private static IEnumerator ResetLeshyEyes(IEnumerator enumerator, TurnManager __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { enumerator = enumerator, __instance = __instance }; } } [HarmonyPatch] internal class PackRatNodeBackgroundFix { [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable FixRareBackground(IEnumerable instructions) { List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode == OpCodes.Callvirt) || !(list[i].operand.ToString() == "DiskCardGame.SelectableCard GetComponent[SelectableCard]()")) { continue; } int num = i - 3; for (int j = i + 1; j < list.Count; j++) { if (list[j].opcode == OpCodes.Stloc_2) { list.RemoveRange(num, j - 3 - num); break; } } break; } return list; } } [HarmonyPatch] public class TradeableTalkingCardFix { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Singleton.Instance.AddCardToHand(CardSpawner.SpawnPlayableCard(((Card)card).Info), new Vector3(0f, 0.5f, -3f), 0f); <>1__state = 1; return true; case 1: <>1__state = -1; Singleton.Instance.SwitchToView((View)6, false, false); Singleton.Instance.Controller.SwitchToControlMode((ControlMode)18, false); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] [HarmonyPatch(typeof(TradeCardsForPelts), "OnTradableSelected")] private static bool OnTalkingCardSelected(TradeCardsForPelts __instance, HighlightedInteractable slot, PlayableCard card) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)card != (Object)null && (Object)(object)((Component)card).GetComponent() == (Object)null) { return true; } if (__instance.PeltInHand()) { AscensionStatsData.TryIncrementStat((Type)8); PlayableCard pelt = Singleton.Instance.CardsInHand.Find((PlayableCard x) => ((Card)x).Info.HasTrait((Trait)13)); Singleton.Instance.RemoveCardFromHand(pelt); ((InteractableBase)pelt).SetEnabled(false); ((Card)pelt).Anim.SetTrigger("fly_off"); Tween.Position(((Component)pelt).transform, ((Component)pelt).transform.position + new Vector3(0f, 3f, 5f), 0.4f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)delegate { Object.Destroy((Object)(object)((Component)pelt).gameObject); }, true); card.UnassignFromSlot(); Tween.Position(((Component)card).transform, ((Component)card).transform.position + new Vector3(0f, 0.25f, -5f), 0.3f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)delegate { Object.Destroy((Object)(object)((Component)card).gameObject); }, true); ((MonoBehaviour)__instance).StartCoroutine(TradeForTalkingCard(card)); ((InteractableBase)slot).ClearDelegates(); slot.HighlightCursorType = (CursorType)0; } return false; } [IteratorStateMachine(typeof(d__1))] public static IEnumerator TradeForTalkingCard(PlayableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { card = card }; } } } namespace InscryptionCommunityPatch.ResourceManagers { [HarmonyPatch] public static class EnergyDrone { public class EnergyConfigInfo { public bool ConfigEnergy { get; set; } = PoolHasEnergy || PatchPlugin.configEnergy.Value; public bool ConfigShowDrone { get; set; } = PoolHasEnergy || PatchPlugin.configDrone.Value; public bool ConfigDroneMox { get; set; } = PoolHasGems || PatchPlugin.configDroneMox.Value; public bool ConfigMox { get; set; } = PoolHasGems || PatchPlugin.configMox.Value; public bool ConfigDefaultDrone { get; set; } = PatchPlugin.configDefaultDrone.Value; public bool ConfigDrone { get { if (!ConfigShowDrone) { return ConfigDroneMox; } return true; } } } [CompilerGenerated] private sealed class d__18 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)$"Awaking ResourceDrone, instance exists? {(Object)(object)Singleton.Instance != (Object)null}."); } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; Singleton.Instance.Awake(); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; case 2: <>1__state = -1; Singleton.Instance.AttachGemsModule(); if (EnergyConfig.ConfigDefaultDrone) { ((Component)Singleton.Instance).gameObject.transform.localPosition = Singleton.Instance.boardPosition + Vector3.up * 5f; } else { AttachDroneToScale(); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__25 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourcesManager __instance; public int amount; public IEnumerator result; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDrone && (Object)(object)Singleton.m_Instance != (Object)null) { 5__2 = __instance.PlayerEnergy - amount; goto IL_00a7; } goto IL_00ba; case 1: <>1__state = -1; 5__2++; goto IL_00a7; case 2: { <>1__state = -1; return false; } IL_00a7: if (5__2 < __instance.PlayerEnergy) { Singleton.Instance.SetCellOn(5__2, true, false); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } goto IL_00ba; IL_00ba: <>2__current = result; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__27 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourcesManager __instance; public GemType gem; public IEnumerator result; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__27(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDroneMox) { __instance.SetGemOnImmediate(gem, true); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } goto IL_006d; case 1: <>1__state = -1; goto IL_006d; case 2: { <>1__state = -1; return false; } IL_006d: <>2__current = result; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__24 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourcesManager __instance; public IEnumerator result; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDrone && (Object)(object)Singleton.m_Instance != (Object)null) { int num = __instance.PlayerMaxEnergy - 1; Singleton.Instance.OpenCell(num); <>2__current = (object)new WaitForSeconds(0.4f); <>1__state = 1; return true; } goto IL_0081; case 1: <>1__state = -1; goto IL_0081; case 2: { <>1__state = -1; return false; } IL_0081: <>2__current = result; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__28 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourcesManager __instance; public GemType gem; public IEnumerator result; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDroneMox) { __instance.SetGemOnImmediate(gem, false); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } goto IL_006d; case 1: <>1__state = -1; goto IL_006d; case 2: { <>1__state = -1; return false; } IL_006d: <>2__current = result; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__26 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourcesManager __instance; public int amount; public IEnumerator result; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDrone && (Object)(object)Singleton.m_Instance != (Object)null) { 5__2 = __instance.PlayerEnergy + amount - 1; goto IL_0105; } goto IL_011b; case 1: <>1__state = -1; 5__2--; goto IL_0105; case 2: { <>1__state = -1; return false; } IL_0105: if (5__2 >= __instance.PlayerEnergy) { AudioController.Instance.PlaySound3D("crushBlip3", (MixerGroup)4, ((Component)__instance).transform.position, 0.4f, 0f, new Pitch(0.9f + (float)(__instance.PlayerEnergy + 5__2) * 0.05f), (Repetition)null, (Randomization)null, (Distortion)null, false); Singleton.Instance.SetCellOn(5__2, false, false); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } goto IL_011b; IL_011b: <>2__current = result; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__30 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator sequence; public bool playerUpkeep; private bool 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__30(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = sequence; <>1__state = 1; return true; case 1: <>1__state = -1; if (!playerUpkeep || !CurrentSceneCanHaveEnergyDrone || !EnergyConfig.ConfigEnergy) { break; } 5__2 = !Singleton.Instance.EnergyAtMax || Singleton.Instance.PlayerEnergy < Singleton.Instance.PlayerMaxEnergy; if (5__2) { Singleton.Instance.SwitchToView((View)1, false, true); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } goto IL_00ce; case 2: <>1__state = -1; goto IL_00ce; case 3: <>1__state = -1; <>2__current = Singleton.Instance.RefreshEnergy(); <>1__state = 4; return true; case 4: <>1__state = -1; if (5__2) { <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 5; return true; } break; case 5: { <>1__state = -1; Singleton.Instance.Controller.LockState = (ViewLockState)0; break; } IL_00ce: <>2__current = Singleton.Instance.AddMaxEnergy(1); <>1__state = 3; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static Dictionary ZoneConfigs = new Dictionary { { (CardTemple)0, new EnergyConfigInfo() }, { (CardTemple)1, new EnergyConfigInfo() }, { (CardTemple)2, new EnergyConfigInfo() }, { (CardTemple)3, new EnergyConfigInfo() } }; public static bool CurrentSceneCanHaveEnergyDrone { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (string.IsNullOrEmpty(((Scene)(ref activeScene)).name)) { return false; } return SceneCanHaveEnergyDrone(((Scene)(ref activeScene)).name); } } private static EnergyConfigInfo EnergyConfig => GetEnergyConfig(); public static bool PoolHasEnergy { get; private set; } public static bool PoolHasGems { get; private set; } public static bool SceneCanHaveEnergyDrone(string sceneName) { string text = sceneName.ToLowerInvariant(); if (text.Contains("part1")) { if (!text.Contains("sanctum")) { return !text.Contains("finale"); } return false; } if (!text.Contains("magnificus")) { return text.Contains("grimora"); } return true; } public static EnergyConfigInfo GetEnergyConfig() { if (SaveManager.SaveFile.IsPart3) { return ZoneConfigs[(CardTemple)2]; } if (SaveManager.SaveFile.IsGrimora) { return ZoneConfigs[(CardTemple)1]; } if (SaveManager.SaveFile.IsMagnificus) { return ZoneConfigs[(CardTemple)3]; } return ZoneConfigs[(CardTemple)0]; } private static bool CardIsVisible(this CardInfo info, CardTemple targetTemple) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (info.temple != targetTemple) { return false; } return CardExtensions.HasAnyOfCardMetaCategories(info, (CardMetaCategory[])(object)new CardMetaCategory[3] { default(CardMetaCategory), (CardMetaCategory)1, (CardMetaCategory)3 }); } internal static void TryEnableEnergy(string sceneName) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (SceneCanHaveEnergyDrone(sceneName)) { CardTemple targetTemple = (CardTemple)(SaveManager.SaveFile.IsGrimora ? 1 : (SaveManager.SaveFile.IsMagnificus ? 3 : 0)); PoolHasEnergy = CardManager.AllCardsCopy.Any((CardInfo ci) => ci.energyCost > 0 && ci.CardIsVisible(targetTemple)); PoolHasGems = CardManager.AllCardsCopy.Any((CardInfo ci) => ci.gemsCost.Count > 0 && ci.CardIsVisible(targetTemple)); PatchPlugin.Logger.LogDebug((object)$"Card pool has Energy cards? {PoolHasEnergy}. Card pool has Gem cards? {PoolHasGems}."); Object.Instantiate(Resources.Load("prefabs/cardbattle/ResourceModules")); if (EnergyConfig.ConfigDrone) { ((MonoBehaviour)PatchPlugin.Instance).StartCoroutine(AwakeDrone()); } } } [IteratorStateMachine(typeof(d__18))] private static IEnumerator AwakeDrone() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0); } private static void AttachDroneToScale() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) try { ((Behaviour)((Component)((Component)Singleton.Instance).transform.Find("Anim")).gameObject.GetComponent()).enabled = false; ((Component)((Component)Singleton.Instance).transform.Find("Anim/Module-Energy/Propellers")).gameObject.SetActive(false); Transform val = ((Component)Singleton.Instance.Scales3D).gameObject.transform.Find("Scale"); ((Component)Singleton.Instance).transform.SetParent(val); ((Component)Singleton.Instance).transform.localEulerAngles = Vector3.zero; ((Component)Singleton.Instance).transform.localScale = new Vector3(0.6f, 0.6f, 0.6f); ((Component)Singleton.Instance).transform.localPosition = new Vector3(0.02f, -0.2f, 2f); Singleton.Instance.boardPosition = val.position; } catch { PatchPlugin.Logger.LogError((object)"Couldn't attach ResourceDrone to LifeManager.Scale3D!"); } } [HarmonyPatch(typeof(ResourceDrone), "SetOnBoard")] [HarmonyPrefix] private static bool Act1ResourceDrone_SetOnBoard(ResourceDrone __instance, bool onBoard, bool immediate) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (!CurrentSceneCanHaveEnergyDrone) { return true; } ((Component)__instance.Gems).gameObject.SetActive(EnergyConfig.ConfigDroneMox); if (onBoard) { ((Component)__instance).gameObject.SetActive(true); __instance.SetAllCellsOn(false); } if (EnergyConfig.ConfigDefaultDrone) { Vector3 val = __instance.boardPosition + (onBoard ? Vector3.zero : (Vector3.up * 5f)); if (immediate) { ((Component)__instance).gameObject.transform.position = val; if (!onBoard) { ((Component)__instance).gameObject.SetActive(false); } } else { Tween.Position(((Component)__instance).gameObject.transform, val, 1.5f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)delegate { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (onBoard) { Tween.Shake(((Component)__instance).gameObject.transform, ((Component)__instance).gameObject.transform.localPosition, Vector3.one * 0.15f, 0.15f, 0f, (LoopType)0, (Action)null, (Action)null, true); } ((Component)__instance).gameObject.SetActive(onBoard); }, true); } } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(ResourceDrone), "UpdateCellAndGemColors")] private static bool DisableUpdateWhenNull() { if ((Object)(object)Singleton.m_Instance == (Object)null) { return false; } return true; } [HarmonyPatch(typeof(Part1ResourcesManager), "CleanUp")] [HarmonyPrefix] private static void Part1ResourcesManager_CleanUp(Part1ResourcesManager __instance) { if (EnergyConfig.ConfigEnergy) { ((ResourcesManager)__instance).PlayerEnergy = 0; ((ResourcesManager)__instance).PlayerMaxEnergy = 0; } if (EnergyConfig.ConfigDrone && (Object)(object)Singleton.m_Instance != (Object)null) { Singleton.Instance.CloseAllCells(false); Singleton.Instance.SetOnBoard(false, false); if (EnergyConfig.ConfigDroneMox) { GemsModule gems = Singleton.Instance.Gems; if (gems != null) { gems.SetAllGemsOn(false, false); } } } if (EnergyConfig.ConfigMox) { ((ResourcesManager)__instance).gems.Clear(); } } [HarmonyPatch(typeof(ResourcesManager), "Setup")] [HarmonyPrefix] private static void ResourcesManager_Setup(ResourcesManager __instance) { if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDrone && (Object)(object)Singleton.m_Instance != (Object)null) { Singleton.Instance.SetOnBoard(true, false); if (EnergyConfig.ConfigDroneMox) { PatchPlugin.Logger.LogDebug((object)"Setting up extra drone resources."); Singleton.Instance.Gems.SetAllGemsOn(false, true); } } } [IteratorStateMachine(typeof(d__24))] [HarmonyPatch(typeof(ResourcesManager), "ShowAddMaxEnergy")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowAddMaxEnergy(IEnumerator result, ResourcesManager __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__24(0) { result = result, __instance = __instance }; } [IteratorStateMachine(typeof(d__25))] [HarmonyPatch(typeof(ResourcesManager), "ShowAddEnergy")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowAddEnergy(IEnumerator result, int amount, ResourcesManager __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__25(0) { result = result, amount = amount, __instance = __instance }; } [IteratorStateMachine(typeof(d__26))] [HarmonyPatch(typeof(ResourcesManager), "ShowSpendEnergy")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowSpendEnergy(IEnumerator result, int amount, ResourcesManager __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__26(0) { result = result, amount = amount, __instance = __instance }; } [IteratorStateMachine(typeof(d__27))] [HarmonyPatch(typeof(ResourcesManager), "ShowAddGem")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowAddGem(IEnumerator result, GemType gem, ResourcesManager __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__27(0) { result = result, gem = gem, __instance = __instance }; } [IteratorStateMachine(typeof(d__28))] [HarmonyPatch(typeof(ResourcesManager), "ShowLoseGem")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowLoseGem(IEnumerator result, GemType gem, ResourcesManager __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__28(0) { result = result, gem = gem, __instance = __instance }; } [HarmonyPatch(typeof(ResourcesManager), "SetGemOnImmediate")] [HarmonyPostfix] private static void ResourcesManager_SetGemOnImmediate(GemType gem, bool on, ResourcesManager __instance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (__instance is Part1ResourcesManager && (Object)(object)Singleton.m_Instance != (Object)null) { GemsModule gems = Singleton.Instance.Gems; if (gems != null) { gems.SetGemOn(gem, on, false); } } } [IteratorStateMachine(typeof(d__30))] [HarmonyPatch(typeof(TurnManager), "DoUpkeepPhase")] [HarmonyPostfix] private static IEnumerator TurnManager_UpkeepPhase(IEnumerator sequence, bool playerUpkeep) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__30(0) { sequence = sequence, playerUpkeep = playerUpkeep }; } } [HarmonyPatch] public static class Act3BonesDisplayer { [CompilerGenerated] private sealed class <>c__DisplayClass25_0 { public GameObject bolt; internal void b__0() { GlitchOutBolt(bolt); } } [CompilerGenerated] private sealed class d__25 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int amount; public CardSlot slot; public IEnumerator sequence; private int 5__2; private int 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; PatchPlugin.Logger.LogDebug((object)$"Adding {amount} bones"); if ((Object)(object)BonesTVScreen != (Object)null && amount > 0) { 5__2 = Singleton.Instance.PlayerBones - amount; 5__3 = 5__2; goto IL_01e9; } <>2__current = sequence; <>1__state = 3; return true; case 1: <>1__state = -1; AudioController.Instance.PlaySound3D((Random.value > 0.5f) ? "metal_drop#3" : "metal_object_short#2", (MixerGroup)4, ((Component)slot).transform.position, 1f, 0f, new Pitch((Variation)1), (Repetition)null, (Randomization)null, (Distortion)null, false); goto IL_0151; case 2: <>1__state = -1; 5__3++; goto IL_01e9; case 3: { <>1__state = -1; break; } IL_0151: DisplayBones(5__3); if ((Object)(object)slot == (Object)null) { AudioController.Instance.PlaySound3D("factory_chest_open", (MixerGroup)4, BonesTVScreen.transform.position, 1f, 0f, new Pitch(0.95f + (float)5__3 * 0.01f), (Repetition)null, (Randomization)null, (Distortion)null, false).spatialBlend = 0.25f; } <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 2; return true; IL_01e9: if (5__3 < 5__2 + amount) { if ((Object)(object)slot != (Object)null) { CustomCoroutine.WaitThenExecute(1.25f, (Action)new <>c__DisplayClass25_0 { bolt = WeightUtil.SpawnWeight(((Component)slot).transform, ((Component)slot).transform.position + Vector3.up, false, (GameObject)null) }.b__0, false); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } goto IL_0151; } DisplayBones(Singleton.Instance.PlayerBones); break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__26 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int amount; public IEnumerator sequence; private int 5__2; private int 5__3; private int 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; PatchPlugin.Logger.LogDebug((object)$"Spending {amount} bones"); if ((Object)(object)BonesTVScreen != (Object)null && amount > 0) { 5__2 = Mathf.Min(20, amount); 5__3 = Singleton.Instance.PlayerBones + amount; 5__4 = 5__3; goto IL_0122; } <>2__current = sequence; <>1__state = 2; return true; case 1: <>1__state = -1; 5__4--; goto IL_0122; case 2: { <>1__state = -1; break; } IL_0122: if (5__4 > 5__3 - 5__2) { DisplayBones(5__4); AudioController.Instance.PlaySound3D("factory_chest_open", (MixerGroup)4, BonesTVScreen.transform.position, 0.6f, 0f, new Pitch(0.95f + (float)5__4 * 0.01f), (Repetition)null, (Randomization)null, (Distortion)null, false).spatialBlend = 0.25f; <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } DisplayBones(Singleton.Instance.PlayerBones); break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static ConditionalWeakTable _boneTvScreen = new ConditionalWeakTable(); private static ConditionalWeakTable _boneCountRenderer = new ConditionalWeakTable(); private static Material _holoRefMaterial; public static bool ForceBonesDisplayActive { get; set; } = false; public static bool DisplayAct3Bones { get { if (!ForceBonesDisplayActive && !PoolHasBones) { return PatchPlugin.configAct3Bones.Value; } return true; } } public static bool PoolHasBones => CardManager.AllCardsCopy.Any((CardInfo ci) => ci.BonesCost > 0 && ci.CardIsVisible()); public static bool SceneCanHaveBonesDisplayer { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (string.IsNullOrEmpty(((Scene)(ref activeScene)).name)) { return false; } return ((Scene)(ref activeScene)).name.ToLowerInvariant().Contains("part3"); } } private static GameObject BonesTVScreen { get { if (_boneTvScreen.TryGetValue(Singleton.Instance, out var value)) { return value; } return null; } set { _boneTvScreen.Add(Singleton.Instance, value); } } private static SpriteRenderer BonesCountRenderer { get { if (_boneCountRenderer.TryGetValue(Singleton.Instance, out var value)) { return value; } return null; } set { _boneCountRenderer.Add(Singleton.Instance, value); } } private static Material HoloRefMaterial { get { if (_holoRefMaterial == null) { _holoRefMaterial = CardLoader.GetCardByName("BridgeRailing").holoPortraitPrefab.GetComponentInChildren().material; } return _holoRefMaterial; } } private static bool CardIsVisible(this CardInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)info.temple != 2) { return false; } return info.metaCategories.Exists((CardMetaCategory x) => (int)x == 0 || (int)x == 2 || (int)x == 3); } private static GameObject MakeBoneTokenPrefab(Transform parent) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(ResourceBank.Get("Prefabs/CardBattle/CardBattle").GetComponentInChildren().boneTokenPrefab, parent); val.transform.position = parent.position + Vector3.up * 0.25f; Object.Destroy((Object)(object)val.GetComponent()); Rigidbody component = val.GetComponent(); component.angularVelocity = new Vector3(0f, 30f, 0f); component.maxAngularVelocity = 30f; component.inertiaTensor = new Vector3(0.2f, 10f, 0.2f); Renderer[] componentsInChildren = val.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] materials = componentsInChildren[i].materials; foreach (Material val2 in materials) { val2.shader = Shader.Find("SFHologram/HologramShader"); val2.CopyPropertiesFromMaterial(HoloRefMaterial); val2.SetColor("_Color", Color.white); if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", Color.white); } if (val2.HasProperty("_MainColor")) { val2.SetColor("_MainColor", Color.white); } if (val2.HasProperty("_RimColor")) { val2.SetColor("_RimColor", Color.white); } } } return val; } private static void DisplayBones(int bones) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)BonesCountRenderer != (Object)null) { Texture2D item = Part3CardCostRender.GetIconifiedCostTexture(Part3CardCostRender.BoneCostIcon, bones, forceDigitDisplay: true).Item2; BonesCountRenderer.sprite = Sprite.Create(item, new Rect(0f, 0f, (float)((Texture)item).width, (float)((Texture)item).height), new Vector2(0.5f, 0.5f)); } } private static void GlitchOutBolt(GameObject bolt) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) AudioController.Instance.PlaySound3D("factory_chest_open", (MixerGroup)4, bolt.transform.position, 1f, 0f, new Pitch((Variation)1), (Repetition)null, (Randomization)null, (Distortion)null, false).spatialBlend = 0.25f; GlitchOutAssetEffect.TryLoad3DMaterial(); Renderer[] componentsInChildren = bolt.GetComponentsInChildren(); foreach (Renderer obj in componentsInChildren) { obj.material = GlitchOutAssetEffect.glitch3DMaterial; obj.material.SetColor("_ASEOutlineColor", Color.white); } Tween.Shake(bolt.transform, bolt.transform.localPosition, Vector3.one * 0.2f, 0.1f, 0f, (LoopType)1, (Action)null, (Action)null, false); CustomCoroutine.WaitThenExecute(0.2f, (Action)delegate { if ((Object)(object)bolt != (Object)null) { Object.Destroy((Object)(object)bolt.gameObject); } }, false); } [IteratorStateMachine(typeof(d__25))] [HarmonyPatch(typeof(ResourcesManager), "ShowAddBones")] [HarmonyPostfix] private static IEnumerator ShowAddBones_Act3(IEnumerator sequence, int amount, CardSlot slot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__25(0) { sequence = sequence, amount = amount, slot = slot }; } [IteratorStateMachine(typeof(d__26))] [HarmonyPatch(typeof(ResourcesManager), "ShowSpendBones")] [HarmonyPostfix] private static IEnumerator ShowSpendBones_Act3(IEnumerator sequence, int amount) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__26(0) { sequence = sequence, amount = amount }; } [HarmonyPatch(typeof(ResourceDrone), "Awake")] [HarmonyPostfix] private static void AttachBonesTVScreen(ref ResourceDrone __instance) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) if (SceneCanHaveBonesDisplayer && DisplayAct3Bones) { BonesTVScreen = Object.Instantiate(((Component)Singleton.Instance.buildACardSequencer.screen).gameObject, ((Component)__instance).gameObject.transform.Find("Anim")); Object.Destroy((Object)(object)((Component)BonesTVScreen.transform.Find("Anim/ScreenInteractables")).gameObject); Object.Destroy((Object)(object)((Component)BonesTVScreen.transform.Find("RenderCamera/Content/BuildACardInterface")).gameObject); ((Component)BonesTVScreen.transform.Find("Anim/CableStart_1")).gameObject.SetActive(false); ((Component)BonesTVScreen.transform.Find("Anim/CableStart_2")).gameObject.SetActive(false); ((Component)BonesTVScreen.transform.Find("Anim/CableStart_3")).gameObject.SetActive(false); BonesTVScreen.transform.localScale = new Vector3(0.3f, 0.2f, 0.2f); BonesTVScreen.transform.localPosition = new Vector3(0.6f, 0.2f, -1.8f); BonesTVScreen.transform.localEulerAngles = new Vector3(270f, 180f, 0f); Renderer component = ((Component)BonesTVScreen.transform.Find("Anim/BasicScreen/Frame")).gameObject.GetComponent(); component.material.EnableKeyword("_EMISSION"); component.material.SetColor("_EmissionColor", new Color(0f, 0.085f, 0.085f, 1f)); Renderer component2 = ((Component)BonesTVScreen.transform.Find("Anim/Pole")).gameObject.GetComponent(); component2.material.EnableKeyword("_EMISSION"); component2.material.SetColor("_EmissionColor", new Color(0f, 0.1f, 0.1f, 1f)); component2.material.SetTexture("_EmissionMap", (Texture)(object)Texture2D.whiteTexture); BonesTVScreen.SetActive(true); ((Object)BonesTVScreen).name = "Module-Bones"; GameObject val = new GameObject("BoneCounter") { layer = LayerMask.NameToLayer("CardOffscreen") }; val.transform.SetParent(BonesTVScreen.transform.Find("RenderCamera/Content")); val.transform.localPosition = new Vector3(-5f, -2.78f, 7.0601f); val.transform.localEulerAngles = new Vector3(0f, 0f, 0f); val.transform.localScale = new Vector3(18f, 33f, 10f); BonesCountRenderer = val.AddComponent(); ((Renderer)BonesCountRenderer).SetMaterial(Resources.Load("art/materials/sprite_coloroverlay")); ((Renderer)BonesCountRenderer).material.SetColor("_Color", GameColors.Instance.brightBlue * 0.85f); ((Renderer)BonesCountRenderer).material.EnableKeyword("_EMISSION"); ((Renderer)BonesCountRenderer).material.SetColor("_EmissionColor", Color.white); OLDTVScreen componentInChildren = BonesTVScreen.GetComponentInChildren(); componentInChildren.chromaticAberrationMagnetude = 0.1f; componentInChildren.noiseMagnetude = 0.2f; componentInChildren.staticMagnetude = 0.2f; componentInChildren.staticVertical = 15f; componentInChildren.staticVerticalScroll = 0.1f; componentInChildren.screenSaturation = 0f; OLDTVTube componentInChildren2 = BonesTVScreen.GetComponentInChildren(); componentInChildren2.radialDistortion = 0.6f; componentInChildren2.reflexMagnetude = 0.2f; ((Component)BonesTVScreen.transform.Find("RenderCamera")).transform.position = new Vector3(0f, -30f, -30f); DisplayBones(0); val.SetActive(true); } } [HarmonyPatch(typeof(Part3ResourcesManager), "CleanUp")] [HarmonyPrefix] private static void CleanUpPart3Bones(Part3ResourcesManager __instance) { ((ResourcesManager)__instance).PlayerBones = 0; DisplayBones(0); } } } namespace InscryptionCommunityPatch.PixelTutor { [HarmonyPatch] public static class Act2TutorFix { [CompilerGenerated] private sealed class <>c__DisplayClass5_0 { public CardInfo selectedCard; internal void b__0(CardInfo c) { selectedCard = c; } } [CompilerGenerated] private sealed class <>c__DisplayClass6_0 { public PixelPlayableCard selectedCard; internal void b__0(PixelPlayableCard x) { selectedCard = x; } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Tutor __instance; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (SaveManager.SaveFile.IsPart2) { <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 1; return true; } goto IL_00ba; case 1: <>1__state = -1; if (((AbilityBehaviour)__instance).Card.OpponentCard || Singleton.Instance.Deck.Cards.Count == 0) { PlayableCard card = ((AbilityBehaviour)__instance).Card; ((Card)((card is PixelPlayableCard) ? card : null)).Anim.NegationEffect(false); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 2; return true; } goto IL_00ba; case 2: <>1__state = -1; return false; case 3: { <>1__state = -1; return false; } IL_00ba: <>2__current = enumerator; <>1__state = 3; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Deck instance; private <>c__DisplayClass6_0 <>8__1; public Action cardSelectedCallback; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass6_0(); <>8__1.selectedCard = null; <>2__current = ((Component)Singleton.Instance).GetComponent().SelectPixelCardFrom(instance.cards, delegate(PixelPlayableCard x) { <>8__1.selectedCard = x; }); <>1__state = 1; return true; case 1: <>1__state = -1; Tween.Position(((Component)<>8__1.selectedCard).transform, ((Component)<>8__1.selectedCard).transform.position + Vector3.back * 4f, 0.1f, 0f, Tween.EaseIn, (LoopType)0, (Action)null, (Action)null, true); Object.Destroy((Object)(object)((Component)<>8__1.selectedCard).gameObject, 0.1f); cardSelectedCallback(((Card)<>8__1.selectedCard).Info); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public Deck __instance; private <>c__DisplayClass5_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass5_0(); if (!SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } if ((Object)(object)((Component)Singleton.Instance).GetComponent() == (Object)null) { <>2__current = ((CardDrawPiles)Singleton.Instance).ChooseDraw(0); <>1__state = 2; return true; } <>8__1.selectedCard = null; <>2__current = ChoosePixelCard(__instance, delegate(CardInfo c) { <>8__1.selectedCard = c; }); <>1__state = 3; return true; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; return false; case 3: <>1__state = -1; if ((Object)(object)<>8__1.selectedCard == (Object)null) { return false; } <>2__current = Singleton.Instance.SpawnCardToHand(<>8__1.selectedCard, 0.25f); <>1__state = 4; return true; case 4: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static bool HasComponent; [HarmonyPatch(typeof(BoardManager), "Initialize")] [HarmonyPostfix] private static void AddPixelSelectableArray(BoardManager __instance) { if (SaveManager.SaveFile.IsPart2 && (Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); HasComponent = true; } } [HarmonyPrefix] [HarmonyPatch(typeof(PixelPlayableCard), "ManagedUpdate")] private static bool DisableManagedUpdateForSelection(PixelPlayableCard __instance) { if (HasComponent && !((PlayableCard)__instance).OnBoard) { return ((PlayableCard)__instance).InHand; } return true; } [HarmonyPatch(typeof(PlayableCard), "OnCursorSelectStart")] [HarmonyPrefix] private static bool AddSelectedCardToHand(PlayableCard __instance) { PixelPlayableCard val = (PixelPlayableCard)(object)((__instance is PixelPlayableCard) ? __instance : null); if (val == null || __instance.OnBoard || __instance.InHand || !HasComponent) { return true; } PixelPlayableCardArray component = ((Component)Singleton.Instance).GetComponent(); if (component.displayedCards.Contains(val)) { component.selectedCard = val; } return false; } [IteratorStateMachine(typeof(d__4))] [HarmonyPatch(typeof(Tutor), "OnResolveOnBoard")] [HarmonyPostfix] private static IEnumerator AddStartDelay(IEnumerator enumerator, Tutor __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { enumerator = enumerator, __instance = __instance }; } [IteratorStateMachine(typeof(d__5))] [HarmonyPatch(typeof(Deck), "Tutor")] [HarmonyPostfix] private static IEnumerator PixelTutorSequence(IEnumerator enumerator, Deck __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { enumerator = enumerator, __instance = __instance }; } [IteratorStateMachine(typeof(d__6))] public static IEnumerator ChoosePixelCard(Deck instance, Action cardSelectedCallback) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { instance = instance, cardSelectedCallback = cardSelectedCallback }; } } public class PixelPlayableCardArray : ManagedBehaviour { [CompilerGenerated] private sealed class <>c__DisplayClass15_0 { public Func cancelCondition; internal bool b__1() { return cancelCondition(); } } [CompilerGenerated] private sealed class <>c__DisplayClass16_0 { public PixelPlayableCardArray <>4__this; public Func cancelCondition; internal bool b__1() { if (!((Object)(object)<>4__this.selectedCard != (Object)null)) { if (cancelCondition != null) { return cancelCondition(); } return false; } return true; } } [CompilerGenerated] private sealed class d__21 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PixelPlayableCardArray <>4__this; public bool forwards; public List cards; public bool deckReview; public bool forPositiveEffect; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; PixelPlayableCardArray pixelPlayableCardArray = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = pixelPlayableCardArray.CleanUpCards(); <>1__state = 1; return true; case 1: <>1__state = -1; if (forwards) { pixelPlayableCardArray.currentPageIndex = ((pixelPlayableCardArray.currentPageIndex + 1 < pixelPlayableCardArray.numPages) ? (pixelPlayableCardArray.currentPageIndex + 1) : 0); } else { pixelPlayableCardArray.currentPageIndex = ((pixelPlayableCardArray.currentPageIndex - 1 < 0) ? (pixelPlayableCardArray.numPages - 1) : (pixelPlayableCardArray.currentPageIndex - 1)); } <>2__current = pixelPlayableCardArray.SpawnAndPlaceCards(cards, pixelPlayableCardArray.GetNumRows(cards.Count), pixelPlayableCardArray.currentPageIndex, deckReview, forPositiveEffect); <>1__state = 2; return true; case 2: <>1__state = -1; pixelPlayableCardArray.SetCardsEnabled(enabled: true); pixelPlayableCardArray.EnableButtons(enable: true); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__24 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PixelPlayableCardArray <>4__this; private List.Enumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown try { int num = <>1__state; PixelPlayableCardArray pixelPlayableCardArray = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; List list = new List(pixelPlayableCardArray.displayedCards); <>7__wrap1 = list.GetEnumerator(); <>1__state = -3; goto IL_00fc; } case 1: <>1__state = -3; goto IL_00fc; case 2: { <>1__state = -1; pixelPlayableCardArray.SetOverlayEnabled(enabled: false); pixelPlayableCardArray.SetBoardEnabled(enabled: true); return false; } IL_00fc: while (<>7__wrap1.MoveNext()) { PixelPlayableCard current = <>7__wrap1.Current; if ((Object)(object)current != (Object)null) { Tween.Position(((Component)current).transform, ((Component)current).transform.position + pixelPlayableCardArray.offscreenPositionOffset, 0.1f, 0f, Tween.EaseIn, (LoopType)0, (Action)null, (Action)null, true); ((Card)current).Anim.PlayQuickRiffleSound(); Object.Destroy((Object)(object)((Component)current).gameObject, 0.1f); <>2__current = (object)new WaitForSeconds(CardPile.GetPauseBetweenCardTime(pixelPlayableCardArray.displayedCards.Count) * pixelPlayableCardArray.tweenDurationModifier * 0.5f); <>1__state = 1; return true; } } <>m__Finally1(); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__15 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Func cancelCondition; public List cards; public PixelPlayableCardArray <>4__this; public Action cardsPlacedCallback; private <>c__DisplayClass15_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown int num = <>1__state; PixelPlayableCardArray pixelPlayableCardArray = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass15_0(); <>8__1.cancelCondition = cancelCondition; cards.RemoveAll((CardInfo x) => (Object)(object)x == (Object)null); pixelPlayableCardArray.currentPageIndex = 0; pixelPlayableCardArray.numPages = 1 + (cards.Count - 1) / (pixelPlayableCardArray.maxCardsPerRow * pixelPlayableCardArray.maxRows); pixelPlayableCardArray.InitializeGamepadGrid(); <>2__current = pixelPlayableCardArray.SpawnAndPlaceCards(cards, pixelPlayableCardArray.GetNumRows(cards.Count), 0, isDeckReview: true); <>1__state = 1; return true; case 1: <>1__state = -1; pixelPlayableCardArray.InitialiseButtons(cards, deckReview: true, forPositiveEffect: true); cardsPlacedCallback?.Invoke(); pixelPlayableCardArray.SetCardsEnabled(enabled: true); if (pixelPlayableCardArray.numPages > 1) { ((Component)pixelPlayableCardArray.forwardButton).gameObject.SetActive(true); ((Component)pixelPlayableCardArray.backButton).gameObject.SetActive(true); pixelPlayableCardArray.EnableButtons(enable: true); } <>2__current = (object)new WaitUntil((Func)(() => <>8__1.cancelCondition())); <>1__state = 2; return true; case 2: <>1__state = -1; pixelPlayableCardArray.SetCardsEnabled(enabled: false); <>2__current = pixelPlayableCardArray.CleanUpCards(); <>1__state = 3; return true; case 3: <>1__state = -1; pixelPlayableCardArray.CleanUpButtons(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__16 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PixelPlayableCardArray <>4__this; public Func cancelCondition; public List cards; public bool forPositiveEffect; private <>c__DisplayClass16_0 <>8__1; public Action cardSelectedCallback; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; PixelPlayableCardArray pixelPlayableCardArray = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass16_0(); <>8__1.<>4__this = <>4__this; <>8__1.cancelCondition = cancelCondition; cards.RemoveAll((CardInfo x) => (Object)(object)x == (Object)null); pixelPlayableCardArray.currentPageIndex = 0; pixelPlayableCardArray.numPages = 1 + (cards.Count - 1) / (pixelPlayableCardArray.maxCardsPerRow * pixelPlayableCardArray.maxRows); if (cards.Count == 0) { return false; } if ((Object)(object)pixelPlayableCardArray.gameObjectReference == (Object)null) { PixelPlayableCard[] array = Resources.FindObjectsOfTypeAll(); LinqExtensions.Sort((IList)array, (Comparison)((PixelPlayableCard a, PixelPlayableCard b) => ((Card)a).Anim.cardRenderer.sortingGroupOrder - ((Card)b).Anim.cardRenderer.sortingGroupOrder)); pixelPlayableCardArray.gameObjectReference = Object.Instantiate(array[0], ((Component)pixelPlayableCardArray).transform); ((Object)pixelPlayableCardArray.gameObjectReference).name = "TutorCardObjRef"; ((Component)pixelPlayableCardArray.gameObjectReference).transform.localPosition = new Vector3(-100f, -100f, 0f); Quaternion rotation = ((Component)pixelPlayableCardArray.gameObjectReference).transform.rotation; ((Quaternion)(ref rotation)).Set(0f, 0f, 0f, 0f); } if ((Object)(object)pixelPlayableCardArray.overlay == (Object)null) { GameObject val = GameObjectExtensions.FindChild(PauseMenu.instance.menuParent, "GameFade"); pixelPlayableCardArray.overlay = Object.Instantiate(val, ((Component)pixelPlayableCardArray).transform); ((Object)pixelPlayableCardArray.overlay).name = "TutorUIFade"; SpriteRenderer component = pixelPlayableCardArray.overlay.GetComponent(); ((Renderer)component).sortingLayerID = ((Card)pixelPlayableCardArray.gameObjectReference).Anim.cardRenderer.sortingLayerID; ((Renderer)component).sortingLayerName = ((Card)pixelPlayableCardArray.gameObjectReference).Anim.cardRenderer.sortingLayerName; ((Renderer)component).sortingGroupID = ((Card)pixelPlayableCardArray.gameObjectReference).Anim.cardRenderer.sortingGroupID; ((Renderer)component).sortingOrder = -7000; } pixelPlayableCardArray.InitializeGamepadGrid(); <>2__current = pixelPlayableCardArray.SpawnAndPlaceCards(cards, pixelPlayableCardArray.GetNumRows(cards.Count), 0, isDeckReview: false, forPositiveEffect); <>1__state = 1; return true; case 1: <>1__state = -1; pixelPlayableCardArray.InitialiseButtons(cards, deckReview: false, forPositiveEffect); <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 2; return true; case 2: <>1__state = -1; pixelPlayableCardArray.SetCardsEnabled(enabled: true); if (pixelPlayableCardArray.numPages > 1) { ((Component)pixelPlayableCardArray.forwardButton).gameObject.SetActive(true); ((Component)pixelPlayableCardArray.backButton).gameObject.SetActive(true); pixelPlayableCardArray.EnableButtons(enable: true); } pixelPlayableCardArray.selectedCard = null; <>2__current = (object)new WaitUntil((Func)(() => (Object)(object)<>8__1.<>4__this.selectedCard != (Object)null || (<>8__1.cancelCondition != null && <>8__1.cancelCondition()))); <>1__state = 3; return true; case 3: <>1__state = -1; pixelPlayableCardArray.SetCardsEnabled(enabled: false); if ((Object)(object)pixelPlayableCardArray.selectedCard != (Object)null) { pixelPlayableCardArray.displayedCards.Remove(pixelPlayableCardArray.selectedCard); } <>2__current = pixelPlayableCardArray.CleanUpCards(); <>1__state = 4; return true; case 4: <>1__state = -1; pixelPlayableCardArray.CleanUpButtons(); pixelPlayableCardArray.forwardButton = (pixelPlayableCardArray.backButton = null); if ((Object)(object)pixelPlayableCardArray.selectedCard != (Object)null) { cards.Remove(((Card)pixelPlayableCardArray.selectedCard).Info); cardSelectedCallback?.Invoke(pixelPlayableCardArray.selectedCard); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__25 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int numRows; public PixelPlayableCardArray <>4__this; public int pageIndex; public List cards; public bool isDeckReview; public bool forPositiveEffect; private int 5__2; private int 5__3; private int 5__4; private int 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; PixelPlayableCardArray pixelPlayableCardArray = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; if (numRows < 1) { PatchPlugin.Logger.LogDebug((object)"NumRows for PixelPlayableCardArray is 0, displaying no cards"); return false; } pixelPlayableCardArray.SetOverlayEnabled(enabled: true); pixelPlayableCardArray.SetBoardEnabled(enabled: false); pixelPlayableCardArray.displayedCards.ForEach(delegate(PixelPlayableCard x) { if ((Object)(object)x != (Object)null) { Object.Destroy((Object)(object)((Component)x).gameObject); } }); pixelPlayableCardArray.displayedCards.Clear(); int num2 = pixelPlayableCardArray.maxRows * pixelPlayableCardArray.maxCardsPerRow; 5__2 = num2 * pageIndex; 5__3 = Mathf.Min(pixelPlayableCardArray.maxCardsPerRow, cards.Count / numRows); 5__4 = Mathf.Min(num2, cards.Count - 5__2); 5__5 = 5__2; break; } case 1: <>1__state = -1; <>2__current = (object)new WaitForSeconds(CardPile.GetPauseBetweenCardTime(cards.Count) * pixelPlayableCardArray.tweenDurationModifier); <>1__state = 2; return true; case 2: <>1__state = -1; 5__5++; break; } if (5__5 < 5__2 + 5__4) { Vector3 cardPosition = pixelPlayableCardArray.GetCardPosition(5__5 - 5__2, 5__4, numRows, 5__3); PixelPlayableCard val = pixelPlayableCardArray.CreateAndPlaceCard(cards[5__5], cardPosition); if ((Object)(object)val == (Object)null) { return false; } <>2__current = pixelPlayableCardArray.TriggerSpecialBehaviours(val, isDeckReview, forPositiveEffect); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__29 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PixelPlayableCard card; public bool isDeckReview; public bool forPositiveEffect; private SpecialCardBehaviour[] <>7__wrap1; private int <>7__wrap2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__29(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_0073; } <>1__state = -1; SpecialCardBehaviour[] components = ((Component)card).GetComponents(); <>7__wrap1 = components; <>7__wrap2 = 0; goto IL_0081; IL_0073: <>7__wrap2++; goto IL_0081; IL_0081: if (<>7__wrap2 < <>7__wrap1.Length) { SpecialCardBehaviour val = <>7__wrap1[<>7__wrap2]; if (isDeckReview) { val.OnShownInDeckReview(); goto IL_0073; } <>2__current = val.OnShownForCardSelect(forPositiveEffect); <>1__state = 1; return true; } <>7__wrap1 = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public PixelPlayableCard selectedCard; public readonly List displayedCards = new List(); private PixelPlayableCard gameObjectReference; private GameObject overlay; private GenericUIButton forwardButton; private GenericUIButton backButton; private readonly int maxRows = 6; private readonly int maxCardsPerRow = 7; private readonly float leftAnchor = -1.75f; private readonly float centreAnchor = -0.52f; private readonly float tweenDurationModifier = 0.5f; private Vector3 offscreenPositionOffset = new Vector3(2f, 2f, -4f); private int numPages; private int currentPageIndex; private GamepadGridControl gamepadGrid; [IteratorStateMachine(typeof(d__15))] public IEnumerator DisplayUntilCancelled(List cards, Func cancelCondition, Action cardsPlacedCallback = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { <>4__this = this, cards = cards, cancelCondition = cancelCondition, cardsPlacedCallback = cardsPlacedCallback }; } [IteratorStateMachine(typeof(d__16))] public IEnumerator SelectPixelCardFrom(List cards, Action cardSelectedCallback, Func cancelCondition = null, bool forPositiveEffect = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__16(0) { <>4__this = this, cards = cards, cardSelectedCallback = cardSelectedCallback, cancelCondition = cancelCondition, forPositiveEffect = forPositiveEffect }; } private void InitialiseButtons(List cards, bool deckReview, bool forPositiveEffect) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)forwardButton == (Object)null) { forwardButton = Object.Instantiate(Singleton.Instance.button, ((Component)this).transform); ((Object)forwardButton).name = "TutorForwardButton"; forwardButton.cursorType = (CursorType)12; forwardButton.defaultSprite = TextureHelper.GetImageAsSprite("forwardButton.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); forwardButton.hoveringSprite = TextureHelper.GetImageAsSprite("forwardButton_hover.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); forwardButton.disabledSprite = TextureHelper.GetImageAsSprite("forwardButton_disabled.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); forwardButton.downSprite = TextureHelper.GetImageAsSprite("forwardButton_down.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); ((Component)forwardButton).transform.position = new Vector3(1.25f, -0.75f, 0f); GenericUIButton obj = forwardButton; ((MainInputInteractable)obj).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)obj).CursorSelectStarted, (Action)delegate { OnChangePage(forwards: true, cards, deckReview, forPositiveEffect); }); backButton = Object.Instantiate(Singleton.Instance.button, ((Component)this).transform); ((Object)backButton).name = "TutorBackButton"; backButton.cursorType = (CursorType)11; backButton.defaultSprite = TextureHelper.GetImageAsSprite("backButton.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); backButton.hoveringSprite = TextureHelper.GetImageAsSprite("backButton_hover.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); backButton.disabledSprite = TextureHelper.GetImageAsSprite("backButton_disabled.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); backButton.downSprite = TextureHelper.GetImageAsSprite("backButton_down.png", typeof(PixelPlayableCardArray).Assembly, (SpriteType)12, (FilterMode)0); ((Component)backButton).transform.position = new Vector3(1.25f, -1f, 0f); GenericUIButton obj2 = backButton; ((MainInputInteractable)obj2).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectStarted, (Action)delegate { OnChangePage(forwards: false, cards, deckReview, forPositiveEffect); }); } ((Component)forwardButton).gameObject.SetActive(false); ((Component)backButton).gameObject.SetActive(false); EnableButtons(enable: false); } private void CleanUpButtons() { if (((Component)forwardButton).gameObject.active) { ((Component)forwardButton).gameObject.SetActive(false); ((Component)backButton).gameObject.SetActive(false); } } private void EnableButtons(bool enable) { ((InteractableBase)forwardButton).SetEnabled(enable); ((InteractableBase)backButton).SetEnabled(enable); } private void OnChangePage(bool forwards, List cards, bool deckReview, bool forPositiveEffect) { EnableButtons(enable: false); SetCardsEnabled(enabled: false); ((MonoBehaviour)this).StartCoroutine(ChangePage(forwards, cards, deckReview, forPositiveEffect)); } [IteratorStateMachine(typeof(d__21))] private IEnumerator ChangePage(bool forwards, List cards, bool deckReview, bool forPositiveEffect) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__21(0) { <>4__this = this, forwards = forwards, cards = cards, deckReview = deckReview, forPositiveEffect = forPositiveEffect }; } protected Vector3 GetCardPosition(int cardIndex, int cardsToPlace, int numRows, int cardsPerRow) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.FloorToInt((float)(cardIndex / cardsPerRow)); float xPos = GetXPos(cardIndex, num, cardsToPlace, cardsPerRow); float num2 = Mathf.Max(-0.801f, 0.451f - (8.5f - (float)numRows) * 0.1f * (float)num); float num3 = 0f + 0.01f * (float)num; return new Vector3(xPos, num2, num3); } private float GetXPos(int cardIndex, int cardRowIndex, int cardsToPlace, int cardsPerRow) { float num = 0.41f; float num2 = leftAnchor; int num3 = cardsPerRow * cardRowIndex; int num4 = cardsToPlace - cardsPerRow * cardRowIndex; float num5 = cardIndex - num3; if (PatchPlugin.act2TutorCenterRows.Value && num4 > 0 && num4 < cardsPerRow) { num2 = centreAnchor; num5 = (float)(cardIndex - num3) - (float)(num4 - 1) / 2f; } return num2 + num * num5; } [IteratorStateMachine(typeof(d__24))] protected IEnumerator CleanUpCards() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__24(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__25))] protected IEnumerator SpawnAndPlaceCards(List cards, int numRows, int pageIndex, bool isDeckReview = false, bool forPositiveEffect = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__25(0) { <>4__this = this, cards = cards, numRows = numRows, pageIndex = pageIndex, isDeckReview = isDeckReview, forPositiveEffect = forPositiveEffect }; } protected void TweenInCard(Transform cardTransform, Vector3 cardPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) cardTransform.localPosition = cardPos; Vector3 position = cardTransform.position; Vector3 val2 = (cardTransform.position = position + offscreenPositionOffset); Tween.Position(cardTransform, position, 0.15f, 0f, Tween.EaseOut, (LoopType)0, (Action)null, (Action)null, true); } private void InitializeGamepadGrid() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if ((Object)(object)gamepadGrid == (Object)null) { gamepadGrid = ((Component)this).gameObject.AddComponent(); gamepadGrid.Rows = new List(); } gamepadGrid.Rows.Clear(); for (int i = 0; i < maxRows + 1; i++) { gamepadGrid.Rows.Add(new Row(Array.Empty())); } ((Behaviour)gamepadGrid).enabled = false; ((Behaviour)gamepadGrid).enabled = true; } private PixelPlayableCard CreateAndPlaceCard(CardInfo info, Vector3 cardPos) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) PixelPlayableCard val = Object.Instantiate(gameObjectReference, ((Component)this).transform); ((Component)val).transform.position = Vector3.zeroVector; ((Card)val).SetInfo(info); ((Card)val).SetFaceDown(false, true); ((InteractableBase)val).SetEnabled(false); CardAnimationController anim = ((Card)val).Anim; CardAnimationController obj = ((anim is PixelCardAnimationController) ? anim : null); obj.cardRenderer.sortingGroupID = ((Card)gameObjectReference).Anim.cardRenderer.sortingGroupID; ((Renderer)((PixelCardAnimationController)obj).cardbackRenderer).sortingGroupID = ((Card)gameObjectReference).Anim.cardRenderer.sortingGroupID; obj.cardRenderer.sortingOrder = -9000; ((Renderer)((PixelCardAnimationController)obj).cardbackRenderer).sortingOrder = -8000; gamepadGrid.Rows[0].interactables.Add((InteractableBase)(object)val); displayedCards.Add(val); TweenInCard(((Component)val).transform, cardPos); ((Card)val).Anim.PlayQuickRiffleSound(); return val; } [IteratorStateMachine(typeof(d__29))] private IEnumerator TriggerSpecialBehaviours(PixelPlayableCard card, bool isDeckReview, bool forPositiveEffect) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__29(0) { card = card, isDeckReview = isDeckReview, forPositiveEffect = forPositiveEffect }; } private void SetOverlayEnabled(bool enabled) { bool flag = false; while (overlay.activeSelf != enabled) { overlay.SetActive(flag); flag = !flag; } } private int GetNumRows(int numCards) { if (numCards == 0) { return 0; } if (numCards < maxCardsPerRow) { return 1; } return Mathf.Min(maxRows, numCards / maxCardsPerRow); } private void SetCardsEnabled(bool enabled) { displayedCards.ForEach(delegate(PixelPlayableCard x) { ((InteractableBase)x).SetEnabled(enabled); }); } private void SetBoardEnabled(bool enabled) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) IEnumerable enumerable = Singleton.Instance.CardsOnBoard.Concat(Singleton.Instance.Opponent.queuedCards).Concat(Singleton.Instance.CardsInHand).Cast(); IEnumerable enumerable2 = ((IEnumerable)Singleton.Instance.AllSlots).Concat(Singleton.Instance.OpponentQueueSlots).Cast(); PixelCombatBell val = (PixelCombatBell)Resources.FindObjectsOfTypeAll(typeof(PixelCombatBell)).FirstOrDefault(); if ((int)val != 0) { ((InteractableBase)val).SetEnabled(enabled); } ((Component)Singleton.Instance).gameObject.SetActive(enabled); foreach (HighlightedInteractable item in enumerable2) { ((InteractableBase)item).SetEnabled(enabled); item.ShowState((State)(enabled ? 2 : 0), false, 0.15f); } foreach (PixelPlayableCard item2 in enumerable) { ((Component)item2).gameObject.SetActive(enabled); } Singleton.Instance.PlayerCanInitiateCombat = enabled; } } } namespace InscryptionCommunityPatch.Card { [HarmonyPatch] internal class Act2HideStatsPatch { [HarmonyPostfix] [HarmonyPatch(typeof(PixelCardDisplayer), "DisplayInfo")] private static void HideAttackAndHealth(PixelCardDisplayer __instance) { if ((((CardDisplayer)(__instance?)).info?.hideAttackAndHealth).GetValueOrDefault()) { ((CardDisplayer)__instance).SetAttackHidden(true); ((CardDisplayer)__instance).SetHealthHidden(true); } } } [HarmonyPatch] internal class Act2LogSpamFixes { [CompilerGenerated] private sealed class <>c__DisplayClass5_0 { public PlayerHand __instance; internal bool b__1() { return __instance.ChoosingSlot; } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayerHand __instance; public IEnumerator enumerator; private <>c__DisplayClass5_0 <>8__1; public PlayableCard card; private bool 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass5_0(); <>8__1.__instance = __instance; if (!SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } <>8__1.__instance.CardsInHand.ForEach(delegate(PlayableCard x) { ((InteractableBase)x).SetEnabled(false); }); <>2__current = (object)new WaitWhile((Func)(() => <>8__1.__instance.ChoosingSlot)); <>1__state = 2; return true; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; <>8__1.__instance.OnSelectSlotStartedForCard(card); Singleton.Instance.CancelledSacrifice = false; <>8__1.__instance.choosingSlotCard = card; if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Anim != (Object)null) { ((Card)card).Anim.SetSelectedToPlay(true); } Singleton.Instance.ShowCardNearBoard(card, true); if ((Object)(object)Singleton.Instance.SpecialSequencer != (Object)null) { <>2__current = Singleton.Instance.SpecialSequencer.CardSelectedFromHand(card); <>1__state = 3; return true; } goto IL_0197; case 3: <>1__state = -1; goto IL_0197; case 4: <>1__state = -1; goto IL_0215; case 5: { <>1__state = -1; CardSlot lastSelectedSlot = Singleton.Instance.LastSelectedSlot; if ((Object)(object)lastSelectedSlot != (Object)null) { 5__2 = true; ((Card)card).Anim.SetSelectedToPlay(false); <>2__current = <>8__1.__instance.PlayCardOnSlot(card, lastSelectedSlot); <>1__state = 6; return true; } break; } case 6: <>1__state = -1; if (((Card)card).Info.BonesCost > 0) { <>2__current = Singleton.Instance.SpendBones(((Card)card).Info.BonesCost); <>1__state = 7; return true; } goto IL_031c; case 7: <>1__state = -1; goto IL_031c; case 8: { <>1__state = -1; break; } IL_031c: if (card.EnergyCost > 0) { <>2__current = Singleton.Instance.SpendEnergy(card.EnergyCost); <>1__state = 8; return true; } break; IL_0215: if (!Singleton.Instance.CancelledSacrifice) { List list = Singleton.Instance.PlayerSlotsCopy.FindAll((CardSlot x) => (Object)(object)x.Card == (Object)null); <>2__current = Singleton.Instance.ChooseSlot(list, !5__3); <>1__state = 5; return true; } break; IL_0197: 5__2 = false; 5__3 = ((Card)card).Info.BloodCost > 0; if (5__3) { List list2 = Singleton.Instance.PlayerSlotsCopy.FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null); <>2__current = Singleton.Instance.ChooseSacrificesForCard(list2, card); <>1__state = 4; return true; } goto IL_0215; } if (!5__2) { Singleton.Instance.ShowCardNearBoard(card, false); } <>8__1.__instance.choosingSlotCard = null; if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Anim != (Object)null) { ((Card)card).Anim.SetSelectedToPlay(false); } <>8__1.__instance.CardsInHand.ForEach(delegate(PlayableCard x) { ((InteractableBase)x).SetEnabled(true); }); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public LifeManager __instance; public bool changeView; public int damage; public int numWeights; public bool toPlayer; public GameObject alternateWeightPrefab; public float waitBeforeCalcDamage; public float waitAfter; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } if (!((Object)(object)__instance.scales != (Object)null)) { break; } if (changeView) { Singleton.Instance.SwitchToView(__instance.scalesView, false, false); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } goto IL_00ad; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; goto IL_00ad; case 3: <>1__state = -1; if (waitBeforeCalcDamage > 0f) { <>2__current = (object)new WaitForSeconds(waitBeforeCalcDamage); <>1__state = 4; return true; } goto IL_0119; case 4: <>1__state = -1; goto IL_0119; case 5: { <>1__state = -1; break; } IL_0119: if (toPlayer) { LifeManager _instance = __instance; _instance.PlayerDamage += damage; } else { LifeManager _instance2 = __instance; _instance2.OpponentDamage += damage; } <>2__current = (object)new WaitForSeconds(waitAfter); <>1__state = 5; return true; IL_00ad: <>2__current = __instance.scales.AddDamage(damage, numWeights, toPlayer, alternateWeightPrefab); <>1__state = 3; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public TurnManager __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } __instance.PlayerWon = __instance.PlayerIsWinner(); __instance.GameEnding = true; if (!__instance.PlayerWon && (Object)(object)__instance.opponent != (Object)null && (Object)(object)__instance.opponent.Blueprint != (Object)null) { AnalyticsManager.SendFailedEncounterEvent(__instance.opponent.Blueprint, __instance.opponent.Difficulty, __instance.TurnNumber); } if ((Object)(object)__instance.SpecialSequencer != (Object)null) { <>2__current = __instance.SpecialSequencer.PreCleanUp(); <>1__state = 2; return true; } goto IL_0123; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; goto IL_0123; case 3: <>1__state = -1; ((MonoBehaviour)__instance).StartCoroutine(Singleton.Instance.CleanUp()); ((MonoBehaviour)__instance).StartCoroutine(Singleton.Instance.CleanUp()); <>2__current = __instance.opponent.CleanUp(); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = __instance.opponent.OutroSequence(__instance.PlayerWon); <>1__state = 5; return true; case 5: <>1__state = -1; ((MonoBehaviour)__instance).StartCoroutine(Singleton.Instance.CleanUp()); ((MonoBehaviour)__instance).StartCoroutine(Singleton.Instance.CleanUp()); <>2__current = Singleton.Instance.CleanUp(); <>1__state = 6; return true; case 6: <>1__state = -1; if ((Object)(object)__instance.SpecialSequencer != (Object)null) { <>2__current = __instance.SpecialSequencer.GameEnd(__instance.PlayerWon); <>1__state = 7; return true; } break; case 7: { <>1__state = -1; break; } IL_0123: Singleton.Instance.Controller.LockState = (ViewLockState)1; if (__instance.PlayerWon && __instance.PostBattleSpecialNode == null) { Singleton.Instance.SwitchToView((View)12, false, false); } else { Singleton.Instance.SwitchToView((View)1, false, false); } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 3; return true; } Object.Destroy((Object)(object)((Component)__instance.opponent).gameObject); Singleton.Instance.SetShown(false, false); Object.Destroy((Object)(object)__instance.SpecialSequencer); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public TurnManager __instance; public EncounterData encounterData; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)Singleton.Instance == (Object)null) { ((Component)Singleton.Instance).gameObject.AddComponent(); } if (!SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } __instance.IsSetupPhase = true; Singleton.Instance.PlayingLocked = true; if ((Object)(object)__instance.SpecialSequencer != (Object)null) { <>2__current = __instance.SpecialSequencer.PreBoardSetup(); <>1__state = 2; return true; } goto IL_00dd; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; goto IL_00dd; case 3: <>1__state = -1; <>2__current = Singleton.Instance.Initialize((Object)(object)__instance.SpecialSequencer == (Object)null || __instance.SpecialSequencer.ShowScalesOnStart); <>1__state = 4; return true; case 4: <>1__state = -1; ((MonoBehaviour)__instance).StartCoroutine(Singleton.Instance.Initialize()); ((MonoBehaviour)__instance).StartCoroutine(Singleton.Instance.Setup()); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 5; return true; case 5: <>1__state = -1; <>2__current = __instance.opponent.IntroSequence(encounterData); <>1__state = 6; return true; case 6: <>1__state = -1; ((MonoBehaviour)__instance).StartCoroutine(__instance.PlacePreSetCards(encounterData)); if ((Object)(object)__instance.SpecialSequencer != (Object)null) { <>2__current = __instance.SpecialSequencer.PreDeckSetup(); <>1__state = 7; return true; } goto IL_0211; case 7: <>1__state = -1; goto IL_0211; case 8: <>1__state = -1; if ((Object)(object)__instance.SpecialSequencer != (Object)null) { <>2__current = __instance.SpecialSequencer.PreHandDraw(); <>1__state = 9; return true; } goto IL_0275; case 9: <>1__state = -1; goto IL_0275; case 10: <>1__state = -1; if (__instance.opponent.QueueFirstCardBeforePlayer) { <>2__current = __instance.opponent.QueueNewCards(true, false); <>1__state = 11; return true; } break; case 11: { <>1__state = -1; break; } IL_0275: <>2__current = Singleton.Instance.DrawOpeningHand(__instance.GetFixedHand()); <>1__state = 10; return true; IL_0211: Singleton.Instance.Initialize(); <>2__current = Singleton.Instance.Initialize(); <>1__state = 8; return true; IL_00dd: <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 3; return true; } __instance.IsSetupPhase = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] [HarmonyPatch(typeof(GameFlowManager), "UpdateForTransitionToFirstPerson")] [HarmonyPatch(typeof(ViewManager), "UpdateViewControlsHintsForView")] private static bool DisableInAct2() { return !SaveManager.SaveFile.IsPart2; } [HarmonyPatch(typeof(ConduitCircuitManager), "UpdateCircuits")] [HarmonyPrefix] private static bool RemoveConduitManagerSpam(ConduitCircuitManager __instance) { if (!SaveManager.SaveFile.IsPart2) { return true; } __instance.UpdateCircuitsForSlots(Singleton.Instance.GetSlots(true)); __instance.UpdateCircuitsForSlots(Singleton.Instance.GetSlots(false)); return false; } [HarmonyPatch(typeof(PixelActivatedAbilityButton), "ManagedUpdate")] [HarmonyPrefix] private static bool RemovePixelActivatedSpam() { return SceneLoader.ActiveSceneName == "GBC_CardBattle"; } [IteratorStateMachine(typeof(d__3))] [HarmonyPatch(typeof(TurnManager), "SetupPhase")] [HarmonyPostfix] private static IEnumerator RemoveSetupPhaseSpam(IEnumerator enumerator, TurnManager __instance, EncounterData encounterData) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { enumerator = enumerator, __instance = __instance, encounterData = encounterData }; } [IteratorStateMachine(typeof(d__4))] [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] [HarmonyPostfix] private static IEnumerator RemoveAct2CleanupPhaseSpam(IEnumerator enumerator, TurnManager __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { enumerator = enumerator, __instance = __instance }; } [IteratorStateMachine(typeof(d__5))] [HarmonyPatch(typeof(PlayerHand), "SelectSlotForCard")] [HarmonyPostfix] private static IEnumerator FixSelectSlotSpamInAct2(IEnumerator enumerator, PlayerHand __instance, PlayableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { enumerator = enumerator, __instance = __instance, card = card }; } [IteratorStateMachine(typeof(d__6))] [HarmonyPatch(typeof(LifeManager), "ShowDamageSequence")] [HarmonyPostfix] private static IEnumerator FixSequenceSpamInAct2(IEnumerator enumerator, LifeManager __instance, int damage, int numWeights, bool toPlayer, float waitAfter = 0.125f, GameObject alternateWeightPrefab = null, float waitBeforeCalcDamage = 0f, bool changeView = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { enumerator = enumerator, __instance = __instance, damage = damage, numWeights = numWeights, toPlayer = toPlayer, waitAfter = waitAfter, alternateWeightPrefab = alternateWeightPrefab, waitBeforeCalcDamage = waitBeforeCalcDamage, changeView = changeView }; } } public class ActivatedAbilityHandler3D : ManagedBehaviour { public List currentIconGroup; public List interactables = new List(); public void AddInteractable(ActivatedAbilityIconInteractable interactable) { interactables.Add(interactable); } public void UpdateInteractableList(List controllerActiveIcons) { interactables.Clear(); currentIconGroup = controllerActiveIcons; CollectionExtensions.Do(controllerActiveIcons.Where((AbilityIconInteractable elem) => AbilitiesUtil.GetInfo(elem.Ability).activated), (Action)delegate(AbilityIconInteractable abIcon) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ActivatedAbilityIconInteractable component = ((Component)abIcon).gameObject.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.AssignAbility(abIcon.Ability); AddInteractable(component); } else { GameObject gameObject = ((Component)abIcon).gameObject; gameObject.layer = 0; ActivatedAbilityIconInteractable activatedAbilityIconInteractable = gameObject.AddComponent(); activatedAbilityIconInteractable.AssignAbility(abIcon.Ability); AddInteractable(activatedAbilityIconInteractable); } }); if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)("[Handler3D] Updated interactable list: [" + GeneralExtensions.Join((IEnumerable)interactables, (Func)((ActivatedAbilityIconInteractable interactable) => $"GO [{((Component)interactable).gameObject}] Ability [{interactable.Ability}]"), ", ") + "]")); } } private void OnDestroy() { foreach (ActivatedAbilityIconInteractable interactable in interactables) { Object.Destroy((Object)(object)interactable); } } } [HarmonyPatch] public static class ActivatedAbilityIconFix { public static bool HasActivatedAbility(this PlayableCard card) { if (!((Card)card).Info.Abilities.Exists((Ability elem) => AbilitiesUtil.GetInfo(elem).activated)) { return card.temporaryMods.Exists((CardModificationInfo elem) => elem.abilities.Exists((Ability elem2) => AbilitiesUtil.GetInfo(elem2).activated)); } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(ActivatedAbilityBehaviour), "RespondsToResolveOnBoard")] private static void RespondsToResolveOnBoard_PostFix(ref bool __result) { __result &= SaveManager.SaveFile.IsPart2; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "OnStatsChanged")] private static void FixActivatedAbilitiesOnAnyChange(ref PlayableCard __instance) { if (SaveManager.SaveFile.IsPart2 || !__instance.HasActivatedAbility()) { return; } ActivatedAbilityHandler3D activatedAbilityHandler3D = ((Component)__instance).GetComponent(); if (UnityExtensions.SafeIsUnityNull((Object)(object)activatedAbilityHandler3D)) { if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)("[PlayableCard.OnStatsChanged] Adding activated ability handler to card [" + ((Card)__instance).Info.displayedName + "]")); } activatedAbilityHandler3D = ((Component)__instance).gameObject.AddComponent(); } if (!UnityExtensions.SafeIsUnityNull((Object)(object)activatedAbilityHandler3D) && ((Card)__instance).AbilityIcons.abilityIcons != null) { if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)("[PlayableCard.OnStatsChanged] -> Resetting icon list for [" + ((Card)__instance).Info.displayedName + "]")); } activatedAbilityHandler3D.UpdateInteractableList(((Card)__instance).AbilityIcons.abilityIcons); } } } public class ActivatedAbilityIconInteractable : MainInputInteractable { private Material _renderMaterial; private Color _originalColor; private readonly Color _enterColor = new Color(0.7f, 0.7f, 0.7f, 0.7f); private readonly Color _selectedColor = new Color(0.4f, 0.4f, 0.4f, 0.4f); private PlayableCard _playableCard; private bool CanActivate { get { if (Object.op_Implicit((Object)(object)Singleton.Instance) && Singleton.Instance.IsPlayerMainPhase && IsValidPlayableCard && !Singleton.Instance.ChoosingSacrifices && !Singleton.Instance.ChoosingSlot) { return Singleton.Instance.StackSize == 0; } return false; } } private bool IsValidPlayableCard { get { if (Object.op_Implicit((Object)(object)_playableCard) && _playableCard.OnBoard) { return !_playableCard.OpponentCard; } return false; } } public bool AbilityAssigned => (int)Ability > 0; public Ability Ability { get; private set; } private void Start() { _playableCard = ((Component)this).GetComponentInParent(); } public void AssignAbility(Ability ability) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)$"Icon was previously {Ability} - asking to change to a {ability}"); } Ability = ability; _renderMaterial = ((Component)this).GetComponent().material; _originalColor = _renderMaterial.color; ((MainInputInteractable)this).CursorSelectEnded = (Action)Delegate.Combine(((MainInputInteractable)this).CursorSelectEnded, (Action)delegate { OnButtonPressed(); }); } private void OnButtonPressed() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (CanActivate) { ((MonoBehaviour)CustomCoroutine.Instance).StartCoroutine(_playableCard.TriggerHandler.OnTrigger((Trigger)18, new object[1] { Ability })); } } public void SetColor(Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _renderMaterial.color = color; } public override void OnCursorEnter() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SetColor(_enterColor); } public override void OnCursorExit() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SetColor(_originalColor); } public override void OnCursorSelectStart() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SetColor(_selectedColor); } public override void OnCursorSelectEnd() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SetColor(_originalColor); } public override void OnCursorDrag() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SetColor(_originalColor); } } [HarmonyPatch] internal class RenderAdditionalSigils { private static Vector3 LocalScaleBase3D { get { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!SaveManager.SaveFile.IsPart1) { return new Vector3(0.3f, 0.3f, 0.75f); } return new Vector3(0.2175f, 0.145f, 1f); } } private static GameObject NewIconGroup(CardAbilityIcons controller, Transform parent, int newSlotNum) { GameObject val = Object.Instantiate(((Component)parent.Find($"DefaultIcons_{newSlotNum - 1}Abilities")).gameObject, parent); ((Object)val).name = $"DefaultIcons_{newSlotNum}Abilities"; controller.defaultIconGroups.Add(val); return val; } private static List NewIcons(GameObject newIconGroup, int slotNum, float act1ScaleMult = 1f) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (Transform item2 in newIconGroup.transform) { Transform item = item2; list.Add(item); } GameObject val = Object.Instantiate(((Component)list[0]).gameObject, newIconGroup.transform); ((Object)val).name = (SaveManager.SaveFile.IsPart1 ? "AbilityIcon" : $"Ability_{slotNum}"); list.Add(val.transform); Vector3 localScale = LocalScaleBase3D * (SaveManager.SaveFile.IsPart1 ? act1ScaleMult : 0.65f); foreach (Transform item3 in list) { item3.localScale = localScale; } return list; } private static void AddIconSlotsToCard(Transform abilityIconParent) { if ((Object)(object)abilityIconParent == (Object)null) { return; } CardAbilityIcons component = ((Component)abilityIconParent).gameObject.GetComponent(); if (!((Object)(object)component == (Object)null)) { if ((Object)(object)abilityIconParent.Find("DefaultIcons_4Abilities") == (Object)null) { AddQuadrupleIconSlotToCard(component, abilityIconParent); } if ((Object)(object)abilityIconParent.Find("DefaultIcons_5Abilities") == (Object)null) { AddQuintupleIconSlotToCard(component, abilityIconParent); } if ((Object)(object)abilityIconParent.Find("DefaultIcons_6Abilities") == (Object)null) { AddSextupleIconSlotToCard(component, abilityIconParent); } if ((Object)(object)abilityIconParent.Find("DefaultIcons_7Abilities") == (Object)null) { AddSeptupleIconSlotToCard(component, abilityIconParent); } if ((Object)(object)abilityIconParent.Find("DefaultIcons_8Abilities") == (Object)null) { AddOctupleIconSlotToCard(component, abilityIconParent); } } } private static void AddQuadrupleIconSlotToCard(CardAbilityIcons controller, Transform abilityIconParent) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) List list = NewIcons(NewIconGroup(controller, abilityIconParent, 4), 4); list[0].localPosition = new Vector3(-0.12f, 0.06f, 0f); list[1].localPosition = new Vector3(0.12f, 0.06f, 0f); list[2].localPosition = new Vector3(-0.12f, -0.077f, 0f); list[3].localPosition = new Vector3(0.12f, -0.077f, 0f); } private static void AddQuintupleIconSlotToCard(CardAbilityIcons controller, Transform abilityIconParent) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) List list = NewIcons(NewIconGroup(controller, abilityIconParent, 5), 5, 0.75f); if (SaveManager.SaveFile.IsPart1) { list[0].localPosition = new Vector3(-0.17f, 0.06f, 0f); list[1].localPosition = new Vector3(0f, 0.06f, 0f); list[2].localPosition = new Vector3(0.17f, 0.06f, 0f); list[3].localPosition = new Vector3(-0.09f, -0.077f, 0f); list[4].localPosition = new Vector3(0.09f, -0.077f, 0f); } else { list[0].localPosition = new Vector3(-0.42f, 0.085f, 0f); list[1].localPosition = new Vector3(-0.14f, 0.085f, 0f); list[2].localPosition = new Vector3(0.14f, 0.085f, 0f); list[3].localPosition = new Vector3(0.42f, 0.085f, 0f); list[4].localPosition = new Vector3(0f, -0.125f, 0f); } } private static void AddSextupleIconSlotToCard(CardAbilityIcons controller, Transform abilityIconParent) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) List list = NewIcons(NewIconGroup(controller, abilityIconParent, 6), 6, 0.75f); if (SaveManager.SaveFile.IsPart1) { list[3].localPosition = new Vector3(-0.17f, -0.077f, 0f); list[4].localPosition = new Vector3(0f, -0.077f, 0f); list[5].localPosition = new Vector3(0.17f, -0.077f, 0f); } else { list[4].localPosition = new Vector3(-0.14f, -0.125f, 0f); list[5].localPosition = new Vector3(0.14f, -0.125f, 0f); } } private static void AddSeptupleIconSlotToCard(CardAbilityIcons controller, Transform abilityIconParent) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) List list = NewIcons(NewIconGroup(controller, abilityIconParent, 7), 7, 0.5625f); if (SaveManager.SaveFile.IsPart1) { list[0].localPosition = new Vector3(-0.18f, 0.06f, 0f); list[1].localPosition = new Vector3(-0.06f, 0.06f, 0f); list[2].localPosition = new Vector3(0.06f, 0.06f, 0f); list[3].localPosition = new Vector3(0.18f, 0.06f, 0f); list[4].localPosition = new Vector3(-0.12f, -0.067f, 0f); list[5].localPosition = new Vector3(0f, -0.067f, 0f); list[6].localPosition = new Vector3(0.12f, -0.067f, 0f); } else { list[4].localPosition = new Vector3(-0.28f, -0.125f, 0f); list[5].localPosition = new Vector3(0f, -0.125f, 0f); list[6].localPosition = new Vector3(0.28f, -0.125f, 0f); } } private static void AddOctupleIconSlotToCard(CardAbilityIcons controller, Transform abilityIconParent) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) List list = NewIcons(NewIconGroup(controller, abilityIconParent, 8), 8, 0.5625f); if (SaveManager.SaveFile.IsPart1) { list[4].localPosition = new Vector3(-0.18f, -0.067f, 0f); list[5].localPosition = new Vector3(-0.06f, -0.067f, 0f); list[6].localPosition = new Vector3(0.06f, -0.067f, 0f); list[7].localPosition = new Vector3(0.18f, -0.067f, 0f); } else { list[4].localPosition = new Vector3(-0.42f, -0.125f, 0f); list[5].localPosition = new Vector3(-0.14f, -0.125f, 0f); list[6].localPosition = new Vector3(0.14f, -0.125f, 0f); list[7].localPosition = new Vector3(0.42f, -0.125f, 0f); } } private static void AddPixelIconSlotsToCard(Transform pixelAbilityIconParent) { if ((Object)(object)pixelAbilityIconParent == (Object)null) { return; } PixelCardAbilityIcons component = ((Component)pixelAbilityIconParent).gameObject.GetComponent(); if (!((Object)(object)component == (Object)null)) { if ((Object)(object)pixelAbilityIconParent.Find("AbilityIcons_3") == (Object)null) { AddTriplePixelicon(component, pixelAbilityIconParent); } if ((Object)(object)pixelAbilityIconParent.Find("AbilityIcons_4") == (Object)null) { AddQuadruplePixelIcon(component, pixelAbilityIconParent); } if ((Object)(object)pixelAbilityIconParent.Find("AbilityIcons_5") == (Object)null) { AddQuintuplePixelIcon(component, pixelAbilityIconParent); } if ((Object)(object)pixelAbilityIconParent.Find("AbilityIcons_6") == (Object)null) { AddSextuplePixelIcon(component, pixelAbilityIconParent); } if ((Object)(object)pixelAbilityIconParent.Find("AbilityIcons_7") == (Object)null) { AddSeptuplePixelIcon(component, pixelAbilityIconParent); } if ((Object)(object)pixelAbilityIconParent.Find("AbilityIcons_8") == (Object)null) { AddOctuplePixelIcon(component, pixelAbilityIconParent); } } } private static GameObject NewPixelIconGroup(PixelCardAbilityIcons controller, Transform parent, int newSlotNum) { GameObject val = Object.Instantiate(((Component)parent.Find($"AbilityIcons_{newSlotNum - 1}")).gameObject, parent); ((Object)val).name = $"AbilityIcons_{newSlotNum}"; controller.abilityIconGroups.Add(val); return val; } private static List NewPixelIcons(GameObject newIconGroup, string newIconName, float scaleMult = 1f) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (Transform item2 in newIconGroup.transform) { Transform item = item2; list.Add(item); } GameObject val = Object.Instantiate(((Component)list[0]).gameObject, newIconGroup.transform); ((Object)val).name = newIconName; list.Add(val.transform); Vector3 localScale = Vector3.one * scaleMult; foreach (Transform item3 in list) { item3.localScale = localScale; foreach (Transform item4 in item3) { item4.localScale = Vector3.one * 0.5f; } } return list; } private static void AddTriplePixelicon(PixelCardAbilityIcons controller, Transform pixelParent) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) List list = NewPixelIcons(NewPixelIconGroup(controller, pixelParent, 3), "Right", 0.6471f); ((Object)list[1]).name = "Center"; list[0].localPosition = new Vector3(-0.13f, 0f, 0f); list[1].localPosition = new Vector3(0f, 0f, 0f); list[2].localPosition = new Vector3(0.12f, 0f, 0f); } private static void AddQuadruplePixelIcon(PixelCardAbilityIcons controller, Transform pixelParent) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) List list = NewPixelIcons(NewPixelIconGroup(controller, pixelParent, 4), "Bottom Right", 0.5294f); ((Object)list[1]).name = "Right"; ((Object)list[2]).name = "Bottom Left"; list[0].localPosition = new Vector3(-0.08f, 0.04f, 0f); list[1].localPosition = new Vector3(0.07f, 0.04f, 0f); list[2].localPosition = new Vector3(-0.08f, -0.06f, 0f); list[3].localPosition = new Vector3(0.07f, -0.06f, 0f); } private static void AddQuintuplePixelIcon(PixelCardAbilityIcons controller, Transform pixelParent) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) List list = NewPixelIcons(NewPixelIconGroup(controller, pixelParent, 5), "Bottom Right", 0.5294f); ((Object)list[1]).name = "Center"; ((Object)list[2]).name = "Right"; ((Object)list[3]).name = "Bottom Left"; list[0].localPosition = new Vector3(-0.13f, 0.04f, 0f); list[1].localPosition = new Vector3(0f, 0.04f, 0f); list[2].localPosition = new Vector3(0.12f, 0.04f, 0f); list[3].localPosition = new Vector3(-0.08f, -0.06f, 0f); list[4].localPosition = new Vector3(0.07f, -0.06f, 0f); } private static void AddSextuplePixelIcon(PixelCardAbilityIcons controller, Transform pixelParent) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) List list = NewPixelIcons(NewPixelIconGroup(controller, pixelParent, 6), "Bottom Right", 0.4706f); ((Object)list[4]).name = "Bottom Center"; list[3].localPosition = new Vector3(-0.13f, -0.04f, 0f); list[4].localPosition = new Vector3(0f, -0.04f, 0f); list[5].localPosition = new Vector3(0.12f, -0.04f, 0f); } private static void AddSeptuplePixelIcon(PixelCardAbilityIcons controller, Transform pixelParent) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) List list = NewPixelIcons(NewPixelIconGroup(controller, pixelParent, 7), "Bottom Right", 0.4706f); ((Object)list[1]).name = "Center Left"; ((Object)list[2]).name = "Center Right"; ((Object)list[3]).name = "Right"; ((Object)list[4]).name = "Bottom Left"; ((Object)list[5]).name = "Bottom Center"; list[0].localPosition = new Vector3(-0.15f, 0.04f, 0f); list[1].localPosition = new Vector3(-0.06f, 0.04f, 0f); list[2].localPosition = new Vector3(0.05f, 0.04f, 0f); list[3].localPosition = new Vector3(0.14f, 0.04f, 0f); list[4].localPosition = new Vector3(-0.09f, -0.04f, 0f); list[5].localPosition = new Vector3(0f, -0.04f, 0f); list[6].localPosition = new Vector3(0.08f, -0.04f, 0f); } private static void AddOctuplePixelIcon(PixelCardAbilityIcons controller, Transform pixelParent) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) List list = NewPixelIcons(NewPixelIconGroup(controller, pixelParent, 8), "Bottom Right", 0.4706f); ((Object)list[5]).name = "Bottom Center Left"; ((Object)list[6]).name = "Bottom Center Right"; list[4].localPosition = new Vector3(-0.15f, -0.04f, 0f); list[5].localPosition = new Vector3(-0.06f, -0.04f, 0f); list[6].localPosition = new Vector3(0.05f, -0.04f, 0f); list[7].localPosition = new Vector3(0.14f, -0.04f, 0f); } [HarmonyPrefix] [HarmonyPatch(typeof(PixelCardAbilityIcons), "DisplayAbilities", new Type[] { typeof(CardRenderInfo), typeof(PlayableCard) })] private static void AddExtraPixelAbilityIcons(PixelCardAbilityIcons __instance) { AddPixelIconSlotsToCard(((Component)__instance).transform); } [HarmonyPrefix] [HarmonyPatch(typeof(CardAbilityIcons), "UpdateAbilityIcons")] private static void AddExtraAbilityIcons(CardAbilityIcons __instance) { if (SaveManager.SaveFile.IsPart1 || SaveManager.SaveFile.IsPart3) { AddIconSlotsToCard(((Component)__instance).transform); } } } internal static class CommunityArtPatches { internal static readonly List regularIconsToPatch = new List { (Ability)74, (Ability)73, (Ability)87, (Ability)82, (Ability)70, (Ability)69, (Ability)80, (Ability)71, (Ability)81, (Ability)67, (Ability)66, (Ability)48, (Ability)49, (Ability)68, (Ability)45, (Ability)44, (Ability)79, (Ability)36, (Ability)46 }; internal static readonly List gbcIconsToPatch = new List { (Ability)77, (Ability)57, (Ability)58, (Ability)56, (Ability)78, (Ability)60, (Ability)105, (Ability)55, (Ability)85, (Ability)84, (Ability)86, (Ability)44, (Ability)72, (Ability)33, (Ability)2, (Ability)76, (Ability)11, (Ability)75, (Ability)6, (Ability)17, (Ability)63, (Ability)88, (Ability)31, (Ability)29, (Ability)64, (Ability)53, (Ability)10, (Ability)61, (Ability)32, (Ability)65 }; internal static readonly List regularCardsToPatch = new List { "Ant", "AquaSquirrel", "Bee", "BrokenEgg", "Dam", "DausBell", "DefaultTail", "EmptyVessel", "EmptyVessel_GreenGem", "EmptyVessel_OrangeGem", "EmptyVessel_BlueGem", "Ijiraq", "RavenEgg", "SkinkTail", "Tail_Bird", "Tail_Furry", "Tail_Insect" }; internal static void PatchCommunityArt() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Assembly assembly = typeof(CommunityArtPatches).Assembly; foreach (Ability item in regularIconsToPatch) { AbilityExtensions.SetIcon(AbilityExtensions.AbilityByID((IEnumerable)AbilityManager.BaseGameAbilities, item), TextureHelper.GetImageAsTexture($"{item}.png", assembly, (FilterMode)0)); } foreach (Ability item2 in gbcIconsToPatch) { AbilityExtensions.SetPixelAbilityIcon(AbilityExtensions.AbilityByID((IEnumerable)AbilityManager.BaseGameAbilities, item2).Info, TextureHelper.GetImageAsTexture($"Pixel{item2}.png", assembly, (FilterMode)0), (FilterMode?)null); } foreach (string item3 in regularCardsToPatch) { CardExtensions.SetPixelPortrait(CardExtensions.CardByName((IEnumerable)CardManager.BaseGameCards, item3), TextureHelper.GetImageAsTexture(item3 + "_pixel.png", assembly, (FilterMode)0), (FilterMode?)null); } if (PatchPlugin.undeadCatEmission.Value) { CardExtensions.AddAppearances(CardExtensions.SetEmissivePortrait(CardExtensions.CardByName((IEnumerable)CardManager.BaseGameCards, "CatUndead"), TextureHelper.GetImageAsTexture("CatUndead_emission.png", assembly, (FilterMode)0), (FilterMode?)null), (Appearance[])(object)new Appearance[1] { (Appearance)14 }); } } } [HarmonyPatch] internal class BoxColliderNegativeScalingLogSpamFix { [HarmonyPrefix] [HarmonyPatch(typeof(AbilityIconInteractable), "SetFlippedY")] private static void ReplaceBoxColliderWithMeshColliderIfIconIsFlippedY(AbilityIconInteractable __instance, bool flippedY) { if (flippedY || SaveManager.SaveFile.IsPart3) { MeshCollider component = ((Component)__instance).gameObject.GetComponent(); MeshFilter component2 = ((Component)__instance).gameObject.GetComponent(); if ((Object)(object)component == (Object)null && (Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)((Component)__instance).GetComponent()); component = ((Component)__instance).gameObject.AddComponent(); component.sharedMesh = component2.mesh; component.convex = true; ((InteractableBase)__instance).coll = (Collider)(object)component; } } } [HarmonyPostfix] [HarmonyPatch(typeof(AbilityIconInteractable), "SetFlippedY")] private static void OffsetFlippedColliderPositionY(AbilityIconInteractable __instance, bool flippedY) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (flippedY || SaveManager.SaveFile.IsPart3) { MeshCollider component = ((Component)__instance).gameObject.GetComponent(); if (!UnityExtensions.SafeIsUnityNull((Object)(object)component) && (!SaveManager.SaveFile.IsPart3 || !(((Object)((Component)__instance).transform.parent.parent).name == "LatchModule"))) { ((Component)component).transform.localPosition = new Vector3(((Component)component).transform.localPosition.x, ((Component)component).transform.localPosition.y, -0.1f); } } } [HarmonyPostfix] [HarmonyPatch(typeof(CardAbilityIcons), "PositionModIcons")] private static void ReadjustFlippedMergePosition(CardAbilityIcons __instance, List defaultAbilities, List mergeAbilities, List mergeIcons, List totemAbilities, List totemIcons) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (defaultAbilities.Count > 0) { return; } if (mergeAbilities.Count == 1 && mergeIcons.Count > 0) { if ((Object)(object)((Component)((Component)mergeIcons[0]).transform).GetComponent() != (Object)null && AbilitiesUtil.GetInfo(mergeAbilities[0]).flipYIfOpponent) { ((Component)mergeIcons[0]).transform.localPosition = new Vector3(__instance.DefaultIconPosition.x, __instance.DefaultIconPosition.y, -0.1f); } } else if (totemAbilities.Count == 1 && totemIcons.Count > 0 && (Object)(object)((Component)((Component)totemIcons[0]).transform).GetComponent() != (Object)null && AbilitiesUtil.GetInfo(totemAbilities[0]).flipYIfOpponent) { ((Component)totemIcons[0]).transform.localPosition = new Vector3(__instance.DefaultIconPosition.x, __instance.DefaultIconPosition.y, -0.1f); } } } [HarmonyPatch] public static class CardCostRender { internal static readonly Dictionary AssembledTextures = new Dictionary(); public static Texture2D GetTextureByName(string key) { if (AssembledTextures.ContainsKey(key)) { if ((Object)(object)AssembledTextures[key] != (Object)null) { return AssembledTextures[key]; } AssembledTextures.Remove(key); } Texture2D imageAsTexture = TextureHelper.GetImageAsTexture(key + ".png", typeof(CardCostRender).Assembly, (FilterMode)0); AssembledTextures.Add(key, imageAsTexture); return imageAsTexture; } public static Sprite FinalCostSprite(CardInfo cardInfo, PlayableCard playableCard, SpriteType spriteType, int yStep) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) int bloodCost = ((playableCard != null) ? CardExtensions.BloodCost(playableCard) : cardInfo.BloodCost); int bonesCost = ((playableCard != null) ? CardExtensions.BonesCost(playableCard) : cardInfo.BonesCost); int energyCost = ((playableCard != null) ? playableCard.EnergyCost : cardInfo.EnergyCost); List gemsCost = ((playableCard != null) ? CardExtensions.GemsCost(playableCard) : null) ?? cardInfo.GemsCost; Texture2D imageAsTexture; List list; if ((int)spriteType != 6) { imageAsTexture = TextureHelper.GetImageAsTexture("pixel_base.png", typeof(CardCostRender).Assembly, (FilterMode)0); list = Part2CardCostRender.CostTextures(cardInfo, playableCard, bloodCost, bonesCost, energyCost, gemsCost); } else { imageAsTexture = TextureHelper.GetImageAsTexture("empty_cost.png", typeof(CardCostRender).Assembly, (FilterMode)0); list = Part1CardCostRender.CostTextures(cardInfo, playableCard, bloodCost, bonesCost, energyCost, gemsCost); } while (list.Count < 4) { list.Add(null); } return TextureHelper.ConvertTexture(TextureHelper.CombineTextures(list, imageAsTexture, 0, yStep, 0, 0), spriteType, (FilterMode)0); } [HarmonyPostfix] [HarmonyPatch(typeof(CardDisplayer), "DisplayInfo")] private static void CreateFullCostSprite(CardDisplayer __instance, CardRenderInfo renderInfo, PlayableCard playableCard) { if ((Object)(object)renderInfo?.baseInfo == (Object)null || (Object)(object)__instance.costRenderer == (Object)null) { return; } if (__instance is CardDisplayer3D && SaveManager.SaveFile.IsPart1) { __instance.costRenderer.sprite = FinalCostSprite(renderInfo.baseInfo, playableCard, (SpriteType)6, 28); return; } PixelCardDisplayer val = (PixelCardDisplayer)(object)((__instance is PixelCardDisplayer) ? __instance : null); if (val != null && PatchPlugin.act2CostRender.Value) { if (PatchPlugin.act2VanillaStyle.Value) { __instance.costRenderer.sprite = Part2CardCostRender.FinalVanillaCostSprite(val, renderInfo.baseInfo, playableCard, !PatchPlugin.rightAct2Cost.Value); } else { __instance.costRenderer.sprite = FinalCostSprite(renderInfo.baseInfo, playableCard, (SpriteType)(PatchPlugin.rightAct2Cost.Value ? 8 : 7), 8); } } } [HarmonyPrefix] [HarmonyPatch(typeof(CardDisplayer), "GetCostSpriteForCard")] private static bool Part1CardCostDisplayerPatch(CardDisplayer __instance, ref Sprite __result, CardInfo card) { if (__instance is CardDisplayer3D && SceneLoader.ActiveSceneName.StartsWith("Part1")) { return false; } if (__instance is PixelCardDisplayer && PatchPlugin.act2CostRender.Value) { return false; } return true; } } [HarmonyPatch] internal class GiantCardEmissionAspectFix { [HarmonyPostfix] [HarmonyPatch(typeof(CardRenderCamera), "TryCreateCameraForLiveRender")] private static void FixGiantEmissionCameraAspectRatio(CardRenderCamera __instance, RenderStatsLayer layer) { if (SaveManager.SaveFile.IsPart1 && __instance.liveRenderCameras.ContainsKey(layer)) { RenderLiveStatsLayer val = (RenderLiveStatsLayer)(object)((layer is RenderLiveStatsLayer) ? layer : null); if (val != null && val.Giant) { Transform obj = ((Component)__instance.liveRenderCameras[layer]).transform.Find("EmissionRenderCamera"); ((Component)obj).GetComponent().aspect = 1.434f; ((Component)obj).GetComponent().defaultAspect = 1.434f; } } } } [HarmonyPatch] internal class HiddenCharIndexFIx { [HarmonyPatch(typeof(SequentialText), "RemoveFirstHiddenChar")] [HarmonyPrefix] private static bool CheckForNegativeIndex(SequentialText __instance, ref int __result) { int num = __instance.GetText().IndexOf(""); if (num != -1) { __instance.SetText(__instance.GetText().Remove(num, 26)); } else { num = 0; } __result = num; return false; } } [HarmonyPatch] public class MergedSigilOnBottom { [HarmonyPatch(typeof(CardAbilityIcons), "ApplyAbilitiesToIcons")] [HarmonyPrefix] private static bool DontPlaceCardModIcons_IfShowOnBottom(CardAbilityIcons __instance, List icons, Material iconMat) { if ((Object)(object)iconMat == (Object)(object)__instance.emissiveIconMat && PatchPlugin.configMergeOnBottom.Value && PatchPlugin.configRemovePatches.Value) { foreach (AbilityIconInteractable icon in icons) { ((Component)icon).gameObject.SetActive(false); } return false; } return true; } [HarmonyPatch(typeof(CardAbilityIcons), "PositionModIcons")] [HarmonyPrefix] private static void MoveMergeIconsToDefaultGroup_IfShowOnBottom(List defaultAbilities, List mergeAbilities) { if (PatchPlugin.configMergeOnBottom.Value) { defaultAbilities.AddRange(mergeAbilities); if (PatchPlugin.configRemovePatches.Value) { mergeAbilities.Clear(); } } } [HarmonyPatch(typeof(AbilityIconInteractable), "LoadIcon")] [HarmonyPostfix] private static void RepositionAndRetextureMergedIcons_IfShowOnBottom(ref CardInfo info, ref AbilityInfo ability, ref AbilityIconInteractable __instance) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) if (!PatchPlugin.configMergeOnBottom.Value || !((Object)(object)info != (Object)null) || info.Mods.Count <= 0) { return; } List list = info.Mods.FindAll((CardModificationInfo x) => x.fromCardMerge); if (list.Count <= 0) { return; } foreach (CardModificationInfo item in list) { if (!item.abilities.Contains(ability.ability) || (!(((Object)__instance).name == "AbilityIcon") && !(((Object)__instance).name == "DefaultIcons_1Ability"))) { continue; } if (PatchPlugin.configRemovePatches.Value) { __instance.SetMaterial(Singleton.Instance.totemIconMat); if ((Object)(object)((Component)__instance).GetComponentInParent() != (Object)null) { ((Renderer)((Component)__instance).GetComponentInParent()).enabled = true; } __instance.SetColor(Color.white); break; } if (info.DefaultAbilities.Count + list.Count > 8) { continue; } Transform[] componentsInChildren = ((Component)((Component)((Component)__instance).transform.parent).transform.parent).GetComponentsInChildren(); if (((Object)__instance).name == "DefaultIcons_1Ability") { componentsInChildren = ((Component)((Component)__instance).transform.parent).GetComponentsInChildren(); } Transform[] array = componentsInChildren; foreach (Transform val in array) { if (((Component)val).gameObject.activeSelf && ((Object)((Component)val).gameObject).name.StartsWith("CardMergeIcon_") && ((Component)val).gameObject.GetComponent().Ability == __instance.Ability) { ((Component)val).gameObject.transform.localPosition = ((Component)__instance).transform.localPosition; ((Component)val).gameObject.transform.localScale = ((Component)__instance).transform.localScale; } } } } } [HarmonyPatch] public class MissingSquirrelTribeIconFix { [HarmonyPatch(typeof(ResourceBank), "Awake")] private class ResourceBank_Awake { [HarmonyPostfix] private static void Postfix(ResourceBank __instance) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("tribeicon_squirrel.png", typeof(MissingSquirrelTribeIconFix).Assembly, (FilterMode)0); __instance.resources.Add(new Resource { path = "Art/Cards/TribeIcons/tribeicon_squirrel", asset = (Object)(object)TextureHelper.ConvertTexture(imageAsTexture, (Vector2?)null) }); } } [HarmonyPatch(typeof(CardDisplayer3D), "UpdateTribeIcon")] private class CardDisplayer3D_UpdateTribeIcon { public static IEnumerable Transpiler(IEnumerable instructions) { MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => ShowTribeOnCard(null, (Tribe)1))); MethodInfo methodInfo2 = AccessTools.Method(typeof(CardInfo), "IsOfTribe", new Type[1] { typeof(Tribe) }, (Type[])null); List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Callvirt && (MethodInfo)list[i].operand == methodInfo2) { list[i].operand = methodInfo; break; } } return list; } private static bool ShowTribeOnCard(CardInfo info, Tribe tribe) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 if (!info.IsOfTribe(tribe)) { return false; } if ((int)tribe == 1) { return PatchPlugin.configShowSquirrelTribeOnCards.Value; } return true; } } } public static class Part1CardCostRender { public static event Action> UpdateCardCost; public static event Action> UpdatePlayableCardCost; public static List CostTextures(CardInfo cardInfo, PlayableCard playableCard, int bloodCost, int bonesCost, int energyCost, List gemsCost) { List list = new List(); if (gemsCost.Count > 0) { List moxTextures = GetMoxTextures(gemsCost); list.Add(TextureHelper.CombineTextures(moxTextures, TextureHelper.GetImageAsTexture("mox_cost_empty.png", typeof(Part1CardCostRender).Assembly, (FilterMode)0), 21, 0, 0, 0)); } if (energyCost > 0) { list.Add(CardCostRender.GetTextureByName($"energy_cost_{Mathf.Min(7, energyCost)}")); } if (bonesCost > 0) { list.Add(CardCostRender.GetTextureByName($"bone_cost_{Mathf.Min(16, bonesCost)}")); } if (bloodCost > 0) { list.Add(CardCostRender.GetTextureByName($"blood_cost_{Mathf.Min(14, bloodCost)}")); } List list2 = (List)((!((Object)(object)playableCard != (Object)null)) ? ((IList)CardExtensions.GetCustomCosts(cardInfo)) : ((IList)(from x in CardExtensions.GetCustomCardCosts((Card)(object)playableCard) select CardCostManager.AllCustomCosts.Find((FullCardCost c) => c.CostName == x.CostName)).ToList())); foreach (FullCardCost item in list2) { int num = ((playableCard != null) ? CardExtensions.GetCustomCost(playableCard, item) : CardExtensions.GetCustomCost(cardInfo, item)); string key = $"{item.ModGUID}_{item.CostName}_{num}_part1"; if (CardCostRender.AssembledTextures.ContainsKey(key)) { if ((Object)(object)CardCostRender.AssembledTextures[key] != (Object)null) { list.Add(CardCostRender.AssembledTextures[key]); } else { CardCostRender.AssembledTextures.Remove(key); } continue; } Texture2D val = item.CostTexture(num, cardInfo, playableCard); if ((Object)(object)val != (Object)null) { list.Add(val); CardCostRender.AssembledTextures.Add(key, val); } } Part1CardCostRender.UpdateCardCost?.Invoke(cardInfo, list); Part1CardCostRender.UpdatePlayableCardCost?.Invoke(playableCard, list); return list; } public static List GetMoxTextures(List gemsCost) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (gemsCost.Count <= 3) { foreach (GemType item in gemsCost.Where((GemType x) => (int)x == 1)) { _ = item; list.Add(CardCostRender.GetTextureByName("mox_cost_o")); } foreach (GemType item2 in gemsCost.Where((GemType x) => (int)x == 0)) { _ = item2; list.Add(CardCostRender.GetTextureByName("mox_cost_g")); } foreach (GemType item3 in gemsCost.Where((GemType x) => (int)x == 2)) { _ = item3; list.Add(CardCostRender.GetTextureByName("mox_cost_b")); } } else { int num = Mathf.Min(4, gemsCost.Count((GemType x) => (int)x == 1)); int num2 = Mathf.Min(4, gemsCost.Count((GemType x) => (int)x == 0)); int num3 = Mathf.Min(4, gemsCost.Count((GemType y) => (int)y == 2)); if (num > 0) { if (num == 1) { list.Add(CardCostRender.GetTextureByName("mox_cost_o")); } else if (num > 2 || num2 + num3 > 1) { list.Add(CardCostRender.GetTextureByName($"mox_cost_o_{num}")); num = 1; } else { list.Add(CardCostRender.GetTextureByName("mox_cost_o")); list.Add(CardCostRender.GetTextureByName("mox_cost_o")); } } if (num2 > 0) { if (num2 == 1) { list.Add(CardCostRender.GetTextureByName("mox_cost_g")); } else if (num2 > 2 || num3 + num > 1) { list.Add(CardCostRender.GetTextureByName($"mox_cost_g_{num2}")); num2 = 1; } else { list.Add(CardCostRender.GetTextureByName("mox_cost_g")); list.Add(CardCostRender.GetTextureByName("mox_cost_g")); } } if (num3 > 0) { if (num3 == 1) { list.Add(CardCostRender.GetTextureByName("mox_cost_b")); } else if (num3 > 2 || num2 + num > 1) { list.Add(CardCostRender.GetTextureByName($"mox_cost_b_{num3}")); } else { list.Add(CardCostRender.GetTextureByName("mox_cost_b")); list.Add(CardCostRender.GetTextureByName("mox_cost_b")); } } } while (list.Count < 3) { list.Insert(0, null); } return list; } } [HarmonyPatch] public class Part1CostEmissionMaskRender { public static readonly Dictionary CostEmissionMaskRenderers = new Dictionary(); public static SpriteRenderer Verify3DCostEmissionMaskRenderer(CardDisplayer3D cardDisplayer, bool emissionEnabled) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!CostEmissionMaskRenderers.TryGetValue(cardDisplayer, out var value)) { GameObject obj = Object.Instantiate(((Component)((CardDisplayer)cardDisplayer).costRenderer).gameObject, ((Component)cardDisplayer).transform); ((Object)obj).name = "CostEmissionMask"; obj.layer = ((Component)cardDisplayer.emissivePortraitRenderer).gameObject.layer; value = obj.GetComponent(); value.color = Color.black; ((Renderer)value).sortingOrder = 100; CostEmissionMaskRenderers.Add(cardDisplayer, value); } if ((Object)(object)value == (Object)null) { PatchPlugin.Logger.LogWarning((object)"[Verify3DCostEmissionMaskRenderer] Could not find/create SpriteRenderer for CardDisplayer3D instance"); } else { ((Component)value).gameObject.SetActive(PatchPlugin.configCostMask.Value && emissionEnabled); } return value; } [HarmonyPrefix] [HarmonyPatch(typeof(CardDisplayer3D), "Awake")] private static void AddCostEmissionMaskOnAwake(CardDisplayer3D __instance) { if (SaveManager.SaveFile.IsPart1) { Verify3DCostEmissionMaskRenderer(__instance, emissionEnabled: false); } } [HarmonyPriority(0)] [HarmonyPostfix] [HarmonyPatch(typeof(CardDisplayer3D), "DisplayInfo")] private static void UpdateCostEmissionMask(CardDisplayer3D __instance) { if (SaveManager.SaveFile.IsPart1) { SpriteRenderer val = Verify3DCostEmissionMaskRenderer(__instance, ((Component)__instance.emissivePortraitRenderer).gameObject.activeSelf); if ((Object)(object)val != (Object)null) { val.sprite = ((CardDisplayer)__instance).costRenderer.sprite; } } } } [HarmonyPatch] public class Part1GemifyIndicator { public static Renderer[] GemifyRenderers = (Renderer[])(object)new Renderer[4]; [HarmonyPostfix] [HarmonyPatch(typeof(CardDisplayer3D), "DisplayInfo")] private static void HandleGemifyAct1(CardRenderInfo renderInfo, PlayableCard playableCard) { if (!SaveManager.SaveFile.IsPart1) { return; } if ((Object)(object)GemifyRenderers[0] == (Object)null) { AddAct1GemifyVisuals(Singleton.Instance); } if (renderInfo.baseInfo.Gemified || renderInfo.temporaryMods.Exists((CardModificationInfo x) => x.gemify) || ((Object)(object)playableCard != (Object)null && CardExtensions.IsGemified(playableCard))) { bool enabled = false; bool enabled2 = false; bool enabled3 = false; if ((Object)(object)playableCard != (Object)null) { if (playableCard.OpponentCard) { enabled = Singleton.Instance.HasGem((GemType)1); enabled2 = Singleton.Instance.HasGem((GemType)0); enabled3 = Singleton.Instance.HasGem((GemType)2); } else { enabled = Singleton.Instance.HasGem((GemType)1); enabled2 = Singleton.Instance.HasGem((GemType)0); enabled3 = Singleton.Instance.HasGem((GemType)2); } } GemifyRenderers[0].enabled = true; GemifyRenderers[1].enabled = enabled; GemifyRenderers[2].enabled = enabled2; GemifyRenderers[3].enabled = enabled3; } else { GemifyRenderers[0].enabled = false; GemifyRenderers[1].enabled = false; GemifyRenderers[2].enabled = false; GemifyRenderers[3].enabled = false; } } public static void AddAct1GemifyVisuals(CardRenderCamera cardRenderCamera) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown CardDisplayer cardDisplayer = cardRenderCamera.cardDisplayer; CardDisplayer3D val = (CardDisplayer3D)(object)((cardDisplayer is CardDisplayer3D) ? cardDisplayer : null); GameObject val2 = new GameObject("GemifyTest"); val2.transform.SetParent(((Component)cardRenderCamera.cardDisplayer).transform); val2.transform.localPosition = Vector3.zero; val2.transform.localScale = Vector3.one; ((Renderer)((Component)val.healthText).gameObject.GetComponent()).sortingOrder = 5; ((Renderer)((Component)val.attackText).gameObject.GetComponent()).sortingOrder = 5; ((Renderer)((Component)val.nameText).gameObject.GetComponent()).sortingOrder = 5; val.nameGraphicRenderer.sortingOrder = 5; ((Renderer)val.emissivePortraitRenderer).sortingOrder = 5; ((Renderer)((CardDisplayer)val).costRenderer).sortingOrder = 6; foreach (SpriteRenderer tribeIconRenderer in val.tribeIconRenderers) { ((Renderer)tribeIconRenderer).sortingOrder = 5; } for (int i = 0; i < val.decalRenderers.Count; i++) { val.decalRenderers[i].sortingOrder = 7 + i; ((Component)val.decalRenderers[i]).GetComponent().sortingOrder = 7 + i; } List list = ((Component)val.AbilityIcons).GetComponentsInChildren(true).ToList(); foreach (Transform item in ((Component)val).transform) { Transform val3 = item; list.Concat(((Component)val3).GetComponentsInChildren(true)); } foreach (AbilityIconInteractable item2 in list) { Renderer component = ((Component)item2).GetComponent(); if (component.sortingOrder == 0) { component.sortingOrder = 5; SetSortingLayer component2 = ((Component)item2).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.sortingOrder = 5; } } } Assembly assembly = typeof(CommunityArtPatches).Assembly; GameObject val4 = Object.Instantiate(((Component)val.decalRenderers[0]).gameObject, val2.transform); GemifyRenderers[0] = val4.GetComponent(); GemifyRenderers[0].sortingOrder = (val4.GetComponent().sortingOrder = 1); GemifyRenderers[0].enabled = true; GemifyRenderers[0].material.mainTexture = (Texture)(object)TextureHelper.GetImageAsTexture("act1_gemify_base.png", assembly, (FilterMode)0); GameObject val5 = Object.Instantiate(((Component)val.decalRenderers[0]).gameObject, val2.transform); GemifyRenderers[1] = val5.GetComponent(); GemifyRenderers[1].sortingOrder = (val5.GetComponent().sortingOrder = 2); GemifyRenderers[1].enabled = true; GemifyRenderers[1].material.mainTexture = (Texture)(object)TextureHelper.GetImageAsTexture("act1_gemify_attack.png", assembly, (FilterMode)0); GameObject val6 = Object.Instantiate(((Component)val.decalRenderers[0]).gameObject, val2.transform); GemifyRenderers[2] = val6.GetComponent(); GemifyRenderers[2].sortingOrder = (val6.GetComponent().sortingOrder = 3); GemifyRenderers[2].enabled = true; GemifyRenderers[2].material.mainTexture = (Texture)(object)TextureHelper.GetImageAsTexture("act1_gemify_health.png", assembly, (FilterMode)0); GameObject val7 = Object.Instantiate(((Component)val.decalRenderers[0]).gameObject, val2.transform); GemifyRenderers[3] = val7.GetComponent(); GemifyRenderers[3].sortingOrder = (val7.GetComponent().sortingOrder = 4); GemifyRenderers[3].enabled = true; GemifyRenderers[3].material.mainTexture = (Texture)(object)TextureHelper.GetImageAsTexture("act1_gemify_cost.png", assembly, (FilterMode)0); } [HarmonyPrefix] [HarmonyPatch(typeof(CardRenderCamera), "UpdateTextureWhenReady")] private static bool AddGemifyRenderersBeforeUpdateTexture(CardRenderCamera __instance) { if (SaveManager.SaveFile.IsPart1 && (Object)(object)GemifyRenderers[0] == (Object)null) { AddAct1GemifyVisuals(__instance); } return true; } } [HarmonyPatch] internal class Part1HintColourFixes { [HarmonyPrefix] [HarmonyPatch(typeof(HintsHandler), "OnNonplayableCardClicked")] private static void FixHintSpeaker(PlayableCard card) { if (card.EnergyCost <= Singleton.Instance.PlayerEnergy) { return; } DialogueEvent @event = DialogueDataUtil.Data.GetEvent(HintsHandler.notEnoughEnergyHint.dialogueId); if (SaveManager.SaveFile.IsPart1) { ModifyDialogueEventLines(@event, delegate(Line x) { x.text = RemoveColourCodes(x.text, "[c:bB]"); }); } else { ModifyDialogueEventLines(@event, delegate(Line x) { x.text = ReAddColourCodes(x.text, "[c:bB]"); }); } } private static void ModifyDialogueEventLines(DialogueEvent dialogueEvent, Action action = null) { if (action != null) { dialogueEvent.mainLines.lines.ForEach(action); dialogueEvent.repeatLines.ForEach(delegate(LineSet x) { x.lines.ForEach(action); }); } } private static string RemoveColourCodes(string text, string codeToRemove) { return text.Replace(codeToRemove, "").Replace("[c:]", ""); } private static string ReAddColourCodes(string text, string startingCode) { string text2 = text; if (!text.StartsWith(startingCode)) { text2 = startingCode + text; } if (!text.EndsWith("[c:]")) { text2 += "[c:]"; } return text2; } } public class Part1SniperVisualizer : ManagedBehaviour { public readonly List sniperIcons = new List(); private GameObject sniperIconPrefab; private GameObject tempSniperIcon; public void VisualizeStartSniperAbility(CardSlot sniperSlot) { } public void VisualizeAimSniperAbility(CardSlot sniperSlot, CardSlot targetSlot) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tempSniperIcon != (Object)null) { CleanUpTargetIcon(tempSniperIcon); tempSniperIcon = null; } if ((Object)(object)sniperIconPrefab == (Object)null) { sniperIconPrefab = ResourceBank.Get("Prefabs/Cards/SpecificCardModels/CannonTargetIcon"); } GameObject val = Object.Instantiate(sniperIconPrefab, ((Component)targetSlot).transform); val.transform.localPosition = new Vector3(0f, 0.25f, 0f); val.transform.localRotation = Quaternion.identity; tempSniperIcon = val; } public void CleanUpTargetIcon(GameObject icon) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) Tween.LocalScale(icon.transform, Vector3.zero, 0.1f, 0f, Tween.EaseIn, (LoopType)0, (Action)null, (Action)delegate { Object.Destroy((Object)(object)icon); }, true); } public void VisualizeConfirmSniperAbility(CardSlot targetSlot) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sniperIconPrefab == (Object)null) { sniperIconPrefab = ResourceBank.Get("Prefabs/Cards/SpecificCardModels/CannonTargetIcon"); } GameObject val = Object.Instantiate(sniperIconPrefab, ((Component)targetSlot).transform); val.transform.localPosition = new Vector3(0f, 0.25f, 0f); val.transform.localRotation = Quaternion.identity; sniperIcons.Add(val); if ((Object)(object)tempSniperIcon != (Object)null) { CleanUpTargetIcon(tempSniperIcon); tempSniperIcon = null; } } public void VisualizeClearSniperAbility() { sniperIcons.ForEach(delegate(GameObject x) { if ((Object)(object)x != (Object)null) { CleanUpTargetIcon(x); } }); sniperIcons.Clear(); if ((Object)(object)tempSniperIcon != (Object)null) { CleanUpTargetIcon(tempSniperIcon); tempSniperIcon = null; } } } public static class Part2CardCostRender { public static bool RightAct2Cost => PatchPlugin.rightAct2Cost.Value; public static event Action> UpdateCardCost; public static event Action> UpdateVanillaCardCost; public static event Action> UpdatePlayableCardCost; public static event Action> UpdateVanillaPlayableCardCost; public static Sprite FinalVanillaCostSprite(PixelCardDisplayer display, CardInfo cardInfo, PlayableCard playableCard, bool leftOriented) { List list = new List(); List list2 = new List(); int bloodCost = ((playableCard != null) ? CardExtensions.BloodCost(playableCard) : cardInfo.BloodCost); int bonesCost = ((playableCard != null) ? CardExtensions.BonesCost(playableCard) : cardInfo.BonesCost); int energyCost = ((playableCard != null) ? playableCard.EnergyCost : cardInfo.EnergyCost); List gemsCost = ((playableCard != null) ? CardExtensions.GemsCost(playableCard) : null) ?? cardInfo.GemsCost; Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("pixel_base_large.png", typeof(CardCostRender).Assembly, (FilterMode)0); List list3 = VanillaCostTextures(display, cardInfo, playableCard, bloodCost, bonesCost, energyCost, gemsCost); while (list3.Count < 4) { list3.Add(null); } if (leftOriented) { list.Add(list3[0]); list.Add(list3[2]); list2.Add(list3[1]); list2.Add(list3[3]); } else { list.Add(list3[2]); list.Add(list3[0]); list2.Add(list3[3]); list2.Add(list3[1]); } Texture2D baseTexture = CombineVanillaCostTextures(list, imageAsTexture, leftOriented, 15); return TextureHelper.ConvertTexture(CombineVanillaCostTextures(list2, baseTexture, leftOriented, 1), (SpriteType)(leftOriented ? 13 : 14), (FilterMode)0); } public static Texture2D CombineVanillaCostTextures(List textures, Texture2D baseTexture, bool leftOriented, int yOffset) { if (textures != null) { int num = ((!leftOriented) ? 24 : 0); for (int i = 0; i < textures.Count; i++) { if ((Object)(object)textures[i] != (Object)null) { int num2 = ((!leftOriented) ? (24 - ((Texture)textures[i]).width) : 0); baseTexture.SetPixels(num2 + num * i, yOffset, ((Texture)textures[i]).width, ((Texture)textures[i]).height, textures[i].GetPixels(), 0); } } baseTexture.Apply(); } return baseTexture; } public static List VanillaCostTextures(PixelCardDisplayer display, CardInfo cardInfo, PlayableCard playableCard, int bloodCost, int bonesCost, int energyCost, List gemsCost) { List list = new List(); if (bloodCost > 0) { list.Add(CardCostRender.GetTextureByName($"pixel_blood_large_{Mathf.Min(14, bloodCost)}")); } if (bonesCost > 0) { list.Add(CardCostRender.GetTextureByName($"pixel_bone_large_{Mathf.Min(16, bonesCost)}")); } if (energyCost > 0) { list.Add(CardCostRender.GetTextureByName($"pixel_energy_large_{Mathf.Min(7, energyCost)}")); } if (gemsCost.Count > 0) { list.AddRange(GetVanillaMoxTextures(gemsCost)); } List list2 = (List)((!((Object)(object)playableCard != (Object)null)) ? ((IList)CardExtensions.GetCustomCosts(cardInfo)) : ((IList)(from x in CardExtensions.GetCustomCardCosts((Card)(object)playableCard) select CardCostManager.AllCustomCosts.Find((FullCardCost c) => c.CostName == x.CostName)).ToList())); foreach (FullCardCost item in list2) { int num = ((playableCard != null) ? CardExtensions.GetCustomCost(playableCard, item) : CardExtensions.GetCustomCost(cardInfo, item)); string key = $"{item.ModGUID}_{item.CostName}_{num}_vanilla_part2"; if (CardCostRender.AssembledTextures.ContainsKey(key)) { if ((Object)(object)CardCostRender.AssembledTextures[key] != (Object)null) { list.Add(CardCostRender.AssembledTextures[key]); } else { CardCostRender.AssembledTextures.Remove(key); } continue; } Texture2D val = item.PixelCostTexture(num, cardInfo, playableCard); if ((Object)(object)val != (Object)null) { list.Add(val); CardCostRender.AssembledTextures.Add(key, val); } } Part2CardCostRender.UpdateCardCost?.Invoke(cardInfo, list); Part2CardCostRender.UpdateVanillaCardCost?.Invoke(cardInfo, list); return list; } public static List CostTextures(CardInfo cardInfo, PlayableCard playableCard, int bloodCost, int bonesCost, int energyCost, List gemsCost) { List list = new List(); if (bloodCost > 0) { list.Add(CombineIconAndCount(bloodCost, CardCostRender.GetTextureByName("pixel_blood"))); } if (bonesCost > 0) { list.Add(CombineIconAndCount(bonesCost, CardCostRender.GetTextureByName("pixel_bone"))); } if (energyCost > 0) { list.Add(CombineIconAndCount(energyCost, CardCostRender.GetTextureByName("pixel_energy"))); } if (gemsCost.Count > 0) { List moxTextures = GetMoxTextures(gemsCost); Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("pixel_blank.png", typeof(Part2CardCostRender).Assembly, (FilterMode)0); list.Add(CombineMoxTextures(moxTextures, imageAsTexture)); } List list2 = (List)((!((Object)(object)playableCard != (Object)null)) ? ((IList)CardExtensions.GetCustomCosts(cardInfo)) : ((IList)(from x in CardExtensions.GetCustomCardCosts((Card)(object)playableCard) select CardCostManager.AllCustomCosts.Find((FullCardCost c) => c.CostName == x.CostName)).ToList())); foreach (FullCardCost item in list2) { int num = ((playableCard != null) ? CardExtensions.GetCustomCost(playableCard, item) : CardExtensions.GetCustomCost(cardInfo, item)); string key = $"{item.ModGUID}_{item.CostName}_{num}_part2"; if (CardCostRender.AssembledTextures.ContainsKey(key)) { if ((Object)(object)CardCostRender.AssembledTextures[key] != (Object)null) { list.Add(CardCostRender.AssembledTextures[key]); } else { CardCostRender.AssembledTextures.Remove(key); } continue; } Texture2D val = item.PixelCostTexture(num, cardInfo, playableCard); if ((Object)(object)val != (Object)null) { list.Add(val); CardCostRender.AssembledTextures.Add(key, val); } } Part2CardCostRender.UpdateCardCost?.Invoke(cardInfo, list); return list; } public static Texture2D CombineIconAndCount(int cardCost, Texture2D artCost) { List list = new List(); if (cardCost <= 4) { for (int i = 0; i < cardCost; i++) { list.Add(artCost); } } else { list.Add(artCost); list.Add(CardCostRender.GetTextureByName($"pixel_L_{cardCost}")); } int num = (RightAct2Cost ? ((cardCost >= 10) ? (10 - ((Texture)artCost).width) : ((cardCost <= 4) ? (30 - ((Texture)artCost).width * cardCost) : (16 - ((Texture)artCost).width))) : 0); Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("pixel_blank.png", typeof(Part2CardCostRender).Assembly, (FilterMode)0); int num2 = num; return TextureHelper.CombineTextures(list, imageAsTexture, ((Texture)artCost).width, 0, num2, 0); } private static Texture2D CombineMoxTextures(List pieces, Texture2D baseTexture) { int num = (RightAct2Cost ? (30 - pieces.ConvertAll((Texture2D x) => ((Texture)x).width).Sum()) : 0); int num2 = 0; for (int i = 0; i < pieces.Count; i++) { if ((Object)(object)pieces[i] != (Object)null) { baseTexture.SetPixels(num + num2, 0, ((Texture)pieces[i]).width, ((Texture)pieces[i]).height, pieces[i].GetPixels(), 0); num2 += ((Texture)pieces[i]).width; } } baseTexture.Apply(); return baseTexture; } public static List GetVanillaMoxTextures(List gemsCost) { List list = new List(); int num = Mathf.Min(4, gemsCost.Count((GemType x) => (int)x == 1)); int num2 = Mathf.Min(4, gemsCost.Count((GemType x) => (int)x == 0)); int num3 = Mathf.Min(4, gemsCost.Count((GemType y) => (int)y == 2)); if (num > 0) { if (num == 1) { if (gemsCost.Count == 2) { if (num2 > 0) { list.Add(CardCostRender.GetTextureByName("pixel_mox_green_orange_large")); } else { list.Add(CardCostRender.GetTextureByName("pixel_mox_blue_orange_large")); } return list; } if (gemsCost.Count == 3 && num2 == num && num3 == num) { list.Add(CardCostRender.GetTextureByName("pixel_mox_grand_large")); return list; } } list.Add(CardCostRender.GetTextureByName($"pixel_mox_orange_large_{num}")); } if (num2 > 0) { if (num2 == 1 && num3 == 1) { list.Add(CardCostRender.GetTextureByName("pixel_mox_blue_green_large")); return list; } list.Add(CardCostRender.GetTextureByName($"pixel_mox_green_large_{num2}")); } if (num3 > 0) { list.Add(CardCostRender.GetTextureByName($"pixel_mox_blue_large_{num3}")); } return list; } public static List GetMoxTextures(List gemsCost) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (gemsCost.Count <= 3) { foreach (GemType item in gemsCost.Where((GemType x) => (int)x == 1)) { _ = item; list.Add(CardCostRender.GetTextureByName("pixel_mox_orange")); } foreach (GemType item2 in gemsCost.Where((GemType x) => (int)x == 0)) { _ = item2; list.Add(CardCostRender.GetTextureByName("pixel_mox_green")); } foreach (GemType item3 in gemsCost.Where((GemType x) => (int)x == 2)) { _ = item3; list.Add(CardCostRender.GetTextureByName("pixel_mox_blue")); } } else { int num = Mathf.Min(4, gemsCost.Count((GemType x) => (int)x == 1)); int num2 = Mathf.Min(4, gemsCost.Count((GemType x) => (int)x == 0)); int num3 = Mathf.Min(4, gemsCost.Count((GemType y) => (int)y == 2)); if (num > 0) { if (num == 1) { list.Add(CardCostRender.GetTextureByName("pixel_mox_orange")); } else if (num > 2 || num2 + num3 > 1) { list.Add(CardCostRender.GetTextureByName($"pixel_mox_orange_{num}")); num = 1; } else { list.Add(CardCostRender.GetTextureByName("pixel_mox_orange")); list.Add(CardCostRender.GetTextureByName("pixel_mox_orange")); } } if (num2 > 0) { if (num2 == 1) { list.Add(CardCostRender.GetTextureByName("pixel_mox_green")); } else if (num2 > 2 || num3 + num > 1) { list.Add(CardCostRender.GetTextureByName($"pixel_mox_green_{num2}")); num2 = 1; } else { list.Add(CardCostRender.GetTextureByName("pixel_mox_green")); list.Add(CardCostRender.GetTextureByName("pixel_mox_green")); } } if (num3 > 0) { if (num3 == 1) { list.Add(CardCostRender.GetTextureByName("pixel_mox_blue")); } else if (num3 > 2 || num2 + num > 1) { list.Add(CardCostRender.GetTextureByName($"pixel_mox_blue_{num3}")); } else { list.Add(CardCostRender.GetTextureByName("pixel_mox_blue")); list.Add(CardCostRender.GetTextureByName("pixel_mox_blue")); } } } return list; } } [HarmonyPatch] public static class Part3CardCostRender { public class CustomCostRenderInfo { public string CostId { get; private set; } public Texture2D MainCostTexture { get; set; } public Texture2D EmissionTexture { get; set; } public GameObject CostContainer { get; internal set; } internal float StretchFactor { get; set; } = 1f; internal void UpdateDisplayedTextures() { CostContainer?.DisplayCostOnContainer(MainCostTexture, EmissionTexture); } public CustomCostRenderInfo(string costId) { CostId = costId; } public CustomCostRenderInfo(string costId, Texture2D mainCostTexture, Texture2D emissionTexture) : this(costId) { MainCostTexture = mainCostTexture; EmissionTexture = emissionTexture; } public CustomCostRenderInfo(string costId, Tuple textures) : this(costId, textures.Item1, textures.Item2) { } internal void Stretch(float factor) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) List list = new List(); while (CostContainer.transform.childCount > 0) { Transform child = CostContainer.transform.GetChild(0); child.SetParent(CostContainer.transform.parent, true); list.Add(child); } CostContainer.transform.localScale = new Vector3(0.475f * factor, 0.1f, 0.145f); CostContainer.transform.localPosition = new Vector3(0.225f + (factor - 1f) * 3f * 0.08f, 0.01f, CostContainer.transform.localPosition.z); foreach (Transform item in list) { item.SetParent(CostContainer.transform, true); } StretchFactor = factor; } } private const float CONTAINER_Z_SPACING = 0.145f; private const float INITIAL_CONTAINER_Z_SPACING = 0.14f; private const int ICON_SPACING = 18; public const string ENERGY_LIGHTS = "Anim/CardBase/Top/EnergyCostLights"; public const string UPPER_GEM_CONTAINER = "Anim/CardBase/Top/Gems"; public const string BLUE_GEM_ORIGINAL = "Anim/CardBase/Top/Gems/Gem_Blue"; public const string ORANGE_GEM_ORIGINAL = "Anim/CardBase/Bottom/Gems/Gem_Orange"; public const string GREEN_GEM_ORIGINAL = "Anim/CardBase/Bottom/Gems/Gem_Green"; public const string BLUE_GEM_COST = "Gem_Cost_Blue"; public const string ORANGE_GEM_COST = "Gem_Cost_Orange"; public const string GREEN_GEM_COST = "Gem_Cost_Green"; public const string INITIAL_ALTERNATE_COST = "Anim/CardBase/Top/Gems/TextureDisplayer"; private static readonly Dictionary COST_LOOKUP = new Dictionary { { (GemType)2, "Anim/CardBase/Top/Gems/Gem_Blue" }, { (GemType)1, "Anim/CardBase/Bottom/Gems/Gem_Orange" }, { (GemType)0, "Anim/CardBase/Bottom/Gems/Gem_Green" } }; private static ConditionalWeakTable CardRenderReverseLookup = new ConditionalWeakTable(); private static Texture2D _bgTexture = null; private static List _sevenSegments = null; private static Sprite _faceBoneSprite = null; private static Sprite _faceBloodSprite = null; private static Texture2D _costCubeBackground = null; private static Texture2D _boneIcon = null; private static Texture2D _bloodIconUnlit = null; private static Texture2D _bloodIcon = null; private static readonly Dictionary AssembledTextures = new Dictionary(); private static readonly ConditionalWeakTable> ExtraCostContainers = new ConditionalWeakTable>(); private static readonly Dictionary> TextureCache = new Dictionary>(); private static readonly Dictionary> EmissionTextureCache = new Dictionary>(); private static readonly ConditionalWeakTable>> GemContainerLookup = new ConditionalWeakTable>>(); private static Color BoneColor => Color.white; private static Color BloodColor => GameColors.Instance.glowRed; private static Texture2D BackgroundTexture { get { if ((Object)(object)_bgTexture == (Object)null) { _bgTexture = TextureHelper.GetImageAsTexture("CostTextureBackground.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); } return _bgTexture; } } private static List SevenSegmentDisplay { get { if (_sevenSegments == null) { _sevenSegments = new List(); for (int i = 0; i <= 9; i++) { Texture2D imageAsTexture = TextureHelper.GetImageAsTexture($"Display_{i}_small.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); ((Object)imageAsTexture).name = $"Display_{i}"; _sevenSegments.Add(imageAsTexture); } Texture2D imageAsTexture2 = TextureHelper.GetImageAsTexture("Display_x_small.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); ((Object)imageAsTexture2).name = "Display_x"; _sevenSegments.Add(imageAsTexture2); } return _sevenSegments; } } private static Sprite FaceBoneSprite { get { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_faceBoneSprite == (Object)null) { Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("p03_face_bones_resource.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); _faceBoneSprite = Sprite.Create(imageAsTexture, new Rect(0f, 0f, (float)((Texture)imageAsTexture).width, (float)((Texture)imageAsTexture).height), new Vector2(0.5f, 0.5f)); } return _faceBoneSprite; } } private static Sprite FaceBloodSprite { get { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_faceBloodSprite == (Object)null) { Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("p03_face_blood_resource.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); _faceBloodSprite = Sprite.Create(imageAsTexture, new Rect(0f, 0f, (float)((Texture)imageAsTexture).width, (float)((Texture)imageAsTexture).height), new Vector2(0.5f, 0.5f)); } return _faceBloodSprite; } } private static Texture2D CostCubeBackground { get { if ((Object)(object)_costCubeBackground == (Object)null) { _costCubeBackground = TextureHelper.GetImageAsTexture("Act3CostCubeBackground.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); ((Object)_costCubeBackground).name = "CostCubeBackground"; } return _costCubeBackground; } } internal static Texture2D BoneCostIcon { get { if ((Object)(object)_boneIcon == (Object)null) { _boneIcon = TextureHelper.GetImageAsTexture("BoneCostIcon_small.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); ((Object)_boneIcon).name = "BoneCostIcon"; } return _boneIcon; } } internal static Texture2D BloodCostIconUnlit { get { if ((Object)(object)_bloodIconUnlit == (Object)null) { _bloodIconUnlit = TextureHelper.GetImageAsTexture("BloodCostIcon_small_unlit.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); ((Object)_bloodIconUnlit).name = "BloodCostIconUnlit"; } return _bloodIconUnlit; } } internal static Texture2D BloodCostIcon { get { if ((Object)(object)_bloodIcon == (Object)null) { _bloodIcon = TextureHelper.GetImageAsTexture("BloodCostIcon_small.png", typeof(Part3CardCostRender).Assembly, (FilterMode)0); ((Object)_bloodIcon).name = "BloodCostIcon"; } return _bloodIcon; } } public static event Action> UpdateCardCostSimple; public static event Action> UpdateCardCostComplex; private static List BlueGemsCost(this CardInfo card) { return card.GemsCost.Where((GemType g) => (int)g == 2).ToList(); } private static List GreenGemsCost(this CardInfo card) { return card.GemsCost.Where((GemType g) => (int)g == 0).ToList(); } private static List OrangeGemsCost(this CardInfo card) { return card.GemsCost.Where((GemType g) => (int)g == 1).ToList(); } private static List BlueGemsCost(this PlayableCard card) { return (from g in CardExtensions.GemsCost(card) where (int)g == 2 select g).ToList(); } private static List GreenGemsCost(this PlayableCard card) { return (from g in CardExtensions.GemsCost(card) where (int)g == 0 select g).ToList(); } private static List OrangeGemsCost(this PlayableCard card) { return (from g in CardExtensions.GemsCost(card) where (int)g == 1 select g).ToList(); } public static GameObject GetPiece(this Card card, string key) { Transform obj = ((Component)card).gameObject.transform.Find(key); if (obj == null) { return null; } return ((Component)obj).gameObject; } public static Card GetCard(this RenderStatsLayer layer) { if (CardRenderReverseLookup.TryGetValue(layer, out var value)) { return value; } value = ((Component)layer).gameObject.GetComponentInParent(); CardRenderReverseLookup.Add(layer, value); return value; } private static GameObject CreateTextureDisplayer(GameObject container) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = "TextureDisplayer"; obj.transform.SetParent(container.transform); Object.Destroy((Object)(object)obj.GetComponent()); Renderer component = obj.GetComponent(); component.material.EnableKeyword("_EMISSION"); component.material.SetTexture("_MainTex", (Texture)(object)BackgroundTexture); component.material.SetTexture("_EmissionMap", (Texture)(object)BackgroundTexture); component.material.SetColor("_EmissionColor", Color.white); obj.transform.localPosition = new Vector3(0f, 0.501f, 0f); obj.transform.localScale = new Vector3(0.95f, 0.95f, 0.95f); obj.transform.localEulerAngles = new Vector3(90f, 180f, 0f); return obj; } private static GameObject GenerateSingleAdditionalCostContainer(Card card, int index) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) if (!(card.StatsLayer is DiskRenderStatsLayer)) { throw new InvalidOperationException("You cannot generate an additional Part 3 cost container on anything other than a Disk Card!!"); } GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = $"Card_Cost_{index}"; obj.transform.SetParent(card.GetPiece("Anim/CardBase/Top/Gems").transform); obj.transform.localPosition = new Vector3(0.24f, 0.01f, 0f); obj.transform.localScale = new Vector3(0.475f, 0.1f, 0.145f); obj.transform.localEulerAngles = new Vector3(0f, 0f, 0f); Object.Destroy((Object)(object)obj.GetComponent()); Mesh mesh = obj.GetComponent().mesh; Vector2[] array = (Vector2[])(object)new Vector2[mesh.vertices.Length]; array[0] = new Vector2(0f, 0f); array[1] = new Vector2(0.333f, 0f); array[2] = new Vector2(0f, 0.333f); array[3] = new Vector2(0.333f, 0.333f); array[4] = new Vector2(0.334f, 0.333f); array[5] = new Vector2(0.666f, 0.333f); array[8] = new Vector2(0.334f, 0f); array[9] = new Vector2(0.666f, 0f); array[6] = new Vector2(1f, 0f); array[7] = new Vector2(0.667f, 0f); array[10] = new Vector2(1f, 0.333f); array[11] = new Vector2(0.667f, 0.333f); array[12] = new Vector2(0f, 0.334f); array[13] = new Vector2(0f, 0.666f); array[14] = new Vector2(0.333f, 0.666f); array[15] = new Vector2(0.333f, 0.334f); array[16] = new Vector2(0.334f, 0.334f); array[17] = new Vector2(0.334f, 0.666f); array[18] = new Vector2(0.666f, 0.666f); array[19] = new Vector2(0.666f, 0.334f); array[20] = new Vector2(0.667f, 0.334f); array[21] = new Vector2(0.667f, 0.666f); array[22] = new Vector2(1f, 0.666f); array[23] = new Vector2(1f, 0.334f); mesh.uv = array; Renderer component = obj.GetComponent(); component.material.SetTexture("_MainTex", (Texture)(object)CostCubeBackground); if (index == 0) { component.enabled = false; } CreateTextureDisplayer(obj); return obj; } public static List GetCostContainers(this RenderStatsLayer layer) { return ExtraCostContainers.GetOrCreateValue(layer); } public static List GetCostContainers(this Card card, int numberOfContainers) { List costContainers = card.StatsLayer.GetCostContainers(); if (!(card.StatsLayer is DiskRenderStatsLayer)) { return costContainers; } while (costContainers.Count < numberOfContainers) { costContainers.Add(GenerateSingleAdditionalCostContainer(card, costContainers.Count)); } List list = new List(); foreach (GameObject item in costContainers) { list.Clear(); for (int i = 0; i < item.transform.childCount; i++) { Transform child = item.transform.GetChild(i); if (!((Object)((Component)child).gameObject).name.Equals("TextureDisplayer")) { list.Add(child); } } for (int j = 0; j < list.Count; j++) { Object.Destroy((Object)(object)((Component)list[j]).gameObject); } } return costContainers; } private static GameObject MakeCostContainer(Card card, string path, Color lightColor) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = path.Split(new char[1] { '/' }).Last(); val.transform.SetParent(card.GetPiece("Anim/CardBase/Top/Gems").transform); Object.Destroy((Object)(object)val.GetComponent()); Renderer component = val.GetComponent(); component.material.EnableKeyword("_EMISSION"); component.material.SetTexture("_MainTex", (Texture)(object)BackgroundTexture); component.material.SetTexture("_EmissionMap", (Texture)(object)BackgroundTexture); val.transform.localPosition = new Vector3(0.25f, 0.0565f, 0f); val.transform.localScale = new Vector3(0.43f, 0.12f, 0.08f); val.transform.localEulerAngles = new Vector3(90f, 245f, 65f); return val; } public static Tuple GetIconifiedCostTexture(Texture2D iconTexture, int cost, bool forceDigitDisplay = false) { return GetIconifiedCostTexture(iconTexture, null, cost, forceDigitDisplay); } public static Tuple GetIconifiedCostTexture(Texture2D iconTexture, Texture2D unlitIconTexture, int cost, bool forceDigitDisplay = false) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(((Object)iconTexture).name) && !((Object)iconTexture).name.Equals("untitled", StringComparison.InvariantCultureIgnoreCase)) { if (!TextureCache.Keys.Contains(((Object)iconTexture).name)) { TextureCache.Add(((Object)iconTexture).name, new Dictionary()); EmissionTextureCache.Add(((Object)iconTexture).name, new Dictionary()); } if (TextureCache[((Object)iconTexture).name].ContainsKey(cost)) { return new Tuple(TextureCache[((Object)iconTexture).name][cost], EmissionTextureCache[((Object)iconTexture).name][cost]); } } Texture2D val = TextureHelper.DuplicateTexture(BackgroundTexture); ((Object)val).name = $"{((Object)iconTexture).name}_{cost}"; Texture2D val2 = new Texture2D(((Texture)val).width, ((Texture)val).height, val.format, false); ((Object)val2).name = $"{((Object)iconTexture).name}_{cost}_emission"; Color[] array = (Color[])(object)new Color[((Texture)val2).width * ((Texture)val2).height]; Color val3 = default(Color); ((Color)(ref val3))..ctor(0f, 0f, 0f, 0f); for (int i = 0; i < array.Length; i++) { array[i] = val3; } val2.SetPixels(array); int num = Mathf.FloorToInt((float)((((Texture)BackgroundTexture).width - 26 + 18) / (18 + ((Texture)iconTexture).width))); int num2 = 13; List list = new List(); if (cost <= num && !forceDigitDisplay) { for (int j = 0; j < cost; j++) { list.Add(iconTexture); } while (list.Count < num) { list.Add(null); } int num3 = (18 + ((Texture)iconTexture).width) * num - 18; num2 = Mathf.FloorToInt((float)((((Texture)BackgroundTexture).width - num3) / 2)); } else { list.Add(SevenSegmentDisplay[cost % 10]); int index = Mathf.FloorToInt((float)cost / 10f) % 10; list.Add(SevenSegmentDisplay[index]); list.Add(SevenSegmentDisplay[10]); list.Add(iconTexture); } int num4 = 0; for (int k = 0; k < list.Count; k++) { float num5 = 1f; if ((Object)(object)list[k] == (Object)null) { list[k] = unlitIconTexture ?? iconTexture; num5 = (((Object)(object)unlitIconTexture == (Object)null) ? 0.4f : 1f); } int num6 = Mathf.FloorToInt((float)(((Texture)val).height - ((Texture)list[k]).height) / 2f); num4 += ((Texture)list[k]).width; int num7 = ((Texture)val).width - num2 - num4 - k * 18; for (int l = 0; l < ((Texture)list[k]).width; l++) { for (int m = 0; m < ((Texture)list[k]).height; m++) { Color pixel = list[k].GetPixel(l, m); if (pixel.a > 0f) { val.SetPixel(num7 + l, num6 + m, pixel * num5); val2.SetPixel(num7 + l, num6 + m, pixel * num5); } } } } val.Apply(); val2.Apply(); ((Texture)val).filterMode = (FilterMode)0; ((Texture)val2).filterMode = (FilterMode)0; if (!string.IsNullOrEmpty(((Object)iconTexture).name) && !((Object)iconTexture).name.Equals("untitled", StringComparison.InvariantCultureIgnoreCase)) { TextureCache[((Object)iconTexture).name].Add(cost, val); EmissionTextureCache[((Object)iconTexture).name].Add(cost, val2); } return new Tuple(val, val2); } public static void DisplayCostOnContainer(this GameObject gameObject, Texture2D texture, Texture2D emission) { Transform val = gameObject.transform.Find("TextureDisplayer"); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)texture == (Object)null && (Object)(object)emission == (Object)null) { ((Component)val).gameObject.SetActive(false); return; } ((Component)val).gameObject.SetActive(true); Renderer component = ((Component)val).gameObject.GetComponent(); component.material.SetTexture("_MainTex", (Texture)(object)texture); component.material.SetTexture("_EmissionMap", (Texture)(object)emission); } } public static void DisplayCostOnContainer(this GameObject gameObject, Tuple costTextures) { gameObject.DisplayCostOnContainer(costTextures.Item1, costTextures.Item2); } public static List> GetGemCostContainer(this RenderStatsLayer layer) { return GemContainerLookup.GetOrCreateValue(layer); } private static bool ValidateContainer(List> container, Card card) { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) Card obj = ((card is PlayableCard) ? card : null); List list = ((obj != null) ? CardExtensions.GemsCost((PlayableCard)(object)obj) : null) ?? card.Info.GemsCost; if (list.Count != container.Count) { return false; } Dictionary dictionary = (from g in container group g by g.Item1).ToDictionary((IGrouping> g) => g.Key, (IGrouping> g) => g.Count()); Dictionary dictionary2 = (from g in list group g by g).ToDictionary((IGrouping g) => g.Key, (IGrouping g) => g.Count()); foreach (GemType item in dictionary.Keys.Concat(dictionary2.Keys)) { if (!dictionary2.ContainsKey(item) || !dictionary.ContainsKey(item) || dictionary2[item] != dictionary[item]) { return false; } } return true; } private static bool MatchesGem(this Tuple item, GemType? gemType) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return (((??)gemType) ?? item.Item1) == item.Item1; } public static List> GetGemCostContainer(this Card card, bool force = false, GameObject container = null, bool verify = false, GemType? gemType = null, float stretchFactor = 1f) { //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: 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_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Invalid comparison between Unknown and I4 //IL_02e4: 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_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) List> gemCostContainer = card.StatsLayer.GetGemCostContainer(); if (gemCostContainer != null) { if (force) { foreach (Tuple item in gemCostContainer) { if (item.MatchesGem(gemType) && !UnityExtensions.SafeIsUnityNull((Object)(object)item.Item3)) { Object.Destroy((Object)(object)item.Item3); } } gemCostContainer.RemoveAll((Tuple item) => item.MatchesGem(gemType)); } else { if (verify && ValidateContainer(gemCostContainer, card)) { return gemCostContainer; } if (gemCostContainer.Any((Tuple item) => item.MatchesGem(gemType))) { return gemCostContainer; } } } GameObject val = container ?? card.GetPiece("Anim/CardBase/Top/Gems"); List list = new List(); for (int i = 0; i < val.transform.childCount; i++) { if (!((Object)((Component)val.transform.GetChild(i)).gameObject).name.Equals("TextureDisplayer")) { list.Add(val.transform.GetChild(i)); } } foreach (Transform item2 in list) { Object.Destroy((Object)(object)((Component)item2).gameObject); } if (!CardRenderReverseLookup.TryGetValue(card.StatsLayer, out var _)) { CardRenderReverseLookup.Add(card.StatsLayer, card); } Card obj = ((card is PlayableCard) ? card : null); List source = ((obj != null) ? CardExtensions.GemsCost((PlayableCard)(object)obj) : null) ?? card.Info.GemsCost; source = (from g in source where gemType.GetValueOrDefault(g) == g orderby 0 - g select g).ToList(); int num = 0; Dictionary dictionary = new Dictionary { { (GemType)2, 0 }, { (GemType)0, 0 }, { (GemType)1, 0 } }; float num2 = ((source.Count <= 3) ? 0.3f : (0.1f * stretchFactor + 0.2f)); float num3 = ((source.Count <= 3) ? 0.3f : (2f * num2 / (float)(source.Count - 1))); foreach (GemType item3 in source) { GameObject val2 = Object.Instantiate(card.GetPiece(COST_LOOKUP[item3]), val.transform); ((Object)val2).name = $"Gem_Cost_{num + 1}"; val2.transform.localScale = new Vector3(650f, 200f / stretchFactor, 450f); val2.transform.localEulerAngles = new Vector3(270f, 90f, 0f); val2.transform.localPosition = new Vector3(0f - num2 + num3 * (float)num, ((int)item3 == 2) ? 0.36f : (((int)item3 == 0) ? 0.39f : 0.41f), 0f); dictionary[item3]++; gemCostContainer.Add(new Tuple(item3, dictionary[item3], val2.GetComponent())); num++; } return gemCostContainer; } private static void ResetBlueGemifyGem(Card card, bool originalPosition, bool active) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) GameObject piece = card.GetPiece("Anim/CardBase/Top/Gems/Gem_Blue"); if (!((Object)(object)piece == (Object)null)) { piece.SetActive(active); if (originalPosition) { piece.transform.localPosition = new Vector3(0.0935f, 0f, 0.162f); piece.transform.localScale = new Vector3(122.6777f, 122.6777f, 100f); } else { piece.transform.localPosition = new Vector3(0.54f, 0f, 0f); piece.transform.localScale = new Vector3(80f, 80f, 100f); } } } [HarmonyPatch(typeof(Card), "RenderCard")] [HarmonyPostfix] private static void DisplayAlternateCostSingle(Card __instance) { //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.StatsLayer is DiskRenderStatsLayer)) { return; } List list = new List(); PlayableCard val = (PlayableCard)(object)((__instance is PlayableCard) ? __instance : null); int num = ((val != null) ? val.EnergyCost : __instance.Info.EnergyCost); if (num > 0) { list.Add(new CustomCostRenderInfo("Energy")); } List list2 = ((val != null) ? CardExtensions.GemsCost(val) : null) ?? __instance.Info.GemsCost; if (list2.Count > 0) { if (list2.Count <= 3) { list.Add(new CustomCostRenderInfo("Gems_All")); } else { if ((((val != null) ? val.OrangeGemsCost() : null) ?? __instance.Info.OrangeGemsCost()).Count > 0) { list.Add(new CustomCostRenderInfo("Gems_Orange")); } if ((((val != null) ? val.BlueGemsCost() : null) ?? __instance.Info.BlueGemsCost()).Count > 0) { list.Add(new CustomCostRenderInfo("Gems_Blue")); } if ((((val != null) ? val.GreenGemsCost() : null) ?? __instance.Info.GreenGemsCost()).Count > 0) { list.Add(new CustomCostRenderInfo("Gems_Green")); } } } int num2 = ((val != null) ? CardExtensions.BonesCost(val) : __instance.Info.BonesCost); if (num2 > 0) { list.Add(new CustomCostRenderInfo("Bones", GetIconifiedCostTexture(BoneCostIcon, num2, forceDigitDisplay: true))); } int num3 = ((val != null) ? CardExtensions.BloodCost(val) : __instance.Info.BloodCost); if (num3 > 0) { list.Add(new CustomCostRenderInfo("Blood", GetIconifiedCostTexture(BloodCostIcon, BloodCostIconUnlit, num3))); } List list3 = (List)((!((Object)(object)val != (Object)null)) ? ((IList)CardExtensions.GetCustomCosts(__instance.Info)) : ((IList)(from x in CardExtensions.GetCustomCardCosts((Card)(object)val) select CardCostManager.AllCustomCosts.Find((FullCardCost c) => c.CostName == x.CostName)).ToList())); foreach (FullCardCost item in list3) { Texture2D val2 = null; string key = item.ModGUID + "_" + item.CostName + "_1_part3"; if (CardCostRender.AssembledTextures.ContainsKey(key)) { if ((Object)(object)CardCostRender.AssembledTextures[key] != (Object)null) { val2 = CardCostRender.AssembledTextures[key]; } else { CardCostRender.AssembledTextures.Remove(key); } } else { Texture2D val3 = item.CostTexture(1, __instance.Info, val); if ((Object)(object)val3 != (Object)null) { val2 = val3; CardCostRender.AssembledTextures.Add(key, val2); } } if ((Object)(object)val2 != (Object)null) { int cost = ((val != null) ? CardExtensions.GetCustomCost(val, item) : CardExtensions.GetCustomCost(__instance.Info, item)); list.Add(new CustomCostRenderInfo(item.CostName, GetIconifiedCostTexture(AssembledTextures[key], cost))); } } Part3CardCostRender.UpdateCardCostSimple?.Invoke(__instance.Info, list); if (list.Count == 0 || (list.Count == 1 && num > 0)) { __instance.GetPiece("Anim/CardBase/Top/EnergyCostLights").SetActive(true); ResetBlueGemifyGem(__instance, originalPosition: true, __instance.Info.Gemified); return; } List costContainers = __instance.GetCostContainers(list.Count); for (int i = 0; i < costContainers.Count; i++) { if (i < list.Count) { costContainers[i].SetActive(true); if (i > 0) { costContainers[i].transform.localPosition = new Vector3(costContainers[i].transform.localPosition.x, costContainers[i].transform.localPosition.y, 0.14f + 0.145f * (float)(i - 1)); } list[i].CostContainer = costContainers[i]; list[i].UpdateDisplayedTextures(); } else { costContainers[i].SetActive(false); } } Part3CardCostRender.UpdateCardCostComplex?.Invoke(__instance.Info, list); List> value; if (list2.Count > 0) { if (list2.Count <= 3) { CustomCostRenderInfo customCostRenderInfo = list.First((CustomCostRenderInfo c) => c.CostId.Equals("Gems_All", StringComparison.InvariantCultureIgnoreCase)); foreach (Renderer item2 in from v in __instance.GetGemCostContainer(force: true, customCostRenderInfo.CostContainer) where v != null && (Object)(object)v.Item3 != (Object)null select v.Item3) { ((Component)item2).gameObject.SetActive(true); } } else { int count = (((val != null) ? val.OrangeGemsCost() : null) ?? __instance.Info.OrangeGemsCost()).Count; int count2 = (((val != null) ? val.BlueGemsCost() : null) ?? __instance.Info.BlueGemsCost()).Count; int count3 = (((val != null) ? val.GreenGemsCost() : null) ?? __instance.Info.GreenGemsCost()).Count; if (count > 0) { CustomCostRenderInfo customCostRenderInfo2 = list.First((CustomCostRenderInfo c) => c.CostId.Equals("Gems_Orange", StringComparison.InvariantCultureIgnoreCase)); if (count > 3) { customCostRenderInfo2.Stretch((float)count / 3f); } foreach (Renderer item3 in from v in __instance.GetGemCostContainer(force: true, customCostRenderInfo2.CostContainer, verify: false, (GemType)1, (float)count / 3f) where v != null && (Object)(object)v.Item3 != (Object)null select v.Item3) { ((Component)item3).gameObject.SetActive(true); } } if (count2 > 0) { CustomCostRenderInfo customCostRenderInfo3 = list.First((CustomCostRenderInfo c) => c.CostId.Equals("Gems_Blue", StringComparison.InvariantCultureIgnoreCase)); if (count2 > 3) { customCostRenderInfo3.Stretch((float)count2 / 3f); } foreach (Renderer item4 in from v in __instance.GetGemCostContainer(force: true, customCostRenderInfo3.CostContainer, verify: false, (GemType)2, (float)count2 / 3f) where v != null && (Object)(object)v.Item3 != (Object)null select v.Item3) { ((Component)item4).gameObject.SetActive(true); } } if (count3 > 0) { CustomCostRenderInfo customCostRenderInfo4 = list.First((CustomCostRenderInfo c) => c.CostId.Equals("Gems_Green", StringComparison.InvariantCultureIgnoreCase)); if (count3 > 3) { customCostRenderInfo4.Stretch((float)count3 / 3f); } foreach (Renderer item5 in from v in __instance.GetGemCostContainer(force: true, customCostRenderInfo4.CostContainer, verify: false, (GemType)0, (float)count3 / 3f) where v != null && (Object)(object)v.Item3 != (Object)null select v.Item3) { ((Component)item5).gameObject.SetActive(true); } } } } else if (GemContainerLookup.TryGetValue(__instance.StatsLayer, out value)) { value.Clear(); } bool flag = num > 0 || list.Count == 0; __instance.GetPiece("Anim/CardBase/Top/EnergyCostLights").SetActive(flag); ResetBlueGemifyGem(__instance, originalPosition: true, __instance.Info.Gemified && flag); } [HarmonyPatch(typeof(DiskRenderStatsLayer), "ManagedUpdate")] [HarmonyPostfix] private static void UpdateGemsCost(DiskRenderStatsLayer __instance) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) List> gemCostContainer = ((RenderStatsLayer)(object)__instance).GetGemCostContainer(); ((RenderStatsLayer)(object)__instance).GetCard(); foreach (Tuple obj in gemCostContainer) { Color val = ((!GameFlowManager.IsCardBattle || Singleton.Instance.gems.Where((GemType g) => g == obj.Item1).Count() >= obj.Item2) ? Color.white : Color.gray); obj.Item3.GetPropertyBlock(__instance.gemsPropertyBlock); __instance.gemsPropertyBlock.SetColor("_EmissionColor", val); obj.Item3.SetPropertyBlock(__instance.gemsPropertyBlock); } } [HarmonyPatch(typeof(P03FaceCardDisplayer), "DisplayCard")] [HarmonyPostfix] private static void SetCostsOnP03Face(P03FaceCardDisplayer __instance, CardInfo info, CardModificationInfo mod) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 //IL_00a4: Invalid comparison between Unknown and I4 //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Invalid comparison between Unknown and I4 //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Unknown result type (might be due to invalid IL or missing references) //IL_07eb: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07b1: Unknown result type (might be due to invalid IL or missing references) //IL_07c2: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07d1: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer val = ((IEnumerable)__instance.energyBars).FirstOrDefault((Func)((SpriteRenderer r) => !((Renderer)r).enabled)); float num = (((Object)(object)val == (Object)null) ? ((Component)__instance.energyBars[5]).transform.localPosition.x : ((Component)val).transform.localPosition.x); num += 0.02f; bool enabled = false; bool flag = false; bool flag2 = false; int num2 = 0; int num3 = 0; int num4 = 0; foreach (GemType item in info.GemsCost) { if ((int)item == 0) { num4++; } if ((int)item == 1) { num3++; } if ((int)item == 2) { num2++; } } if (mod != null) { if (mod.addGemCost != null) { foreach (GemType item2 in mod.addGemCost) { if ((int)item2 == 0) { num4++; } if ((int)item2 == 1) { num3++; } if ((int)item2 == 2) { num2++; } } enabled = true; } if (CardModificationInfoExtensions.HasRemovedAnyGemCost(mod)) { enabled = true; } if (CardModificationInfoExtensions.HasRemoveBlueGemCost(mod) && num2 > 0) { num2--; } if (CardModificationInfoExtensions.HasRemovedGreenGemCost(mod) && num4 > 0) { num4--; } if (CardModificationInfoExtensions.HasRemovedOrangeGemCost(mod) && num3 > 0) { num3--; } if (mod.nullifyGemsCost) { num4 = (num3 = (num2 = 0)); enabled = true; } } Transform val2 = ((Component)__instance).transform.Find("Resources/Gems"); ((Component)val2).transform.localPosition = Vector3.zero; for (int i = 0; i < val2.childCount; i++) { Transform child = val2.GetChild(i); GameObject val3 = ((child != null) ? ((Component)child).gameObject : null); if (!((Object)(object)val3 == (Object)null)) { val3.SetActive(false); if ((Object)(object)val3.GetComponent() == (Object)null) { BlinkColor obj = val3.AddComponent(); obj.color1 = val3.GetComponent().color; obj.color2 = new Color(0.0078f, 0.0392f, 0.0667f); obj.renderers = new List { (Renderer)(object)val3.GetComponent() }; obj.colorId = "_Color"; ((TimedBehaviour)obj).frequency = 0.2f; ((TimedBehaviour)obj).originalFrequency = 0.2f; ((TimedBehaviour)obj).timer = 0.0681f; } } } for (int j = 0; j < num2; j++) { string text = "Gem_Blue"; if (j > 0) { text += $"_{j}"; } Transform obj2 = ((Component)__instance).transform.Find("Resources/Gems/" + text) ?? Object.Instantiate(((Component)((Component)__instance).transform.Find("Resources/Gems/Gem_Blue")).gameObject, val2).transform; ((Object)obj2).name = text; num -= 0.1f; obj2.localPosition = new Vector3(num, 0f, 0f); ((Component)obj2).gameObject.SetActive(true); Color val4 = new Color(0f, 0.8507f, 1f) * 0.8f; ((Renderer)((Component)obj2).GetComponent()).enabled = true; ((Component)obj2).GetComponent().color = val4; ((Behaviour)((Component)obj2).GetComponent()).enabled = enabled; ((Component)obj2).GetComponent().color1 = val4; num -= 0.1f; } for (int k = 0; k < num3; k++) { string text2 = "Gem_Orange"; if (k > 0) { text2 += $"_{k}"; } Transform obj3 = ((Component)__instance).transform.Find("Resources/Gems/" + text2) ?? Object.Instantiate(((Component)((Component)__instance).transform.Find("Resources/Gems/Gem_Orange")).gameObject, val2).transform; ((Object)obj3).name = text2; num -= 0.1f; obj3.localPosition = new Vector3(num, 0f, 0f); ((Component)obj3).gameObject.SetActive(true); ((Renderer)((Component)obj3).GetComponent()).enabled = true; ((Behaviour)((Component)obj3).GetComponent()).enabled = enabled; num -= 0.1f; } for (int l = 0; l < num4; l++) { string text3 = "Gem_Green"; if (l > 0) { text3 += $"_{l}"; } Transform obj4 = ((Component)__instance).transform.Find("Resources/Gems/" + text3) ?? Object.Instantiate(((Component)((Component)__instance).transform.Find("Resources/Gems/Gem_Green")).gameObject, val2).transform; ((Object)obj4).name = text3; num -= 0.095f; obj4.localPosition = new Vector3(num, 0f, 0f); ((Component)obj4).gameObject.SetActive(true); ((Renderer)((Component)obj4).GetComponent()).enabled = true; ((Behaviour)((Component)obj4).GetComponent()).enabled = enabled; num -= 0.095f; } Transform val5 = ((Component)__instance).transform.Find("Resources"); for (int m = 0; m < val5.childCount; m++) { Transform child2 = val5.GetChild(m); if (((Object)((Component)child2).gameObject).name.Contains("Bone") || ((Object)((Component)child2).gameObject).name.Contains("Blood")) { ((Component)child2).gameObject.SetActive(false); } } int num5 = info.BonesCost + (mod?.bonesCostAdjustment).GetValueOrDefault(0); flag = (mod?.bonesCostAdjustment).GetValueOrDefault(0) != 0; for (int n = 0; n < num5; n++) { string text4 = $"Resources/Bones_{n}"; Transform val6 = ((Component)__instance).transform.Find(text4); if ((Object)(object)val6 == (Object)null) { val6 = Object.Instantiate(((Component)((Component)__instance).transform.Find("Resources/Gems/Gem_Green")).gameObject, val5).transform; ((Object)val6).name = $"Bones_{n}"; SpriteRenderer component = ((Component)val6).GetComponent(); component.sprite = FaceBoneSprite; component.color = BoneColor * 0.9f; ((Component)val6).GetComponent().color1 = BoneColor * 0.9f; } num -= 0.069f; val6.localPosition = new Vector3(num, 0f, 0f); ((Component)val6).gameObject.SetActive(true); ((Renderer)((Component)val6).GetComponent()).enabled = true; ((Behaviour)((Component)val6).GetComponent()).enabled = flag; num -= 0.069f; } int num6 = info.BloodCost + (mod?.bloodCostAdjustment).GetValueOrDefault(0); flag2 = (mod?.bloodCostAdjustment).GetValueOrDefault(0) != 0; for (int num7 = 0; num7 < num6; num7++) { string text5 = $"Resources/Blood_{num7}"; Transform val7 = ((Component)__instance).transform.Find(text5); if ((Object)(object)val7 == (Object)null) { val7 = Object.Instantiate(((Component)((Component)__instance).transform.Find("Resources/Gems/Gem_Green")).gameObject, val5).transform; ((Object)val7).name = $"Blood_{num7}"; SpriteRenderer component2 = ((Component)val7).GetComponent(); component2.sprite = FaceBloodSprite; component2.color = BloodColor * 0.9f; ((Component)val7).GetComponent().color1 = BloodColor * 0.9f; } num -= 0.057f; val7.localPosition = new Vector3(num, 0f, 0f); ((Component)val7).gameObject.SetActive(true); ((Renderer)((Component)val7).GetComponent()).enabled = true; ((Behaviour)((Component)val7).GetComponent()).enabled = flag2; num -= 0.057f; } BlinkColor[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(); foreach (BlinkColor obj5 in componentsInChildren) { obj5.blinkOn = false; ((TimedBehaviour)obj5).Reset(); } } } [HarmonyPatch] internal static class Part3StatIcons { private static readonly Vector3 ICON_SCALE = new Vector3(0.2f, 0.2f, 1f); private static readonly Vector3 LEFT_ICON = new Vector3(-0.39f, 0.033f, 0f); private static readonly Vector3 RIGHT_ICON = new Vector3(0.39f, 0.033f, 0f); private static readonly Color ICON_COLOR = GameColors.Instance.brightBlue; [HarmonyPatch(typeof(Card), "RenderCard")] [HarmonyPrefix] private static void UpdateLiveRenderedCard(ref Card __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (SaveManager.SaveFile == null || !SaveManager.SaveFile.IsPart3) { return; } CardStatIcons componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren(); if (!((Object)(object)componentInChildren == (Object)null)) { if ((Object)(object)componentInChildren.attackIconRenderer != (Object)null) { ((Component)componentInChildren.attackIconRenderer).gameObject.transform.localPosition = RIGHT_ICON; ((Component)componentInChildren.attackIconRenderer).gameObject.transform.localScale = ICON_SCALE; componentInChildren.attackIconRenderer.material.color = ICON_COLOR; componentInChildren.attackIconRenderer.enabled = false; } if ((Object)(object)componentInChildren.healthIconRenderer != (Object)null) { ((Component)componentInChildren.healthIconRenderer).gameObject.transform.localPosition = LEFT_ICON; ((Component)componentInChildren.healthIconRenderer).gameObject.transform.localScale = ICON_SCALE; componentInChildren.healthIconRenderer.material.color = ICON_COLOR; componentInChildren.healthIconRenderer.enabled = false; } } } [HarmonyPatch(typeof(CardDisplayer3D), "DisplayInfo")] [HarmonyPrefix] private static void UpdateCardDisplayer(ref CardDisplayer3D __instance) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (!(__instance is DiskScreenCardDisplayer)) { return; } CardStatIcons componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren(); if (!((Object)(object)componentInChildren == (Object)null)) { if ((Object)(object)componentInChildren.attackIconRenderer != (Object)null) { ((Component)componentInChildren.attackIconRenderer).gameObject.transform.localPosition = LEFT_ICON; ((Component)componentInChildren.attackIconRenderer).gameObject.transform.localScale = ICON_SCALE; ((Component)componentInChildren.attackIconRenderer).gameObject.layer = LayerMask.NameToLayer("CardOffscreenEmission"); componentInChildren.attackIconRenderer.material.color = ICON_COLOR; componentInChildren.attackIconRenderer.enabled = true; } if ((Object)(object)componentInChildren.healthIconRenderer != (Object)null) { ((Component)componentInChildren.healthIconRenderer).gameObject.transform.localPosition = RIGHT_ICON; ((Component)componentInChildren.healthIconRenderer).gameObject.transform.localScale = ICON_SCALE; ((Component)componentInChildren.healthIconRenderer).gameObject.layer = LayerMask.NameToLayer("CardOffscreenEmission"); componentInChildren.healthIconRenderer.material.color = ICON_COLOR; componentInChildren.healthIconRenderer.enabled = true; } } } [HarmonyPatch(typeof(CardRenderCamera), "LiveRenderCard")] [HarmonyPrefix] private static void UpdateCamera(ref CardRenderCamera __instance) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) if (!SaveManager.SaveFile.IsPart3) { return; } CardStatIcons componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren(); if (!((Object)(object)componentInChildren == (Object)null)) { if ((Object)(object)componentInChildren.attackIconRenderer != (Object)null) { ((Component)componentInChildren.attackIconRenderer).gameObject.transform.localPosition = RIGHT_ICON; ((Component)componentInChildren.attackIconRenderer).gameObject.transform.localScale = ICON_SCALE; ((Component)componentInChildren.attackIconRenderer).gameObject.layer = LayerMask.NameToLayer("CardOffscreenEmission"); componentInChildren.attackIconRenderer.material.color = ICON_COLOR; componentInChildren.attackIconRenderer.enabled = true; } if ((Object)(object)componentInChildren.healthIconRenderer != (Object)null) { ((Component)componentInChildren.healthIconRenderer).gameObject.transform.localPosition = LEFT_ICON; ((Component)componentInChildren.healthIconRenderer).gameObject.transform.localScale = ICON_SCALE; ((Component)componentInChildren.healthIconRenderer).gameObject.layer = LayerMask.NameToLayer("CardOffscreenEmission"); componentInChildren.healthIconRenderer.material.color = ICON_COLOR; componentInChildren.healthIconRenderer.enabled = true; } } } private static bool OpponentHasGem(GemType gem) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Singleton.Instance)) { return Singleton.Instance.HasGem(gem); } return false; } [HarmonyPatch(typeof(DiskRenderStatsLayer), "ManagedUpdate")] [HarmonyPrefix] private static bool RenderOpposingGemification(DiskRenderStatsLayer __instance) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)((RenderStatsLayer)__instance).PlayableCard)) { return true; } if (__instance.gemSquares[0].activeInHierarchy && GameFlowManager.IsCardBattle) { for (int i = 0; i < __instance.gemRenderers.Count; i++) { __instance.gemRenderers[i].GetPropertyBlock(__instance.gemsPropertyBlock); GemType val = (GemType)i; bool flag = Object.op_Implicit((Object)(object)((RenderStatsLayer)__instance).PlayableCard) && (((RenderStatsLayer)__instance).PlayableCard.OpponentCard ? OpponentHasGem(val) : Singleton.Instance.HasGem(val)); __instance.gemsPropertyBlock.SetColor("_EmissionColor", flag ? Color.white : Color.black); __instance.gemRenderers[i].SetPropertyBlock(__instance.gemsPropertyBlock); } } return false; } } [HarmonyPatch] public static class PassiveAttackBuffPatches { [HarmonyPatch(typeof(PlayableCard), "GetPassiveHealthBuffs")] [HarmonyPrefix] private static bool BetterHealthBuffs(ref int __result, ref PlayableCard __instance) { __result = 0; if (((Card)__instance).Info.Gemified) { if (__instance.OpponentCard) { if (Object.op_Implicit((Object)(object)Singleton.Instance) && Singleton.Instance.HasGem((GemType)0)) { __result += 2; } } else if (Singleton.Instance.HasGem((GemType)0)) { __result += 2; } } return false; } [HarmonyPatch(typeof(PlayableCard), "GetPassiveAttackBuffs")] [HarmonyPrefix] private static bool BetterAttackBuffs(ref int __result, ref PlayableCard __instance) { if (__instance.OnBoard) { __result += CardSlotExtensions.GetAdjacentCards(__instance.Slot).Sum((PlayableCard playableCard) => CardExtensions.GetAbilityStacks(playableCard, (Ability)34)); if (CardExtensions.HasTrait(__instance, (Trait)16)) { foreach (CardSlot item in from slot in Singleton.Instance.GetSlots(__instance.OpponentCard) where Object.op_Implicit((Object)(object)slot.Card) select slot) { __result += CardExtensions.GetAbilityStacks(item.Card, (Ability)76); if (CardExtensions.LacksAbility(__instance, (Ability)105)) { __result -= CardExtensions.GetAbilityStacks(item.Card, (Ability)83); } } } else if (CardExtensions.HasOpposingCard(__instance)) { __result += CardExtensions.GetAbilityStacks(CardExtensions.OpposingCard(__instance), (Ability)76); if (CardExtensions.LacksAbility(__instance, (Ability)105)) { __result -= CardExtensions.GetAbilityStacks(CardExtensions.OpposingCard(__instance), (Ability)83); } } if ((Object)(object)Singleton.Instance != (Object)null) { List conduitsForSlot = Singleton.Instance.GetConduitsForSlot(__instance.Slot); __result += conduitsForSlot.Sum((PlayableCard playableCard) => CardExtensions.GetAbilityStacks(playableCard, (Ability)47)); if (conduitsForSlot.Count > 0) { __result += 2 * CardExtensions.GetAbilityStacks(__instance, (Ability)84); } } if (((Card)__instance).Info.HasTrait((Trait)17)) { __result += (from slot in Singleton.Instance.GetSlots(CardExtensions.IsPlayerCard(__instance)) where Object.op_Implicit((Object)(object)slot.Card) select slot).Sum((CardSlot slot) => CardExtensions.GetAbilityStacks(slot.Card, (Ability)40)); } } if (((Card)__instance).Info.Gemified) { if (__instance.OpponentCard) { if (Object.op_Implicit((Object)(object)Singleton.Instance) && Singleton.Instance.HasGem((GemType)1)) { __result++; } } else if (Singleton.Instance.HasGem((GemType)1)) { __result++; } } return false; } } [HarmonyPatch] internal class PixelCurrentDeckPatch { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void CheckForNegativeIndex(SaveFile __instance, ref DeckInfo __result) { if (__instance.IsPart2) { __result = __instance.gbcData.deck; } } } public static class SacrificeTokensFix { [HarmonyPatch(typeof(BoardManager3D), "Start")] private class BoardManager3DPatch { [HarmonyPostfix] private static void Postfix(ref BoardManager3D __instance) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.tokens != (Object)null)) { return; } if (amountOfNewTokens > 0) { for (int i = 0; i < amountOfNewTokens; i++) { List tokens = __instance.tokens.tokens; SacrificeToken val = Object.Instantiate(tokens[i], ((Component)tokens[0]).transform.parent); ((Object)val).name = $"SacrificeToken_{5 + i}"; Transform transform = ((Component)val).transform; transform.localPosition += new Vector3(0f, 0.1f, 0f); tokens.Add(val); } } if (!SaveManager.SaveFile.IsPart3) { return; } foreach (SacrificeToken token in __instance.tokens.tokens) { Transform transform2 = ((Component)token).transform; transform2.localPosition += new Vector3(1.4f, 0f, 2f); } } } public static int amountOfNewTokens = 20; } [HarmonyPatch] public static class StackAbilityIcons { private static readonly Texture2D[] NUMBER_TEXTURES = (Texture2D[])(object)new Texture2D[10] { TextureHelper.GetImageAsTexture("Stack_0.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_1.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_2.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_3.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_4.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_5.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_6.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_7.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_8.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_9.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0) }; private static readonly Texture2D[] MEDIUM_NUMBER_TEXTURES = (Texture2D[])(object)new Texture2D[10] { TextureHelper.GetImageAsTexture("Stack_0_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_1_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_2_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_3_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_4_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_5_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_6_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_7_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_8_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0), TextureHelper.GetImageAsTexture("Stack_9_med.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0) }; private static readonly Sprite[] GBC_NUMBER_SPRITES = (Sprite[])(object)new Sprite[9] { GetGBCNumberSprite(1), GetGBCNumberSprite(2), GetGBCNumberSprite(3), GetGBCNumberSprite(4), GetGBCNumberSprite(5), GetGBCNumberSprite(6), GetGBCNumberSprite(7), GetGBCNumberSprite(8), GetGBCNumberSprite(9) }; private static Color[] _topBorder = null; private static Color[] _leftBorder = null; private static readonly int NORMAL = 1; private static readonly int MEDIUM = 2; private static readonly int FORCED = 3; private static readonly Dictionary patchedTexture = new Dictionary(); private static readonly Dictionary> patchLocations = new Dictionary>(); private static Color[] TOP_BORDER { get { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_topBorder == null) { _topBorder = (Color[])(object)new Color[((Texture)NUMBER_TEXTURES[0]).width + 1]; for (int i = 0; i < _topBorder.Length; i++) { _topBorder[i] = new Color(0f, 0f, 0f, 0f); } } return _topBorder; } } private static Color[] LEFT_BORDER { get { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_leftBorder == null) { _leftBorder = (Color[])(object)new Color[((Texture)NUMBER_TEXTURES[0]).height + 1]; for (int i = 0; i < _leftBorder.Length; i++) { _leftBorder[i] = new Color(0f, 0f, 0f, 0f); } } return _leftBorder; } } private static Sprite GetGBCNumberSprite(int number) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) string text = "stack_gbc.png"; if (!PatchPlugin.act2StackIconType.Value) { text = "stack_gbc_alt.png"; } return Sprite.Create(TextureHelper.GetImageAsTexture(text, typeof(StackAbilityIcons).Assembly, (FilterMode)0), new Rect(0f, 10f * (9f - (float)number), 15f, 10f), new Vector2(0.5f, 0.5f)); } private static Vector2Int FindMatchingOnesDigit(Texture2D searchTex, bool normalSize = true) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) Texture2D val = (normalSize ? NUMBER_TEXTURES[1] : MEDIUM_NUMBER_TEXTURES[1]); Color[] pixels = val.GetPixels(); return FindMatchingTexture(searchTex, ((Texture)val).width, ((Texture)val).height, pixels); } private static Vector2Int FindMatchingTexture(Texture2D searchTex, int width, int height, Color[] matchPixels = null) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Color[] pixels = searchTex.GetPixels(); int num = -1; int num2 = -1; bool flag = false; for (int i = 0; i < ((Texture)searchTex).width - width; i++) { for (int j = 0; j < ((Texture)searchTex).height - height; j++) { flag = false; for (int k = 0; k < width; k++) { for (int l = 0; l < height; l++) { int num3 = k + l * width; int num4 = i + k + (j + l) * ((Texture)searchTex).width; if (matchPixels != null && pixels[num4].a > 0f != matchPixels[num3].a > 0f) { flag = true; break; } } if (flag) { break; } } if (!flag) { num = i; num2 = j; } } if (!flag) { break; } } return new Vector2Int(num, num2); } private static Tuple FindNextBestLocation(Texture2D texture) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Color[] pixels = texture.GetPixels(); Vector2Int item = default(Vector2Int); ((Vector2Int)(ref item))..ctor(((Texture)texture).width - ((Texture)NUMBER_TEXTURES[0]).width, 0); bool flag = true; for (int i = ((Vector2Int)(ref item)).x - 1; i < ((Texture)texture).width; i++) { for (int j = ((Vector2Int)(ref item)).y; j < ((Texture)texture).height; j++) { int num = i + ((Texture)texture).width * j; if (pixels[num].a > 0f) { flag = false; break; } } if (!flag) { break; } } if (flag) { return new Tuple(item, NORMAL); } Vector2Int item2 = FindMatchingTexture(texture, ((Texture)NUMBER_TEXTURES[0]).width + 2, ((Texture)NUMBER_TEXTURES[0]).height + 2); if (((Vector2Int)(ref item2)).x != -1) { return new Tuple(item2, NORMAL); } return new Tuple(item, FORCED); } private static Tuple GetPatchLocationForAbility(Ability ability, Texture2D abilityTexture, int stackAmount) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (patchLocations.ContainsKey(ability)) { return patchLocations[ability]; } if (stackAmount < 10) { Vector2Int item = FindMatchingOnesDigit(abilityTexture); if (((Vector2Int)(ref item)).x != -1) { patchLocations.Add(ability, new Tuple(item, NORMAL)); return patchLocations[ability]; } item = FindMatchingOnesDigit(abilityTexture, normalSize: false); if (((Vector2Int)(ref item)).x != -1) { patchLocations.Add(ability, new Tuple(item, MEDIUM)); return patchLocations[ability]; } } Tuple value = new Tuple(new Vector2Int(((Texture)abilityTexture).width - ((Texture)NUMBER_TEXTURES[0]).width, 0), NORMAL); patchLocations.Add(ability, value); return patchLocations[ability]; } private static Texture2D PatchTexture(Ability ability, int count) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (count <= 1 || count > 99) { return null; } string text = $"{ability}-icon-{count}-PATCHEDINF"; if (patchedTexture.ContainsKey(text)) { return patchedTexture[text]; } PatchPlugin.Logger.LogDebug((object)$"Ability [{AbilitiesUtil.GetInfo(ability).rulebookName}] stacks [{count}] time(s)."); bool num = count > 9; Texture obj = AbilitiesUtil.LoadAbilityIcon(((object)(Ability)(ref ability)).ToString(), false, false); Texture2D val = TextureHelper.DuplicateTexture((Texture2D)(object)((obj is Texture2D) ? obj : null)); ((Object)val).name = text; Tuple patchLocationForAbility = GetPatchLocationForAbility(ability, val, count); Vector2Int item = patchLocationForAbility.Item1; int item2 = patchLocationForAbility.Item2; if (item2 == FORCED) { val.SetPixels(((Vector2Int)(ref item)).x - 1, ((Vector2Int)(ref item)).y + 1, TOP_BORDER.Length, 1, TOP_BORDER, 0); val.SetPixels(((Vector2Int)(ref item)).x - 1, ((Vector2Int)(ref item)).y + 1, 1, LEFT_BORDER.Length, LEFT_BORDER, 0); } Texture2D val2 = null; Texture2D val4; if (num) { int num2 = 1; int num3; for (num3 = count - 10; num3 > 9; num3 -= 10) { num2++; } Texture2D val3 = ((item2 == NORMAL) ? NUMBER_TEXTURES[num2] : MEDIUM_NUMBER_TEXTURES[num2]); val4 = ((item2 == NORMAL) ? NUMBER_TEXTURES[num3] : MEDIUM_NUMBER_TEXTURES[num3]); val2 = val3; } else { val4 = ((item2 == NORMAL) ? NUMBER_TEXTURES[count] : MEDIUM_NUMBER_TEXTURES[count]); } if ((Object)(object)val2 != (Object)null) { try { val.SetPixels(((Vector2Int)(ref item)).x - (((Texture)val4).width + 1), ((Vector2Int)(ref item)).y, ((Texture)val2).width, ((Texture)val2).height, val2.GetPixels(), 0); } catch { PatchPlugin.Logger.LogError((object)"Couldn't properly set new texture."); } } val.SetPixels(((Vector2Int)(ref item)).x, ((Vector2Int)(ref item)).y, ((Texture)val4).width, ((Texture)val4).height, val4.GetPixels(), 0); ((Texture)val).filterMode = (FilterMode)0; val.Apply(); patchedTexture.Add(text, val); return val; } [HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")] [HarmonyPostfix] private static void ClearStackableIcons(ref List __result, CardInfo info, List mods, List hiddenAbilities) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) int count = __result.Count; __result = __result.Distinct().ToList(); if (PatchPlugin.doubleStackSplit.Value && __result.Count == 1 && count == 2 && AbilitiesUtil.GetInfo(__result[0]).canStack) { __result.Add(__result[0]); } } [HarmonyPatch(typeof(AbilityIconInteractable), "AssignAbility")] [HarmonyPostfix] private static void AddIconNumber(Ability ability, CardInfo info, PlayableCard card, ref AbilityIconInteractable __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)info == (Object)null || !AbilitiesUtil.GetInfo(ability).canStack) { return; } int? num = null; List list = new List(info.Abilities); AbilityInfo val = AbilityExtensions.AbilityByID((IEnumerable)AbilityManager.AllAbilityInfos, ability); if ((Object)(object)card != (Object)null) { if (CardExtensions.IsShieldAbility(val)) { DamageShieldBehaviour shieldBehaviour = CardExtensions.GetShieldBehaviour(card, ability); num = ((shieldBehaviour != null) ? new int?(shieldBehaviour.NumShields) : null); } list.AddRange(AbilitiesUtil.GetAbilitiesFromMods(card.TemporaryMods)); if (AbilityExtensions.GetHideSingleStacks(val)) { for (int i = 0; i < card.Status.hiddenAbilities.Count; i++) { if (card.Status.hiddenAbilities[i] == ability) { list.Remove(ability); } } } else if (card.Status.hiddenAbilities.Contains(ability)) { list.RemoveAll((Ability x) => x == ability); } } int valueOrDefault = num.GetValueOrDefault(); if (!num.HasValue) { valueOrDefault = list.Count((Ability ab) => ab == ability); num = valueOrDefault; } if (num > 1) { if (PatchPlugin.doubleStackSplit.Value && num.GetValueOrDefault() == 2 && num == list.Count) { __instance.SetIcon(__instance.LoadIcon(info, val, (Object)(object)card != (Object)null && card.OpponentCard)); } else { __instance.SetIcon((Texture)(object)PatchTexture(ability, num.Value)); } } } [HarmonyPatch(typeof(PixelCardAbilityIcons), "DisplayAbilities", new Type[] { typeof(List), typeof(PlayableCard) })] [HarmonyPrefix] private static bool PatchPixelCardStacks(PixelCardAbilityIcons __instance, List abilities, PlayableCard card) { return RenderPixelAbilityStacks(__instance, abilities, card); } public static bool RenderPixelAbilityStacks(PixelCardAbilityIcons __instance, List abilities, PlayableCard card) { //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_02de: 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_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) List abilityIconGroups = __instance.abilityIconGroups; if (abilityIconGroups.Count == 0) { return false; } foreach (GameObject item in abilityIconGroups) { item.gameObject.SetActive(false); } List list = new List(abilities); if ((Object)(object)card != (Object)null) { list.AddRange(AbilitiesUtil.GetAbilitiesFromMods(card.TemporaryMods)); } List> grps = (from a in list.Distinct() select new Tuple(a, (!AbilitiesUtil.GetInfo(a).canStack) ? 1 : abilities.Count((Ability ab) => ab == a))).ToList(); if (grps.Count > 0 && grps.Count - 1 < abilityIconGroups.Count) { if (PatchPlugin.doubleStackSplit.Value && grps.Count == 1 && grps[0].Item2 == 2) { grps[0] = new Tuple(grps[0].Item1, 1); grps.Add(grps[0]); } GameObject obj = abilityIconGroups[grps.Count - 1]; obj.gameObject.SetActive(true); List list2 = new List(); foreach (Transform item2 in obj.transform) { Transform val = item2; list2.Add(((Component)val).gameObject.GetComponent()); } list2.RemoveAll((SpriteRenderer sr) => (Object)(object)sr == (Object)null); object obj2 = ((card != null) ? ((Card)card).Info : null); if (obj2 == null) { Card componentInParent = ((Component)__instance).GetComponentInParent(); obj2 = ((componentInParent != null) ? componentInParent.Info : null); } CardInfo cardInfo = (CardInfo)obj2; int i; for (i = 0; i < list2.Count; i++) { SpriteRenderer val2 = list2[i]; AbilityInfo info = AbilitiesUtil.GetInfo(grps[i].Item1); int num = grps[i].Item2; if ((Object)(object)card != (Object)null) { if (AbilityExtensions.GetHideSingleStacks(info)) { for (int j = 0; j < card.Status.hiddenAbilities.Count((Ability x) => x == grps[i].Item1); j++) { num--; } } else if (card.Status.hiddenAbilities.Contains(grps[i].Item1)) { num -= list.Count((Ability x) => x == grps[i].Item1); } if (CardExtensions.IsShieldAbility(info)) { DamageShieldBehaviour shieldBehaviour = CardExtensions.GetShieldBehaviour(card, grps[i].Item1); num = ((shieldBehaviour != null) ? shieldBehaviour.NumShields : 0); } } object obj3 = val2; obj3 = ((!info.activated) ? ((object)OverridePixelSprite(info, cardInfo, card)) : ((object)new Sprite())); ((SpriteRenderer)obj3).sprite = (Sprite)obj3; if (info.flipYIfOpponent && (Object)(object)card != (Object)null && card.OpponentCard) { if (Object.op_Implicit((Object)(object)info.customFlippedPixelIcon)) { val2.sprite = info.customFlippedPixelIcon; } else { val2.flipY = true; } } else { val2.flipY = false; } PatchPlugin.Logger.LogDebug((object)$"Ability [{grps[i].Item1}] stacks [{num}] time(s)"); AddStackCount(val2, grps[i].Item1, num); } } __instance.conduitIcon.SetActive(abilities.Exists((Ability x) => AbilitiesUtil.GetInfo(x).conduit)); Ability val3 = abilities.Find((Ability x) => AbilitiesUtil.GetInfo(x).activated); PixelActivatedAbilityButton activatedAbilityButton = __instance.activatedAbilityButton; if ((int)val3 != 0) { ((Component)activatedAbilityButton).gameObject.SetActive(true); activatedAbilityButton.SetAbility(val3); } else { ((Component)activatedAbilityButton).gameObject.SetActive(false); } return false; } private static void AddStackCount(SpriteRenderer abilityRenderer, Ability ability, int count) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)abilityRenderer).transform.Find("Count"); if ((Object)(object)val == (Object)null) { if (count <= 1) { return; } GameObject val2 = new GameObject(); val2.transform.SetParent(((Component)abilityRenderer).transform); val2.layer = LayerMask.NameToLayer("GBCPauseMenu"); SpriteRenderer obj = val2.AddComponent(); obj.size = new Vector2(0.14f, 0.08f); obj.color = new Color(1f, 1f, 1f, 1f); obj.adaptiveModeThreshold = 0.5f; ((Renderer)obj).enabled = true; ((Renderer)obj).sortingLayerName = "PauseMenuUI"; ((Renderer)obj).sortingOrder = 200; ((Object)val2).name = "Count"; val2.transform.localPosition = new Vector3(0.03f, -0.05f, 0f); val = val2.transform; } if (count < 2) { ((Component)val).gameObject.SetActive(false); return; } ((Component)val).gameObject.SetActive(true); ((Component)val).gameObject.GetComponent().sprite = GBC_NUMBER_SPRITES[count - 1]; PatchPlugin.Logger.LogDebug((object)$"countTransform [{count - 1}]"); } private static Sprite OverridePixelSprite(AbilityInfo abilityInfo, CardInfo cardInfo, PlayableCard card) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 if ((Object)(object)cardInfo != (Object)null && ((int)abilityInfo.ability == 5 || (int)abilityInfo.ability == 61)) { int valueOrDefault = ((card == null) ? null : ((Component)card).GetComponentInChildren()?.numTurnsInPlay).GetValueOrDefault(); int num = Mathf.Max(1, ((cardInfo.evolveParams == null) ? 1 : cardInfo.evolveParams.turnsToEvolve) - valueOrDefault); int num2 = ((num <= 3) ? num : 0); if (num2 == 0) { return abilityInfo.pixelIcon; } Texture2D val = (((int)abilityInfo.ability != 5) ? TextureHelper.GetImageAsTexture($"pixel_transformer_{Mathf.Min(num2, 6)}.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0) : TextureHelper.GetImageAsTexture($"pixel_evolve_{Mathf.Min(num2, 6)}.png", typeof(StackAbilityIcons).Assembly, (FilterMode)0)); return TextureHelper.ConvertTexture(val, (SpriteType)2, (FilterMode)0); } if ((Object)(object)card != (Object)null && ((Card)card).RenderInfo.overriddenAbilityIcons.ContainsKey(abilityInfo.ability)) { ((Card)card).RenderInfo.overriddenAbilityIcons.TryGetValue(abilityInfo.ability, out var value); if ((Object)(object)value != (Object)null) { return TextureHelper.ConvertTexture((Texture2D)value, (SpriteType)2, (FilterMode)0); } } return abilityInfo.pixelIcon; } public static string StackDescription(string input) { string[] array = input.Split(new char[1] { '\n' }); string text = array[0]; int num = 0; for (int i = 1; i < array.Length; i++) { if (array[i] == array[i - 1]) { num++; continue; } if (num > 0) { text += $" (x{num + 1})"; } text = text + "\n" + array[i]; num = 0; } if (num > 0) { text += $" (x{num + 1})"; } return text; } [HarmonyPatch(typeof(CardInfo), "GetGBCDescriptionLocalized")] [HarmonyPostfix] private static void GetStackedGBCDescriptionLocalized(ref string __result) { __result = StackDescription(__result); } } [HarmonyPatch] internal class TempModDecalsFix { [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; foreach (CardInfo card in ((CardCollectionInfo)SaveManager.SaveFile.CurrentDeck).Cards) { card.Mods.RemoveAll((CardModificationInfo x) => CardModificationInfoExtensions.IsTemporaryDecal(x)); } <>2__current = this.enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayableCard), "RemoveTemporaryMod")] private static void RemoveTemporaryModsWithDecals(PlayableCard __instance, CardModificationInfo mod) { if (mod != null && __instance.TemporaryMods.Contains(mod) && mod.DecalIds.Count != 0) { CardModificationInfo val = ((Card)__instance).Info.Mods.Find((CardModificationInfo x) => x.singletonId == mod.singletonId || x.DecalIds == mod.DecalIds); if (val != null) { ((Card)__instance).Info.Mods.Remove(val); } } } [HarmonyPatch(typeof(PlayableCard), "AddTemporaryMod")] [HarmonyTranspiler] private static IEnumerable AddTemporaryDecalsWithDecals(IEnumerable instructions) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown List list = new List(instructions); object obj = null; for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldfld && list[i].operand.ToString() == "DiskCardGame.CardModificationInfo mod") { obj = list[i].operand; } else if (list[i].opcode == OpCodes.Endfinally) { int num = i + 1; MethodInfo methodInfo = AccessTools.Method(typeof(TempModDecalsFix), "AddDecalIdsToMods", new Type[2] { typeof(PlayableCard), typeof(CardModificationInfo) }, (Type[])null); list.Insert(num, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Ldloc_0, (object)null)); list.Insert(num + 2, new CodeInstruction(OpCodes.Ldfld, obj)); list.Insert(num + 3, new CodeInstruction(OpCodes.Call, (object)methodInfo)); break; } } return list; } private static void AddDecalIdsToMods(PlayableCard card, CardModificationInfo tempMod) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown if (tempMod.DecalIds.Count == 0) { return; } if (!string.IsNullOrEmpty(tempMod.singletonId)) { CardModificationInfo val = ((Card)card).Info.Mods.Find((CardModificationInfo x) => x.singletonId == tempMod.singletonId); if (val != null) { ((Card)card).Info.Mods.Remove(val); } } CardModificationInfo val2 = new CardModificationInfo { decalIds = tempMod.DecalIds, singletonId = tempMod.singletonId }; CardModificationInfoExtensions.SetTemporaryDecal(val2); ((Card)card).Info.Mods.Add(val2); } [IteratorStateMachine(typeof(d__3))] [HarmonyPatch(typeof(BoardManager), "CleanUp")] [HarmonyPostfix] private static IEnumerator ClearTempDecals(IEnumerator enumerator) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { enumerator = enumerator }; } } [HarmonyPatch] public class TempModPixelSigilsFix { [HarmonyTranspiler] [HarmonyPatch(typeof(PixelCardAbilityIcons), "DisplayAbilities", new Type[] { typeof(CardRenderInfo), typeof(PlayableCard) })] private static IEnumerable AddTemporaryMods(IEnumerable instructions) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Callvirt) { MethodInfo operand = AccessTools.Method(typeof(TempModPixelSigilsFix), "RenderTemporarySigils", new Type[2] { typeof(CardInfo), typeof(PlayableCard) }, (Type[])null); list[i].operand = operand; list.Insert(i, new CodeInstruction(OpCodes.Ldarg_2, (object)null)); break; } } return list; } public static List RenderTemporarySigils(CardInfo info, PlayableCard card) { if ((Object)(object)card == (Object)null) { return info.Abilities; } List list = new List(info.Abilities); List list2 = new List(); foreach (CardModificationInfo temporaryMod in ((Card)card).RenderInfo.temporaryMods) { if (temporaryMod.singletonId != "paint") { list2.AddRange(temporaryMod.abilities); } } list.AddRange(list2); list = AbilitiesUtil.RemoveNonDistinctNonStacking(list); list.RemoveAll((Ability x) => ((Card)card).RenderInfo.temporaryMods.Exists((CardModificationInfo m) => m.negateAbilities.Contains(x))); if (card.Status.hiddenAbilities != null) { list.RemoveAll((Ability x) => card.Status.hiddenAbilities.Contains(x)); } return list; } } [HarmonyPatch] public class Act1LatchAbilityFix { private class SelectTargetHolder : MonoBehaviour { public bool isSelectingTarget; } [CompilerGenerated] private sealed class <>c__DisplayClass8_0 { public Latch __state; public CardSlot selectedSlot; public Transform latchParent; public GameObject claw; internal bool b__0(CardSlot slot) { if (!((Object)(object)slot.Card == (Object)null) && !slot.Card.Dead && !__state.CardHasLatchMod(slot.Card)) { return (Object)(object)slot.Card == (Object)(object)((AbilityBehaviour)__state).Card; } return true; } internal void b__1(CardSlot s) { selectedSlot = s; } internal void b__5(CardSlot s) { selectedSlot = s; } internal void b__6(CardSlot s) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s.Card == (Object)null)) { AimWeaponAnim(((Component)latchParent).gameObject, ((Component)s).transform.position); } } internal void b__2() { claw.SetActive(true); } internal void b__3() { claw.SetActive(false); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Latch __state; public IEnumerator enumerator; private <>c__DisplayClass8_0 <>8__1; private List 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Expected O, but got Unknown //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass8_0(); <>8__1.__state = __state; if (SaveManager.SaveFile.IsPart3) { <>2__current = this.enumerator; <>1__state = 1; return true; } 5__2 = Singleton.Instance.AllSlotsCopy; 5__2.RemoveAll((CardSlot slot) => (Object)(object)slot.Card == (Object)null || slot.Card.Dead || <>8__1.__state.CardHasLatchMod(slot.Card) || (Object)(object)slot.Card == (Object)(object)((AbilityBehaviour)<>8__1.__state).Card); if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)("[LatchFix] Started death, latch name: [" + ((Object)<>8__1.__state).name + "]")); PatchPlugin.Logger.LogDebug((object)("[LatchFix] Count of Valid Targets : " + 5__2.Count)); } if (5__2.Count == 0) { return false; } Singleton.Instance.SwitchToView((View)4, false, false); ((Card)((AbilityBehaviour)<>8__1.__state).Card).Anim.PlayHitAnimation(); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; case 1: <>1__state = -1; return false; case 2: { <>1__state = -1; CardAnimationController anim = ((Card)((AbilityBehaviour)<>8__1.__state).Card).Anim; GameObject val2 = new GameObject { name = "LatchParent" }; val2.transform.position = ((Component)anim).transform.position; GameObject val3 = val2; val3.transform.SetParent(((Component)anim).transform); <>8__1.latchParent = val3.transform; <>8__1.claw = Object.Instantiate(ClawPrefab, <>8__1.latchParent); Material val4 = null; try { val4 = new Material(ResourceBank.Get("Prefabs/Cards/SpecificCardModels/CannonTargetIcon").GetComponentInChildren().material); } catch { } if ((Object)(object)val4 != (Object)null) { foreach (Renderer item in from rend in <>8__1.claw.GetComponentsInChildren() where Object.op_Implicit((Object)(object)rend) select rend) { item.material = val4; } } <>8__1.selectedSlot = null; if (((AbilityBehaviour)<>8__1.__state).Card.OpponentCard) { <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 3; return true; } List allSlotsCopy = Singleton.Instance.AllSlotsCopy; allSlotsCopy.Remove(((AbilityBehaviour)<>8__1.__state).Card.Slot); <>2__current = Singleton.Instance.ChooseTarget(allSlotsCopy, 5__2, (Action)delegate(CardSlot s) { <>8__1.selectedSlot = s; }, (Action)<>8__1.__state.OnInvalidTarget, (Action)delegate(CardSlot s) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s.Card == (Object)null)) { AimWeaponAnim(((Component)<>8__1.latchParent).gameObject, ((Component)s).transform.position); } }, (Func)null, (CursorType)16); <>1__state = 6; return true; } case 3: <>1__state = -1; <>2__current = <>8__1.__state.AISelectTarget(5__2, (Action)delegate(CardSlot s) { <>8__1.selectedSlot = s; }); <>1__state = 4; return true; case 4: <>1__state = -1; if ((Object)(object)<>8__1.selectedSlot != (Object)null && (Object)(object)<>8__1.selectedSlot.Card != (Object)null) { AimWeaponAnim(((Component)<>8__1.latchParent).gameObject, ((Component)<>8__1.selectedSlot).transform.position); <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 5; return true; } goto IL_03f9; case 5: <>1__state = -1; goto IL_03f9; case 6: <>1__state = -1; goto IL_03f9; case 7: <>1__state = -1; <>2__current = ((AbilityBehaviour)<>8__1.__state).LearnAbility(0f); <>1__state = 8; return true; case 8: { <>1__state = -1; break; } IL_03f9: <>8__1.claw.SetActive(true); CustomCoroutine.FlickerSequence((Action)delegate { <>8__1.claw.SetActive(true); }, (Action)delegate { <>8__1.claw.SetActive(false); }, true, false, 0.05f, 2, (Action)null); if ((Object)(object)<>8__1.selectedSlot != (Object)null && (Object)(object)<>8__1.selectedSlot.Card != (Object)null) { CardModificationInfo val = new CardModificationInfo(<>8__1.__state.LatchAbility) { fromCardMerge = SaveManager.SaveFile.IsPart1 }; CardModificationInfoExtensions.SetExtendedProperty(val, "LatchMod", (object)true, false); if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)("[LatchFix] Selected card name [" + ((Object)<>8__1.selectedSlot.Card).name + "]")); } <>8__1.selectedSlot.Card.AddTemporaryMod(val); ((Card)<>8__1.selectedSlot.Card).Anim.LightNegationEffect(); <>8__1.__state.OnSuccessfullyLatched(<>8__1.selectedSlot.Card); <>2__current = (object)new WaitForSeconds(0.75f); <>1__state = 7; return true; } break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public BoardManager __instance; public List allTargets; public IEnumerator result; private List 5__2; private List 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = ((__instance.currentValidSlots == null) ? new List() : new List(__instance.currentValidSlots)); __instance.currentValidSlots = null; (((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent()).isSelectingTarget = true; 5__3 = new List(); foreach (CardSlot item in allTargets.Where((CardSlot cs) => !((InteractableBase)cs).Enabled)) { ((InteractableBase)item).SetEnabled(true); 5__3.Add(item); } <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; foreach (CardSlot item2 in 5__3) { ((InteractableBase)item2).SetEnabled(false); } (((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent()).isSelectingTarget = false; __instance.currentValidSlots = 5__2; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static GameObject _clawPrefab; private static GameObject ClawPrefab { get { if ((Object)(object)_clawPrefab == (Object)null) { _clawPrefab = ResourceBank.Get("Prefabs/Cards/SpecificCardModels/LatchClaw"); } return _clawPrefab; } } [IteratorStateMachine(typeof(d__3))] [HarmonyPatch(typeof(BoardManager), "ChooseTarget")] [HarmonyPostfix] private static IEnumerator ReEnableSlots(IEnumerator result, BoardManager __instance, List allTargets) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { result = result, __instance = __instance, allTargets = allTargets }; } [HarmonyPatch(typeof(CardSlot), "OnCursorEnter")] [HarmonyPostfix] private static void NoSacrificeMarker(CardSlot __instance) { if (Object.op_Implicit((Object)(object)__instance.Card) && Object.op_Implicit((Object)(object)Singleton.Instance) && (((Component)Singleton.Instance).GetComponent()?.isSelectingTarget).GetValueOrDefault()) { ((Card)__instance.Card).Anim.SetSacrificeHoverMarkerShown(false); } } private static void AimWeaponAnim(GameObject tweenObj, Vector3 target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Tween.LookAt(tweenObj.transform, target, Vector3.up, 0.075f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true); } [HarmonyPrefix] [HarmonyPatch(typeof(Latch), "OnPreDeathAnimation")] private static void PrefixPassStateOnPreDeath(out Latch __state, ref Latch __instance) { __state = __instance; } [IteratorStateMachine(typeof(d__8))] [HarmonyPostfix] [HarmonyPatch(typeof(Latch), "OnPreDeathAnimation")] private static IEnumerator Postfix(IEnumerator enumerator, Latch __state, bool wasSacrifice) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { enumerator = enumerator, __state = __state }; } } [HarmonyPatch(typeof(CardAnimationController), "PlayPermaDeathAnimation")] internal class Act1PermaDeathPatch { [HarmonyPostfix] private static void PlayPermaDeathAnimation(CardAnimationController __instance, bool playSound) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0085: Expected O, but got Unknown if (SaveManager.SaveFile.IsPart1) { SkinnedMeshRenderer componentInChildren = ((Component)__instance.PlayableCard).GetComponentInChildren(); if (playSound) { AudioController.Instance.PlaySound3D("disk_card_overload", (MixerGroup)3, ((Component)__instance).transform.position, 1f, 0.45f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false); AudioController.Instance.PlaySound3D("card_death", (MixerGroup)4, ((Component)__instance).transform.position, 1f, 0f, new Pitch((Variation)3), new Repetition(0.05f, ""), (Randomization)null, (Distortion)null, false); } GameObject obj = Singleton.Instance.AnimController.PlayOneShotAnimation("SplitCard", (Action)null); obj.transform.parent = null; obj.transform.position = ((Component)__instance.PlayableCard).transform.position; obj.transform.eulerAngles = new Vector3(90f, 0f, 0f); ((Renderer)componentInChildren).enabled = false; ((MonoBehaviour)__instance).StopAllCoroutines(); } else if (SaveManager.SaveFile.IsPart2) { __instance.PlayDeathAnimation(playSound); } } } [HarmonyPatch] internal class Act2CuckooFix { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CreateEgg instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected I4, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (SaveManager.SaveFile.IsPart2) { InBattleDialogueSpeakers val = Singleton.Instance; CardTemple temple = ((Card)((AbilityBehaviour)instance).Card).Info.temple; DialogueSpeaker speaker = val.GetSpeaker((Character)((temple - 1) switch { 0 => 0, 2 => 9, 1 => 2, _ => 1, })); <>2__current = Singleton.Instance.PlayDialogueEvent("CuckooSpawnRavenEgg", (Style)((Card)((AbilityBehaviour)instance).Card).Info.temple, speaker, (string[])null, (ScreenPosition)2, true); <>1__state = 1; return true; } <>2__current = Singleton.Instance.PlayDialogueEvent("CuckooSpawnRavenEgg", (MessageAdvanceMode)1, (EventIntersectMode)0, (string[])null, (Action)null); <>1__state = 2; return true; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable FixDialogueSoftlock(IEnumerable instructions) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Call && list[i].operand.ToString() == "DiskCardGame.TextDisplayer get_Instance()") { list.RemoveRange(i, 7); MethodInfo methodInfo = AccessTools.Method(typeof(Act2CuckooFix), "PixelDialogue", new Type[1] { typeof(CreateEgg) }, (Type[])null); list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo)); break; } } return list; } [IteratorStateMachine(typeof(d__1))] private static IEnumerator PixelDialogue(CreateEgg instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { instance = instance }; } } [HarmonyPatch] internal class Act2HiddenAbilitiesPatch { [HarmonyPrefix] [HarmonyPatch(typeof(PixelCardAbilityIcons), "DisplayAbilities", new Type[] { typeof(List), typeof(PlayableCard) })] private static void DerenderHiddenAbilities(ref List abilities, PlayableCard card) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)card)) { return; } for (int num = abilities.Count - 1; num >= 0; num--) { if (card.Status.hiddenAbilities.Contains(abilities[num])) { abilities.RemoveAt(num); } } foreach (CardModificationInfo item in card.TemporaryMods.FindAll((CardModificationInfo x) => x.abilities.Count > 0 && x.singletonId != "paint")) { foreach (Ability ability in item.abilities) { if (!card.Status.hiddenAbilities.Contains(ability)) { abilities.Add(ability); } } } } [HarmonyPrefix] [HarmonyPatch(typeof(WizardDummyBattleSequencer), "AddIconAbilityToCard")] private static bool AddSingletonToDummy(PlayableCard card, Ability ability, string iconPrefabName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) card.AddTemporaryMod(new CardModificationInfo(ability) { singletonId = "paint" }); GameObject obj = Object.Instantiate(Resources.Load("Prefabs/GBCUI/TextAdditive/" + iconPrefabName)); obj.transform.parent = ((Component)card).GetComponentInChildren().CardElements.transform; obj.transform.localPosition = Vector3.zero; return false; } } [HarmonyPatch] internal class Act2HodagFix { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GainAttackOnKill __instance; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!SaveManager.SaveFile.IsPart2 || !__instance.PermanentForRun) { <>2__current = enumerator; <>1__state = 1; return true; } <>2__current = ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence(); <>1__state = 2; return true; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 3; return true; case 3: { <>1__state = -1; CardModificationInfo val = ((Card)((AbilityBehaviour)__instance).Card).Info.Mods.Find((CardModificationInfo x) => x.singletonId == "hodag"); if (val == null) { val = new CardModificationInfo { singletonId = "hodag" }; SaveManager.SaveFile.gbcData.deck.ModifyCard(((Card)((AbilityBehaviour)__instance).Card).Info, val); } CardModificationInfo obj = val; obj.attackAdjustment++; if (!((AbilityBehaviour)__instance).Card.Dead) { ((Card)((AbilityBehaviour)__instance).Card).Anim.LightNegationEffect(); <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 4; return true; } break; } case 4: <>1__state = -1; <>2__current = ((AbilityBehaviour)__instance).LearnAbility(0f); <>1__state = 5; return true; case 5: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyPatch(typeof(GainAttackOnKill), "OnOtherCardDie")] [HarmonyPostfix] private static IEnumerator MakeHodagWorkInPixels(IEnumerator enumerator, GainAttackOnKill __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { enumerator = enumerator, __instance = __instance }; } } [HarmonyPatch] internal static class Act2ShapeshifterPatches { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Shapeshifter __instance; public IEnumerator result; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (SaveManager.SaveFile.IsPart2) { <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 1; return true; } <>2__current = result; <>1__state = 5; return true; case 1: <>1__state = -1; AudioController.Instance.PlaySound2D("trial_cave_outro#1", (MixerGroup)4, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false); <>2__current = ((SpecialCardBehaviour)__instance).PlayableCard.TransformIntoCard(CardLoader.GetCardByName("Ijiraq"), (Action)null, (Action)((Card)((SpecialCardBehaviour)__instance).PlayableCard).ClearAppearanceBehaviours); <>1__state = 2; return true; case 2: <>1__state = -1; if (!DialogueEventsData.EventIsPlayed("IjiraqRevealed")) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 3; return true; } break; case 3: <>1__state = -1; <>2__current = DialogueManager.PlayDialogueEventSafe("IjiraqRevealed", (MessageAdvanceMode)1, (EventIntersectMode)0, (DialogueSpeaker)null, (Style)4, (ScreenPosition)2, (string[])null, (Action)null, true); <>1__state = 4; return true; case 4: <>1__state = -1; break; case 5: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyPostfix] [HarmonyPatch(typeof(Shapeshifter), "RevealInBattle")] private static IEnumerator Act2RevealInBattle(IEnumerator result, Shapeshifter __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { result = result, __instance = __instance }; } [HarmonyPatch(typeof(Shapeshifter), "DisguiseOutOfBattle")] [HarmonyTranspiler] private static IEnumerable PixelOutsideFix(IEnumerable instructions) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown List list = new List(instructions); MethodBase methodBase = AccessTools.Method(typeof(Act2ShapeshifterPatches), "GetIjiraqDisguises", (Type[])null, (Type[])null); int count = list.FindIndex((CodeInstruction x) => x.opcode == OpCodes.Stloc_1); list.RemoveRange(0, count); list.Insert(0, new CodeInstruction(OpCodes.Callvirt, (object)methodBase)); return list; } public static List GetIjiraqDisguises() { if (SaveManager.SaveFile.IsPart2) { if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)$"GetIjiraqDisguises: Act2:{SaveData.Data.collection.CardInfos.Count}"); } return new List(SaveData.Data.collection.CardInfos); } if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)$"GetIjiraqDisguises: DeckCount:{((CardCollectionInfo)RunState.Run.playerDeck).Cards.Count}"); } return new List(((CardCollectionInfo)RunState.Run.playerDeck).Cards); } } [HarmonyPatch] internal class Act2ShieldGemsPatch { [HarmonyPatch(typeof(ShieldGeneratorItem), "AddShieldsToCards")] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldloc_1) { MethodInfo methodInfo = AccessTools.Method(typeof(Act2ShieldGemsPatch), "ShowSigilIcon", new Type[1] { typeof(PlayableCard) }, (Type[])null); i++; list.RemoveRange(i, 2); list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); break; } } return list; } private static bool ShowSigilIcon(PlayableCard card) { if (SaveManager.SaveFile.IsPart1 || SaveManager.SaveFile.IsPart2) { return true; } return card.HasAbility((Ability)54); } } [HarmonyPatch(typeof(Submerge), "OnUpkeep")] internal class Act2SubmergeFix { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if (SaveManager.SaveFile.IsPart2) { <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyPostfix] private static IEnumerator AddWaitInAct2(IEnumerator enumerator) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { enumerator = enumerator }; } } [HarmonyPatch] internal class ActivatedSacrificeDrawCardsPatch { [HarmonyPatch(typeof(ActivatedAbilityBehaviour), "CanActivate")] [HarmonyPostfix] private static void FixGemsDraw(ActivatedAbilityBehaviour __instance, ref bool __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 if (__result && (int)((AbilityBehaviour)__instance).Ability == 80 && !ResourcesManagerHelpers.OwnerHasGems(!((AbilityBehaviour)__instance).Card.OpponentCard, (GemType[])(object)new GemType[1] { (GemType)2 })) { __result = false; } } } [HarmonyPatch(typeof(PlayableCard), "GetOpposingSlots")] public class AllStrikeAbilityFix { private static IEnumerable Transpiler(IEnumerable instructions) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown int num = -1; List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode == OpCodes.Endfinally)) { continue; } for (int j = i + 1; j < list.Count; j++) { if (list[j].opcode == OpCodes.Ldc_I4_0) { num = j; } else if (list[j].opcode == OpCodes.Br) { MethodInfo methodInfo = AccessTools.Method(typeof(AllStrikeAbilityFix), "AllStrikeDirectAttackFix", new Type[3] { typeof(List), typeof(List), typeof(PlayableCard) }, (Type[])null); list.RemoveRange(num, j - num); list.Insert(num, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo)); break; } } break; } return list; } public static void AllStrikeDirectAttackFix(List list, List list2, PlayableCard __instance) { if (!list2.Exists((CardSlot x) => (Object)(object)x.Card != (Object)null && !__instance.CanAttackDirectly(x))) { list.Add(CardExtensions.LacksTrait(__instance, (Trait)16) ? __instance.Slot.opposingSlot : list2[0]); } } } [HarmonyPatch] public class DefaultEvolveFix { [HarmonyILManipulator] [HarmonyPatch(typeof(EvolveParams), "GetDefaultEvolution")] private static void FixDefaultEvolveParamsIL(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int modLoc = -1; val.GotoNext((MoveType)0, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchNewobj(x, (MethodBase)AccessTools.DeclaredConstructor(typeof(CardModificationInfo), new Type[2] { typeof(int), typeof(int) }, false)) }); val.GotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref modLoc) }); val.Emit(OpCodes.Ldloc, modLoc); val.EmitDelegate>((Action)delegate(CardModificationInfo mod) { mod.negateAbilities.Add((Ability)5); }); int num = default(int); val.GotoNext((MoveType)0, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 5), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.DeclaredMethod(typeof(CardInfo), "RemoveBaseAbility", (Type[])null, (Type[])null)) }); val.RemoveRange(3); } } [HarmonyPatch] internal class DrawCopyOnDeathFix { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void UseAlternatePortrait(DrawCopyOnDeath __instance, ref CardInfo __result) { object obj; if (__instance == null) { obj = null; } else { PlayableCard card = ((AbilityBehaviour)__instance).Card; obj = ((card != null) ? ((Card)card).Info : null); } if ((Object)obj != (Object)null) { object obj2 = ((Card)((AbilityBehaviour)__instance).Card).Info.Clone(); __result = (CardInfo)((obj2 is CardInfo) ? obj2 : null); } } } [HarmonyPatch] internal class DrawNewHand3DFix { [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardDrawPiles instance; public CardInfo info; public Action action; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!SaveManager.SaveFile.IsPart2) { CardDrawPiles obj = instance; ((CardDrawPiles3D)((obj is CardDrawPiles3D) ? obj : null)).Pile.Draw(); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } goto IL_0063; case 1: <>1__state = -1; goto IL_0063; case 2: { <>1__state = -1; return false; } IL_0063: <>2__current = instance.DrawCardFromDeck(info, action); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static MethodBase TargetMethod() { return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(DrawNewHand), "OnResolveOnBoard", (Type[])null, (Type[])null)); } private static IEnumerable Transpiler(IEnumerable instructions) { List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Callvirt && list[i].operand.ToString().Contains("DrawCardFromDeck")) { MethodInfo operand = AccessTools.Method(typeof(DrawNewHand3DFix), "DrawFromPiles", new Type[3] { typeof(CardDrawPiles), typeof(CardInfo), typeof(Action) }, (Type[])null); list[i].operand = operand; break; } } return list; } [IteratorStateMachine(typeof(d__2))] private static IEnumerator DrawFromPiles(CardDrawPiles instance, CardInfo info, Action action) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { instance = instance, info = info, action = action }; } } [HarmonyPatch] internal class DrawNewHand3DViewFix { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 2; return true; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; Singleton.Instance.SwitchToView((View)0, false, false); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = enumerator; <>1__state = 4; return true; case 4: <>1__state = -1; if (((CardDrawPiles)CardDrawPiles3D.Instance).Deck.CardsInDeck == 0) { CardDrawPiles3D.Instance.ClearPileDelegates(); } <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 5; return true; case 5: <>1__state = -1; Singleton.Instance.SwitchToView((View)1, false, false); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 6; return true; case 6: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyPatch(typeof(DrawNewHand), "OnResolveOnBoard")] [HarmonyPostfix] private static IEnumerator LookAtHand3D(IEnumerator enumerator) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { enumerator = enumerator }; } } [HarmonyPatch] internal static class EvolveDescriptionFixes { [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = this.enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if (SaveManager.SaveFile.IsPart2) { foreach (CardSlot item in ((BoardManager)Singleton.Instance).AllSlotsCopy.Where((CardSlot x) => Object.op_Implicit((Object)(object)x.Card) && x.Card.HasAbility((Ability)5))) { if (Singleton.Instance.nameText.Text == ((Card)item.Card).Info.DisplayedNameLocalized) { Singleton.Instance.DisplayCard(((Card)item.Card).RenderInfo, item.Card); break; } } } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static int EvolveTurns = -1; [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void ChangeLocalisedDescription(AbilityInfo __instance, ref string __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)__instance.ability == 5 && EvolveTurns != -1) { __result = LocalizedReplacement(__result, EvolveTurns.ToString()); } } [HarmonyPrefix] [HarmonyPatch(typeof(RuleBookController), "SetShown")] private static void ResetAlteredDescriptions(bool shown) { if (!shown) { EvolveTurns = -1; } } [HarmonyPrefix] [HarmonyPatch(typeof(RuleBookController), "OpenToAbilityPage")] private static void UpdateRulebookEvolve(PlayableCard card) { if (Object.op_Implicit((Object)(object)card) && card.HasAbility((Ability)5)) { int turnsToEvolve = GetTurnsToEvolve(card, ((Card)card).Info); if (turnsToEvolve != 1) { EvolveTurns = turnsToEvolve; } } } [IteratorStateMachine(typeof(d__4))] [HarmonyPatch(typeof(TurnManager), "DoUpkeepPhase")] [HarmonyPostfix] private static IEnumerator UpdatePreviewOnUpkeep(IEnumerator enumerator) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { enumerator = enumerator }; } [HarmonyPatch(typeof(CardPreviewPanel), "DisplayCard")] [HarmonyTranspiler] private static IEnumerable DisplayBetterEvolveDescription(IEnumerable instructions) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown List list = new List(instructions); for (int num = list.Count - 1; num >= 0; num--) { if (list[num].opcode == OpCodes.Callvirt && list[num].operand.ToString() == "Void DisplayDescription(DiskCardGame.CardInfo, System.Collections.Generic.List`1[DiskCardGame.Ability])") { MethodBase methodBase = AccessTools.Method(typeof(EvolveDescriptionFixes), "DisplayDescription", new Type[4] { typeof(CardPreviewPanel), typeof(CardInfo), typeof(List), typeof(PlayableCard) }, (Type[])null); list[num] = new CodeInstruction(OpCodes.Call, (object)methodBase); list.Insert(num, new CodeInstruction(OpCodes.Ldarg_2, (object)null)); break; } } return list; } private static void DisplayDescription(CardPreviewPanel instance, CardInfo cardInfo, List abilities, PlayableCard card) { if ((Object)(object)card != (Object)null) { abilities.RemoveAll((Ability x) => card.Status.hiddenAbilities.Contains(x)); } instance.DisplayDescription(cardInfo, abilities); string updatedDescription = GetUpdatedDescription(instance.descriptionText.hiddenText.Text, card, cardInfo, abilities); if (updatedDescription != instance.descriptionText.hiddenText.Text) { instance.descriptionText.SetText(updatedDescription); } } private static string LocalizedReplacement(string str, string turns) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected I4, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 Language currentLanguage = Localization.CurrentLanguage; string text = (int)currentLanguage switch { 0 => str.Replace("turn", "turns"), 1 => str.Replace("tour", "tours"), 2 => str.Replace("turno", "turni"), 3 => str.Replace("runde", "runden"), 4 => str.Replace("turno", "turnos"), 5 => str.Replace("turno", "turnos"), _ => str, }; currentLanguage = Localization.CurrentLanguage; if ((int)currentLanguage != 5) { if ((int)currentLanguage == 9) { return text.Replace("한", turns); } return text.Replace("1", turns); } return text.Replace("um", turns); } private static string GetUpdatedDescription(string result, PlayableCard card, CardInfo info, List abilities) { if (abilities.Contains((Ability)5)) { int turnsToEvolve = GetTurnsToEvolve(card, info); if (turnsToEvolve == 1) { return result; } string text = info.FormatDescriptionText(AbilitiesUtil.GetInfo((Ability)5).LocalizedRulebookDescription, info.DisplayedNameLocalized); string newValue = LocalizedReplacement(text, turnsToEvolve.ToString()); return result.Replace(text, newValue); } return result; } private static int GetTurnsToEvolve(PlayableCard card, CardInfo cardInfo) { int valueOrDefault = ((card == null) ? null : ((Component)card).GetComponentInChildren()?.numTurnsInPlay).GetValueOrDefault(); return Mathf.Max(1, ((cardInfo.evolveParams == null) ? 1 : cardInfo.evolveParams.turnsToEvolve) - valueOrDefault); } } [HarmonyPatch(typeof(GemsDraw), "OnOtherCardResolve")] internal class GemsDrawFix { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GemsDraw __instance; private int 5__2; private int 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence(); <>1__state = 1; return true; case 1: <>1__state = -1; Singleton.Instance.SwitchToView((View)((!SaveManager.SaveFile.IsMagnificus) ? 1 : 48), false, false); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; case 2: <>1__state = -1; 5__2 = Singleton.Instance.GetSlots(!((AbilityBehaviour)__instance).Card.OpponentCard).Count((CardSlot x) => (Object)(object)x.Card != (Object)null && CardExtensions.HasTrait(x.Card, (Trait)17)); if (5__2 == 0) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 3; return true; } 5__3 = 0; goto IL_01ca; case 3: <>1__state = -1; ((Card)((AbilityBehaviour)__instance).Card).Anim.StrongNegationEffect(); <>2__current = (object)new WaitForSeconds(0.45f); <>1__state = 4; return true; case 4: <>1__state = -1; return false; case 5: <>1__state = -1; goto IL_01ba; case 6: <>1__state = -1; goto IL_01ba; case 7: { <>1__state = -1; return false; } IL_01ba: 5__3++; goto IL_01ca; IL_01ca: if (5__3 < 5__2) { if ((Object)(object)Singleton.Instance != (Object)null && (Object)(object)Singleton.Instance.Pile != (Object)null) { Singleton.Instance.Pile.Draw(); <>2__current = ((CardDrawPiles)Singleton.Instance).DrawCardFromDeck((CardInfo)null, (Action)null); <>1__state = 5; return true; } <>2__current = Singleton.Instance.DrawCardFromDeck((CardInfo)null, (Action)null); <>1__state = 6; return true; } <>2__current = ((AbilityBehaviour)__instance).LearnAbility(0.5f); <>1__state = 7; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] private static bool FixGemsDraw(GemsDraw __instance, ref IEnumerator __result) { __result = BetterGemsDraw(__instance); return false; } [IteratorStateMachine(typeof(d__1))] public static IEnumerator BetterGemsDraw(GemsDraw __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { __instance = __instance }; } } [HarmonyPatch] public static class GreenGemStatIconFix { [HarmonyPatch(typeof(StatIconInfo), "LoadAbilityData")] [HarmonyPostfix] private static void StatIconInfo_LoadAbilityData() { StatIconInfo? obj = StatIconInfo.allIconInfo.Find((StatIconInfo a) => ((Object)a).name == "GreenGemsStatIcon"); Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("GreenGem.png", typeof(GreenGemStatIconFix).Assembly, (FilterMode)0); obj.iconGraphic = (Texture)(object)imageAsTexture; obj.rulebookDescription = "The power of this card is equal to the number of Green Gems that the owner has on their side of the table."; AbilityExtensions.AddMetaCategories(obj, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]); } } [HarmonyPatch(typeof(PackMule), "RespondsToResolveOnBoard")] internal class PackMuleBugFix { [HarmonyPostfix] private static void AlwaysResolveOnBoard(ref bool __result) { __result = true; } } [HarmonyPatch] public static class RandomAbilityPatches { [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public CardSlot slot; internal bool b__0(PlayableCard x) { return (Object)(object)x.QueuedSlot == (Object)(object)slot; } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public RandomAbility __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; if (!SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } CardModificationInfo item = new CardModificationInfo(__instance.ChooseAbility()) { negateAbilities = new List { ((AbilityBehaviour)__instance).Ability } }; object obj = ((Card)((AbilityBehaviour)__instance).Card).Info.Clone(); CardInfo val = (CardInfo)((obj is CardInfo) ? obj : null); val.Mods = new List(((Card)((AbilityBehaviour)__instance).Card).Info.Mods) { item }; ((Card)((AbilityBehaviour)__instance).Card).SetInfo(val); <>2__current = ((AbilityBehaviour)__instance).LearnAbility(0.5f); <>1__state = 2; return true; } case 1: <>1__state = -1; return false; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public PlayableCard __instance; public CardInfo evolvedInfo; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)__instance == (Object)null || (Object)(object)evolvedInfo == (Object)null) { return false; } if (evolvedInfo.HasAbility((Ability)31) && !__instance.Status.hiddenAbilities.Contains((Ability)31)) { <>2__current = AddRandomSigil(__instance); <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot slot; public IEnumerator enumerator; public Opponent __instance; private <>c__DisplayClass2_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass2_0(); <>8__1.slot = slot; <>2__current = enumerator; <>1__state = 1; return true; case 1: { <>1__state = -1; PlayableCard val = __instance.Queue.Find((PlayableCard x) => (Object)(object)x.QueuedSlot == (Object)(object)<>8__1.slot); if ((Object)(object)val == (Object)null) { return false; } if (val.HasAbility((Ability)31) && !val.Status.hiddenAbilities.Contains((Ability)31)) { <>2__current = AddRandomSigil(val); <>1__state = 2; return true; } break; } case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public PlayableCard card; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)card == (Object)null || card.Dead) { return false; } if (card.HasAbility((Ability)31) && !card.Status.hiddenAbilities.Contains((Ability)31)) { <>2__current = AddRandomSigil(card); <>1__state = 2; return true; } break; case 2: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 3; return true; case 3: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; private RandomAbility 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; 5__2 = ((Component)card).GetComponent(); if ((Object)(object)5__2 == (Object)null) { return false; } GlobalTriggerHandler instance = Singleton.Instance; int numTriggersThisBattle = instance.NumTriggersThisBattle; instance.NumTriggersThisBattle = numTriggersThisBattle + 1; if (SaveManager.SaveFile.IsPart2) { CardModificationInfo item = new CardModificationInfo(5__2.ChooseAbility()) { negateAbilities = new List { ((AbilityBehaviour)5__2).Ability } }; object obj = ((Card)card).Info.Clone(); CardInfo val = (CardInfo)((obj is CardInfo) ? obj : null); val.Mods = new List(((Card)card).Info.Mods) { item }; ((Card)card).SetInfo(val); return false; } <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 1; return true; } case 1: <>1__state = -1; ((Card)card).Anim.PlayTransformAnimation(); <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 2; return true; case 2: <>1__state = -1; 5__2.AddMod(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPostfix] [HarmonyPatch(typeof(RandomAbility), "ChooseAbility")] private static void OpponentChooseAbility(RandomAbility __instance, ref Ability __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected I4, but got Unknown __result = (Ability)(int)GetRandomAbility(((AbilityBehaviour)__instance).Card); } [IteratorStateMachine(typeof(d__1))] [HarmonyPostfix] [HarmonyPatch(typeof(RandomAbility), "OnDrawn")] private static IEnumerator Act2Random(IEnumerator enumerator, RandomAbility __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { enumerator = enumerator, __instance = __instance }; } [IteratorStateMachine(typeof(d__2))] [HarmonyPostfix] [HarmonyPatch(typeof(Opponent), "QueueCard")] private static IEnumerator ActivateRandomOnQueue(IEnumerator enumerator, Opponent __instance, CardSlot slot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { enumerator = enumerator, __instance = __instance, slot = slot }; } [IteratorStateMachine(typeof(d__3))] [HarmonyPatch(typeof(BoardManager), "ResolveCardOnBoard")] [HarmonyPostfix] private static IEnumerator ActivateRandomOnResolve(IEnumerator enumerator, PlayableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { enumerator = enumerator, card = card }; } [IteratorStateMachine(typeof(d__4))] [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "TransformIntoCard")] private static IEnumerator ActivateOnEvolve(IEnumerator enumerator, PlayableCard __instance, CardInfo evolvedInfo) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { enumerator = enumerator, __instance = __instance, evolvedInfo = evolvedInfo }; } [HarmonyPrefix] [HarmonyPatch(typeof(PlayableCard), "AddTemporaryMod")] private static void ActivateOnAddTempMod(PlayableCard __instance, CardModificationInfo mod) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (mod == null || !mod.HasAbility((Ability)31)) { return; } for (int i = 0; i < mod.abilities.Count; i++) { if ((int)mod.abilities[i] == 31) { GlobalTriggerHandler instance = Singleton.Instance; int numTriggersThisBattle = instance.NumTriggersThisBattle; instance.NumTriggersThisBattle = numTriggersThisBattle + 1; mod.abilities[i] = GetRandomAbility(__instance); } } } [IteratorStateMachine(typeof(d__6))] private static IEnumerator AddRandomSigil(PlayableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { card = card }; } public static Ability GetRandomAbility(PlayableCard card) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) AbilityMetaCategory val = (AbilityMetaCategory)1; if (SaveManager.SaveFile.IsPart2) { val = AbilityManager.Part2Modular; } else if (SaveManager.SaveFile.IsPart3) { val = (AbilityMetaCategory)3; } List learnedAbilities = AbilitiesUtil.GetLearnedAbilities(card.OpponentCard, 0, 5, val); if (SaveManager.SaveFile.IsPart2) { learnedAbilities.Remove((Ability)29); } learnedAbilities.RemoveAll((Ability x) => (int)x == 31 || card.HasAbility(x)); if (learnedAbilities.Count > 0) { return learnedAbilities[SeededRandom.Range(0, learnedAbilities.Count, SaveManager.SaveFile.GetCurrentRandomSeed() + Singleton.Instance.NumTriggersThisBattle)]; } return (Ability)15; } } [HarmonyPatch] internal class RandomConsumablePatch { [HarmonyPatch(typeof(RandomConsumable), "RespondsToResolveOnBoard")] [HarmonyPostfix] private static void DisableInAct2(ref bool __result) { if (SaveManager.SaveFile.IsPart2) { PatchPlugin.Logger.LogMessage((object)"Trinket Bearer is disabled in Act 2."); __result = false; } } } [HarmonyPatch] public class SentryInteractionFixes { [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public Sentry instance; public Func <>9__0; internal bool b__0() { return !((Card)((AbilityBehaviour)instance).Card).Anim.DoingAttackAnimation; } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Sentry instance; public PlayableCard otherCard; private <>c__DisplayClass2_0 <>8__1; private PlayableCard 5__2; private bool 5__3; private int 5__4; private PlayableCard 5__5; private CardSlot 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__5 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass2_0(); <>8__1.instance = instance; if ((Object)(object)((AbilityBehaviour)<>8__1.instance).Card == (Object)null) { return false; } 5__2 = otherCard; if (!((Object)(object)5__2 != (Object)(object)<>8__1.instance.lastShotCard) && Singleton.Instance.TurnNumber == <>8__1.instance.lastShotTurn) { return false; } 5__3 = false; <>8__1.instance.lastShotCard = 5__2; <>8__1.instance.lastShotTurn = Singleton.Instance.TurnNumber; Singleton.Instance.SwitchToView((View)4, false, true); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__4 = 0; goto IL_04cf; case 2: <>1__state = -1; if (((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.Anim.speed == 0f) { if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)$"{((AbilityBehaviour)<>8__1.instance).Card} is frozen, unpausing animation."); } 5__3 = true; ShowPart3Turret(((AbilityBehaviour)<>8__1.instance).Card, 5__2); ((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.Anim.speed = 1f; <>2__current = (object)new WaitUntil((Func)(() => !((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.DoingAttackAnimation)); <>1__state = 3; return true; } ((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.LightNegationEffect(); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 4; return true; case 3: <>1__state = -1; goto IL_047e; case 4: <>1__state = -1; ShowPart3Turret(((AbilityBehaviour)<>8__1.instance).Card, 5__2); ((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.PlayAttackAnimation(((AbilityBehaviour)<>8__1.instance).Card.IsFlyingAttackingReach(), 5__2.Slot, (Action)null); <>2__current = (object)new WaitForSeconds(0.07f); <>1__state = 5; return true; case 5: <>1__state = -1; ((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.SetAnimationPaused(true); 5__5 = ((AbilityBehaviour)<>8__1.instance).Card; <>2__current = Singleton.Instance.TriggerCardsOnBoard((Trigger)7, false, new object[1] { 5__2 }); <>1__state = 6; return true; case 6: <>1__state = -1; 5__2 = UpdateOpposingCard(((AbilityBehaviour)<>8__1.instance).Card, 5__2); if ((Object)(object)5__5 != (Object)null && (Object)(object)5__5.Slot != (Object)null) { 5__6 = 5__5.Slot; if ((Object)(object)5__2 != (Object)null) { if (5__6.Card.IsFlyingAttackingReach()) { ((Card)5__2).Anim.PlayJumpAnimation(); <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 7; return true; } goto IL_043a; } goto IL_0470; } goto IL_0477; case 7: <>1__state = -1; ((Card)5__6.Card).Anim.PlayAttackInAirAnimation(); goto IL_043a; case 8: <>1__state = -1; goto IL_0470; case 9: <>1__state = -1; goto IL_04bf; case 10: <>1__state = -1; Singleton.Instance.Controller.LockState = (ViewLockState)0; if (5__3 && !otherCard.Dead) { ((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.PlayAttackAnimation(((AbilityBehaviour)<>8__1.instance).Card.IsFlyingAttackingReach(), otherCard.Slot, (Action)null); <>2__current = (object)new WaitForSeconds(0.07f); <>1__state = 11; return true; } break; case 11: { <>1__state = -1; ((Card)((AbilityBehaviour)<>8__1.instance).Card).Anim.SetAnimationPaused(true); break; } IL_04bf: 5__4++; goto IL_04cf; IL_04cf: if (5__4 < <>8__1.instance.NumShots) { if ((Object)(object)5__2 != (Object)null && !5__2.Dead) { <>2__current = ((AbilityBehaviour)<>8__1.instance).PreSuccessfulTriggerSequence(); <>1__state = 2; return true; } goto IL_04bf; } <>2__current = ((AbilityBehaviour)<>8__1.instance).LearnAbility(0.5f); <>1__state = 10; return true; IL_043a: ((Card)5__6.Card).Anim.SetAnimationPaused(false); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 8; return true; IL_0470: 5__6 = null; goto IL_0477; IL_0477: 5__5 = null; goto IL_047e; IL_047e: if ((Object)(object)5__2 != (Object)null) { <>2__current = 5__2.TakeDamage(1, ((AbilityBehaviour)<>8__1.instance).Card); <>1__state = 9; return true; } goto IL_04bf; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPatch(typeof(CardGainAbility), "RespondsToOtherCardAssignedToSlot")] [HarmonyPrefix] private static bool CardGainAbilityNullCheckPatch(ref PlayableCard otherCard) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)otherCard != (Object)null && !otherCard.Dead && otherCard.Slot.IsPlayerSlot && ((TriggerReceiver)Singleton.Instance).RespondsToOtherCardDrawn(otherCard) && !otherCard.HasAbility(Singleton.Instance.Data.bottom.effectParams.ability)) { return !((Card)otherCard).Info.Mods.Exists((CardModificationInfo x) => x.fromEvolve); } return false; } [HarmonyPatch(typeof(Sentry), "FireAtOpposingSlot")] [HarmonyPrefix] private static bool FireAtOpposingSlotPatch(Sentry __instance, PlayableCard otherCard, ref IEnumerator __result) { __result = NewFireAtOpposingSlot(__instance, otherCard); return false; } [IteratorStateMachine(typeof(d__2))] public static IEnumerator NewFireAtOpposingSlot(Sentry instance, PlayableCard otherCard) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { instance = instance, otherCard = otherCard }; } private static void ShowPart3Turret(PlayableCard card, PlayableCard otherCard) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (((Card)card).Anim is DiskCardAnimationController) { CardAnimationController anim = ((Card)card).Anim; ((DiskCardAnimationController)((anim is DiskCardAnimationController) ? anim : null)).SetWeaponMesh((DiskCardWeapon)2); CardAnimationController anim2 = ((Card)card).Anim; ((DiskCardAnimationController)((anim2 is DiskCardAnimationController) ? anim2 : null)).AimWeaponAnim(((Component)otherCard.Slot).transform.position); CardAnimationController anim3 = ((Card)card).Anim; ((DiskCardAnimationController)((anim3 is DiskCardAnimationController) ? anim3 : null)).ShowWeaponAnim(); } } private static PlayableCard UpdateOpposingCard(PlayableCard source, PlayableCard target) { CardSlot opposingSlot = source.Slot.opposingSlot; if ((Object)(object)opposingSlot.Card != (Object)null) { if ((Object)(object)opposingSlot.Card != (Object)(object)target) { return opposingSlot.Card; } return target; } return null; } } [HarmonyPatch] internal class SentryPackMuleFixes { [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public PackMule __instance; public Predicate <>9__1; internal bool b__0() { return !Tween.activeTweens.Exists((TweenBase t) => t.targetInstanceID == ((Object)((Component)((SpecialCardBehaviour)__instance).PlayableCard).transform).GetInstanceID()); } internal bool b__1(TweenBase t) { return t.targetInstanceID == ((Object)((Component)((SpecialCardBehaviour)__instance).PlayableCard).transform).GetInstanceID(); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PackMule __instance; private <>c__DisplayClass1_0 <>8__1; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass1_0(); <>8__1.__instance = __instance; if ((Object)(object)<>8__1.__instance.pack == (Object)null) { if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)(((Object)((SpecialCardBehaviour)<>8__1.__instance).PlayableCard).name + " died before fully resolving on board, instantiating pack.")); } <>2__current = (object)new WaitForSeconds(0.4f); <>1__state = 1; return true; } goto IL_01e3; case 1: { <>1__state = -1; GameObject val = Object.Instantiate(ResourceBank.Get("Prefabs/Cards/SpecificCardModels/CardPack")); <>8__1.__instance.pack = val.transform; Vector3 position = ((Component)((SpecialCardBehaviour)<>8__1.__instance).PlayableCard.Slot).transform.position; Vector3 position2 = position + Vector3.forward * 8f; <>8__1.__instance.pack.position = position2; Tween.Position(<>8__1.__instance.pack, position, 0.25f, 0f, Tween.EaseOut, (LoopType)0, (Action)null, (Action)null, true); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } case 2: <>1__state = -1; <>2__current = (object)new WaitUntil((Func)(() => !Tween.activeTweens.Exists((TweenBase t) => t.targetInstanceID == ((Object)((Component)((SpecialCardBehaviour)<>8__1.__instance).PlayableCard).transform).GetInstanceID()))); <>1__state = 3; return true; case 3: <>1__state = -1; <>8__1.__instance.pack.SetParent(((Component)((SpecialCardBehaviour)<>8__1.__instance).PlayableCard).transform); if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)"Pack has been instantiated. Reality has been saved."); } goto IL_01e3; case 4: { <>1__state = -1; return false; } IL_01e3: <>2__current = enumerator; <>1__state = 4; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPatch(typeof(PackMule), "SpawnAndOpenPack")] [HarmonyPrefix] private static bool FixPackMuleBreakingRealityOnDeath(Transform pack) { if ((Object)(object)pack == (Object)null) { return false; } return true; } [IteratorStateMachine(typeof(d__1))] [HarmonyPatch(typeof(PackMule), "OnDie")] [HarmonyPostfix] private static IEnumerator FixPackNotExisting(IEnumerator enumerator, PackMule __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { enumerator = enumerator, __instance = __instance }; } [HarmonyPatch(typeof(PackMule), "OnResolveOnBoard")] [HarmonyPrefix] private static bool FixPackMuleVisualGlitch(PackMule __instance) { if (((SpecialCardBehaviour)__instance).PlayableCard.Dead) { return false; } return true; } } [HarmonyPatch] public class SentryTailOnHitFix { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TailOnHit instance; private CardSlot 5__2; private CardSlot 5__3; private CardSlot 5__4; private bool 5__5; private PlayableCard 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; 5__4 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Expected O, but got Unknown //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; 5__2 = ((AbilityBehaviour)instance).Card.Slot; 5__3 = Singleton.Instance.GetAdjacent(((AbilityBehaviour)instance).Card.Slot, true); 5__4 = Singleton.Instance.GetAdjacent(((AbilityBehaviour)instance).Card.Slot, false); bool num = (Object)(object)5__3 != (Object)null && (Object)(object)5__3.Card == (Object)null; 5__5 = (Object)(object)5__4 != (Object)null && (Object)(object)5__4.Card == (Object)null; if (num | 5__5) { <>2__current = ((AbilityBehaviour)instance).PreSuccessfulTriggerSequence(); <>1__state = 1; return true; } break; } case 1: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 2; return true; case 2: <>1__state = -1; instance.SetTailLost(true); if (5__5) { <>2__current = Singleton.Instance.AssignCardToSlot(((AbilityBehaviour)instance).Card, 5__4, 0.1f, (Action)null, true); <>1__state = 3; return true; } <>2__current = Singleton.Instance.AssignCardToSlot(((AbilityBehaviour)instance).Card, 5__3, 0.1f, (Action)null, true); <>1__state = 4; return true; case 3: <>1__state = -1; goto IL_01b3; case 4: <>1__state = -1; goto IL_01b3; case 5: { <>1__state = -1; CardInfo val = (CardInfo)((((Card)((AbilityBehaviour)instance).Card).Info.tailParams == null) ? ((object)TailParams.GetDefaultTail(((Card)((AbilityBehaviour)instance).Card).Info)) : ((object)/*isinst with value type is only supported in some contexts*/)); 5__6 = CardSpawner.SpawnPlayableCardWithCopiedMods(val, ((AbilityBehaviour)instance).Card, (Ability)10); ((Component)5__6).transform.position = ((Component)5__2).transform.position + Vector3.back * 2f + Vector3.up * 2f; ((Component)5__6).transform.rotation = Quaternion.Euler(110f, 90f, 90f); <>2__current = Singleton.Instance.ResolveCardOnBoard(5__6, 5__2, 0.1f, (Action)null, true); <>1__state = 6; return true; } case 6: <>1__state = -1; Singleton.Instance.SwitchToView((View)4, false, false); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 7; return true; case 7: <>1__state = -1; if (!5__6.Dead) { ((Card)5__6).Anim.StrongNegationEffect(); } <>2__current = ((MonoBehaviour)instance).StartCoroutine(((AbilityBehaviour)instance).LearnAbility(0.5f)); <>1__state = 8; return true; case 8: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 9; return true; case 9: { <>1__state = -1; 5__6 = null; break; } IL_01b3: if (!((AbilityBehaviour)instance).Card.Dead) { ((Card)((AbilityBehaviour)instance).Card).Anim.StrongNegationEffect(); ((AbilityBehaviour)instance).Card.Status.hiddenAbilities.Add(((AbilityBehaviour)instance).Ability); ((Card)((AbilityBehaviour)instance).Card).RenderCard(); } <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 5; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPatch(typeof(TailOnHit), "OnCardGettingAttacked")] [HarmonyPrefix] private static bool TailOnHitGettingAttackedPatch(TailOnHit __instance, ref IEnumerator __result) { __result = NewOnCardGettingAttacked(__instance); return false; } [IteratorStateMachine(typeof(d__1))] public static IEnumerator NewOnCardGettingAttacked(TailOnHit instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { instance = instance }; } } [HarmonyPatch] public class SniperFix { [CompilerGenerated] private sealed class <>c__DisplayClass4_0 { public List opposingSlots; public CardSlot attackingSlot; public CombatPhaseManager instance; public Part1SniperVisualizer visualizer; public Action <>9__0; public Action <>9__1; internal void b__0(CardSlot s) { PlayerTargetSelectedCallback(opposingSlots, s, attackingSlot); instance.VisualizeConfirmSniperAbility(s); visualizer?.VisualizeConfirmSniperAbility(s); } internal void b__1(CardSlot s) { PlayerSlotCursorEnterCallback(opposingSlots, s, attackingSlot); instance.VisualizeAimSniperAbility(attackingSlot, s); visualizer?.VisualizeAimSniperAbility(attackingSlot, s); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CombatPhaseManager instance; public CardSlot attackingSlot; public CardSlot opposingSlot; public List opposingSlots; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; Singleton.Instance.SwitchToView(Singleton.Instance.CombatView, false, false); <>2__current = instance.SlotAttackSlot(attackingSlot, opposingSlot, (opposingSlots.Count > 1) ? 0.1f : 0f); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot attackingSlot; public CombatPhaseManager instance; public Part1SniperVisualizer visualizer; public List opposingSlots; public int numAttacks; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!attackingSlot.IsPlayerSlot) { <>2__current = OpponentSniperLogic(instance, visualizer, opposingSlots, attackingSlot, numAttacks); <>1__state = 1; return true; } <>2__current = PlayerSniperLogic(instance, visualizer, opposingSlots, attackingSlot, numAttacks); <>1__state = 2; return true; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot attackingSlot; public List opposingSlots; public int numAttacks; public CombatPhaseManager instance; public Part1SniperVisualizer visualizer; private List 5__2; private List 5__3; private int 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_0103; } <>1__state = -1; 5__2 = GetValidTargets(playerIsAttacker: false, attackingSlot); 5__3 = 5__2.FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null).ConvertAll((CardSlot x) => x.Card); 5__4 = 0; goto IL_0113; IL_0103: 5__4++; goto IL_0113; IL_0113: if (5__4 < numAttacks) { CardSlot val = OpponentSelectTargetSlot(opposingSlots, 5__2, 5__3, attackingSlot, numAttacks); if (!((Object)(object)val == (Object)null)) { opposingSlots.Add(val); instance.VisualizeConfirmSniperAbility(val); visualizer?.VisualizeConfirmSniperAbility(val); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 1; return true; } goto IL_0103; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public List opposingSlots; public CardSlot attackingSlot; public CombatPhaseManager instance; public Part1SniperVisualizer visualizer; private <>c__DisplayClass4_0 <>8__1; public int numAttacks; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass4_0(); <>8__1.opposingSlots = opposingSlots; <>8__1.attackingSlot = attackingSlot; <>8__1.instance = instance; <>8__1.visualizer = visualizer; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < numAttacks) { <>8__1.instance.VisualizeStartSniperAbility(<>8__1.attackingSlot); <>8__1.visualizer?.VisualizeStartSniperAbility(<>8__1.attackingSlot); MainInputInteractable currentInteractable = Singleton.Instance.CurrentInteractable; CardSlot val = (CardSlot)(object)((currentInteractable is CardSlot) ? currentInteractable : null); if ((Object)(object)val != (Object)null && <>8__1.opposingSlots.Contains(val)) { <>8__1.instance.VisualizeAimSniperAbility(<>8__1.attackingSlot, val); <>8__1.visualizer?.VisualizeAimSniperAbility(<>8__1.attackingSlot, val); } List validTargets = GetValidTargets(<>8__1.attackingSlot.IsPlayerSlot, <>8__1.attackingSlot); <>2__current = Singleton.Instance.ChooseTarget(validTargets, validTargets, (Action)delegate(CardSlot s) { PlayerTargetSelectedCallback(<>8__1.opposingSlots, s, <>8__1.attackingSlot); <>8__1.instance.VisualizeConfirmSniperAbility(s); <>8__1.visualizer?.VisualizeConfirmSniperAbility(s); }, (Action)null, (Action)delegate(CardSlot s) { PlayerSlotCursorEnterCallback(<>8__1.opposingSlots, s, <>8__1.attackingSlot); <>8__1.instance.VisualizeAimSniperAbility(<>8__1.attackingSlot, s); <>8__1.visualizer?.VisualizeAimSniperAbility(<>8__1.attackingSlot, s); }, (Func)(() => false), (CursorType)16); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot slot; public CombatPhaseManager instance; private List 5__2; private Part1SniperVisualizer 5__3; private List.Enumerator <>7__wrap3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; 5__2 = new List(); Singleton.Instance.SwitchToView(Singleton.Instance.CombatView, false, false); Singleton.Instance.Controller.LockState = (ViewLockState)1; int attackCount = GetAttackCount(slot.Card); Singleton.Instance.Controller.SwitchToControlMode(Singleton.Instance.ChoosingSlotViewMode, false); Singleton.Instance.Controller.LockState = (ViewLockState)0; 5__3 = null; SaveFile saveFile = SaveManager.SaveFile; if (((saveFile != null) ? new bool?(saveFile.IsPart1) : null).GetValueOrDefault()) { 5__3 = ((Component)instance).GetComponent() ?? ((Component)instance).gameObject.AddComponent(); } <>2__current = DoSniperLogic(instance, 5__3, 5__2, slot, attackCount); <>1__state = 1; return true; } case 1: <>1__state = -1; Singleton.Instance.Controller.SwitchToControlMode(Singleton.Instance.DefaultViewMode, false); Singleton.Instance.Controller.LockState = (ViewLockState)1; <>7__wrap3 = 5__2.GetEnumerator(); <>1__state = -3; break; case 2: <>1__state = -3; break; } if (<>7__wrap3.MoveNext()) { CardSlot current = <>7__wrap3.Current; <>2__current = DoAttackTargetSlotsLogic(instance, 5__3, 5__2, slot, current); <>1__state = 2; return true; } <>m__Finally1(); instance.VisualizeClearSniperAbility(); 5__3?.VisualizeClearSniperAbility(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap3).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSequence")] [HarmonyPrefix] private static bool MaybeOverrideAttack(CombatPhaseManager __instance, ref IEnumerator __result, CardSlot slot) { if ((Object)(object)((slot != null) ? slot.Card : null) != (Object)null && slot.Card.HasAbility((Ability)53)) { __result = SniperAttack(__instance, slot); return false; } return true; } [IteratorStateMachine(typeof(d__1))] public static IEnumerator SniperAttack(CombatPhaseManager instance, CardSlot slot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { instance = instance, slot = slot }; } [IteratorStateMachine(typeof(d__2))] public static IEnumerator DoSniperLogic(CombatPhaseManager instance, Part1SniperVisualizer visualizer, List opposingSlots, CardSlot attackingSlot, int numAttacks) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { instance = instance, visualizer = visualizer, opposingSlots = opposingSlots, attackingSlot = attackingSlot, numAttacks = numAttacks }; } [IteratorStateMachine(typeof(d__3))] public static IEnumerator DoAttackTargetSlotsLogic(CombatPhaseManager instance, Part1SniperVisualizer visualizer, List opposingSlots, CardSlot attackingSlot, CardSlot opposingSlot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { instance = instance, opposingSlots = opposingSlots, attackingSlot = attackingSlot, opposingSlot = opposingSlot }; } [IteratorStateMachine(typeof(d__4))] public static IEnumerator PlayerSniperLogic(CombatPhaseManager instance, Part1SniperVisualizer visualizer, List opposingSlots, CardSlot attackingSlot, int numAttacks) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { instance = instance, visualizer = visualizer, opposingSlots = opposingSlots, attackingSlot = attackingSlot, numAttacks = numAttacks }; } public static List GetValidTargets(bool playerIsAttacker, CardSlot attackingSlot) { return BoardManagerExtensions.GetSlotsCopy(Singleton.Instance, !playerIsAttacker); } public static void PlayerTargetSelectedCallback(List opposingSlots, CardSlot targetSlot, CardSlot attackingSlot) { opposingSlots.Add(targetSlot); } public static void PlayerSlotCursorEnterCallback(List opposingSlots, CardSlot targetSlot, CardSlot attackingSlot) { } [IteratorStateMachine(typeof(d__8))] public static IEnumerator OpponentSniperLogic(CombatPhaseManager instance, Part1SniperVisualizer visualizer, List opposingSlots, CardSlot attackingSlot, int numAttacks) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { instance = instance, visualizer = visualizer, opposingSlots = opposingSlots, attackingSlot = attackingSlot, numAttacks = numAttacks }; } public static CardSlot OpponentSelectTargetSlot(List opposingSlots, List playerSlots, List playerCards, CardSlot attackingSlot, int numAttacks) { bool flag = playerCards.Count > 0; if (flag) { if (CanWin(opposingSlots, playerSlots, attackingSlot, numAttacks)) { return GetFirstAvailableOpenSlot(opposingSlots, playerSlots, attackingSlot, numAttacks); } PlayableCard strongestKillableCard = GetStrongestKillableCard(flag, playerCards, opposingSlots, attackingSlot, numAttacks); PlayableCard firstStrongestAttackableCard = GetFirstStrongestAttackableCard(flag, playerCards, opposingSlots, attackingSlot, numAttacks); PlayableCard firstStrongestAttackableCardNoPreferences = GetFirstStrongestAttackableCardNoPreferences(flag, playerCards, opposingSlots, attackingSlot, numAttacks); if ((Object)(object)strongestKillableCard != (Object)null) { return strongestKillableCard.Slot; } if ((Object)(object)firstStrongestAttackableCard != (Object)null) { return firstStrongestAttackableCard.Slot; } if ((Object)(object)firstStrongestAttackableCardNoPreferences != (Object)null) { return firstStrongestAttackableCardNoPreferences.Slot; } } return playerSlots[SeededRandom.Range(0, playerSlots.Count, SaveManager.SaveFile.GetCurrentRandomSeed() + Singleton.Instance.NumTriggersThisBattle)]; } public static List GetSorted(List unsorted, Comparison sort) { List list = new List(unsorted); list.Sort(sort); return list; } public static CardSlot GetFirstAvailableOpenSlot(List opposingSlots, List playerSlots, CardSlot slot, int numAttacks) { return playerSlots.Find((CardSlot x) => slot.Card.CanAttackDirectly(x) && !playerSlots.Exists((CardSlot y) => (Object)(object)y.Card != (Object)null && y.Card.HasAbility((Ability)8) && !CardIsDeadOrHasRepulsive(y.Card, opposingSlots, slot, numAttacks) && !slot.Card.CanAttackDirectly(y))); } public static bool CanWin(List opposingSlots, List playerSlots, CardSlot slot, int numAttacks) { if ((Object)(object)Singleton.Instance != (Object)null && Singleton.Instance.Balance - numAttacks * slot.Card.Attack <= -5) { return (Object)(object)GetFirstAvailableOpenSlot(opposingSlots, playerSlots, slot, numAttacks) != (Object)null; } return false; } public static bool CanKillCard(PlayableCard pc, int numAttacks, CardSlot slot, int? overrideAttacks = null) { int valueOrDefault = overrideAttacks.GetValueOrDefault(numAttacks); int num = (pc.HasShield() ? (valueOrDefault - 1) : valueOrDefault); if (!slot.Card.HasAbility((Ability)4) || pc.HasAbility((Ability)105)) { if (num * slot.Card.Attack >= pc.Health) { return !slot.Card.CanAttackDirectly(pc.Slot); } return false; } return num > 0; } public static int NumCardTargets(PlayableCard pc, List opposingSlots) { return opposingSlots.FindAll((CardSlot x) => (Object)(object)x != (Object)null && (Object)(object)x.Card != (Object)null && (Object)(object)x.Card == (Object)(object)pc).Count; } public static bool CardIsDeadOrHasRepulsive(PlayableCard pc, List opposingSlots, CardSlot slot, int numAttacks) { if (!((Object)(object)pc == (Object)null) && !pc.Dead && !pc.HasAbility((Ability)21)) { return CanKillCard(pc, numAttacks, slot, NumCardTargets(pc, opposingSlots)); } return true; } public static bool WillDieFromSharp(PlayableCard pc, CardSlot slot) { int num = ((Card)pc).Info.Abilities.FindAll((Ability x) => (int)x == 15).Count; if (pc.HasAbility((Ability)15) && num < 1) { num = 1; } if (slot.Card.HasShield()) { num--; } num = Mathf.Max(0, num); if (!pc.HasAbility((Ability)4)) { return num >= slot.Card.Health; } return num > 0; } public static PlayableCard GetFirstStrongestAttackableCard(bool anyCards, List playerCards, List opposingSlots, CardSlot slot, int numAttacks) { if (!anyCards) { return null; } return GetSorted(playerCards.FindAll((PlayableCard x) => !slot.Card.CanAttackDirectly(x.Slot) && !WillDieFromSharp(x, slot) && !CardIsDeadOrHasRepulsive(x, opposingSlots, slot, numAttacks)), (PlayableCard x, PlayableCard x2) => x.PowerLevel - x2.PowerLevel).FirstOrDefault(); } public static PlayableCard GetStrongestKillableCard(bool anyCards, List playerCards, List opposingSlots, CardSlot slot, int numAttacks) { if (!anyCards) { return null; } if (!anyCards) { return null; } return GetSorted(playerCards.FindAll((PlayableCard x) => CanKillCard(x, numAttacks, slot) && !WillDieFromSharp(x, slot) && !CardIsDeadOrHasRepulsive(x, opposingSlots, slot, numAttacks)), (PlayableCard x, PlayableCard x2) => x.PowerLevel - x2.PowerLevel).FirstOrDefault(); } public static PlayableCard GetFirstStrongestAttackableCardNoPreferences(bool anyCards, List playerCards, List opposingSlots, CardSlot slot, int numAttacks) { if (!anyCards) { return null; } return GetSorted(playerCards.FindAll((PlayableCard x) => !slot.Card.CanAttackDirectly(x.Slot) && !CardIsDeadOrHasRepulsive(x, opposingSlots, slot, numAttacks)), (PlayableCard x, PlayableCard x2) => x.PowerLevel - x2.PowerLevel).FirstOrDefault(); } public static int GetAttackCount(PlayableCard card) { CardSlot slot = card.Slot; List obj = (card.OpponentCard ? Singleton.Instance.OpponentSlotsCopy : Singleton.Instance.PlayerSlotsCopy); int num = 1; foreach (CardSlot item in obj) { card.Slot = item; int count = card.GetOpposingSlots().Count; if (count > num) { num = count; } } card.Slot = slot; return num; } } [HarmonyPatch] internal class SteelTrapFix { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SteelTrap __instance; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (CardExtensions.IsBaseGameCard(((Card)((AbilityBehaviour)__instance).Card).Info) && ((Object)((AbilityBehaviour)__instance).Card).name.Contains("Trap")) { <>2__current = enumerator; <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds(0.65f); <>1__state = 2; return true; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; AudioController.Instance.PlaySound3D("sacrifice_default", (MixerGroup)4, ((Component)((AbilityBehaviour)__instance).Card).transform.position, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 3; return true; case 3: <>1__state = -1; ((Card)((AbilityBehaviour)__instance).Card).Anim.LightNegationEffect(); if (CardExtensions.HasSteelTrapPortrait(((Card)((AbilityBehaviour)__instance).Card).Info)) { ((AbilityBehaviour)__instance).Card.SwitchToPortrait(CardManager.SteelTrapPortrait(((Card)((AbilityBehaviour)__instance).Card).Info)); } AudioController.Instance.PlaySound3D("dial_metal", (MixerGroup)4, ((Component)((AbilityBehaviour)__instance).Card).transform.position, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false); <>2__current = (object)new WaitForSeconds(0.75f); <>1__state = 4; return true; case 4: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyPatch(typeof(SteelTrap), "OnTakeDamage")] [HarmonyPostfix] private static IEnumerator UseAlternatePortrait(IEnumerator enumerator, SteelTrap __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { enumerator = enumerator, __instance = __instance }; } } [HarmonyPatch] internal class VesselOnHitPatch { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public DrawVesselOnHit __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!SaveManager.SaveFile.IsPart2) { <>2__current = enumerator; <>1__state = 1; return true; } <>2__current = ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence(); <>1__state = 2; return true; case 1: <>1__state = -1; return false; case 2: <>1__state = -1; ((Card)((AbilityBehaviour)__instance).Card).Anim.StrongNegationEffect(); <>2__current = (object)new WaitForSeconds(0.4f); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = Singleton.Instance.SpawnCardToHand(CardLoader.GetCardByName("EmptyVessel"), 0.25f); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = ((AbilityBehaviour)__instance).LearnAbility(0.5f); <>1__state = 5; return true; case 5: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPatch(typeof(DrawVesselOnHit), "RespondsToTakeDamage")] [HarmonyPrefix] private static bool NewTrigger(ref bool __result) { if (SaveManager.SaveFile.IsPart2) { __result = true; return false; } return true; } [IteratorStateMachine(typeof(d__1))] [HarmonyPatch(typeof(DrawVesselOnHit), "OnTakeDamage")] [HarmonyPostfix] private static IEnumerator WorkInAct2(IEnumerator enumerator, DrawVesselOnHit __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { enumerator = enumerator, __instance = __instance }; } } }