Decompiled source of API v2.22.3
monomod/Assembly-CSharp.APIPatcher.mm.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx.Logging; using InscryptionAPI; using Microsoft.CodeAnalysis; using MonoMod; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("APIPatcher")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e3d314467cda100be17517be6cfb93a1af6e677e")] [assembly: AssemblyProduct("APIPatcher")] [assembly: AssemblyTitle("APIPatcher")] [assembly: AssemblyVersion("1.0.0.0")] [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 APIPatcher { [MonoModPatch("global::ScriptableObjectLoader`1")] internal class patch_ScriptableObjectLoader<T> : ScriptableObjectLoader<T> where T : Object { public static List<T> AllData { get { InscryptionAPIPlugin.InvokeSOLEvent(typeof(T)); ScriptableObjectLoader<T>.LoadData(""); return ScriptableObjectLoader<T>.allData; } } } [MonoModPatch("global::Singleton`1")] internal class patch_Singleton<T> : Singleton<T> where T : ManagedBehaviour { protected static void FindInstance() { if ((Object)(object)Singleton<T>.m_Instance == (Object)null) { T val = Object.FindObjectOfType<T>(); if ((Object)(object)val == (Object)null) { Singleton.SingletonLogSource.LogWarning((object)("Got null in Singleton<" + typeof(T).FullName + ">.FindInstance")); } Singleton<T>.m_Instance = val; } } } internal static class Singleton { internal static readonly ManualLogSource SingletonLogSource = Logger.CreateLogSource("Singleton"); } }
plugins/InscryptionAPI.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DiskCardGame; using GBC; using HarmonyLib; using InscryptionAPI; using InscryptionAPI.Boons; using InscryptionAPI.Card; using InscryptionAPI.Card.CostProperties; using InscryptionAPI.CardCosts; using InscryptionAPI.Dialogue; using InscryptionAPI.Encounters; using InscryptionAPI.Guid; using InscryptionAPI.Helpers; using InscryptionAPI.Helpers.Extensions; using InscryptionAPI.Items; using InscryptionAPI.Items.Extensions; using InscryptionAPI.Masks; using InscryptionAPI.Nodes; using InscryptionAPI.Pelts; using InscryptionAPI.PixelCard; using InscryptionAPI.Regions; using InscryptionAPI.RuleBook; using InscryptionAPI.Saves; using InscryptionAPI.Slots; using InscryptionAPI.Sound; using InscryptionAPI.TalkingCards.Animation; using InscryptionAPI.TalkingCards.Create; using InscryptionAPI.TalkingCards.Helpers; using InscryptionAPI.Totems; using InscryptionAPI.Triggers; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.Utils; using Pixelplacement; using Sirenix.Serialization.Utilities; using Sirenix.Utilities; using TMPro; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using VolumetricFogAndMist; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("Assembly-CSharp")] [assembly: InternalsVisibleTo("Assembly-CSharp.APIPatcher.mm")] [assembly: InternalsVisibleTo("APIPatcher")] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("InscryptionAPI")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.22.3.0")] [assembly: AssemblyInformationalVersion("2.22.3+e3d314467cda100be17517be6cfb93a1af6e677e")] [assembly: AssemblyProduct("InscryptionAPI")] [assembly: AssemblyTitle("InscryptionAPI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.22.3.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] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 APIPlugin { [Obsolete("Use AbilityManager instead", true)] public class AbilityIdentifier { internal string guid; private string name; public Ability id; internal Ability realID; private AbilityIdentifier(string guid, string name) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) this.guid = guid; this.name = name; realID = (id = GuidManager.GetEnumValue<Ability>(guid, name)); } public static AbilityIdentifier GetAbilityIdentifier(string guid, string name) { return GetID(guid, name); } public static AbilityIdentifier GetID(string guid, string name) { return new AbilityIdentifier(guid, name); } public override string ToString() { return guid + "(" + name + ")"; } } [Obsolete("Use AbilityManager and extension methods instead", true)] public class AbilityInfoUtils { public static AbilityInfo CreateInfoWithDefaultSettings(string rulebookName, string rulebookDescription) { AbilityInfo obj = ScriptableObject.CreateInstance<AbilityInfo>(); obj.powerLevel = 0; obj.rulebookName = rulebookName; obj.rulebookDescription = rulebookDescription; obj.metaCategories = new List<AbilityMetaCategory> { (AbilityMetaCategory)1, (AbilityMetaCategory)0 }; return obj; } } [Obsolete("Use CardManager and extension methods instead", true)] public static class CardUtils { public static readonly Vector2 DefaultVector2 = new Vector2(0.5f, 0.5f); public static readonly Rect DefaultCardArtRect = new Rect(0f, 0f, 114f, 94f); public static readonly Rect DefaultCardPixelArtRect = new Rect(0f, 0f, 41f, 28f); public static Predicate<CardInfo> IsNonLivingCard = (CardInfo card) => card.traits.Exists((Trait t) => t - 12 <= 1); public static List<CardMetaCategory> getNormalCardMetadata = new List<CardMetaCategory> { (CardMetaCategory)0, (CardMetaCategory)1 }; public static List<CardMetaCategory> getRareCardMetadata = new List<CardMetaCategory> { (CardMetaCategory)0, (CardMetaCategory)1, (CardMetaCategory)3 }; public static List<CardMetaCategory> getGBCCardMetadata = new List<CardMetaCategory> { (CardMetaCategory)4, (CardMetaCategory)5 }; public static List<CardMetaCategory> getGBCRareCardMetadata = new List<CardMetaCategory> { (CardMetaCategory)4, (CardMetaCategory)5, (CardMetaCategory)3 }; public static List<CardMetaCategory> getAllActsCardMetadata = new List<CardMetaCategory> { (CardMetaCategory)0, (CardMetaCategory)3, (CardMetaCategory)1, (CardMetaCategory)3, (CardMetaCategory)4, (CardMetaCategory)5, (CardMetaCategory)2 }; public static List<Appearance> getRareAppearance = new List<Appearance> { (Appearance)7 }; public static List<Appearance> getTerrainBackgroundAppearance = new List<Appearance> { (Appearance)2 }; public static List<Appearance> getTerrainLayoutAppearance = new List<Appearance> { (Appearance)9 }; public static List<Appearance> getTerrainAppearance = new List<Appearance> { (Appearance)2, (Appearance)9 }; public static List<Appearance> getHologramAppearance = new List<Appearance> { (Appearance)12 }; public static List<Appearance> getAnimatedAppearance = new List<Appearance> { (Appearance)5 }; public static List<Appearance> getGoldAppearance = new List<Appearance> { (Appearance)6 }; public static List<Appearance> getBloodDecalAppearance = new List<Appearance> { (Appearance)8 }; public static List<Appearance> getDynamicAppearance = new List<Appearance> { (Appearance)10 }; public static byte[] ReadArtworkFileAsBytes(string nameOfCardArt) { return File.ReadAllBytes(Directory.GetFiles(Paths.PluginPath, nameOfCardArt, SearchOption.AllDirectories)[0]); } public static Texture2D getAndloadImageAsTexture(string pathCardArt) { return TextureHelper.GetImageAsTexture(pathCardArt, (FilterMode)0); } } [Obsolete("Use CardManager instead", true)] public class CustomCard { public static List<CustomCard> cards = new List<CustomCard>(); public static Dictionary<int, List<AbilityIdentifier>> abilityIds = new Dictionary<int, List<AbilityIdentifier>>(); public static Dictionary<int, List<SpecialAbilityIdentifier>> specialAbilityIds = new Dictionary<int, List<SpecialAbilityIdentifier>>(); public static Dictionary<int, EvolveIdentifier> evolveIds = new Dictionary<int, EvolveIdentifier>(); public static Dictionary<int, IceCubeIdentifier> iceCubeIds = new Dictionary<int, IceCubeIdentifier>(); public static Dictionary<int, TailIdentifier> tailIds = new Dictionary<int, TailIdentifier>(); public static Dictionary<string, Sprite> emissions = new Dictionary<string, Sprite>(); public string name; public List<CardMetaCategory> metaCategories; public CardComplexity? cardComplexity; public CardTemple? temple; public string displayedName; public int? baseAttack; public int? baseHealth; public string description; public bool? hideAttackAndHealth; public int? cost; public int? bonesCost; public int? energyCost; public List<GemType> gemsCost; public SpecialStatIcon? specialStatIcon; public List<Tribe> tribes; public List<Trait> traits; public List<SpecialTriggeredAbility> specialAbilities; public List<Ability> abilities; public EvolveParams evolveParams; public string defaultEvolutionName; public TailParams tailParams; public IceCubeParams iceCubeParams; public bool? flipPortraitForStrafe; public bool? onePerDeck; public List<Appearance> appearanceBehaviour; [IgnoreMapping] public Texture2D tex; [IgnoreMapping] public Texture2D altTex; public Texture titleGraphic; [IgnoreMapping] public Texture2D pixelTex; [IgnoreMapping] public Texture2D emissionTex; public GameObject animatedPortrait; public List<Texture> decals; [IgnoreMapping] private List<AbilityIdentifier> abilityIdParam; [IgnoreMapping] private List<SpecialAbilityIdentifier> specialAbilityIdParam; [IgnoreMapping] private EvolveIdentifier evolveId; [IgnoreMapping] private IceCubeIdentifier iceCubeId; [IgnoreMapping] private TailIdentifier tailId; public CustomCard(string name, List<AbilityIdentifier> abilityIdParam = null, List<SpecialAbilityIdentifier> specialAbilityIdParam = null, EvolveIdentifier evolveId = null, IceCubeIdentifier iceCubeId = null, TailIdentifier tailId = null) { this.name = name; this.abilityIdParam = abilityIdParam; this.specialAbilityIdParam = specialAbilityIdParam; this.evolveId = evolveId; this.iceCubeId = iceCubeId; this.tailId = tailId; CardManager.ModifyCardList += delegate(List<CardInfo> cards) { CardInfo val = cards.CardByName(this.name); if ((Object)(object)val != (Object)null) { AdjustCard(val, cards); } return cards; }; } public CardInfo AdjustCard(CardInfo card, List<CardInfo> cardsToSearch) { TypeMapper<CustomCard, CardInfo>.Convert(this, card); if (tex != null) { card.SetPortrait(tex); } if (altTex != null) { card.SetAltPortrait(altTex); } if (pixelTex != null) { card.SetPixelPortrait(pixelTex); } if (decals != null) { card.AddDecal(decals.ToArray()); } if (abilityIdParam != null) { card.AddAbilities(abilityIdParam.Select((AbilityIdentifier ai) => ai.realID).ToArray()); } if (specialAbilityIdParam != null) { card.AssignSpecialAbilities(specialAbilityIdParam); } if (evolveId != null) { CardInfo val = cardsToSearch.CardByName(evolveId.name); if ((Object)(object)val != (Object)null) { card.SetEvolve(val, evolveId.turnsToEvolve, new List<CardModificationInfo> { evolveId.mods }); } } if (tailId != null) { CardInfo val2 = cardsToSearch.CardByName(tailId.name); if ((Object)(object)val2 != (Object)null) { Texture2D tailLostTex = tailId.tailLostTex; IEnumerable<CardModificationInfo> mods = new List<CardModificationInfo> { tailId.mods }; card.SetTail(val2, tailLostTex, null, mods); } } if (iceCubeId != null) { CardInfo val3 = cardsToSearch.CardByName(iceCubeId.name); if ((Object)(object)val3 != (Object)null) { card.SetIceCube(val3, new List<CardModificationInfo> { iceCubeId.mods }); } } return card; } } [Obsolete("Use RegionManager instead", true)] public class CustomRegion { public string name; public int? tier; public List<CardInfo> terrainCards; public List<ConsumableItemData> consumableItems; public List<EncounterBlueprintData> encounters; public List<Type> bosses; public List<CardInfo> likelyCards; public List<Tribe> dominantTribes; public PredefinedNodes predefinedNodes; public EncounterBlueprintData bossPrepEncounter; public StoryEventCondition bossPrepCondition; public List<ScarceSceneryEntry> scarceScenery; public List<FillerSceneryEntry> fillerScenery; public PredefinedScenery predefinedScenery; public string ambientLoopId; public bool? silenceCabinAmbience; public Color? boardLightColor; public Color? cardsLightColor; public bool? dustParticlesDisabled; public bool? fogEnabled; public VolumetricFogProfile fogProfile; public float? fogAlpha; public Texture mapAlbedo; public Texture mapEmission; public Color? mapEmissionColor; public List<GameObject> mapParticlesPrefabs; public CustomRegion(string name) { this.name = name; RegionManager.ModifyRegionsList += ModifyRegions; } public List<RegionData> ModifyRegions(List<RegionData> regions) { RegionData val = ((IEnumerable<RegionData>)regions).FirstOrDefault((Func<RegionData, bool>)((RegionData r) => ((Object)r).name.Equals(name))); if ((Object)(object)val != (Object)null) { AdjustRegion(val); } return regions; } public RegionData AdjustRegion(RegionData region) { TypeMapper<CustomRegion, RegionData>.Convert(this, region); return region; } } [Obsolete("Use CardManager and CardInfo extension methods instead", true)] public class EvolveIdentifier { internal string name; internal int turnsToEvolve; internal CardModificationInfo mods; private EvolveParams evolution; public EvolveParams Evolution { get { if (evolution == null) { SetParams(CardLoader.GetCardByName(name)); } return evolution; } } public EvolveIdentifier(string name, int turnsToEvolve, CardModificationInfo mods = null) { this.name = name; this.turnsToEvolve = turnsToEvolve; this.mods = mods; } private void SetParams(CardInfo card) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown evolution = new EvolveParams(); evolution.turnsToEvolve = turnsToEvolve; evolution.evolution = card; if (mods != null) { evolution.evolution.mods.Add(mods); } } public override string ToString() { return name; } } [Obsolete("Use CardManager and CardInfo extension methods instead", true)] public class IceCubeIdentifier { internal string name; internal CardModificationInfo mods; private IceCubeParams iceCube; public IceCubeParams IceCube { get { if (iceCube == null) { SetParams(CardLoader.GetCardByName(name)); } return iceCube; } } public IceCubeIdentifier(string name, CardModificationInfo mods = null) { this.name = name; this.mods = mods; } private void SetParams(CardInfo card) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown iceCube = new IceCubeParams(); iceCube.creatureWithin = card; if (mods != null) { iceCube.creatureWithin.mods.Add(mods); } } public override string ToString() { return name; } } [Obsolete("Use AbilityManager instead", true)] public class NewAbility { public Ability ability; public AbilityInfo info; public Type abilityBehaviour; public Texture tex; public AbilityIdentifier id; public NewAbility(AbilityInfo info, Type abilityBehaviour, Texture tex, AbilityIdentifier id = null) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) string guid = ((id == null) ? abilityBehaviour.Namespace : id.guid); AbilityManager.FullAbility fullAbility = AbilityManager.Add(guid, info, abilityBehaviour, tex); ability = fullAbility.Id; this.info = fullAbility.Info; this.abilityBehaviour = fullAbility.AbilityBehavior; this.tex = fullAbility.Texture; this.id = AbilityIdentifier.GetID(guid, fullAbility.Info.rulebookName); } } [Obsolete("Use CardManager instead", true)] public static class NewCard { public static List<CardInfo> cards = new List<CardInfo>(); public static Dictionary<int, List<AbilityIdentifier>> abilityIds = new Dictionary<int, List<AbilityIdentifier>>(); public static Dictionary<int, List<SpecialAbilityIdentifier>> specialAbilityIds = new Dictionary<int, List<SpecialAbilityIdentifier>>(); public static Dictionary<int, EvolveIdentifier> evolveIds = new Dictionary<int, EvolveIdentifier>(); public static Dictionary<int, IceCubeIdentifier> iceCubeIds = new Dictionary<int, IceCubeIdentifier>(); public static Dictionary<int, TailIdentifier> tailIds = new Dictionary<int, TailIdentifier>(); public static Dictionary<string, Sprite> emissions = new Dictionary<string, Sprite>(); public static void Add(CardInfo card, List<AbilityIdentifier> abilityIdsParam = null, List<SpecialAbilityIdentifier> specialAbilitiesIdsParam = null, EvolveIdentifier evolveId = null, IceCubeIdentifier iceCubeId = null, TailIdentifier tailId = null) { if (abilityIdsParam != null) { card.AddAbilities(abilityIdsParam.Select((AbilityIdentifier a) => a.realID).ToArray()); } if (specialAbilitiesIdsParam != null) { card.AssignSpecialAbilities(specialAbilitiesIdsParam); } if (evolveId != null) { card.evolveParams = evolveId.Evolution; } if (iceCubeId != null) { card.iceCubeParams = iceCubeId.IceCube; } if (tailId != null) { card.tailParams = tailId.Tail; } CardManager.Add(card); } public static void Add(string name, string displayedName, int baseAttack, int baseHealth, List<CardMetaCategory> metaCategories, CardComplexity cardComplexity, CardTemple temple, string description = null, bool hideAttackAndHealth = false, int bloodCost = 0, int bonesCost = 0, int energyCost = 0, List<GemType> gemsCost = null, SpecialStatIcon specialStatIcon = 0, List<Tribe> tribes = null, List<Trait> traits = null, List<SpecialTriggeredAbility> specialAbilities = null, List<Ability> abilities = null, List<AbilityIdentifier> abilityIdsParam = null, List<SpecialAbilityIdentifier> specialAbilitiesIdsParam = null, EvolveParams evolveParams = null, string defaultEvolutionName = null, TailParams tailParams = null, IceCubeParams iceCubeParams = null, bool flipPortraitForStrafe = false, bool onePerDeck = false, List<Appearance> appearanceBehaviour = null, Texture2D defaultTex = null, Texture2D altTex = null, Texture titleGraphic = null, Texture2D pixelTex = null, Texture2D emissionTex = null, GameObject animatedPortrait = null, List<Texture> decals = null, EvolveIdentifier evolveId = null, IceCubeIdentifier iceCubeId = null, TailIdentifier tailId = null) { //IL_0059: 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_0061: 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_0077: 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) CardInfo val = ScriptableObject.CreateInstance<CardInfo>(); val.SetOldApiCard(); ((Object)val).name = name; val.displayedName = displayedName; val.baseAttack = baseAttack; val.baseHealth = baseHealth; val.description = description; val.SetCost(bloodCost, bonesCost, energyCost, gemsCost); val.hideAttackAndHealth = hideAttackAndHealth; val.cardComplexity = cardComplexity; val.temple = temple; val.AddMetaCategories(metaCategories.ToArray()); val.specialStatIcon = specialStatIcon; if (tribes != null) { val.AddTribes(tribes.ToArray()); } if (traits != null) { val.AddTraits(traits.ToArray()); } if (specialAbilities != null) { val.AddSpecialAbilities(specialAbilities.ToArray()); } if (specialAbilitiesIdsParam != null) { val.AssignSpecialAbilities(specialAbilitiesIdsParam); } if (abilities != null) { val.AddAbilities(abilities.ToArray()); } if (abilityIdsParam != null) { val.AddAbilities(abilityIdsParam.Select((AbilityIdentifier a) => a.realID).ToArray()); } val.evolveParams = evolveParams; val.tailParams = tailParams; val.iceCubeParams = iceCubeParams; val.defaultEvolutionName = defaultEvolutionName; val.flipPortraitForStrafe = flipPortraitForStrafe; val.onePerDeck = onePerDeck; if (appearanceBehaviour != null) { val.AddAppearances(appearanceBehaviour.ToArray()); } if ((Object)(object)defaultTex != (Object)null) { val.SetPortrait(defaultTex); } if ((Object)(object)altTex != (Object)null) { val.SetAltPortrait(altTex); } val.titleGraphic = titleGraphic; if ((Object)(object)pixelTex != (Object)null) { val.SetPixelPortrait(pixelTex); } if ((Object)(object)emissionTex != (Object)null) { val.SetEmissivePortrait(emissionTex); } val.animatedPortrait = animatedPortrait; if (decals != null) { val.decals = new List<Texture>(decals); } if (evolveId != null) { val.SetEvolve(evolveId.name, evolveId.turnsToEvolve, new List<CardModificationInfo> { evolveId.mods }); } if (iceCubeId != null) { val.SetIceCube(iceCubeId.name, new List<CardModificationInfo> { iceCubeId.mods }); } if (tailId != null) { string name2 = tailId.name; Texture2D tailLostTex = tailId.tailLostTex; IEnumerable<CardModificationInfo> mods = new List<CardModificationInfo> { tailId.mods }; val.SetTail(name2, tailLostTex, null, mods); } CardManager.Add(val); } internal static void AssignSpecialAbilities(this CardInfo info, IEnumerable<SpecialAbilityIdentifier> ids) { //IL_0080: 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) info.AddSpecialAbilities((from a in ids where !a.ForStatIcon select a.specialTriggerID).ToArray()); SpecialAbilityIdentifier specialAbilityIdentifier = ids.FirstOrDefault((SpecialAbilityIdentifier a) => a.ForStatIcon); if (specialAbilityIdentifier != null) { info.specialStatIcon = specialAbilityIdentifier.statIconID; } } } [Obsolete("Use CardAppearanceBehaviourManager instead", true)] public class NewCardAppearanceBehaviour { public static Dictionary<Appearance, NewCardAppearanceBehaviour> behaviours = new Dictionary<Appearance, NewCardAppearanceBehaviour>(); public static List<NewCardAppearanceBehaviour> allBehaviours = new List<NewCardAppearanceBehaviour>(); public Appearance Appearance; public string Name; public Type Behaviour; public static NewCardAppearanceBehaviour AddNewBackground(Type type, string name) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) CardAppearanceBehaviourManager.FullCardAppearanceBehaviour fullCardAppearanceBehaviour = CardAppearanceBehaviourManager.Add(type.Namespace, name, type); return new NewCardAppearanceBehaviour { Appearance = fullCardAppearanceBehaviour.Id, Name = name, Behaviour = type }; } } [Obsolete("Use EncounterManager instead", true)] public class NewEncounter { public static List<NewEncounter> encounters = new List<NewEncounter>(); public string name; public string regionName; public bool regular; public bool bossPrep; public EncounterBlueprintData encounterBlueprintData; private List<RegionData> SyncRegion(List<RegionData> region) { EncounterBlueprintData curClone = ((IEnumerable<EncounterBlueprintData>)EncounterManager.AllEncountersCopy).FirstOrDefault((Func<EncounterBlueprintData, bool>)((EncounterBlueprintData e) => ((Object)e).name.Equals(((Object)encounterBlueprintData).name))); if ((Object)(object)curClone == (Object)null) { InscryptionAPIPlugin.Logger.LogDebug((object)("Could not attach encounter named " + ((Object)encounterBlueprintData).name)); return region; } if (curClone.regionSpecific) { if (!string.IsNullOrEmpty(regionName)) { RegionData val = ((IEnumerable<RegionData>)region).FirstOrDefault((Func<RegionData, bool>)((RegionData r) => ((Object)r).name.Equals(regionName))); if ((Object)(object)val != (Object)null) { if (!bossPrep && !val.encounters.Any((EncounterBlueprintData e) => ((Object)e).name.Equals(((Object)curClone).name))) { InscryptionAPIPlugin.Logger.LogDebug((object)("Attaching encounter named " + ((Object)encounterBlueprintData).name + " to region " + ((Object)val).name)); val.encounters.Add(curClone); } if (bossPrep) { val.bossPrepEncounter = curClone; } } } } else { foreach (RegionData item in region) { if (!item.encounters.Any((EncounterBlueprintData e) => ((Object)e).name.Equals(((Object)curClone).name))) { InscryptionAPIPlugin.Logger.LogDebug((object)("Attaching encounter named " + ((Object)encounterBlueprintData).name + " to region " + ((Object)item).name)); item.encounters.Add(curClone); } } } return region; } public NewEncounter(string name, EncounterBlueprintData encounterBlueprintData, string regionName, bool regular, bool bossPrep) { this.name = name; this.encounterBlueprintData = encounterBlueprintData; ((Object)this.encounterBlueprintData).name = name; this.regionName = regionName; this.bossPrep = bossPrep; this.regular = regular; EncounterManager.Add(encounterBlueprintData); RegionManager.ModifyRegionsList += SyncRegion; RegionManager.SyncRegionList(); } public static void Add(string name, string regionName, List<TurnModBlueprint> turnMods = null, List<Tribe> dominantTribes = null, List<Ability> redundantAbilities = null, List<CardInfo> unlockedCardPrerequisites = null, bool regionSpecific = true, int minDifficulty = 0, int maxDifficulty = 30, List<CardInfo> randomReplacementCards = null, List<List<CardBlueprint>> turns = null, bool regular = true, bool bossPrep = false, int oldPreviewDifficulty = 0) { EncounterBlueprintData val = ScriptableObject.CreateInstance<EncounterBlueprintData>(); if (turnMods != null) { val.turnMods = turnMods; } if (dominantTribes != null) { val.dominantTribes = dominantTribes; } if (redundantAbilities != null) { val.redundantAbilities = redundantAbilities; } if (unlockedCardPrerequisites != null) { val.unlockedCardPrerequisites = unlockedCardPrerequisites; } val.regionSpecific = regionSpecific; val.minDifficulty = minDifficulty; val.maxDifficulty = maxDifficulty; if (randomReplacementCards != null) { val.randomReplacementCards = randomReplacementCards; } if (turns != null) { val.turns = turns; } val.oldPreviewDifficulty = oldPreviewDifficulty; new NewEncounter(name, val, regionName, regular, bossPrep); } } [Obsolete("Use RegionManager instead", true)] public class NewRegion { public NewRegion(RegionData region, int tier) { RegionManager.Add(region, tier); } } [Obsolete("Use SpecialTriggeredAbilityManager instead", true)] public class NewSpecialAbility { public static List<NewSpecialAbility> specialAbilities = new List<NewSpecialAbility>(); public SpecialTriggeredAbility specialTriggeredAbility; public StatIconInfo statIconInfo; public Type abilityBehaviour; public SpecialAbilityIdentifier id; public NewSpecialAbility(Type abilityBehaviour, SpecialAbilityIdentifier id, StatIconInfo statIconInfo = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)statIconInfo == (Object)null) { SpecialTriggeredAbilityManager.FullSpecialTriggeredAbility fullSpecialTriggeredAbility = SpecialTriggeredAbilityManager.Add(id.guid, id.name, abilityBehaviour); specialTriggeredAbility = fullSpecialTriggeredAbility.Id; this.abilityBehaviour = abilityBehaviour; this.id = id; } if ((Object)(object)statIconInfo != (Object)null) { StatIconManager.Add(id.guid, statIconInfo, abilityBehaviour); id.ForStatIcon = true; this.statIconInfo = statIconInfo; this.abilityBehaviour = abilityBehaviour; } } } [Obsolete("Use SpecialTriggeredAbilityManager instead", true)] public class SpecialAbilityIdentifier { internal string guid; internal string name; public SpecialTriggeredAbility id; internal SpecialTriggeredAbility specialTriggerID; internal SpecialStatIcon statIconID; internal bool ForStatIcon; private SpecialAbilityIdentifier(string guid, string name) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) this.guid = guid; this.name = name; specialTriggerID = (id = GuidManager.GetEnumValue<SpecialTriggeredAbility>(guid, name)); statIconID = GuidManager.GetEnumValue<SpecialStatIcon>(guid, name); } public static SpecialAbilityIdentifier GetID(string guid, string name) { return new SpecialAbilityIdentifier(guid, name); } public override string ToString() { return guid + "(" + name + ")"; } } [Obsolete("Use CardManager and CardInfo extension methods", true)] public class TailIdentifier { internal string name; internal CardModificationInfo mods; internal Texture2D tailLostTex; private TailParams tail; public TailParams Tail { get { if (tail == null) { SetParams(CardLoader.GetCardByName(name)); } return tail; } } public TailIdentifier(string name, Texture2D tailLostTex = null, CardModificationInfo mods = null) { this.name = name; this.mods = mods; this.tailLostTex = tailLostTex; } private void SetParams(CardInfo card) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown TailParams val = new TailParams(); if (tailLostTex != null) { ((Object)tailLostTex).name = name; ((Texture)tailLostTex).filterMode = (FilterMode)0; val.tailLostPortrait = tailLostTex.ConvertTexture(TextureHelper.SpriteType.CardPortrait, (FilterMode)0); ((Object)val.tailLostPortrait).name = name; } val.tail = card; if (mods != null) { val.tail.mods.Add(mods); } tail = val; } public override string ToString() { return name; } } [Obsolete("Unncessary", true)] [AttributeUsage(AttributeTargets.Field)] public class IgnoreMappingAttribute : Attribute { } [Obsolete("Unnecessary", true)] public static class TypeMapper<S, D> where S : class where D : class { private static Dictionary<string, MethodInfo> _accessors; private static Dictionary<string, MethodInfo> _setters; private static Dictionary<string, MethodInfo> FieldAccessors { get { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0094: 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_00d4: 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 (_accessors == null) { _accessors = new Dictionary<string, MethodInfo>(); foreach (FieldInfo item in from x in AccessTools.GetDeclaredFields(typeof(S)) where !x.GetCustomAttributes(typeof(IgnoreMappingAttribute), inherit: false).Any() select x) { DynamicMethodDefinition val = new DynamicMethodDefinition("get_" + item.Name, typeof(object), new Type[1] { typeof(S) }); ILProcessor iLProcessor = val.GetILProcessor(); iLProcessor.Emit(OpCodes.Ldarg_0); iLProcessor.Emit(OpCodes.Ldfld, val.Module.ImportReference(item)); if (item.FieldType.IsValueType) { Extensions.Emit(iLProcessor, OpCodes.Box, item.FieldType); } iLProcessor.Emit(OpCodes.Ret); _accessors.Add(item.Name, val.Generate()); } } return _accessors; } } private static Dictionary<string, MethodInfo> FieldSetters { get { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_007d: 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_0093: 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_00c5: Unknown result type (might be due to invalid IL or missing references) if (_setters == null) { _setters = new Dictionary<string, MethodInfo>(); foreach (FieldInfo declaredField in AccessTools.GetDeclaredFields(typeof(D))) { DynamicMethodDefinition val = new DynamicMethodDefinition("set_" + declaredField.Name, typeof(void), new Type[2] { typeof(D), typeof(object) }); ILProcessor iLProcessor = val.GetILProcessor(); iLProcessor.Emit(OpCodes.Ldarg_0); iLProcessor.Emit(OpCodes.Ldarg_1); iLProcessor.Emit(OpCodes.Unbox_Any, val.Module.ImportReference(declaredField.FieldType)); iLProcessor.Emit(OpCodes.Stfld, val.Module.ImportReference(declaredField)); iLProcessor.Emit(OpCodes.Ret); _setters.Add(declaredField.Name, val.Generate()); } } return _setters; } } public static D Convert(S source, D destination) { foreach (KeyValuePair<string, MethodInfo> fieldAccessor in FieldAccessors) { object obj = fieldAccessor.Value.Invoke(null, new object[1] { source }); if (obj != null && FieldSetters.ContainsKey(fieldAccessor.Key)) { FieldSetters[fieldAccessor.Key].Invoke(null, new object[2] { destination, obj }); } } return destination; } } } namespace InscryptionAPI { [BepInPlugin("cyantist.inscryption.api", "InscryptionAPI", "2.22.3")] [HarmonyPatch] public class InscryptionAPIPlugin : BaseUnityPlugin { public const string ModGUID = "cyantist.inscryption.api"; public const string ModName = "InscryptionAPI"; public const string ModVer = "2.22.3"; public static string Directory; internal static ConfigEntry<bool> configOverrideArrows; internal static ConfigEntry<bool> configRandomChoiceOrder; internal static ConfigEntry<bool> configHideAct1BossScenery; internal static ConfigEntry<TotemManager.TotemTopState> configCustomTotemTopTypes; internal static ConfigEntry<ConsumableItemManager.ConsumableState> configCustomItemTypes; internal static ManualLogSource Logger; private readonly Harmony HarmonyInstance = new Harmony("cyantist.inscryption.api"); public static event Action<Type> ScriptableObjectLoaderLoad; static InscryptionAPIPlugin() { Directory = ""; AppDomain.CurrentDomain.AssemblyResolve += (object _, ResolveEventArgs e) => e.Name.StartsWith("API, Version=1") ? typeof(InscryptionAPIPlugin).Assembly : null; } internal static void InvokeSOLEvent(Type type) { InscryptionAPIPlugin.ScriptableObjectLoaderLoad?.Invoke(type); } private void OnEnable() { Logger = ((BaseUnityPlugin)this).Logger; Directory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); HarmonyInstance.PatchAll(typeof(InscryptionAPIPlugin).Assembly); } private void OnDisable() { HarmonyInstance.UnpatchSelf(); } internal static void ResyncAll() { CardManager.SyncCardList(); CardCostManager.SyncCustomCostList(); CardModificationInfoManager.SyncCardMods(); AbilityManager.SyncAbilityList(); SlotModificationManager.SyncSlotModificationList(); EncounterManager.SyncEncounterList(); RegionManager.SyncRegionList(); RuleBookManager.SyncRuleBookList(); } internal static void CheckForOutdatedPlugins() { string text = ""; foreach (Assembly item in Chainloader.PluginInfos.Values.Select((PluginInfo p) => ((object)p.Instance).GetType().Assembly).Distinct()) { AssemblyName[] referencedAssemblies = item.GetReferencedAssemblies(); for (int i = 0; i < referencedAssemblies.Length; i++) { if (referencedAssemblies[i].Name.Equals("API")) { text = text + " - " + item.GetName().Name + "\n"; } } } if (text != "") { Logger.LogWarning((object)("The following mods use an outdated version of the API:\n" + text + "\nThese mods may not work correctly. If problems arise, please update or disable them!")); } } private void Awake() { configCustomTotemTopTypes = ((BaseUnityPlugin)this).Config.Bind<TotemManager.TotemTopState>("Totems", "Top Types", TotemManager.TotemTopState.CustomTribes, "If Vanilla, don't change totem tops; if CustomTribes, added custom tribes will use custom totem tops; if AllTribes then all totem tops will use a custom top."); configCustomItemTypes = ((BaseUnityPlugin)this).Config.Bind<ConsumableItemManager.ConsumableState>("Items", "Types", ConsumableItemManager.ConsumableState.Custom, "If Vanilla, only vanilla items will be used; if Custom, added custom items will use custom models; if All then all items will use a custom model."); configOverrideArrows = ((BaseUnityPlugin)this).Config.Bind<bool>("Menus", "Override Arrows", false, "When true, forces the challenge screen arrows to appear at the top of the screen instead of the sides."); configRandomChoiceOrder = ((BaseUnityPlugin)this).Config.Bind<bool>("Miscellaneous", "Randomise Cost Choice Order", false, "When true, randomises the order card cost choices are presented in Act 1."); configHideAct1BossScenery = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimization", "Hide Act 1 Scenery", false, "When true bosses will not spawn their scenery. (eg: Prospector's trees) This can improve performance on low-end machines."); } private void Start() { CheckForOutdatedPlugins(); DeathCardManager.AddCustomDeathCards(); CardManager.ActivateEvents(); CardManager.ResolveMissingModPrefixes(); ResyncAll(); CardManager.AuditCardList(); PixelCardManager.Initialise(); PeltManager.CreateDialogueEvents(); DialogueManager.CustomDialogue.Exists((DialogueManager.Dialogue x) => x.DialogueEvent.id == "Hint_NotEnoughSameColourGemsHint"); Logger.LogDebug((object)$"Inserted {DialogueManager.CustomDialogue.Count} dialogue event(s)!"); } [HarmonyPatch(typeof(AscensionMenuScreens), "TransitionToGame")] [HarmonyPrefix] private static void SyncCardsAndAbilitiesWhenTransitioningToAscensionGame() { ResyncAll(); } [HarmonyPatch(typeof(MenuController), "TransitionToGame")] [HarmonyPrefix] private static void SyncCardsAndAbilitiesWhenTransitioningToGame() { ResyncAll(); } } } namespace InscryptionAPI.Triggers { public static class CustomTriggerFinder { public static IEnumerator CustomTriggerSequence(this TriggerReceiver receiver, IEnumerator triggerCoroutine) { GlobalTriggerHandler self = Singleton<GlobalTriggerHandler>.Instance; if ((Object)(object)self != (Object)null) { self.NumTriggersThisBattle += 1; self.StackSize += 1; receiver.Activating = true; yield return triggerCoroutine; self.StackSize -= 1; receiver.Activating = false; if (receiver.DestroyAfterActivation) { receiver.Destroy(); } } } public static IEnumerator TriggerAll<T>(bool triggerFacedown, Func<T, bool> respond, Func<T, IEnumerator> trigger) { IEnumerable<T> enumerable = FindGlobalTriggers<T>(triggerFacedown); foreach (T item in enumerable) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; yield return ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(item)); } } _ = triggerFacedown; } public static IEnumerator Trigger<T>(this CardTriggerHandler handler, Func<T, bool> respond, Func<T, IEnumerator> trigger) { IEnumerable<T> enumerable = handler.FindTriggersOnCard<T>(); foreach (T item in enumerable) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; yield return ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(item)); } } } public static IEnumerator Trigger<T>(this PlayableCard card, Func<T, bool> respond, Func<T, IEnumerator> trigger) { yield return card.TriggerHandler.Trigger(respond, trigger); } public static IEnumerator TriggerOnBoard<T>(bool triggerFacedown, Func<T, bool> respond, Func<T, IEnumerator> trigger) { IEnumerable<T> enumerable = FindTriggersOnBoard<T>(triggerFacedown); foreach (T item in enumerable) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; yield return ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(item)); } } } public static IEnumerator TriggerInHand<T>(Func<T, bool> respond, Func<T, IEnumerator> trigger) { IEnumerable<T> enumerable = FindTriggersInHand<T>(); foreach (T item in enumerable) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; yield return ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(item)); } } } public static List<(TriggerReceiver, T2)> CollectDataAll<T, T2>(bool collectFromFacedown, Func<T, bool> respond, Func<T, T2> collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in FindGlobalTriggers<T>(collectFromFacedown)) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add(((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null), collect(item))); } } return list; } public static List<(TriggerReceiver, T2)> CollectDataOnBoard<T, T2>(bool collectFromFacedown, Func<T, bool> respond, Func<T, T2> collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in FindTriggersOnBoard<T>(collectFromFacedown)) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add(((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null), collect(item))); } } return list; } public static List<(TriggerReceiver, T2)> CollectDataInHand<T, T2>(Func<T, bool> respond, Func<T, T2> collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in FindTriggersInHand<T>()) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add(((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null), collect(item))); } } return list; } public static List<(TriggerReceiver, T2)> CollectData<T, T2>(this PlayableCard self, Func<T, bool> respond, Func<T, T2> collect) { return self.TriggerHandler.CollectData(respond, collect); } public static List<(TriggerReceiver, T2)> CollectData<T, T2>(this CardTriggerHandler self, Func<T, bool> respond, Func<T, T2> collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in self.FindTriggersOnCard<T>()) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add(((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null), collect(item))); } } return list; } public static List<TriggerReceiver> CallAll<T>(bool triggerFacedown, Func<T, bool> respond, Action<T> call) { List<TriggerReceiver> list = new List<TriggerReceiver>(); foreach (T item in FindGlobalTriggers<T>(triggerFacedown)) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)); call(item); } } return list; } public static List<TriggerReceiver> CallOnBoard<T>(bool triggerFacedown, Func<T, bool> respond, Action<T> call) { List<TriggerReceiver> list = new List<TriggerReceiver>(); foreach (T item in FindTriggersOnBoard<T>(triggerFacedown)) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)); call(item); } } return list; } public static List<TriggerReceiver> CallInHand<T>(Func<T, bool> respond, Action<T> call) { List<TriggerReceiver> list = new List<TriggerReceiver>(); foreach (T item in FindTriggersInHand<T>()) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)); call(item); } } return list; } public static List<TriggerReceiver> Call<T>(this PlayableCard self, Func<T, bool> respond, Action<T> call) { return self.TriggerHandler.Call(respond, call); } public static List<TriggerReceiver> Call<T>(this CardTriggerHandler self, Func<T, bool> respond, Action<T> call) { List<TriggerReceiver> list = new List<TriggerReceiver>(); foreach (T item in self.FindTriggersOnCard<T>()) { object obj = item; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(item)) { object obj2 = item; list.Add((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)); call(item); } } return list; } public static IEnumerable<T> FindGlobalTriggers<T>(bool findFacedown, PlayableCard excluding = null) { IEnumerable<T> enumerable = Enumerable.Empty<T>(); if (Object.op_Implicit((Object)(object)Singleton<BoardManager>.Instance)) { enumerable = enumerable.Concat(FindTriggersOnBoard<T>(findFacedown)); } if (Object.op_Implicit((Object)(object)Singleton<PlayerHand>.Instance)) { enumerable = enumerable.Concat(FindTriggersInHandExcluding<T>(excluding)); } return enumerable; } public static IEnumerable<T> FindGlobalTriggers<T>(PlayableCard excluding = null) { return FindGlobalTriggers<T>(findFacedown: true, excluding); } public static IEnumerable<T> FindTriggersInHand<T>() { return new List<PlayableCard>(Singleton<PlayerHand>.Instance.CardsInHand).Where((PlayableCard c) => (Object)(object)c != (Object)null && c.InHand).SelectMany(FindTriggersOnCard<T>); } public static IEnumerable<T> FindTriggersOnBoard<T>() { return FindTriggersOnBoard<T>(findFacedown: true); } public static IEnumerable<T> FindTriggersOnBoard<T>(bool findFacedown) { List<PlayableCard> source = new List<PlayableCard>(Singleton<BoardManager>.Instance.CardsOnBoard); List<NonCardTriggerReceiver> source2 = new List<NonCardTriggerReceiver>(Singleton<GlobalTriggerHandler>.Instance.nonCardReceivers); List<SlotModificationBehaviour> source3 = new List<SlotModificationBehaviour>(SlotModificationManager.Instance?.SlotReceivers?.Select((KeyValuePair<CardSlot, Tuple<SlotModificationManager.ModificationType, SlotModificationBehaviour>> kvp) => kvp.Value.Item2) ?? Enumerable.Empty<SlotModificationBehaviour>()); return (from x in source2 where !UnityExtensions.SafeIsUnityNull((Object)(object)x) where x.TriggerBeforeCards select x).OfType<T>().Concat(source3.Where((SlotModificationBehaviour x) => !UnityExtensions.SafeIsUnityNull((Object)(object)x)).OfType<T>()).Concat(source.Where((PlayableCard x) => (Object)(object)x != (Object)null && x.OnBoard && (!((Card)x).FaceDown || findFacedown)).SelectMany(FindTriggersOnCard<T>)) .Concat((from x in source2 where !UnityExtensions.SafeIsUnityNull((Object)(object)x) where !x.TriggerBeforeCards select x).OfType<T>()) .Concat(from x in source.Where((PlayableCard x) => (Object)(object)x != (Object)null && x.OnBoard && ((Card)x).FaceDown && !findFacedown).SelectMany(FindTriggersOnCard<T>) where x is IActivateWhenFacedown && (x as IActivateWhenFacedown).ShouldTriggerCustomWhenFaceDown(typeof(T)) select x); } public static IEnumerable<T> FindTriggersInHandExcluding<T>(PlayableCard card) { return new List<PlayableCard>(Singleton<PlayerHand>.Instance.CardsInHand).Where((PlayableCard x) => (Object)(object)x != (Object)null && x.InHand && (Object)(object)x != (Object)(object)card).SelectMany(FindTriggersOnCard<T>); } public static IEnumerable<T> FindTriggersOnCard<T>(this PlayableCard card) { foreach (T item in card.TriggerHandler.GetAllReceivers().OfType<T>()) { yield return item; } } public static IEnumerable<T> FindTriggersOnCard<T>(this CardTriggerHandler card) { foreach (T item in card.GetAllReceivers().OfType<T>()) { yield return item; } } public static IEnumerable<T> FindTriggersInQueue<T>() { TurnManager instance = Singleton<TurnManager>.Instance; object obj; if (instance == null) { obj = null; } else { Opponent opponent = instance.Opponent; T val = default(T); obj = ((opponent != null) ? (from card in opponent.Queue where ((Component)card).TryGetComponent<T>(ref val) select ((Component)card).GetComponent<T>()) : null); } if (obj == null) { obj = new T[0]; } return (IEnumerable<T>)obj; } } [HarmonyPatch] internal static class CustomTriggerPatches { private static Type scaleChangedCoroutine; private static FieldInfo scaleChangedDamage; private static FieldInfo scaleChangedToPlayer; private static FieldInfo scaleChangedNumWeights; private static FieldInfo triggerField; private static readonly Type triggerType = AccessTools.TypeByName("DiskCardGame.GlobalTriggerHandler+<TriggerCardsOnBoard>d__16"); [HarmonyPatch(typeof(PlayerHand), "AddCardToHand")] [HarmonyPostfix] private static IEnumerator TriggerOnAddedToHand(IEnumerator result, PlayableCard card) { yield return result; yield return card.TriggerHandler.Trigger((IOnAddedToHand x) => x.RespondsToAddedToHand(), (IOnAddedToHand x) => x.OnAddedToHand()); yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnOtherCardAddedToHand x) => x.RespondsToOtherCardAddedToHand(card), (IOnOtherCardAddedToHand x) => x.OnOtherCardAddedToHand(card)); } [HarmonyPatch(typeof(CombatPhaseManager), "DoCombatPhase")] [HarmonyPostfix] private static IEnumerator TriggerOnBellRung(IEnumerator result, bool playerIsAttacker) { yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnBellRung x) => x.RespondsToBellRung(playerIsAttacker), (IOnBellRung x) => x.OnBellRung(playerIsAttacker)); yield return result; } [HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSequence")] [HarmonyPostfix] private static IEnumerator TriggerOnSlotAttackSequence(IEnumerator result, CardSlot slot) { yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPreSlotAttackSequence x) => x.RespondsToPreSlotAttackSequence(slot), (IOnPreSlotAttackSequence x) => x.OnPreSlotAttackSequence(slot)); yield return result; yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostSlotAttackSequence x) => x.RespondsToPostSlotAttackSequence(slot), (IOnPostSlotAttackSequence x) => x.OnPostSlotAttackSequence(slot)); } [HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSlot")] [HarmonyPostfix] private static IEnumerator TriggerOnPostSingularSlotAttackSlot(IEnumerator result, CardSlot attackingSlot, CardSlot opposingSlot) { yield return result; yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostSingularSlotAttackSlot x) => x.RespondsToPostSingularSlotAttackSlot(attackingSlot, opposingSlot), (IOnPostSingularSlotAttackSlot x) => x.OnPostSingularSlotAttackSlot(attackingSlot, opposingSlot)); } [HarmonyPatch(typeof(LifeManager), "ShowDamageSequence")] [HarmonyPostfix] private static IEnumerator TriggerOnScalesChanged(IEnumerator result, int damage, int numWeights, bool toPlayer) { int initialDamage = damage; bool initialToPlayer = toPlayer; CustomTriggerFinder.CollectDataAll(collectFromFacedown: false, (IOnPreScalesChangedRef x) => x.RespondsToPreScalesChangedRef(damage, numWeights, toPlayer), delegate(IOnPreScalesChangedRef x) { damage = x.CollectPreScalesChangedRef(damage, ref numWeights, ref toPlayer); if (damage < 0) { damage = -damage; toPlayer = !toPlayer; } return damage; }); yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPreScalesChanged x) => x.RespondsToPreScalesChanged(damage, toPlayer, initialDamage, initialToPlayer), (IOnPreScalesChanged x) => x.OnPreScalesChanged(damage, toPlayer, initialDamage, initialToPlayer)); (scaleChangedDamage ?? (scaleChangedDamage = (scaleChangedCoroutine ?? (scaleChangedCoroutine = result?.GetType()))?.GetField("damage")))?.SetValue(result, damage); (scaleChangedToPlayer ?? (scaleChangedToPlayer = (scaleChangedCoroutine ?? (scaleChangedCoroutine = result?.GetType()))?.GetField("toPlayer")))?.SetValue(result, toPlayer); (scaleChangedNumWeights ?? (scaleChangedNumWeights = (scaleChangedCoroutine ?? (scaleChangedCoroutine = result?.GetType()))?.GetField("numWeights")))?.SetValue(result, numWeights); yield return result; yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostScalesChanged x) => x.RespondsToPostScalesChanged(damage, toPlayer, initialDamage, initialToPlayer), (IOnPostScalesChanged x) => x.OnPostScalesChanged(damage, toPlayer, initialDamage, initialToPlayer)); } [HarmonyPatch(typeof(TurnManager), "DoUpkeepPhase")] [HarmonyPostfix] private static IEnumerator TriggerOnUpkeepInHand(IEnumerator result, bool playerUpkeep) { yield return result; yield return CustomTriggerFinder.TriggerInHand((IOnUpkeepInHand x) => x.RespondsToUpkeepInHand(playerUpkeep), (IOnUpkeepInHand x) => x.OnUpkeepInHand(playerUpkeep)); } [HarmonyPatch(typeof(BoardManager), "ResolveCardOnBoard")] [HarmonyPostfix] private static IEnumerator TriggerOnOtherCardResolveInHand(IEnumerator result, PlayableCard card, bool resolveTriggers = true) { yield return result; if (resolveTriggers) { yield return CustomTriggerFinder.TriggerInHand((IOnOtherCardResolveInHand x) => x.RespondsToOtherCardResolveInHand(card), (IOnOtherCardResolveInHand x) => x.OnOtherCardResolveInHand(card)); } } [HarmonyPatch(typeof(TurnManager), "PlayerTurn")] [HarmonyPostfix] private static IEnumerator TriggerOnTurnEndInHandPlayer(IEnumerator result) { yield return result; yield return CustomTriggerFinder.TriggerInHand((IOnTurnEndInHand x) => x.RespondsToTurnEndInHand(playerTurn: true), (IOnTurnEndInHand x) => x.OnTurnEndInHand(playerTurn: true)); } [HarmonyPatch(typeof(TurnManager), "OpponentTurn")] [HarmonyPostfix] private static IEnumerator TriggerOnTurnEndInHandOpponent(IEnumerator result, TurnManager __instance) { bool turnSkipped = __instance.Opponent.SkipNextTurn; yield return result; if (!turnSkipped) { yield return CustomTriggerFinder.TriggerInHand((IOnTurnEndInHand x) => x.RespondsToTurnEndInHand(playerTurn: false), (IOnTurnEndInHand x) => x.OnTurnEndInHand(playerTurn: false)); } } [HarmonyPatch(typeof(BoardManager), "AssignCardToSlot")] [HarmonyPostfix] private static IEnumerator TriggerOnOtherCardAssignedToSlotInHand(IEnumerator result, PlayableCard card, bool resolveTriggers) { CardSlot slot2 = card.Slot; yield return result; if (resolveTriggers && (Object)(object)slot2 != (Object)(object)card.Slot) { yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnCardAssignedToSlotContext x) => x.RespondsToCardAssignedToSlotContext(card, slot2, card.Slot), (IOnCardAssignedToSlotContext x) => x.OnCardAssignedToSlotContext(card, slot2, card.Slot)); } if (resolveTriggers && (Object)(object)slot2 != (Object)(object)card.Slot) { yield return CustomTriggerFinder.TriggerInHand((IOnOtherCardAssignedToSlotInHand x) => x.RespondsToOtherCardAssignedToSlotInHand(card), (IOnOtherCardAssignedToSlotInHand x) => x.OnOtherCardAssignedToSlotInHand(card)); } if (resolveTriggers && (Object)(object)slot2 != (Object)(object)card.Slot && (Object)(object)slot2 != (Object)null) { yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnCardAssignedToSlotNoResolve x) => x.RespondsToCardAssignedToSlotNoResolve(card), (IOnCardAssignedToSlotNoResolve x) => x.OnCardAssignedToSlotNoResolve(card)); } } [HarmonyPatch(typeof(PlayableCard), "Die")] [HarmonyPostfix] private static IEnumerator TriggerDeathTriggers(IEnumerator result, PlayableCard __instance, bool wasSacrifice, PlayableCard killer = null) { CardSlot slotBeforeDeath = __instance.Slot; while (result.MoveNext()) { yield return result.Current; if (!(result.Current.GetType() == triggerType)) { continue; } Trigger val = (Trigger)21; try { val = (Trigger)(triggerField ?? (triggerField = triggerType.GetField("trigger"))).GetValue(result.Current); } catch { } if ((int)val == 17) { yield return CustomTriggerFinder.TriggerInHand((IOnOtherCardPreDeathInHand x) => x.RespondsToOtherCardPreDeathInHand(slotBeforeDeath, !wasSacrifice, killer), (IOnOtherCardPreDeathInHand x) => x.OnOtherCardPreDeathInHand(slotBeforeDeath, !wasSacrifice, killer)); } else if ((int)val == 11) { yield return CustomTriggerFinder.TriggerInHand((IOnOtherCardDieInHand x) => x.RespondsToOtherCardDieInHand(__instance, slotBeforeDeath, !wasSacrifice, killer), (IOnOtherCardDieInHand x) => x.OnOtherCardDieInHand(__instance, slotBeforeDeath, !wasSacrifice, killer)); } } } [HarmonyPatch(typeof(ConsumableItemSlot), "ConsumeItem")] [HarmonyPostfix] private static IEnumerator TriggerItemUse(IEnumerator result, ConsumableItemSlot __instance) { bool itemCanBeUsed = true; ConsumableItemSlot obj = __instance; object obj2; if (obj == null) { obj2 = null; } else { ConsumableItem consumable = obj.Consumable; if (consumable == null) { obj2 = null; } else { ItemData data = ((Item)consumable).Data; obj2 = ((data != null) ? ((Object)data).name : null); } } string consumableName = (string)obj2; if (!string.IsNullOrEmpty(consumableName)) { CustomTriggerFinder.CollectDataAll(collectFromFacedown: false, (IItemCanBeUsed x) => x.RespondsToItemCanBeUsed(consumableName, itemCanBeUsed), (IItemCanBeUsed x) => itemCanBeUsed = x.CollectItemCanBeUsed(consumableName, itemCanBeUsed)); } if (itemCanBeUsed) { bool successInActivation = false; Type activationtype = __instance.Consumable.ActivateSequence().GetType(); if (!string.IsNullOrEmpty(consumableName)) { yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPreItemUsed x) => x.RespondsToPreItemUsed(consumableName, __instance is HammerItemSlot), (IOnPreItemUsed x) => x.OnPreItemUsed(consumableName, __instance is HammerItemSlot)); } while (result.MoveNext()) { yield return result.Current; if (result.Current.GetType() == activationtype && !string.IsNullOrEmpty(consumableName) && (Object)(object)__instance.Consumable != (Object)null) { successInActivation = !__instance.Consumable.ActivationCancelled; } } if (!string.IsNullOrEmpty(consumableName)) { yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostItemUsed x) => x.RespondsToPostItemUsed(consumableName, successInActivation, __instance is HammerItemSlot), (IOnPostItemUsed x) => x.OnPostItemUsed(consumableName, successInActivation, __instance is HammerItemSlot)); } yield break; } ConsumableItemSlot obj3 = __instance; if (obj3 != null) { ConsumableItem consumable2 = obj3.Consumable; if (consumable2 != null) { consumable2.PlayShakeAnimation(); } } if (!string.IsNullOrEmpty(consumableName)) { yield return CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnItemPreventedFromUse x) => x.RespondsToItemPreventedFromUse(consumableName), (IOnItemPreventedFromUse x) => x.OnItemPreventedFromUse(consumableName)); } } [HarmonyPatch(typeof(PlayableCard), "GetPassiveAttackBuffs")] [HarmonyPostfix] private static void PassiveAttackBuffs(PlayableCard __instance, ref int __result) { int dummyResult = __result; CustomTriggerFinder.CollectDataAll(collectFromFacedown: true, (IOnCardPassiveAttackBuffs x) => x.RespondsToCardPassiveAttackBuffs(__instance, dummyResult), (IOnCardPassiveAttackBuffs x) => dummyResult = x.CollectCardPassiveAttackBuffs(__instance, dummyResult)); if (__instance.OnBoard) { CustomTriggerFinder.CollectDataAll(collectFromFacedown: true, (IPassiveAttackBuff x) => true, (IPassiveAttackBuff x) => dummyResult += x.GetPassiveAttackBuff(__instance)); } __result = dummyResult; } [HarmonyPatch(typeof(PlayableCard), "GetPassiveHealthBuffs")] [HarmonyPostfix] private static void PassiveHealthBuffs(PlayableCard __instance, ref int __result) { int dummyResult = __result; CustomTriggerFinder.CollectDataAll(collectFromFacedown: true, (IOnCardPassiveHealthBuffs x) => x.RespondsToCardPassiveHealthBuffs(__instance, dummyResult), (IOnCardPassiveHealthBuffs x) => dummyResult = x.CollectCardPassiveHealthBuffs(__instance, dummyResult)); if (__instance.OnBoard) { CustomTriggerFinder.CollectDataAll(collectFromFacedown: true, (IPassiveHealthBuff x) => true, (IPassiveHealthBuff x) => dummyResult += x.GetPassiveHealthBuff(__instance)); } __result = dummyResult; } [HarmonyPatch(typeof(PlayableCard), "GetOpposingSlots")] [HarmonyPrefix] private static bool OpposingSlotsPrefix(PlayableCard __instance, ref List<CardSlot> __result, ref int __state) { List<ISetupAttackSequence> list = CustomTriggerFinder.FindGlobalTriggers<ISetupAttackSequence>(findFacedown: true).ToList(); list.RemoveAll((ISetupAttackSequence x) => (Object)((x is TriggerReceiver) ? x : null) == (Object)null); list.Sort((ISetupAttackSequence x, ISetupAttackSequence x2) => x.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.ReplacesDefaultOpposingSlot, new List<CardSlot>(), new List<CardSlot>(), 0, didRemoveDefaultSlot: false) - x2.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.ReplacesDefaultOpposingSlot, new List<CardSlot>(), new List<CardSlot>(), 0, didRemoveDefaultSlot: false)); bool flag = false; bool didRemoveDefaultSlot = false; __state = 1; foreach (ISetupAttackSequence item in list) { if (item.RespondsToModifyAttackSlots(__instance, OpposingSlotTriggerPriority.ReplacesDefaultOpposingSlot, new List<CardSlot>(), __result ?? new List<CardSlot>(), __state, didRemoveDefaultSlot: false)) { flag = true; __result = item.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.ReplacesDefaultOpposingSlot, new List<CardSlot>(), __result ?? new List<CardSlot>(), ref __state, ref didRemoveDefaultSlot); didRemoveDefaultSlot = false; } } if (!flag && __instance.HasAbility((Ability)33)) { __state = Mathf.Max(1, (__instance.OpponentCard ? Singleton<BoardManager>.Instance.PlayerSlotsCopy : Singleton<BoardManager>.Instance.OpponentSlotsCopy).FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null && !__instance.CanAttackDirectly(x)).Count); } if (flag) { if (__instance.HasAbility((Ability)24)) { ProgressionData.SetAbilityLearned((Ability)24); __result.Remove(__instance.Slot.opposingSlot); __result.AddRange(Singleton<BoardManager>.Instance.GetAdjacentSlots(__instance.Slot.opposingSlot)); } if (__instance.HasTriStrike()) { ProgressionData.SetAbilityLearned((Ability)25); __result.AddRange(Singleton<BoardManager>.Instance.GetAdjacentSlots(__instance.Slot.opposingSlot)); if (!__result.Contains(__instance.Slot.opposingSlot)) { __result.Add(__instance.Slot.opposingSlot); } } if (__instance.HasAbility((Ability)100)) { ProgressionData.SetAbilityLearned((Ability)100); __result.Add(__instance.slot.opposingSlot); } } if (__instance.HasAbility((Ability)24)) { __state++; } if (__instance.HasTriStrike()) { __state += 2; if (__instance.HasAbility((Ability)24)) { __state++; } } if (__instance.HasAbility((Ability)100)) { __state++; } __result?.Sort((CardSlot a, CardSlot b) => a.Index - b.Index); return !flag; } [HarmonyPatch(typeof(PlayableCard), "GetOpposingSlots")] [HarmonyPostfix] private static void OpposingSlots(PlayableCard __instance, ref List<CardSlot> __result, int __state) { List<CardSlot> original = new List<CardSlot>(__result); bool flag = !__instance.HasTriStrike() && !__instance.HasAbility((Ability)24); CardSlot opposingSlot = __instance.Slot.opposingSlot; List<CardSlot> list = new List<CardSlot>(); bool flag2 = false; foreach (IGetOpposingSlots item in __instance.FindTriggersOnCard<IGetOpposingSlots>()) { if ((Object)((item is TriggerReceiver) ? item : null) != (Object)null && item.RespondsToGetOpposingSlots()) { list.AddRange(item.GetOpposingSlots(__result, new List<CardSlot>(list))); flag2 = flag2 || item.RemoveDefaultAttackSlot(); } } if (list.Count > 0) { __result.AddRange(list); } if (flag && flag2) { __result.Remove(opposingSlot); } bool didRemoveOriginalSlot = __instance.HasAbility((Ability)24) && (!__instance.HasTriStrike() || flag2); List<ISetupAttackSequence> list2 = CustomTriggerFinder.FindGlobalTriggers<ISetupAttackSequence>(findFacedown: true).ToList(); list2.RemoveAll((ISetupAttackSequence x) => (Object)((x is TriggerReceiver) ? x : null) == (Object)null); List<CardSlot> dummyresult = __result; list2.Sort((ISetupAttackSequence x, ISetupAttackSequence x2) => x.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.Normal, original, dummyresult, __state, didRemoveOriginalSlot) - x2.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.Normal, original, dummyresult, __state, didRemoveOriginalSlot)); foreach (ISetupAttackSequence item2 in list2) { if (item2.RespondsToModifyAttackSlots(__instance, OpposingSlotTriggerPriority.Normal, original, __result ?? new List<CardSlot>(), __state, didRemoveOriginalSlot)) { __result = item2.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.Normal, original, __result ?? new List<CardSlot>(), ref __state, ref didRemoveOriginalSlot); } } dummyresult = __result; list2.Sort((ISetupAttackSequence x, ISetupAttackSequence x2) => x.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.BringsBackOpposingSlot, original, dummyresult, __state, didRemoveOriginalSlot) - x2.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.BringsBackOpposingSlot, original, dummyresult, __state, didRemoveOriginalSlot)); foreach (ISetupAttackSequence item3 in list2) { if (item3.RespondsToModifyAttackSlots(__instance, OpposingSlotTriggerPriority.BringsBackOpposingSlot, original, __result ?? new List<CardSlot>(), __state, didRemoveOriginalSlot)) { __result = item3.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.BringsBackOpposingSlot, original, __result ?? new List<CardSlot>(), ref __state, ref didRemoveOriginalSlot); } } dummyresult = __result; list2.Sort((ISetupAttackSequence x, ISetupAttackSequence x2) => x.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.PostAdditionModification, original, dummyresult, __state, didRemoveOriginalSlot) - x2.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.PostAdditionModification, original, dummyresult, __state, didRemoveOriginalSlot)); foreach (ISetupAttackSequence item4 in list2) { if (item4.RespondsToModifyAttackSlots(__instance, OpposingSlotTriggerPriority.PostAdditionModification, original, __result ?? new List<CardSlot>(), __state, didRemoveOriginalSlot)) { __result = item4.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.PostAdditionModification, original, __result ?? new List<CardSlot>(), ref __state, ref didRemoveOriginalSlot); } } if (didRemoveOriginalSlot && __instance.HasTriStrike()) { __result.Add(__instance.Slot.opposingSlot); } __result.Sort((CardSlot a, CardSlot b) => a.Index - b.Index); } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> TriggerOnTurnEndInQueuePlayer(IEnumerable<CodeInstruction> instructions) { return TriggerOnTurnEndInQueue(instructions, playerTurn: true); } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> TriggerOnTurnEndInQueueOpponent(IEnumerable<CodeInstruction> instructions) { return TriggerOnTurnEndInQueue(instructions, playerTurn: false); } private static IEnumerable<CodeInstruction> TriggerOnTurnEndInQueue(IEnumerable<CodeInstruction> instructions, bool playerTurn) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); int num = list.IndexOf(list.First((CodeInstruction code) => code.opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(code, (MemberInfo)AccessTools.Method(typeof(GlobalTriggerHandler), "TriggerCardsOnBoard", (Type[])null, (Type[])null)))); num++; list.Insert(num++, new CodeInstruction(playerTurn ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CustomTriggerPatches), "TriggerOnTurnEndInQueueCoro", (Type[])null, (Type[])null))); return list; } private static IEnumerator TriggerOnTurnEndInQueueCoro(IEnumerator originalTrigger, bool playerTurn) { yield return originalTrigger; foreach (IOnTurnEndInQueue item in CustomTriggerFinder.FindTriggersInQueue<IOnTurnEndInQueue>()) { if ((Object)((item is TriggerReceiver) ? item : null) != (Object)null && item.RespondsToTurnEndInQueue(playerTurn)) { yield return item.OnTurnEndInQueue(playerTurn); } } } [HarmonyPatch(typeof(GlobalTriggerHandler), "TriggerNonCardReceivers")] [HarmonyPostfix] private static IEnumerator TriggerSlotModificationHandlers(IEnumerator sequence, bool beforeCards, Trigger trigger, params object[] otherArgs) { //IL_0015: 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) yield return sequence; if (!beforeCards) { yield break; } List<SlotModificationBehaviour> list = new List<SlotModificationBehaviour>(SlotModificationManager.Instance?.SlotReceivers?.Select((KeyValuePair<CardSlot, Tuple<SlotModificationManager.ModificationType, SlotModificationBehaviour>> kvp) => kvp.Value.Item2) ?? Enumerable.Empty<SlotModificationBehaviour>()); foreach (SlotModificationBehaviour item in list) { if ((Object)(object)item != (Object)null && GlobalTriggerHandler.ReceiverRespondsToTrigger(trigger, (TriggerReceiver)(object)item, otherArgs)) { yield return Singleton<GlobalTriggerHandler>.Instance.TriggerSequence(trigger, (TriggerReceiver)(object)item, otherArgs); } } } } [HarmonyPatch] public static class DoCombatPhasePatches { private const string name_GetDamageDealt = "Int32 get_DamageDealtThisPhase()"; private const string name_PlayerAttacker = "System.Boolean playerIsAttacker"; private const string name_SpecialSequencer = "DiskCardGame.SpecialBattleSequencer specialSequencer"; private const string name_SquirrelAttacker = "System.Boolean <attackedWithSquirrel>5__4"; private const string name_CombatCurrent = "System.Object <>2__current"; public static IEnumerator NegativeDamageSupport(CombatPhaseManager __instance, bool playerIsAttacker, SpecialBattleSequencer specialSequencer, bool attackedWithSquirrel) { if (__instance.DamageDealtThisPhase == 0) { yield break; } bool targetOfDamage = ((__instance.DamageDealtThisPhase < 0) ? (!playerIsAttacker) : playerIsAttacker); yield return (object)new WaitForSeconds(0.4f); yield return __instance.VisualizeDamageMovingToScales(targetOfDamage); int overkillDamage = 0; if (playerIsAttacker && __instance.DamageDealtThisPhase > 0) { overkillDamage = Singleton<LifeManager>.Instance.Balance + __instance.DamageDealtThisPhase - 5; if (attackedWithSquirrel && overkillDamage >= 0) { AchievementManager.Unlock((Achievement)14); } overkillDamage = Mathf.Max(0, overkillDamage); } int num = Math.Abs(__instance.DamageDealtThisPhase); int damage = num - overkillDamage; AscensionStatsData.TryIncreaseStat((Type)4, num); if (num >= 666) { AchievementManager.Unlock((Achievement)25); } bool canDealDamage = (Object)(object)specialSequencer == (Object)null || !specialSequencer.PreventDamageAddedToScales; if (canDealDamage) { yield return Singleton<LifeManager>.Instance.ShowDamageSequence(damage, damage, !targetOfDamage, 0f, (GameObject)null, 0f, true); } if ((Object)(object)specialSequencer != (Object)null) { yield return specialSequencer.DamageAddedToScale(damage + overkillDamage, targetOfDamage); } if (canDealDamage && overkillDamage > 0 && Singleton<TurnManager>.Instance.Opponent.NumLives == 1 && Singleton<TurnManager>.Instance.Opponent.GiveCurrencyOnDefeat) { yield return Singleton<TurnManager>.Instance.Opponent.TryRevokeSurrender(); RunState run = RunState.Run; run.currency += overkillDamage; yield return __instance.VisualizeExcessLethalDamage(overkillDamage, specialSequencer); } } public static List<CardSlot> ModifyAttackingSlots(bool playerIsAttacker) { List<CardSlot> originalSlots = Singleton<BoardManager>.Instance.GetSlotsCopy(playerIsAttacker); List<CardSlot> list = new List<CardSlot>(originalSlots); List<IGetAttackingSlots> list2 = CustomTriggerFinder.FindTriggersOnBoard<IGetAttackingSlots>(findFacedown: false).ToList(); list2.Sort((IGetAttackingSlots a, IGetAttackingSlots b) => b.TriggerPriority(playerIsAttacker, originalSlots) - a.TriggerPriority(playerIsAttacker, originalSlots)); foreach (IGetAttackingSlots item in list2) { if ((Object)((item is TriggerReceiver) ? item : null) != (Object)null && item.RespondsToGetAttackingSlots(playerIsAttacker, originalSlots, list)) { List<CardSlot> attackingSlots = item.GetAttackingSlots(playerIsAttacker, originalSlots, list); if (attackingSlots != null && attackingSlots.Count > 0) { list.AddRange(attackingSlots); } } } return list; } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> SelfDamage(IEnumerable<CodeInstruction> instructions) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Expected O, but got Unknown //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); object obj = null; object obj2 = null; object obj3 = null; for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode == OpCodes.Brtrue)) { continue; } MethodBase methodBase = AccessTools.Method(typeof(DoCombatPhasePatches), "ModifyAttackingSlots", new Type[1] { typeof(bool) }, (Type[])null); for (int j = i; j < list.Count; j++) { if (list[j].opcode == OpCodes.Stfld) { list.RemoveRange(i, j - i); break; } } list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodBase)); break; } for (int k = 0; k < list.Count; k++) { if (obj == null && list[k].operand?.ToString() == "System.Boolean playerIsAttacker") { obj = list[k].operand; } else if (obj2 == null && list[k].operand?.ToString() == "DiskCardGame.SpecialBattleSequencer specialSequencer") { obj2 = list[k].operand; } else if (obj3 == null && list[k].operand?.ToString() == "System.Boolean <attackedWithSquirrel>5__4") { obj3 = list[k].operand; } else { if (!(list[k].operand?.ToString() == "Int32 get_DamageDealtThisPhase()")) { continue; } int num = k - 1; for (int l = k; l < list.Count; l++) { if (list[l + 2].opcode == OpCodes.Ldc_I4_S && list[l + 2].operand.ToString() == "11") { MethodBase methodBase2 = AccessTools.Method(typeof(DoCombatPhasePatches), "NegativeDamageSupport", new Type[4] { typeof(CombatPhaseManager), typeof(bool), typeof(SpecialBattleSequencer), typeof(bool) }, (Type[])null); list.RemoveAll((CodeInstruction x) => x.opcode == OpCodes.Nop); list[num].opcode = OpCodes.Ldarg_0; list.Insert(num + 1, new CodeInstruction(OpCodes.Ldloc_2, (object)null)); list.Insert(num + 2, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 3, new CodeInstruction(OpCodes.Ldfld, obj)); list.Insert(num + 4, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 5, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(num + 6, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 7, new CodeInstruction(OpCodes.Ldfld, obj3)); list.Insert(num + 8, new CodeInstruction(OpCodes.Callvirt, (object)methodBase2)); return list; } CodeInstructionExtensions.MoveLabelsTo(list[l], list[num]); list[l].opcode = OpCodes.Nop; } } } return list; } } public interface IOnAddedToHand { bool RespondsToAddedToHand(); IEnumerator OnAddedToHand(); } public interface IOnOtherCardAddedToHand { bool RespondsToOtherCardAddedToHand(PlayableCard card); IEnumerator OnOtherCardAddedToHand(PlayableCard card); } public interface IOnCardAssignedToSlotNoResolve { bool RespondsToCardAssignedToSlotNoResolve(PlayableCard card); IEnumerator OnCardAssignedToSlotNoResolve(PlayableCard card); } public interface IOnCardAssignedToSlotContext { bool RespondsToCardAssignedToSlotContext(PlayableCard card, CardSlot oldSlot, CardSlot newSlot); IEnumerator OnCardAssignedToSlotContext(PlayableCard card, CardSlot oldSlot, CardSlot newSlot); } public interface IOnBellRung { bool RespondsToBellRung(bool playerCombatPhase); IEnumerator OnBellRung(bool playerCombatPhase); } public interface IOnPreSlotAttackSequence { bool RespondsToPreSlotAttackSequence(CardSlot attackingSlot); IEnumerator OnPreSlotAttackSequence(CardSlot attackingSlot); } public interface IOnPostSlotAttackSequence { bool RespondsToPostSlotAttackSequence(CardSlot attackingSlot); IEnumerator OnPostSlotAttackSequence(CardSlot attackingSlot); } public interface IOnPostSingularSlotAttackSlot { bool RespondsToPostSingularSlotAttackSlot(CardSlot attackingSlot, CardSlot targetSlot); IEnumerator OnPostSingularSlotAttackSlot(CardSlot attackingSlot, CardSlot targetSlot); } public interface IOnPreScalesChangedRef { bool RespondsToPreScalesChangedRef(int damage, int numWeights, bool toPlayer); int CollectPreScalesChangedRef(int damage, ref int numWeights, ref bool toPlayer); } public interface IOnPreScalesChanged { bool RespondsToPreScalesChanged(int damage, bool toPlayer, int originalDamage, bool originalToPlayer); IEnumerator OnPreScalesChanged(int damage, bool toPlayer, int originalDamage, bool originalToPlayer); } public interface IOnPostScalesChanged { bool RespondsToPostScalesChanged(int damage, bool toPlayer, int originalDamage, bool originalToPlayer); IEnumerator OnPostScalesChanged(int damage, bool toPlayer, int originalDamage, bool originalToPlayer); } public interface IOnUpkeepInHand { bool RespondsToUpkeepInHand(bool playerUpkeep); IEnumerator OnUpkeepInHand(bool playerUpkeep); } public interface IOnOtherCardResolveInHand { bool RespondsToOtherCardResolveInHand(PlayableCard resolvingCard); IEnumerator OnOtherCardResolveInHand(PlayableCard resolvingCard); } public interface IOnTurnEndInHand { bool RespondsToTurnEndInHand(bool playerTurn); IEnumerator OnTurnEndInHand(bool playerTurn); } public interface IOnOtherCardAssignedToSlotInHand { bool RespondsToOtherCardAssignedToSlotInHand(PlayableCard card); IEnumerator OnOtherCardAssignedToSlotInHand(PlayableCard card); } public interface IOnOtherCardPreDeathInHand { bool RespondsToOtherCardPreDeathInHand(CardSlot deathSlot, bool fromCombat, PlayableCard killer); IEnumerator OnOtherCardPreDeathInHand(CardSlot deathSlot, bool fromCombat, PlayableCard killer); } public interface IOnOtherCardDealtDamageInHand { bool RespondsToOtherCardDealtDamageInHand(PlayableCard attacker, int amount, PlayableCard target); IEnumerator OnOtherCardDealtDamageInHand(PlayableCard attacker, int amount, PlayableCard target); } public interface IOnOtherCardDieInHand { bool RespondsToOtherCardDieInHand(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer); IEnumerator OnOtherCardDieInHand(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer); } public interface IOnPreItemUsed { bool RespondsToPreItemUsed(string itemName, bool isHammer); IEnumerator OnPreItemUsed(string itemName, bool isHammer); } public interface IOnPostItemUsed { bool RespondsToPostItemUsed(string itemName, bool success, bool isHammer); IEnumerator OnPostItemUsed(string itemName, bool success, bool isHammer); } public interface IGetOpposingSlots { bool RespondsToGetOpposingSlots(); List<CardSlot> GetOpposingSlots(List<CardSlot> originalSlots, List<CardSlot> otherAddedSlots); bool RemoveDefaultAttackSlot(); } public interface ISetupAttackSequence { bool RespondsToModifyAttackSlots(PlayableCard card, OpposingSlotTriggerPriority modType, List<CardSlot> originalSlots, List<CardSlot> currentSlots, int attackCount, bool didRemoveDefaultSlot); List<CardSlot> CollectModifyAttackSlots(PlayableCard card, OpposingSlotTriggerPriority modType, List<CardSlot> originalSlots, List<CardSlot> currentSlots, ref int attackCount, ref bool didRemoveDefaultSlot); int GetTriggerPriority(PlayableCard card, OpposingSlotTriggerPriority modType, List<CardSlot> originalSlots, List<CardSlot> currentSlots, int attackCount, bool didRemoveDefaultSlot); } public enum OpposingSlotTriggerPriority { Normal, BringsBackOpposingSlot, PostAdditionModification, ReplacesDefaultOpposingSlot } public interface IItemCanBeUsed { bool RespondsToItemCanBeUsed(string itemname, bool currentValue); bool CollectItemCanBeUsed(string itemname, bool currentValue); } public interface IOnItemPreventedFromUse { bool RespondsToItemPreventedFromUse(string itemName); IEnumerator OnItemPreventedFromUse(string itemName); } public interface IOnCardPassiveAttackBuffs { bool RespondsToCardPassiveAttackBuffs(PlayableCard card, int currentValue); int CollectCardPassiveAttackBuffs(PlayableCard card, int currentValue); } public interface IOnCardPassiveHealthBuffs { bool RespondsToCardPassiveHealthBuffs(PlayableCard card, int currentValue); int CollectCardPassiveHealthBuffs(PlayableCard card, int currentValue); } public interface IPassiveHealthBuff { int GetPassiveHealthBuff(PlayableCard target); } public interface IPassiveAttackBuff { int GetPassiveAttackBuff(PlayableCard target); } [Obsolete("Use IModifyDamageTaken instead.")] public interface ICardTakenDamageModifier { bool RespondsToCardTakenDamageModifier(PlayableCard card, int currentValue); int CollectCardTakenDamageModifier(PlayableCard card, int currentValue); } public interface IGetAttackingSlots { bool RespondsToGetAttackingSlots(bool playerIsAttacker, List<CardSlot> originalSlots, List<CardSlot> currentSlots); List<CardSlot> GetAttackingSlots(bool playerIsAttacker, List<CardSlot> originalSlots, List<CardSlot> currentSlots); int TriggerPriority(bool playerIsAttacker, List<CardSlot> originalSlots); } public interface IModifyDamageTaken { bool RespondsToModifyDamageTaken(PlayableCard target, int damage, PlayableCard attacker, int originalDamage); int OnModifyDamageTaken(PlayableCard target, int damage, PlayableCard attacker, int originalDamage); int TriggerPriority(PlayableCard target, int damage, PlayableCard attacker); } public interface IPreTakeDamage { bool RespondsToPreTakeDamage(PlayableCard source, int damage); IEnumerator OnPreTakeDamage(PlayableCard source, int damage); } public interface IModifyDirectDamage { bool RespondsToModifyDirectDamage(CardSlot target, int damage, PlayableCard attacker, int originalDamage); int OnModifyDirectDamage(CardSlot target, int damage, PlayableCard attacker, int originalDamage); int TriggerPriority(CardSlot target, int damage, PlayableCard attacker); } public interface IOnTurnEndInQueue { bool RespondsToTurnEndInQueue(bool playerTurn); IEnumerator OnTurnEndInQueue(bool playerTurn); } public interface IOnCardDealtDamageDirectly { bool RespondsToCardDealtDamageDirectly(PlayableCard attacker, CardSlot opposingSlot, int damage); IEnumerator OnCardDealtDamageDirectly(PlayableCard attacker, CardSlot opposingSlot, int damage); } public interface IShieldPreventedDamage { bool RespondsToShieldPreventedDamage(PlayableCard target, int damage, PlayableCard attacker); IEnumerator OnShieldPreventedDamage(PlayableCard target, int damage, PlayableCard attacker); int ShieldPreventedDamagePriority(PlayableCard target, int damage, PlayableCard attacker); } public interface IShieldPreventedDamageInHand { bool RespondsToShieldPreventedDamageInHand(PlayableCard target, int damage, PlayableCard attacker); IEnumerator OnShieldPreventedDamageInHand(PlayableCard target, int damage, PlayableCard attacker); int ShieldPreventedDamageInHandPriority(PlayableCard target, int damage, PlayableCard attacker); } [HarmonyPatch] public static class SlotAttackSlotPatches { private const string name_GlobalTrigger = "DiskCardGame.GlobalTriggerHandler get_Instance()"; private const string name_GetCard = "DiskCardGame.PlayableCard get_Card()"; private const string name_GetAttack = "Int32 get_Attack()"; private const string name_OpposingSlot = "DiskCardGame.CardSlot opposingSlot"; private const string name_CombatPhase = "DiskCardGame.CombatPhaseManager+<>c__DisplayClass5_0 <>8__1"; private const string name_AttackingSlot = "DiskCardGame.CardSlot attackingSlot"; private const string name_CanAttackDirectly = "Boolean CanAttackDirectly(DiskCardGame.CardSlot)"; private const string name_VisualizeCardAttackingDirectly = "System.Collections.IEnumerator VisualizeCardAttackingDirectly(DiskCardGame.CardSlot, DiskCardGame.CardSlot, Int32)"; private const string modifiedAttackCustomField = "modifiedAttack"; private static readonly MethodInfo method_GetCard = AccessTools.PropertyGetter(typeof(CardSlot), "Card"); private static readonly MethodInfo method_NewDamage = AccessTools.Method(typeof(SlotAttackSlotPatches), "DamageToDealThisPhase", new Type[2] { typeof(CardSlot), typeof(CardSlot) }, (Type[])null); private static readonly MethodInfo method_NewTriggers = AccessTools.Method(typeof(SlotAttackSlotPatches), "TriggerOnDirectDamageTriggers", new Type[2] { typeof(PlayableCard), typeof(CardSlot) }, (Type[])null); private static readonly MethodInfo method_SetCustomField = AccessTools.Method(typeof(CustomFields), "Set", (Type[])null, (Type[])null); private static readonly MethodInfo method_GetCustomField = AccessTools.Method(typeof(CustomFields), "Get", new Type[2] { typeof(object), typeof(string) }, new Type[1] { typeof(int) }); public static int DamageToDealThisPhase(CardSlot attackingSlot, CardSlot opposingSlot) { int damage; int originalDamage = (damage = attackingSlot.Card.Attack); List<IModifyDirectDamage> list = CustomTriggerFinder.FindGlobalTriggers<IModifyDirectDamage>(findFacedown: true).ToList(); list.Sort((IModifyDirectDamage a, IModifyDirectDamage b) => b.TriggerPriority(opposingSlot, damage, attackingSlot.Card) - a.TriggerPriority(opposingSlot, damage, attackingSlot.Card)); foreach (IModifyDirectDamage item in list) { if (item.RespondsToModifyDirectDamage(opposingSlot, damage, attackingSlot.Card, originalDamage)) { damage = item.OnModifyDirectDamage(opposingSlot, damage, attackingSlot.Card, originalDamage); } } if (attackingSlot.IsPlayerSlot == opposingSlot.IsPlayerSlot) { return -damage; } if (Singleton<TurnManager>.Instance.IsPlayerTurn) { if (attackingSlot.IsOpponentSlot()) { if (!opposingSlot.IsPlayerSlot) { return damage; } return -damage; } } else if (attackingSlot.IsPlayerSlot) { if (!opposingSlot.IsOpponentSlot()) { return damage; } return -damage; } return damage; } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (!ModifyDirectDamageCheck(list, ref i)) { continue; } for (int j = i; j < list.Count; j++) { if (CallTriggerOnDirectDamage(list, ref j)) { for (int k = j; k < list.Count && !OpposingCardNullCheck(list, k); k++) { } break; } } break; } return list; } private static bool OpposingCardNullCheck(List<CodeInstruction> codes, int i) { //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Expected O, but got Unknown if (codes[i].opcode == OpCodes.Call && codes[i].operand.ToString() == "DiskCardGame.GlobalTriggerHandler get_Instance()" && codes[i + 1].opcode == OpCodes.Ldc_I4_7) { MethodInfo methodInfo = null; object obj = null; object obj2 = null; object obj3 = null; for (int j = i + 1; j < codes.Count; j++) { if (codes[j].opcode == OpCodes.Ldfld && codes[j].operand.ToString() == "DiskCardGame.CardSlot opposingSlot" && obj == null) { obj = codes[j].operand; } if (codes[j].opcode == OpCodes.Callvirt && codes[j].operand.ToString() == "DiskCardGame.PlayableCard get_Card()" && obj2 == null) { obj2 = codes[j].operand; } if (!(codes[j].opcode == OpCodes.Stfld) || !(codes[j - 1].opcode == OpCodes.Ldc_I4_M1)) { continue; } for (int k = j + 1; k < codes.Count; k++) { if (codes[k].opcode == OpCodes.Call && methodInfo == null) { methodInfo = (MethodInfo)codes[k].operand; } if (obj3 == null && codes[k].opcode == OpCodes.Brfalse) { obj3 = codes[k].operand; } if (codes[k].opcode == OpCodes.Stfld) { codes.Insert(k + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(k + 2, new CodeInstruction(OpCodes.Ldfld, obj)); codes.Insert(k + 3, new CodeInstruction(OpCodes.Callvirt, obj2)); codes.Insert(k + 4, new CodeInstruction(OpCodes.Ldnull, (object)null)); codes.Insert(k + 5, new CodeInstruction(OpCodes.Call, (object)methodInfo)); codes.Insert(k + 6, new CodeInstruction(OpCodes.Brfalse, obj3)); return true; } } break; } } return false; } private static bool ModifyDirectDamageCheck(List<CodeInstruction> codes, ref int index) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown if (codes[index].opcode == OpCodes.Callvirt && codes[index].operand.ToString() == "Boolean CanAttackDirectly(DiskCardGame.CardSlot)") { int num = index + 2; object obj = null; object obj2 = null; object obj3 = null; for (int num2 = index - 1; num2 > 0; num2--) { if (obj == null && codes[num2].operand?.ToString() == "DiskCardGame.CardSlot opposingSlot") { obj = codes[num2].operand; break; } } for (int i = num; i < codes.Count; i++) { if (obj2 == null && codes[i].operand?.ToString() == "DiskCardGame.CombatPhaseManager+<>c__DisplayClass5_0 <>8__1") { obj2 = codes[i].operand; obj3 = codes[i + 1].operand; break; } } int j = num; codes.Insert(j++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(j++, new CodeInstruction(OpCodes.Ldfld, obj2)); codes.Insert(j++, new CodeInstruction(OpCodes.Ldfld, obj3)); codes.Insert(j++, new CodeInstruction(OpCodes.Callvirt, (object)method_GetCard)); codes.Insert(j++, new CodeInstruction(OpCodes.Ldstr, (object)"modifiedAttack")); codes.Insert(j++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(j++, new CodeInstruction(OpCodes.Ldfld, obj2)); codes.Insert(j++, new CodeInstruction(OpCodes.Ldfld, obj3)); codes.Insert(j++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(j++, new CodeInstruction(OpCodes.Ldfld, obj)); codes.Insert(j++, new CodeInstruction(OpCodes.Callvirt, (object)method_NewDamage)); codes.Insert(j++, new CodeInstruction(OpCodes.Box, (object)typeof(int))); codes.Insert(j++, new CodeInstruction(OpCodes.Call, (object)method_SetCustomField)); index = j; for (int k = 0; k < 2; k++) { for (; j < codes.Count; j++) { if (!(codes[j].opcode != OpCodes.Callvirt) && !(codes[j].operand.ToString() != "Int32 get_Attack()")) { codes[j++] = new CodeInstruction(OpCodes.Ldstr, (object)"modifiedAttack"); codes.Insert(j++, new CodeInstruction(OpCodes.Callvirt, (object)method_GetCustomField)); index = j; break; } } } return true; } return false; } private static bool CallTriggerOnDirectDamage(List<CodeInstruction> codes, ref int index) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown if (codes[index].opcode != OpCodes.Callvirt || codes[index].operand.ToString() != "DiskCardGame.PlayableCard get_Card()") { return false; } int num = ++index; object obj = null; for (int num2 = num - 1; num2 > 0; num2--) { if (obj == null && codes[num2].operand?.ToString() == "DiskCardGame.CardSlot opposingSlot") { obj = codes[num2].operand; break; } } for (int num3 = num - 1; num3 > 0; num3--) { if (codes[num3].opcode == OpCodes.Ldarg_0) { codes.Insert(num3, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); index++; num++; break; } }
plugins/InscryptionCommunityPatch.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
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.22.0.0")] [assembly: AssemblyInformationalVersion("2.22.0+e3d314467cda100be17517be6cfb93a1af6e677e")] [assembly: AssemblyProduct("InscryptionCommunityPatch")] [assembly: AssemblyTitle("InscryptionCommunityPatch")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.22.0.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<bool> configEnergy; internal static ConfigEntry<bool> configDrone; internal static ConfigEntry<bool> configMox; internal static ConfigEntry<bool> configDroneMox; internal static ConfigEntry<bool> configShowSquirrelTribeOnCards; internal static ConfigEntry<bool> configAct3Bones; internal static ConfigEntry<bool> configResetEyes; internal static ConfigEntry<bool> undeadCatEmission; internal static ConfigEntry<bool> rightAct2Cost; internal static ConfigEntry<bool> act2CostRender; internal static ConfigEntry<bool> act2StackIconType; internal static ConfigEntry<bool> configMergeOnBottom; internal static ConfigEntry<bool> configRemovePatches; internal static ConfigEntry<bool> configSmallPricetags; internal static ConfigEntry<bool> configMovePricetags; internal static ConfigEntry<bool> configTestState; internal static ConfigEntry<bool> configFullDebug; internal static ConfigEntry<bool> configDefaultDrone; internal static ConfigEntry<bool> 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<bool>("Energy", "Energy Refresh", true, "Max energy increases and energy refreshes at end of turn"); configDrone = ((BaseUnityPlugin)this).Config.Bind<bool>("Energy", "Energy Drone", false, "Drone is visible to display energy (requires Energy Refresh)"); configDefaultDrone = ((BaseUnityPlugin)this).Config.Bind<bool>("Energy", "Default Drone", false, "Drone uses the vanilla model instead of being attached to the scales (requires Energy Drone)"); configMox = ((BaseUnityPlugin)this).Config.Bind<bool>("Mox", "Mox Refresh", true, "Mox refreshes at end of battle"); configDroneMox = ((BaseUnityPlugin)this).Config.Bind<bool>("Mox", "Mox Drone", false, "Drone displays mox (requires Energy Drone and Mox Refresh)"); configAct3Bones = ((BaseUnityPlugin)this).Config.Bind<bool>("Bones", "Act 3 Bones", false, "Force bones displayer to be active in Act 3"); configShowSquirrelTribeOnCards = ((BaseUnityPlugin)this).Config.Bind<bool>("Tribes", "Show Squirrel Tribe", false, "Shows the Squirrel tribe icon on cards"); act2CostRender = ((BaseUnityPlugin)this).Config.Bind<bool>("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<bool>("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"); configMergeOnBottom = ((BaseUnityPlugin)this).Config.Bind<bool>("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<bool>("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)."); configSmallPricetags = ((BaseUnityPlugin)this).Config.Bind<bool>("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<bool>("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<bool>("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<bool>("Act 2", "Centred Hoarder UI", true, "If true, centres displayed cards in each row during the Hoarder selection sequence."); configFullDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Full Debug", true, "If true, displays all debug logs in the console."); configTestState = ((BaseUnityPlugin)this).Config.Bind<bool>("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<bool>("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."); undeadCatEmission = ((BaseUnityPlugin)this).Config.Bind<bool>("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 { public override bool RespondsToOtherCardResolve(PlayableCard otherCard) { return ((Object)((Card)otherCard).Info).name.ToLowerInvariant().Equals("squirrel"); } public override IEnumerator OnOtherCardResolve(PlayableCard otherCard) { yield return ((BoonBehaviour)this).PlayBoonAnimation(); otherCard.TemporaryMods.Add(new CardModificationInfo((Ability)14)); ((Card)otherCard).RenderCard(); } } [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<FullAbility>)AbilityManager.BaseGameAbilities, (Ability)15).Info.canStack = true; AbilityExtensions.AbilityByID((IEnumerable<FullAbility>)AbilityManager.BaseGameAbilities, (Ability)34).Info.canStack = true; AbilityExtensions.AbilityByID((IEnumerable<FullAbility>)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<Texture2D>("art/cards/abilityicons/ability_drawcopyondeath"), (Texture)(object)Resources.Load<Texture2D>("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<Ability> list = new List<Ability> { (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<Ability>(list.Take(i)); cardByName.mods.Add(val); CardModificationInfo val2 = new CardModificationInfo(); val2.abilities = new List<Ability> { 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<Ability>(); 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 { 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<int, CardInfo, PlayableCard, Texture2D>)Texture3D, (Func<int, CardInfo, PlayableCard, Texture2D>)TexturePixel), (Func<int, int>)CostTier), (Func<int, CardInfo, List<CardInfo>, 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<CardInfo> 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<ResourcesManager>.Instance.PlayerEnergy - card.EnergyCost; } public override string CostUnsatisfiedHint(int cardCost, PlayableCard card) { return "Eat your greens aby. " + ((Card)card).Info.DisplayedNameLocalized; } public override IEnumerator OnPlayed(int cardCost, PlayableCard card) { if (cardCost > 0) { yield return Singleton<ResourcesManager>.Instance.SpendEnergy(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 { 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<CodeInstruction> 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<CodeInstruction> list = new List<CodeInstruction>(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; } private static IEnumerator NewStatBoostSequence(CardStatBoostSequencer instance, bool attackMod) { 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."); } yield return (object)new WaitForSeconds(0.5f); yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("You have no creatures to warm.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true); yield return (object)new WaitForSeconds(0.25f); } yield return (object)new WaitForSeconds(0.25f); } } [HarmonyPatch] internal class LeshyResetRedEyes { [HarmonyPostfix] [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] private static IEnumerator ResetLeshyEyes(IEnumerator enumerator, TurnManager __instance) { if (!PatchPlugin.configResetEyes.Value || !SaveManager.SaveFile.IsPart1 || (Object)(object)__instance.opponent == (Object)null) { yield return enumerator; yield break; } 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(); } } yield return enumerator; } } [HarmonyPatch] internal class PackRatNodeBackgroundFix { [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> FixRareBackground(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(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 { [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<TalkingCard>() == (Object)null) { return true; } if (__instance.PeltInHand()) { AscensionStatsData.TryIncrementStat((Type)8); PlayableCard pelt = Singleton<PlayerHand>.Instance.CardsInHand.Find((PlayableCard x) => ((Card)x).Info.HasTrait((Trait)13)); Singleton<PlayerHand>.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; } public static IEnumerator TradeForTalkingCard(PlayableCard card) { yield return Singleton<PlayerHand>.Instance.AddCardToHand(CardSpawner.SpawnPlayableCard(((Card)card).Info), new Vector3(0f, 0.5f, -3f), 0f); Singleton<ViewManager>.Instance.SwitchToView((View)6, false, false); Singleton<ViewManager>.Instance.Controller.SwitchToControlMode((ControlMode)18, false); } } } 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; } } } public static Dictionary<CardTemple, EnergyConfigInfo> ZoneConfigs = new Dictionary<CardTemple, EnergyConfigInfo> { { (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<ResourceDrone>(Resources.Load<ResourceDrone>("prefabs/cardbattle/ResourceModules")); if (EnergyConfig.ConfigDrone) { ((MonoBehaviour)PatchPlugin.Instance).StartCoroutine(AwakeDrone()); } } } private static IEnumerator AwakeDrone() { if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)$"Awaking ResourceDrone, instance exists? {(Object)(object)Singleton<ResourceDrone>.Instance != (Object)null}."); } yield return (object)new WaitForSeconds(1f); Singleton<ResourceDrone>.Instance.Awake(); yield return (object)new WaitForSeconds(1f); Singleton<ResourceDrone>.Instance.AttachGemsModule(); if (EnergyConfig.ConfigDefaultDrone) { ((Component)Singleton<ResourceDrone>.Instance).gameObject.transform.localPosition = Singleton<ResourceDrone>.Instance.boardPosition + Vector3.up * 5f; } else { AttachDroneToScale(); } } 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<ResourceDrone>.Instance).transform.Find("Anim")).gameObject.GetComponent<Animator>()).enabled = false; ((Component)((Component)Singleton<ResourceDrone>.Instance).transform.Find("Anim/Module-Energy/Propellers")).gameObject.SetActive(false); Transform val = ((Component)Singleton<LifeManager>.Instance.Scales3D).gameObject.transform.Find("Scale"); ((Component)Singleton<ResourceDrone>.Instance).transform.SetParent(val); ((Component)Singleton<ResourceDrone>.Instance).transform.localEulerAngles = Vector3.zero; ((Component)Singleton<ResourceDrone>.Instance).transform.localScale = new Vector3(0.6f, 0.6f, 0.6f); ((Component)Singleton<ResourceDrone>.Instance).transform.localPosition = new Vector3(0.02f, -0.2f, 2f); Singleton<ResourceDrone>.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<ResourcesManager>.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<ResourceDrone>.m_Instance != (Object)null) { Singleton<ResourceDrone>.Instance.CloseAllCells(false); Singleton<ResourceDrone>.Instance.SetOnBoard(false, false); if (EnergyConfig.ConfigDroneMox) { GemsModule gems = Singleton<ResourceDrone>.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<ResourceDrone>.m_Instance != (Object)null) { Singleton<ResourceDrone>.Instance.SetOnBoard(true, false); if (EnergyConfig.ConfigDroneMox) { PatchPlugin.Logger.LogDebug((object)"Setting up extra drone resources."); Singleton<ResourceDrone>.Instance.Gems.SetAllGemsOn(false, true); } } } [HarmonyPatch(typeof(ResourcesManager), "ShowAddMaxEnergy")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowAddMaxEnergy(IEnumerator result, ResourcesManager __instance) { if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDrone && (Object)(object)Singleton<ResourceDrone>.m_Instance != (Object)null) { int num = __instance.PlayerMaxEnergy - 1; Singleton<ResourceDrone>.Instance.OpenCell(num); yield return (object)new WaitForSeconds(0.4f); } yield return result; } [HarmonyPatch(typeof(ResourcesManager), "ShowAddEnergy")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowAddEnergy(IEnumerator result, int amount, ResourcesManager __instance) { if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDrone && (Object)(object)Singleton<ResourceDrone>.m_Instance != (Object)null) { for (int i = __instance.PlayerEnergy - amount; i < __instance.PlayerEnergy; i++) { Singleton<ResourceDrone>.Instance.SetCellOn(i, true, false); yield return (object)new WaitForSeconds(0.05f); } } yield return result; } [HarmonyPatch(typeof(ResourcesManager), "ShowSpendEnergy")] [HarmonyPostfix] private static IEnumerator ResourcesManager_ShowSpendEnergy(IEnumerator result, int amount, ResourcesManager __instance) { if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDrone && (Object)(object)Singleton<ResourceDrone>.m_Instance != (Object)null) { for (int i = __instance.PlayerEnergy + amount - 1; i >= __instance.PlayerEnergy; i--) { AudioController.Instance.PlaySound3D("crushBlip3", (MixerGroup)4, ((Component)__instance).transform.position, 0.4f, 0f, new Pitch(0.9f + (float)(__instance.PlayerEnergy + i) * 0.05f), (Repetition)null, (Randomization)null, (Distortion)null, false); Singleton<ResourceDrone>.Instance.SetCellOn(i, false, false); yield return (object)new WaitForSeconds(0.05f); } } yield return result; } [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) if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDroneMox) { __instance.SetGemOnImmediate(gem, true); yield return (object)new WaitForSeconds(0.05f); } yield return result; } [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) if (__instance is Part1ResourcesManager && EnergyConfig.ConfigDroneMox) { __instance.SetGemOnImmediate(gem, false); yield return (object)new WaitForSeconds(0.05f); } yield return result; } [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<ResourceDrone>.m_Instance != (Object)null) { GemsModule gems = Singleton<ResourceDrone>.Instance.Gems; if (gems != null) { gems.SetGemOn(gem, on, false); } } } [HarmonyPatch(typeof(TurnManager), "DoUpkeepPhase")] [HarmonyPostfix] private static IEnumerator TurnManager_UpkeepPhase(IEnumerator sequence, bool playerUpkeep) { yield return sequence; if (playerUpkeep && CurrentSceneCanHaveEnergyDrone && EnergyConfig.ConfigEnergy) { bool showEnergyModule = !Singleton<ResourcesManager>.Instance.EnergyAtMax || Singleton<ResourcesManager>.Instance.PlayerEnergy < Singleton<ResourcesManager>.Instance.PlayerMaxEnergy; if (showEnergyModule) { Singleton<ViewManager>.Instance.SwitchToView((View)1, false, true); yield return (object)new WaitForSeconds(0.1f); } yield return Singleton<ResourcesManager>.Instance.AddMaxEnergy(1); yield return Singleton<ResourcesManager>.Instance.RefreshEnergy(); if (showEnergyModule) { yield return (object)new WaitForSeconds(0.25f); Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0; } } } } [HarmonyPatch] public static class Act3BonesDisplayer { private static ConditionalWeakTable<ResourceDrone, GameObject> _boneTvScreen = new ConditionalWeakTable<ResourceDrone, GameObject>(); private static ConditionalWeakTable<ResourceDrone, SpriteRenderer> _boneCountRenderer = new ConditionalWeakTable<ResourceDrone, SpriteRenderer>(); 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<ResourceDrone>.Instance, out var value)) { return value; } return null; } set { _boneTvScreen.Add(Singleton<ResourceDrone>.Instance, value); } } private static SpriteRenderer BonesCountRenderer { get { if (_boneCountRenderer.TryGetValue(Singleton<ResourceDrone>.Instance, out var value)) { return value; } return null; } set { _boneCountRenderer.Add(Singleton<ResourceDrone>.Instance, value); } } private static Material HoloRefMaterial { get { if (_holoRefMaterial == null) { _holoRefMaterial = CardLoader.GetCardByName("BridgeRailing").holoPortraitPrefab.GetComponentInChildren<Renderer>().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<GameObject>(ResourceBank.Get<GameObject>("Prefabs/CardBattle/CardBattle").GetComponentInChildren<Part1ResourcesManager>().boneTokenPrefab, parent); val.transform.position = parent.position + Vector3.up * 0.25f; Object.Destroy((Object)(object)val.GetComponent<BoneTokenInteractable>()); Rigidbody component = val.GetComponent<Rigidbody>(); component.angularVelocity = new Vector3(0f, 30f, 0f); component.maxAngularVelocity = 30f; component.inertiaTensor = new Vector3(0.2f, 10f, 0.2f); Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(); 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<Renderer>(); 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); } [HarmonyPatch(typeof(ResourcesManager), "ShowAddBones")] [HarmonyPostfix] private static IEnumerator ShowAddBones_Act3(IEnumerator sequence, int amount, CardSlot slot) { PatchPlugin.Logger.LogDebug((object)$"Adding {amount} bones"); if ((Object)(object)BonesTVScreen != (Object)null && amount > 0) { int oldBones = Singleton<ResourcesManager>.Instance.PlayerBones - amount; for (int i = oldBones; i < oldBones + amount; i++) { if ((Object)(object)slot != (Object)null) { GameObject bolt = WeightUtil.SpawnWeight(((Component)slot).transform, ((Component)slot).transform.position + Vector3.up, false, (GameObject)null); CustomCoroutine.WaitThenExecute(1.25f, (Action)delegate { GlitchOutBolt(bolt); }, false); yield return (object)new WaitForSeconds(0.1f); 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); } DisplayBones(i); if ((Object)(object)slot == (Object)null) { AudioController.Instance.PlaySound3D("factory_chest_open", (MixerGroup)4, BonesTVScreen.transform.position, 1f, 0f, new Pitch(0.95f + (float)i * 0.01f), (Repetition)null, (Randomization)null, (Distortion)null, false).spatialBlend = 0.25f; } yield return (object)new WaitForSeconds(0.05f); } DisplayBones(Singleton<ResourcesManager>.Instance.PlayerBones); } else { yield return sequence; } } [HarmonyPatch(typeof(ResourcesManager), "ShowSpendBones")] [HarmonyPostfix] private static IEnumerator ShowSpendBones_Act3(IEnumerator sequence, int amount) { PatchPlugin.Logger.LogDebug((object)$"Spending {amount} bones"); if ((Object)(object)BonesTVScreen != (Object)null && amount > 0) { int visualizedDrop = Mathf.Min(20, amount); int oldBones = Singleton<ResourcesManager>.Instance.PlayerBones + amount; for (int i = oldBones; i > oldBones - visualizedDrop; i--) { DisplayBones(i); AudioController.Instance.PlaySound3D("factory_chest_open", (MixerGroup)4, BonesTVScreen.transform.position, 0.6f, 0f, new Pitch(0.95f + (float)i * 0.01f), (Repetition)null, (Randomization)null, (Distortion)null, false).spatialBlend = 0.25f; yield return (object)new WaitForSeconds(0.05f); } DisplayBones(Singleton<ResourcesManager>.Instance.PlayerBones); } else { yield return sequence; } } [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<GameObject>(((Component)Singleton<SpecialNodeHandler>.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<Renderer>(); 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<Renderer>(); 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<SpriteRenderer>(); ((Renderer)BonesCountRenderer).SetMaterial(Resources.Load<Material>("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<OLDTVScreen>(); 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<OLDTVTube>(); 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 { private static bool HasComponent; [HarmonyPatch(typeof(BoardManager), "Initialize")] [HarmonyPostfix] private static void AddPixelSelectableArray(BoardManager __instance) { if (SaveManager.SaveFile.IsPart2 && (Object)(object)((Component)__instance).GetComponent<PixelPlayableCardArray>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<PixelPlayableCardArray>(); 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<BoardManager>.Instance).GetComponent<PixelPlayableCardArray>(); if (component.displayedCards.Contains(val)) { component.selectedCard = val; } return false; } [HarmonyPatch(typeof(Tutor), "OnResolveOnBoard")] [HarmonyPostfix] private static IEnumerator AddStartDelay(IEnumerator enumerator, Tutor __instance) { if (SaveManager.SaveFile.IsPart2) { yield return (object)new WaitForSeconds(0.15f); if (((AbilityBehaviour)__instance).Card.OpponentCard || Singleton<CardDrawPiles>.Instance.Deck.Cards.Count == 0) { PlayableCard card = ((AbilityBehaviour)__instance).Card; ((Card)((card is PixelPlayableCard) ? card : null)).Anim.NegationEffect(false); yield return (object)new WaitForSeconds(0.25f); yield break; } } yield return enumerator; } [HarmonyPatch(typeof(Deck), "Tutor")] [HarmonyPostfix] private static IEnumerator PixelTutorSequence(IEnumerator enumerator, Deck __instance) { if (!SaveManager.SaveFile.IsPart2) { yield return enumerator; yield break; } if ((Object)(object)((Component)Singleton<BoardManager>.Instance).GetComponent<PixelPlayableCardArray>() == (Object)null) { yield return ((CardDrawPiles)Singleton<PixelCardDrawPiles>.Instance).ChooseDraw(0); yield break; } CardInfo selectedCard = null; yield return ChoosePixelCard(__instance, delegate(CardInfo c) { selectedCard = c; }); if (!((Object)(object)selectedCard == (Object)null)) { yield return Singleton<CardSpawner>.Instance.SpawnCardToHand(selectedCard, 0.25f); } } public static IEnumerator ChoosePixelCard(Deck instance, Action<CardInfo> cardSelectedCallback) { PixelPlayableCard selectedCard = null; yield return ((Component)Singleton<BoardManager>.Instance).GetComponent<PixelPlayableCardArray>().SelectPixelCardFrom(instance.cards, delegate(PixelPlayableCard x) { selectedCard = x; }); Tween.Position(((Component)selectedCard).transform, ((Component)selectedCard).transform.position + Vector3.back * 4f, 0.1f, 0f, Tween.EaseIn, (LoopType)0, (Action)null, (Action)null, true); Object.Destroy((Object)(object)((Component)selectedCard).gameObject, 0.1f); cardSelectedCallback(((Card)selectedCard).Info); } } public class PixelPlayableCardArray : ManagedBehaviour { public PixelPlayableCard selectedCard; public readonly List<PixelPlayableCard> displayedCards = new List<PixelPlayableCard>(); 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; public IEnumerator DisplayUntilCancelled(List<CardInfo> cards, Func<bool> cancelCondition, Action cardsPlacedCallback = null) { cards.RemoveAll((CardInfo x) => (Object)(object)x == (Object)null); currentPageIndex = 0; numPages = 1 + (cards.Count - 1) / (maxCardsPerRow * maxRows); InitializeGamepadGrid(); yield return SpawnAndPlaceCards(cards, GetNumRows(cards.Count), 0, isDeckReview: true); InitialiseButtons(cards, deckReview: true, forPositiveEffect: true); cardsPlacedCallback?.Invoke(); SetCardsEnabled(enabled: true); if (numPages > 1) { ((Component)forwardButton).gameObject.SetActive(true); ((Component)backButton).gameObject.SetActive(true); EnableButtons(enable: true); } yield return (object)new WaitUntil((Func<bool>)(() => cancelCondition())); SetCardsEnabled(enabled: false); yield return CleanUpCards(); CleanUpButtons(); } public IEnumerator SelectPixelCardFrom(List<CardInfo> cards, Action<PixelPlayableCard> cardSelectedCallback, Func<bool> cancelCondition = null, bool forPositiveEffect = true) { cards.RemoveAll((CardInfo x) => (Object)(object)x == (Object)null); currentPageIndex = 0; numPages = 1 + (cards.Count - 1) / (maxCardsPerRow * maxRows); if (cards.Count == 0) { yield break; } if ((Object)(object)gameObjectReference == (Object)null) { PixelPlayableCard[] array = Resources.FindObjectsOfTypeAll<PixelPlayableCard>(); LinqExtensions.Sort<PixelPlayableCard>((IList<PixelPlayableCard>)array, (Comparison<PixelPlayableCard>)((PixelPlayableCard a, PixelPlayableCard b) => ((Card)a).Anim.cardRenderer.sortingGroupOrder - ((Card)b).Anim.cardRenderer.sortingGroupOrder)); gameObjectReference = Object.Instantiate<PixelPlayableCard>(array[0], ((Component)this).transform); ((Object)gameObjectReference).name = "TutorCardObjRef"; ((Component)gameObjectReference).transform.localPosition = new Vector3(-100f, -100f, 0f); Quaternion rotation = ((Component)gameObjectReference).transform.rotation; ((Quaternion)(ref rotation)).Set(0f, 0f, 0f, 0f); } if ((Object)(object)overlay == (Object)null) { GameObject val = GameObjectExtensions.FindChild(PauseMenu.instance.menuParent, "GameFade"); overlay = Object.Instantiate<GameObject>(val, ((Component)this).transform); ((Object)overlay).name = "TutorUIFade"; SpriteRenderer component = overlay.GetComponent<SpriteRenderer>(); ((Renderer)component).sortingLayerID = ((Card)gameObjectReference).Anim.cardRenderer.sortingLayerID; ((Renderer)component).sortingLayerName = ((Card)gameObjectReference).Anim.cardRenderer.sortingLayerName; ((Renderer)component).sortingGroupID = ((Card)gameObjectReference).Anim.cardRenderer.sortingGroupID; ((Renderer)component).sortingOrder = -7000; } InitializeGamepadGrid(); yield return SpawnAndPlaceCards(cards, GetNumRows(cards.Count), 0, isDeckReview: false, forPositiveEffect); InitialiseButtons(cards, deckReview: false, forPositiveEffect); yield return (object)new WaitForSeconds(0.15f); SetCardsEnabled(enabled: true); if (numPages > 1) { ((Component)forwardButton).gameObject.SetActive(true); ((Component)backButton).gameObject.SetActive(true); EnableButtons(enable: true); } selectedCard = null; yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)selectedCard != (Object)null || (cancelCondition != null && cancelCondition()))); SetCardsEnabled(enabled: false); if ((Object)(object)selectedCard != (Object)null) { displayedCards.Remove(selectedCard); } yield return CleanUpCards(); CleanUpButtons(); forwardButton = (backButton = null); if ((Object)(object)selectedCard != (Object)null) { cards.Remove(((Card)selectedCard).Info); cardSelectedCallback?.Invoke(selectedCard); } } private void InitialiseButtons(List<CardInfo> 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<GenericUIButton>(Singleton<HammerButton>.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<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj).CursorSelectStarted, (Action<MainInputInteractable>)delegate { OnChangePage(forwards: true, cards, deckReview, forPositiveEffect); }); backButton = Object.Instantiate<GenericUIButton>(Singleton<HammerButton>.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<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)obj2).CursorSelectStarted, (Action<MainInputInteractable>)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<CardInfo> cards, bool deckReview, bool forPositiveEffect) { EnableButtons(enable: false); SetCardsEnabled(enabled: false); ((MonoBehaviour)this).StartCoroutine(ChangePage(forwards, cards, deckReview, forPositiveEffect)); } private IEnumerator ChangePage(bool forwards, List<CardInfo> cards, bool deckReview, bool forPositiveEffect) { yield return CleanUpCards(); if (forwards) { currentPageIndex = ((currentPageIndex + 1 < numPages) ? (currentPageIndex + 1) : 0); } else { currentPageIndex = ((currentPageIndex - 1 < 0) ? (numPages - 1) : (currentPageIndex - 1)); } yield return SpawnAndPlaceCards(cards, GetNumRows(cards.Count), currentPageIndex, deckReview, forPositiveEffect); SetCardsEnabled(enabled: true); EnableButtons(enable: true); } 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; } protected IEnumerator CleanUpCards() { List<PixelPlayableCard> list = new List<PixelPlayableCard>(displayedCards); foreach (PixelPlayableCard item in list) { if ((Object)(object)item != (Object)null) { Tween.Position(((Component)item).transform, ((Component)item).transform.position + offscreenPositionOffset, 0.1f, 0f, Tween.EaseIn, (LoopType)0, (Action)null, (Action)null, true); ((Card)item).Anim.PlayQuickRiffleSound(); Object.Destroy((Object)(object)((Component)item).gameObject, 0.1f); yield return (object)new WaitForSeconds(CardPile.GetPauseBetweenCardTime(displayedCards.Count) * tweenDurationModifier * 0.5f); } } yield return (object)new WaitForSeconds(0.1f); SetOverlayEnabled(enabled: false); SetBoardEnabled(enabled: true); } protected IEnumerator SpawnAndPlaceCards(List<CardInfo> cards, int numRows, int pageIndex, bool isDeckReview = false, bool forPositiveEffect = true) { SetOverlayEnabled(enabled: true); SetBoardEnabled(enabled: false); displayedCards.ForEach(delegate(PixelPlayableCard x) { if ((Object)(object)x != (Object)null) { Object.Destroy((Object)(object)((Component)x).gameObject); } }); displayedCards.Clear(); if (numRows <= 0) { PatchPlugin.Logger.LogDebug((object)"NumRows for PixelPlayableCardArray is 0, displaying no cards"); yield break; } int num = maxRows * maxCardsPerRow; int startingIndex = num * pageIndex; int cardsPerRow = Mathf.Min(maxCardsPerRow, cards.Count / numRows); int cardsToPlace = Mathf.Min(num, cards.Count - startingIndex); for (int i = startingIndex; i < startingIndex + cardsToPlace; i++) { Vector3 cardPosition = GetCardPosition(i - startingIndex, cardsToPlace, numRows, cardsPerRow); PixelPlayableCard val = CreateAndPlaceCard(cards[i], cardPosition); if ((Object)(object)val == (Object)null) { break; } yield return TriggerSpecialBehaviours(val, isDeckReview, forPositiveEffect); yield return (object)new WaitForSeconds(CardPile.GetPauseBetweenCardTime(cards.Count) * tweenDurationModifier); } } 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<GamepadGridControl>(); gamepadGrid.Rows = new List<Row>(); } gamepadGrid.Rows.Clear(); for (int i = 0; i < maxRows + 1; i++) { gamepadGrid.Rows.Add(new Row(Array.Empty<InteractableBase>())); } ((Behaviour)gamepadGrid).enabled = false; ((Behaviour)gamepadGrid).enabled = true; } private PixelPlayableCard CreateAndPlaceCard(CardInfo info, Vector3 cardPos) { //IL_0098: 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<PixelPlayableCard>(gameObjectReference, ((Component)this).transform); 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; ((Card)val).SetFaceDown(false, true); ((Card)val).SetInfo(info); ((InteractableBase)val).SetEnabled(false); ((Component)val).transform.position = Vector3.zeroVector; gamepadGrid.Rows[0].interactables.Add((InteractableBase)(object)val); displayedCards.Add(val); TweenInCard(((Component)val).transform, cardPos); ((Card)val).Anim.PlayQuickRiffleSound(); return val; } private IEnumerator TriggerSpecialBehaviours(PixelPlayableCard card, bool isDeckReview, bool forPositiveEffect) { SpecialCardBehaviour[] components = ((Component)card).GetComponents<SpecialCardBehaviour>(); SpecialCardBehaviour[] array = components; foreach (SpecialCardBehaviour val in array) { if (isDeckReview) { val.OnShownInDeckReview(); } else { yield return val.OnShownForCardSelect(forPositiveEffect); } } } private void SetOverlayEnabled(bool enabled) { bool flag = false; while (overlay.activeSelf != enabled) { overlay.SetActive(flag); flag = !flag; } } private int GetNumRows(int numCards) { 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<PixelPlayableCard> enumerable = Singleton<BoardManager>.Instance.CardsOnBoard.Concat(Singleton<TurnManager>.Instance.Opponent.queuedCards).Concat(Singleton<PlayerHand>.Instance.CardsInHand).Cast<PixelPlayableCard>(); IEnumerable<HighlightedInteractable> enumerable2 = ((IEnumerable<HighlightedInteractable>)Singleton<BoardManager>.Instance.AllSlots).Concat(Singleton<BoardManager>.Instance.OpponentQueueSlots).Cast<HighlightedInteractable>(); PixelCombatBell val = (PixelCombatBell)Resources.FindObjectsOfTypeAll(typeof(PixelCombatBell)).FirstOrDefault(); if ((int)val != 0) { ((InteractableBase)val).SetEnabled(enabled); } ((Component)Singleton<HammerButton>.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<TurnManager>.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 { [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<BoardManager>.Instance.GetSlots(true)); __instance.UpdateCircuitsForSlots(Singleton<BoardManager>.Instance.GetSlots(false)); return false; } [HarmonyPatch(typeof(PixelActivatedAbilityButton), "ManagedUpdate")] [HarmonyPrefix] private static bool RemovePixelActivatedSpam() { return SceneLoader.ActiveSceneName == "GBC_CardBattle"; } [HarmonyPatch(typeof(TurnManager), "SetupPhase")] [HarmonyPostfix] private static IEnumerator RemoveSetupPhaseSpam(IEnumerator enumerator, TurnManager __instance, EncounterData encounterData) { if ((Object)(object)Singleton<ConduitCircuitManager>.Instance == (Object)null) { ((Component)Singleton<BoardManager>.Instance).gameObject.AddComponent<ConduitCircuitManager>(); } if (!SaveManager.SaveFile.IsPart2) { yield return enumerator; yield break; } __instance.IsSetupPhase = true; Singleton<PlayerHand>.Instance.PlayingLocked = true; if ((Object)(object)__instance.SpecialSequencer != (Object)null) { yield return __instance.SpecialSequencer.PreBoardSetup(); } yield return (object)new WaitForSeconds(0.15f); yield return Singleton<LifeManager>.Instance.Initialize((Object)(object)__instance.SpecialSequencer == (Object)null || __instance.SpecialSequencer.ShowScalesOnStart); ((MonoBehaviour)__instance).StartCoroutine(Singleton<BoardManager>.Instance.Initialize()); ((MonoBehaviour)__instance).StartCoroutine(Singleton<ResourcesManager>.Instance.Setup()); yield return (object)new WaitForSeconds(0.2f); yield return __instance.opponent.IntroSequence(encounterData); ((MonoBehaviour)__instance).StartCoroutine(__instance.PlacePreSetCards(encounterData)); if ((Object)(object)__instance.SpecialSequencer != (Object)null) { yield return __instance.SpecialSequencer.PreDeckSetup(); } Singleton<PlayerHand>.Instance.Initialize(); yield return Singleton<CardDrawPiles>.Instance.Initialize(); if ((Object)(object)__instance.SpecialSequencer != (Object)null) { yield return __instance.SpecialSequencer.PreHandDraw(); } yield return Singleton<CardDrawPiles>.Instance.DrawOpeningHand(__instance.GetFixedHand()); if (__instance.opponent.QueueFirstCardBeforePlayer) { yield return __instance.opponent.QueueNewCards(true, false); } __instance.IsSetupPhase = false; } [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] [HarmonyPostfix] private static IEnumerator RemoveAct2CleanupPhaseSpam(IEnumerator enumerator, TurnManager __instance) { if (!SaveManager.SaveFile.IsPart2) { yield return enumerator; yield break; } __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) { yield return __instance.SpecialSequencer.PreCleanUp(); } Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1; if (__instance.PlayerWon && __instance.PostBattleSpecialNode == null) { Singleton<ViewManager>.Instance.SwitchToView((View)12, false, false); } else { Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false); } yield return (object)new WaitForSeconds(0.1f); ((MonoBehaviour)__instance).StartCoroutine(Singleton<PlayerHand>.Instance.CleanUp()); ((MonoBehaviour)__instance).StartCoroutine(Singleton<CardDrawPiles>.Instance.CleanUp()); yield return __instance.opponent.CleanUp(); yield return __instance.opponent.OutroSequence(__instance.PlayerWon); ((MonoBehaviour)__instance).StartCoroutine(Singleton<BoardManager>.Instance.CleanUp()); ((MonoBehaviour)__instance).StartCoroutine(Singleton<ResourcesManager>.Instance.CleanUp()); yield return Singleton<LifeManager>.Instance.CleanUp(); if ((Object)(object)__instance.SpecialSequencer != (Object)null) { yield return __instance.SpecialSequencer.GameEnd(__instance.PlayerWon); } Object.Destroy((Object)(object)((Component)__instance.opponent).gameObject); Singleton<PlayerHand>.Instance.SetShown(false, false); Object.Destroy((Object)(object)__instance.SpecialSequencer); } [HarmonyPatch(typeof(PlayerHand), "SelectSlotForCard")] [HarmonyPostfix] private static IEnumerator FixSelectSlotSpamInAct2(IEnumerator enumerator, PlayerHand __instance, PlayableCard card) { if (!SaveManager.SaveFile.IsPart2) { yield return enumerator; yield break; } __instance.CardsInHand.ForEach(delegate(PlayableCard x) { ((InteractableBase)x).SetEnabled(false); }); yield return (object)new WaitWhile((Func<bool>)(() => __instance.ChoosingSlot)); __instance.OnSelectSlotStartedForCard(card); Singleton<BoardManager>.Instance.CancelledSacrifice = false; __instance.choosingSlotCard = card; if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Anim != (Object)null) { ((Card)card).Anim.SetSelectedToPlay(true); } Singleton<BoardManager>.Instance.ShowCardNearBoard(card, true); if ((Object)(object)Singleton<TurnManager>.Instance.SpecialSequencer != (Object)null) { yield return Singleton<TurnManager>.Instance.SpecialSequencer.CardSelectedFromHand(card); } bool cardWasPlayed = false; bool requiresSacrifices = ((Card)card).Info.BloodCost > 0; if (requiresSacrifices) { List<CardSlot> list = Singleton<BoardManager>.Instance.PlayerSlotsCopy.FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null); yield return Singleton<BoardManager>.Instance.ChooseSacrificesForCard(list, card); } if (!Singleton<BoardManager>.Instance.CancelledSacrifice) { List<CardSlot> list2 = Singleton<BoardManager>.Instance.PlayerSlotsCopy.FindAll((CardSlot x) => (Object)(object)x.Card == (Object)null); yield return Singleton<BoardManager>.Instance.ChooseSlot(list2, !requiresSacrifices); CardSlot lastSelectedSlot = Singleton<BoardManager>.Instance.LastSelectedSlot; if ((Object)(object)lastSelectedSlot != (Object)null) { cardWasPlayed = true; ((Card)card).Anim.SetSelectedToPlay(false); yield return __instance.PlayCardOnSlot(card, lastSelectedSlot); if (((Card)card).Info.BonesCost > 0) { yield return Singleton<ResourcesManager>.Instance.SpendBones(((Card)card).Info.BonesCost); } if (card.EnergyCost > 0) { yield return Singleton<ResourcesManager>.Instance.SpendEnergy(card.EnergyCost); } } } if (!cardWasPlayed) { Singleton<BoardManager>.Instance.ShowCardNearBoard(card, false); } __instance.choosingSlotCard = null; if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Anim != (Object)null) { ((Card)card).Anim.SetSelectedToPlay(false); } __instance.CardsInHand.ForEach(delegate(PlayableCard x) { ((InteractableBase)x).SetEnabled(true); }); } [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) { if (!SaveManager.SaveFile.IsPart2) { yield return enumerator; } else if ((Object)(object)__instance.scales != (Object)null) { if (changeView) { Singleton<ViewManager>.Instance.SwitchToView(__instance.scalesView, false, false); yield return (object)new WaitForSeconds(0.1f); } yield return __instance.scales.AddDamage(damage, numWeights, toPlayer, alternateWeightPrefab); if (waitBeforeCalcDamage > 0f) { yield return (object)new WaitForSeconds(waitBeforeCalcDamage); } if (toPlayer) { __instance.PlayerDamage += damage; } else { __instance.OpponentDamage += damage; } yield return (object)new WaitForSeconds(waitAfter); } } } public class ActivatedAbilityHandler3D : ManagedBehaviour { public List<AbilityIconInteractable> currentIconGroup; public List<ActivatedAbilityIconInteractable> interactables = new List<ActivatedAbilityIconInteractable>(); public void AddInteractable(ActivatedAbilityIconInteractable interactable) { interactables.Add(interactable); } public void UpdateInteractableList(List<AbilityIconInteractable> controllerActiveIcons) { interactables.Clear(); currentIconGroup = controllerActiveIcons; CollectionExtensions.Do<AbilityIconInteractable>(controllerActiveIcons.Where((AbilityIconInteractable elem) => AbilitiesUtil.GetInfo(elem.Ability).activated), (Action<AbilityIconInteractable>)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<ActivatedAbilityIconInteractable>(); 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>(); activatedAbilityIconInteractable.AssignAbility(abIcon.Ability); AddInteractable(activatedAbilityIconInteractable); } }); if (PatchPlugin.configFullDebug.Value) { PatchPlugin.Logger.LogDebug((object)("[Handler3D] Updated interactable list: [" + GeneralExtensions.Join<ActivatedAbilityIconInteractable>((IEnumerable<ActivatedAbilityIconInteractable>)interactables, (Func<ActivatedAbilityIconInteractable, string>)((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<ActivatedAbilityHandler3D>(); 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<ActivatedAbilityHandler3D>(); } 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<TurnManager>.Instance) && Singleton<TurnManager>.Instance.IsPlayerMainPhase && IsValidPlayableCard && !Singleton<BoardManager>.Instance.ChoosingSacrifices && !Singleton<BoardManager>.Instance.ChoosingSlot) { return Singleton<GlobalTriggerHandler>.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<PlayableCard>(); } 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<Renderer>().material; _originalColor = _renderMaterial.color; ((MainInputInteractable)this).CursorSelectEnded = (Action<MainInputInteractable>)Delegate.Combine(((MainInputInteractable)this).CursorSelectEnded, (Action<MainInputInteractable>)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<GameObject>(((Component)parent.Find($"DefaultIcons_{newSlotNum - 1}Abilities")).gameObject, parent); ((Object)val).name = $"DefaultIcons_{newSlotNum}Abilities"; controller.defaultIconGroups.Add(val); return val; } private static List<Transform> 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<Transform> list = new List<Transform>(); foreach (Transform item2 in newIconGroup.transform) { Transform item = item2; list.Add(item); } GameObject val = Object.Instantiate<GameObject>(((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<CardAbilityIcons>(); 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<Transform> 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<Transform> 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<Transform> 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)