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.23.7.0")] [assembly: AssemblyInformationalVersion("2.23.7+c2c1d85e82ab55ad3b88eceba9182618d37c1e16")] [assembly: AssemblyProduct("InscryptionAPI")] [assembly: AssemblyTitle("InscryptionAPI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.23.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] 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(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(); obj.powerLevel = 0; obj.rulebookName = rulebookName; obj.rulebookDescription = rulebookDescription; obj.metaCategories = new List { (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 IsNonLivingCard = (CardInfo card) => card.traits.Exists((Trait t) => t - 12 <= 1); public static List getNormalCardMetadata = new List { (CardMetaCategory)0, (CardMetaCategory)1 }; public static List getRareCardMetadata = new List { (CardMetaCategory)0, (CardMetaCategory)1, (CardMetaCategory)3 }; public static List getGBCCardMetadata = new List { (CardMetaCategory)4, (CardMetaCategory)5 }; public static List getGBCRareCardMetadata = new List { (CardMetaCategory)4, (CardMetaCategory)5, (CardMetaCategory)3 }; public static List getAllActsCardMetadata = new List { (CardMetaCategory)0, (CardMetaCategory)3, (CardMetaCategory)1, (CardMetaCategory)3, (CardMetaCategory)4, (CardMetaCategory)5, (CardMetaCategory)2 }; public static List getRareAppearance = new List { (Appearance)7 }; public static List getTerrainBackgroundAppearance = new List { (Appearance)2 }; public static List getTerrainLayoutAppearance = new List { (Appearance)9 }; public static List getTerrainAppearance = new List { (Appearance)2, (Appearance)9 }; public static List getHologramAppearance = new List { (Appearance)12 }; public static List getAnimatedAppearance = new List { (Appearance)5 }; public static List getGoldAppearance = new List { (Appearance)6 }; public static List getBloodDecalAppearance = new List { (Appearance)8 }; public static List getDynamicAppearance = new List { (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 cards = new List(); public static Dictionary> abilityIds = new Dictionary>(); public static Dictionary> specialAbilityIds = new Dictionary>(); public static Dictionary evolveIds = new Dictionary(); public static Dictionary iceCubeIds = new Dictionary(); public static Dictionary tailIds = new Dictionary(); public static Dictionary emissions = new Dictionary(); public string name; public List 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 gemsCost; public SpecialStatIcon? specialStatIcon; public List tribes; public List traits; public List specialAbilities; public List abilities; public EvolveParams evolveParams; public string defaultEvolutionName; public TailParams tailParams; public IceCubeParams iceCubeParams; public bool? flipPortraitForStrafe; public bool? onePerDeck; public List 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 decals; [IgnoreMapping] private List abilityIdParam; [IgnoreMapping] private List specialAbilityIdParam; [IgnoreMapping] private EvolveIdentifier evolveId; [IgnoreMapping] private IceCubeIdentifier iceCubeId; [IgnoreMapping] private TailIdentifier tailId; public CustomCard(string name, List abilityIdParam = null, List 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 cards) { CardInfo val = cards.CardByName(this.name); if ((Object)(object)val != (Object)null) { AdjustCard(val, cards); } return cards; }; } public CardInfo AdjustCard(CardInfo card, List cardsToSearch) { TypeMapper.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 { evolveId.mods }); } } if (tailId != null) { CardInfo val2 = cardsToSearch.CardByName(tailId.name); if ((Object)(object)val2 != (Object)null) { Texture2D tailLostTex = tailId.tailLostTex; IEnumerable mods = new List { 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 { iceCubeId.mods }); } } return card; } } [Obsolete("Use RegionManager instead", true)] public class CustomRegion { public string name; public int? tier; public List terrainCards; public List consumableItems; public List encounters; public List bosses; public List likelyCards; public List dominantTribes; public PredefinedNodes predefinedNodes; public EncounterBlueprintData bossPrepEncounter; public StoryEventCondition bossPrepCondition; public List scarceScenery; public List 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 mapParticlesPrefabs; public CustomRegion(string name) { this.name = name; RegionManager.ModifyRegionsList += ModifyRegions; } public List ModifyRegions(List regions) { RegionData val = ((IEnumerable)regions).FirstOrDefault((Func)((RegionData r) => ((Object)r).name.Equals(name))); if ((Object)(object)val != (Object)null) { AdjustRegion(val); } return regions; } public RegionData AdjustRegion(RegionData region) { TypeMapper.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 cards = new List(); public static Dictionary> abilityIds = new Dictionary>(); public static Dictionary> specialAbilityIds = new Dictionary>(); public static Dictionary evolveIds = new Dictionary(); public static Dictionary iceCubeIds = new Dictionary(); public static Dictionary tailIds = new Dictionary(); public static Dictionary emissions = new Dictionary(); public static void Add(CardInfo card, List abilityIdsParam = null, List 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 metaCategories, CardComplexity cardComplexity, CardTemple temple, string description = null, bool hideAttackAndHealth = false, int bloodCost = 0, int bonesCost = 0, int energyCost = 0, List gemsCost = null, SpecialStatIcon specialStatIcon = 0, List tribes = null, List traits = null, List specialAbilities = null, List abilities = null, List abilityIdsParam = null, List specialAbilitiesIdsParam = null, EvolveParams evolveParams = null, string defaultEvolutionName = null, TailParams tailParams = null, IceCubeParams iceCubeParams = null, bool flipPortraitForStrafe = false, bool onePerDeck = false, List appearanceBehaviour = null, Texture2D defaultTex = null, Texture2D altTex = null, Texture titleGraphic = null, Texture2D pixelTex = null, Texture2D emissionTex = null, GameObject animatedPortrait = null, List 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(); 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(decals); } if (evolveId != null) { val.SetEvolve(evolveId.name, evolveId.turnsToEvolve, new List { evolveId.mods }); } if (iceCubeId != null) { val.SetIceCube(iceCubeId.name, new List { iceCubeId.mods }); } if (tailId != null) { string name2 = tailId.name; Texture2D tailLostTex = tailId.tailLostTex; IEnumerable mods = new List { tailId.mods }; val.SetTail(name2, tailLostTex, null, mods); } CardManager.Add(val); } internal static void AssignSpecialAbilities(this CardInfo info, IEnumerable 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 behaviours = new Dictionary(); public static List allBehaviours = new List(); 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 encounters = new List(); public string name; public string regionName; public bool regular; public bool bossPrep; public EncounterBlueprintData encounterBlueprintData; private List SyncRegion(List region) { EncounterBlueprintData curClone = ((IEnumerable)EncounterManager.AllEncountersCopy).FirstOrDefault((Func)((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)region).FirstOrDefault((Func)((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 turnMods = null, List dominantTribes = null, List redundantAbilities = null, List unlockedCardPrerequisites = null, bool regionSpecific = true, int minDifficulty = 0, int maxDifficulty = 30, List randomReplacementCards = null, List> turns = null, bool regular = true, bool bossPrep = false, int oldPreviewDifficulty = 0) { EncounterBlueprintData val = ScriptableObject.CreateInstance(); 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 specialAbilities = new List(); 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(guid, name)); statIconID = GuidManager.GetEnumValue(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 where S : class where D : class { private static Dictionary _accessors; private static Dictionary _setters; private static Dictionary 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(); 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 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(); 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 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.23.7")] [HarmonyPatch] public class InscryptionAPIPlugin : BaseUnityPlugin { public const string ModGUID = "cyantist.inscryption.api"; public const string ModName = "InscryptionAPI"; public const string ModVer = "2.23.7"; public static string Directory; internal static ConfigEntry configOverrideArrows; internal static ConfigEntry configRandomChoiceOrder; internal static ConfigEntry configHideAct1BossScenery; internal static ConfigEntry configCustomTotemTopTypes; internal static ConfigEntry configCustomItemTypes; internal static ManualLogSource Logger; private readonly Harmony HarmonyInstance = new Harmony("cyantist.inscryption.api"); internal static Assembly APIAssembly { get; private set; } public static event Action ScriptableObjectLoaderLoad; static InscryptionAPIPlugin() { Directory = ""; APIAssembly = null; AppDomain.CurrentDomain.AssemblyResolve += (object _, ResolveEventArgs e) => e.Name.StartsWith("API, Version=1") ? (APIAssembly ?? (APIAssembly = 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(APIAssembly); } 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() { if ((object)APIAssembly == null) { APIAssembly = typeof(InscryptionAPIPlugin).Assembly; } configCustomTotemTopTypes = ((BaseUnityPlugin)this).Config.Bind("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("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("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("Miscellaneous", "Randomise Cost Choice Order", false, "When true, randomises the order card cost choices are presented in Act 1."); configHideAct1BossScenery = ((BaseUnityPlugin)this).Config.Bind("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(); 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 { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TriggerReceiver receiver; public IEnumerator triggerCoroutine; private GlobalTriggerHandler 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = Singleton.Instance; if ((Object)(object)5__2 != (Object)null) { GlobalTriggerHandler obj2 = 5__2; obj2.NumTriggersThisBattle += 1; GlobalTriggerHandler obj3 = 5__2; obj3.StackSize += 1; receiver.Activating = true; <>2__current = triggerCoroutine; <>1__state = 1; return true; } break; case 1: { <>1__state = -1; GlobalTriggerHandler obj = 5__2; obj.StackSize -= 1; receiver.Activating = false; if (receiver.DestroyAfterActivation) { receiver.Destroy(); } break; } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__22 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private T <>2__current; private int <>l__initialThreadId; private PlayableCard card; public PlayableCard <>3__card; private IEnumerator <>7__wrap1; T IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = card.TriggerHandler.GetAllReceivers().OfType().GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } if (<>7__wrap1.MoveNext()) { T current = <>7__wrap1.Current; <>2__current = current; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__22 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__22(0); } d__.card = <>3__card; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__23 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private T <>2__current; private int <>l__initialThreadId; private CardTriggerHandler card; public CardTriggerHandler <>3__card; private IEnumerator <>7__wrap1; T IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__23(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = card.GetAllReceivers().OfType().GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } if (<>7__wrap1.MoveNext()) { T current = <>7__wrap1.Current; <>2__current = current; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__23 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__23(0); } d__.card = <>3__card; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardTriggerHandler handler; public Func respond; public Func trigger; private IEnumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; IEnumerable enumerable = handler.FindTriggersOnCard(); <>7__wrap1 = enumerable.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { T current = <>7__wrap1.Current; object obj = current; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(current)) { ref object reference = ref <>2__current; object obj2 = current; reference = ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(current)); <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; public Func respond; public Func trigger; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = card.TriggerHandler.Trigger(respond, trigger); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool triggerFacedown; public Func respond; public Func trigger; private IEnumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; IEnumerable enumerable = FindGlobalTriggers(triggerFacedown); <>7__wrap1 = enumerable.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { T current = <>7__wrap1.Current; object obj = current; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(current)) { ref object reference = ref <>2__current; object obj2 = current; reference = ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(current)); <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; _ = triggerFacedown; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Func respond; public Func trigger; private IEnumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; IEnumerable enumerable = FindTriggersInHand(); <>7__wrap1 = enumerable.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { T current = <>7__wrap1.Current; object obj = current; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(current)) { ref object reference = ref <>2__current; object obj2 = current; reference = ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(current)); <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool triggerFacedown; public Func respond; public Func trigger; private IEnumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; IEnumerable enumerable = FindTriggersOnBoard(triggerFacedown); <>7__wrap1 = enumerable.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { T current = <>7__wrap1.Current; object obj = current; if ((Object)((obj is TriggerReceiver) ? obj : null) != (Object)null && respond(current)) { ref object reference = ref <>2__current; object obj2 = current; reference = ((TriggerReceiver)((obj2 is TriggerReceiver) ? obj2 : null)).CustomTriggerSequence(trigger(current)); <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerator CustomTriggerSequence(this TriggerReceiver receiver, IEnumerator triggerCoroutine) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { receiver = receiver, triggerCoroutine = triggerCoroutine }; } [IteratorStateMachine(typeof(d__1<>))] public static IEnumerator TriggerAll(bool triggerFacedown, Func respond, Func trigger) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { triggerFacedown = triggerFacedown, respond = respond, trigger = trigger }; } [IteratorStateMachine(typeof(d__2<>))] public static IEnumerator Trigger(this CardTriggerHandler handler, Func respond, Func trigger) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { handler = handler, respond = respond, trigger = trigger }; } [IteratorStateMachine(typeof(d__3<>))] public static IEnumerator Trigger(this PlayableCard card, Func respond, Func trigger) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { card = card, respond = respond, trigger = trigger }; } [IteratorStateMachine(typeof(d__4<>))] public static IEnumerator TriggerOnBoard(bool triggerFacedown, Func respond, Func trigger) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { triggerFacedown = triggerFacedown, respond = respond, trigger = trigger }; } [IteratorStateMachine(typeof(d__5<>))] public static IEnumerator TriggerInHand(Func respond, Func trigger) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { respond = respond, trigger = trigger }; } public static List<(TriggerReceiver, T2)> CollectDataAll(bool collectFromFacedown, Func respond, Func collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in FindGlobalTriggers(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(bool collectFromFacedown, Func respond, Func collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in FindTriggersOnBoard(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(Func respond, Func collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in FindTriggersInHand()) { 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(this PlayableCard self, Func respond, Func collect) { return self.TriggerHandler.CollectData(respond, collect); } public static List<(TriggerReceiver, T2)> CollectData(this CardTriggerHandler self, Func respond, Func collect) { List<(TriggerReceiver, T2)> list = new List<(TriggerReceiver, T2)>(); foreach (T item in self.FindTriggersOnCard()) { 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 CallAll(bool triggerFacedown, Func respond, Action call) { List list = new List(); foreach (T item in FindGlobalTriggers(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 CallOnBoard(bool triggerFacedown, Func respond, Action call) { List list = new List(); foreach (T item in FindTriggersOnBoard(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 CallInHand(Func respond, Action call) { List list = new List(); foreach (T item in FindTriggersInHand()) { 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 Call(this PlayableCard self, Func respond, Action call) { return self.TriggerHandler.Call(respond, call); } public static List Call(this CardTriggerHandler self, Func respond, Action call) { List list = new List(); foreach (T item in self.FindTriggersOnCard()) { 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 FindGlobalTriggers(bool findFacedown, PlayableCard excluding = null) { IEnumerable enumerable = Enumerable.Empty(); if (Object.op_Implicit((Object)(object)Singleton.Instance)) { enumerable = enumerable.Concat(FindTriggersOnBoard(findFacedown)); } if (Object.op_Implicit((Object)(object)Singleton.Instance)) { enumerable = enumerable.Concat(FindTriggersInHandExcluding(excluding)); } return enumerable; } public static IEnumerable FindGlobalTriggers(PlayableCard excluding = null) { return FindGlobalTriggers(findFacedown: true, excluding); } public static IEnumerable FindTriggersInHand() { return new List(Singleton.Instance.CardsInHand).Where((PlayableCard c) => (Object)(object)c != (Object)null && c.InHand).SelectMany(FindTriggersOnCard); } public static IEnumerable FindTriggersOnBoard() { return FindTriggersOnBoard(findFacedown: true); } public static IEnumerable FindTriggersOnBoard(bool findFacedown) { List source = new List(Singleton.Instance.CardsOnBoard); List source2 = new List(Singleton.Instance.nonCardReceivers); List source3 = new List(SlotModificationManager.Instance?.SlotReceivers?.Select((KeyValuePair> kvp) => kvp.Value.Item2) ?? Enumerable.Empty()); return (from x in source2 where !UnityExtensions.SafeIsUnityNull((Object)(object)x) where x.TriggerBeforeCards select x).OfType().Concat(source3.Where((SlotModificationBehaviour x) => !UnityExtensions.SafeIsUnityNull((Object)(object)x)).OfType()).Concat(source.Where((PlayableCard x) => (Object)(object)x != (Object)null && x.OnBoard && (!((Card)x).FaceDown || findFacedown)).SelectMany(FindTriggersOnCard)) .Concat((from x in source2 where !UnityExtensions.SafeIsUnityNull((Object)(object)x) where !x.TriggerBeforeCards select x).OfType()) .Concat(from x in source.Where((PlayableCard x) => (Object)(object)x != (Object)null && x.OnBoard && ((Card)x).FaceDown && !findFacedown).SelectMany(FindTriggersOnCard) where x is IActivateWhenFacedown && (x as IActivateWhenFacedown).ShouldTriggerCustomWhenFaceDown(typeof(T)) select x); } public static IEnumerable FindTriggersInHandExcluding(PlayableCard card) { return new List(Singleton.Instance.CardsInHand).Where((PlayableCard x) => (Object)(object)x != (Object)null && x.InHand && (Object)(object)x != (Object)(object)card).SelectMany(FindTriggersOnCard); } [IteratorStateMachine(typeof(d__22<>))] public static IEnumerable FindTriggersOnCard(this PlayableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__22(-2) { <>3__card = card }; } [IteratorStateMachine(typeof(d__23<>))] public static IEnumerable FindTriggersOnCard(this CardTriggerHandler card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__23(-2) { <>3__card = card }; } public static IEnumerable FindTriggersInQueue() { TurnManager instance = Singleton.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(ref val) select ((Component)card).GetComponent()) : null); } if (obj == null) { obj = new T[0]; } return (IEnumerable)obj; } } [HarmonyPatch] internal static class CustomTriggerPatches { [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public PlayableCard card; internal bool b__2(IOnOtherCardAddedToHand x) { return x.RespondsToOtherCardAddedToHand(card); } internal IEnumerator b__3(IOnOtherCardAddedToHand x) { return x.OnOtherCardAddedToHand(card); } } [CompilerGenerated] private sealed class <>c__DisplayClass10_0 { public PlayableCard card; public CardSlot slot2; internal bool b__0(IOnCardAssignedToSlotContext x) { return x.RespondsToCardAssignedToSlotContext(card, slot2, card.Slot); } internal IEnumerator b__1(IOnCardAssignedToSlotContext x) { return x.OnCardAssignedToSlotContext(card, slot2, card.Slot); } internal bool b__2(IOnOtherCardAssignedToSlotInHand x) { return x.RespondsToOtherCardAssignedToSlotInHand(card); } internal IEnumerator b__3(IOnOtherCardAssignedToSlotInHand x) { return x.OnOtherCardAssignedToSlotInHand(card); } internal bool b__4(IOnCardAssignedToSlotNoResolve x) { return x.RespondsToCardAssignedToSlotNoResolve(card); } internal IEnumerator b__5(IOnCardAssignedToSlotNoResolve x) { return x.OnCardAssignedToSlotNoResolve(card); } } [CompilerGenerated] private sealed class <>c__DisplayClass12_0 { public CardSlot slotBeforeDeath; public bool wasSacrifice; public PlayableCard killer; public PlayableCard __instance; public Func <>9__0; public Func <>9__1; public Func <>9__2; public Func <>9__3; internal bool b__0(IOnOtherCardPreDeathInHand x) { return x.RespondsToOtherCardPreDeathInHand(slotBeforeDeath, !wasSacrifice, killer); } internal IEnumerator b__1(IOnOtherCardPreDeathInHand x) { return x.OnOtherCardPreDeathInHand(slotBeforeDeath, !wasSacrifice, killer); } internal bool b__2(IOnOtherCardDieInHand x) { return x.RespondsToOtherCardDieInHand(__instance, slotBeforeDeath, !wasSacrifice, killer); } internal IEnumerator b__3(IOnOtherCardDieInHand x) { return x.OnOtherCardDieInHand(__instance, slotBeforeDeath, !wasSacrifice, killer); } } [CompilerGenerated] private sealed class <>c__DisplayClass13_0 { public string consumableName; public bool itemCanBeUsed; public ConsumableItemSlot __instance; internal bool b__0(IItemCanBeUsed x) { return x.RespondsToItemCanBeUsed(consumableName, itemCanBeUsed); } internal bool b__1(IItemCanBeUsed x) { return itemCanBeUsed = x.CollectItemCanBeUsed(consumableName, itemCanBeUsed); } internal bool b__4(IOnPreItemUsed x) { return x.RespondsToPreItemUsed(consumableName, __instance is HammerItemSlot); } internal IEnumerator b__5(IOnPreItemUsed x) { return x.OnPreItemUsed(consumableName, __instance is HammerItemSlot); } internal bool b__2(IOnItemPreventedFromUse x) { return x.RespondsToItemPreventedFromUse(consumableName); } internal IEnumerator b__3(IOnItemPreventedFromUse x) { return x.OnItemPreventedFromUse(consumableName); } } [CompilerGenerated] private sealed class <>c__DisplayClass13_1 { public bool successInActivation; public <>c__DisplayClass13_0 CS$<>8__locals1; internal bool b__6(IOnPostItemUsed x) { return x.RespondsToPostItemUsed(CS$<>8__locals1.consumableName, successInActivation, CS$<>8__locals1.__instance is HammerItemSlot); } internal IEnumerator b__7(IOnPostItemUsed x) { return x.OnPostItemUsed(CS$<>8__locals1.consumableName, successInActivation, CS$<>8__locals1.__instance is HammerItemSlot); } } [CompilerGenerated] private sealed class <>c__DisplayClass18_0 { public bool playerUpkeep; internal bool b__0(IOnUpkeepInHand x) { return x.RespondsToUpkeepInHand(playerUpkeep); } internal IEnumerator b__1(IOnUpkeepInHand x) { return x.OnUpkeepInHand(playerUpkeep); } } [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public bool playerIsAttacker; internal bool b__0(IOnBellRung x) { return x.RespondsToBellRung(playerIsAttacker); } internal IEnumerator b__1(IOnBellRung x) { return x.OnBellRung(playerIsAttacker); } } [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public CardSlot slot; internal bool b__0(IOnPreSlotAttackSequence x) { return x.RespondsToPreSlotAttackSequence(slot); } internal IEnumerator b__1(IOnPreSlotAttackSequence x) { return x.OnPreSlotAttackSequence(slot); } internal bool b__2(IOnPostSlotAttackSequence x) { return x.RespondsToPostSlotAttackSequence(slot); } internal IEnumerator b__3(IOnPostSlotAttackSequence x) { return x.OnPostSlotAttackSequence(slot); } } [CompilerGenerated] private sealed class <>c__DisplayClass3_0 { public CardSlot attackingSlot; public CardSlot opposingSlot; internal bool b__0(IOnPostSingularSlotAttackSlot x) { return x.RespondsToPostSingularSlotAttackSlot(attackingSlot, opposingSlot); } internal IEnumerator b__1(IOnPostSingularSlotAttackSlot x) { return x.OnPostSingularSlotAttackSlot(attackingSlot, opposingSlot); } } [CompilerGenerated] private sealed class <>c__DisplayClass8_0 { public int damage; public int numWeights; public bool toPlayer; public int initialDamage; public bool initialToPlayer; internal bool b__0(IOnPreScalesChangedRef x) { return x.RespondsToPreScalesChangedRef(damage, numWeights, toPlayer); } internal int b__1(IOnPreScalesChangedRef x) { damage = x.CollectPreScalesChangedRef(damage, ref numWeights, ref toPlayer); if (damage < 0) { damage = -damage; toPlayer = !toPlayer; } return damage; } internal bool b__2(IOnPreScalesChanged x) { return x.RespondsToPreScalesChanged(damage, toPlayer, initialDamage, initialToPlayer); } internal IEnumerator b__3(IOnPreScalesChanged x) { return x.OnPreScalesChanged(damage, toPlayer, initialDamage, initialToPlayer); } internal bool b__4(IOnPostScalesChanged x) { return x.RespondsToPostScalesChanged(damage, toPlayer, initialDamage, initialToPlayer); } internal IEnumerator b__5(IOnPostScalesChanged x) { return x.OnPostScalesChanged(damage, toPlayer, initialDamage, initialToPlayer); } } [CompilerGenerated] private sealed class <>c__DisplayClass9_0 { public PlayableCard card; internal bool b__0(IOnOtherCardResolveInHand x) { return x.RespondsToOtherCardResolveInHand(card); } internal IEnumerator b__1(IOnOtherCardResolveInHand x) { return x.OnOtherCardResolveInHand(card); } } [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool wasSacrifice; public PlayableCard killer; public PlayableCard __instance; public IEnumerator result; private <>c__DisplayClass12_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Invalid comparison between Unknown and I4 //IL_00f5: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass12_0(); <>8__1.wasSacrifice = wasSacrifice; <>8__1.killer = killer; <>8__1.__instance = __instance; <>8__1.slotBeforeDeath = <>8__1.__instance.Slot; break; case 1: { <>1__state = -1; if (!(result.Current.GetType() == triggerType)) { break; } Trigger val = (Trigger)21; try { val = (Trigger)(triggerField ?? (triggerField = triggerType.GetField("trigger"))).GetValue(result.Current); } catch { } if ((int)val == 17) { <>2__current = CustomTriggerFinder.TriggerInHand((IOnOtherCardPreDeathInHand x) => x.RespondsToOtherCardPreDeathInHand(<>8__1.slotBeforeDeath, !<>8__1.wasSacrifice, <>8__1.killer), (IOnOtherCardPreDeathInHand x) => x.OnOtherCardPreDeathInHand(<>8__1.slotBeforeDeath, !<>8__1.wasSacrifice, <>8__1.killer)); <>1__state = 2; return true; } if ((int)val == 11) { <>2__current = CustomTriggerFinder.TriggerInHand((IOnOtherCardDieInHand x) => x.RespondsToOtherCardDieInHand(<>8__1.__instance, <>8__1.slotBeforeDeath, !<>8__1.wasSacrifice, <>8__1.killer), (IOnOtherCardDieInHand x) => x.OnOtherCardDieInHand(<>8__1.__instance, <>8__1.slotBeforeDeath, !<>8__1.wasSacrifice, <>8__1.killer)); <>1__state = 3; return true; } break; } case 2: <>1__state = -1; break; case 3: <>1__state = -1; break; } if (result.MoveNext()) { <>2__current = result.Current; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__13 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ConsumableItemSlot __instance; public IEnumerator result; private <>c__DisplayClass13_1 <>8__1; private Type 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>c__DisplayClass13_0 CS$<>8__locals0 = new <>c__DisplayClass13_0 { __instance = __instance, itemCanBeUsed = true }; ConsumableItemSlot _instance = CS$<>8__locals0.__instance; object consumableName; if (_instance == null) { consumableName = null; } else { ConsumableItem consumable = _instance.Consumable; if (consumable == null) { consumableName = null; } else { ItemData data = ((Item)consumable).Data; consumableName = ((data != null) ? ((Object)data).name : null); } } CS$<>8__locals0.consumableName = (string)consumableName; if (!string.IsNullOrEmpty(CS$<>8__locals0.consumableName)) { CustomTriggerFinder.CollectDataAll(collectFromFacedown: false, (IItemCanBeUsed x) => x.RespondsToItemCanBeUsed(CS$<>8__locals0.consumableName, CS$<>8__locals0.itemCanBeUsed), (IItemCanBeUsed x) => CS$<>8__locals0.itemCanBeUsed = x.CollectItemCanBeUsed(CS$<>8__locals0.consumableName, CS$<>8__locals0.itemCanBeUsed)); } if (CS$<>8__locals0.itemCanBeUsed) { <>8__1 = new <>c__DisplayClass13_1(); <>8__1.CS$<>8__locals1 = CS$<>8__locals0; <>8__1.successInActivation = false; 5__2 = <>8__1.CS$<>8__locals1.__instance.Consumable.ActivateSequence().GetType(); if (!string.IsNullOrEmpty(<>8__1.CS$<>8__locals1.consumableName)) { <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPreItemUsed x) => x.RespondsToPreItemUsed(<>8__1.CS$<>8__locals1.consumableName, <>8__1.CS$<>8__locals1.__instance is HammerItemSlot), (IOnPreItemUsed x) => x.OnPreItemUsed(<>8__1.CS$<>8__locals1.consumableName, <>8__1.CS$<>8__locals1.__instance is HammerItemSlot)); <>1__state = 1; return true; } goto IL_01f3; } ConsumableItemSlot _instance2 = CS$<>8__locals0.__instance; if (_instance2 != null) { ConsumableItem consumable2 = _instance2.Consumable; if (consumable2 != null) { consumable2.PlayShakeAnimation(); } } if (!string.IsNullOrEmpty(CS$<>8__locals0.consumableName)) { <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnItemPreventedFromUse x) => x.RespondsToItemPreventedFromUse(CS$<>8__locals0.consumableName), (IOnItemPreventedFromUse x) => x.OnItemPreventedFromUse(CS$<>8__locals0.consumableName)); <>1__state = 4; return true; } break; } case 1: <>1__state = -1; goto IL_01f3; case 2: <>1__state = -1; if (result.Current.GetType() == 5__2 && !string.IsNullOrEmpty(<>8__1.CS$<>8__locals1.consumableName) && (Object)(object)<>8__1.CS$<>8__locals1.__instance.Consumable != (Object)null) { <>8__1.successInActivation = !<>8__1.CS$<>8__locals1.__instance.Consumable.ActivationCancelled; } goto IL_01f3; case 3: <>1__state = -1; goto IL_0258; case 4: { <>1__state = -1; break; } IL_0258: <>8__1 = null; 5__2 = null; break; IL_01f3: if (result.MoveNext()) { <>2__current = result.Current; <>1__state = 2; return true; } if (!string.IsNullOrEmpty(<>8__1.CS$<>8__locals1.consumableName)) { <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostItemUsed x) => x.RespondsToPostItemUsed(<>8__1.CS$<>8__locals1.consumableName, <>8__1.successInActivation, <>8__1.CS$<>8__locals1.__instance is HammerItemSlot), (IOnPostItemUsed x) => x.OnPostItemUsed(<>8__1.CS$<>8__locals1.consumableName, <>8__1.successInActivation, <>8__1.CS$<>8__locals1.__instance is HammerItemSlot)); <>1__state = 3; return true; } goto IL_0258; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; public IEnumerator result; private <>c__DisplayClass0_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass0_0(); <>8__1.card = card; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = <>8__1.card.TriggerHandler.Trigger((IOnAddedToHand x) => x.RespondsToAddedToHand(), (IOnAddedToHand x) => x.OnAddedToHand()); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnOtherCardAddedToHand x) => x.RespondsToOtherCardAddedToHand(<>8__1.card), (IOnOtherCardAddedToHand x) => x.OnOtherCardAddedToHand(<>8__1.card)); <>1__state = 3; return true; case 3: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool playerIsAttacker; public IEnumerator result; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>c__DisplayClass1_0 CS$<>8__locals0 = new <>c__DisplayClass1_0 { playerIsAttacker = playerIsAttacker }; <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnBellRung x) => x.RespondsToBellRung(CS$<>8__locals0.playerIsAttacker), (IOnBellRung x) => x.OnBellRung(CS$<>8__locals0.playerIsAttacker)); <>1__state = 1; return true; } case 1: <>1__state = -1; <>2__current = result; <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; public IEnumerator result; public bool resolveTriggers; private <>c__DisplayClass10_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass10_0(); <>8__1.card = card; <>8__1.slot2 = <>8__1.card.Slot; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; if (resolveTriggers && (Object)(object)<>8__1.slot2 != (Object)(object)<>8__1.card.Slot) { <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnCardAssignedToSlotContext x) => x.RespondsToCardAssignedToSlotContext(<>8__1.card, <>8__1.slot2, <>8__1.card.Slot), (IOnCardAssignedToSlotContext x) => x.OnCardAssignedToSlotContext(<>8__1.card, <>8__1.slot2, <>8__1.card.Slot)); <>1__state = 2; return true; } goto IL_00e5; case 2: <>1__state = -1; goto IL_00e5; case 3: <>1__state = -1; goto IL_014c; case 4: { <>1__state = -1; break; } IL_014c: if (resolveTriggers && (Object)(object)<>8__1.slot2 != (Object)(object)<>8__1.card.Slot && (Object)(object)<>8__1.slot2 != (Object)null) { <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnCardAssignedToSlotNoResolve x) => x.RespondsToCardAssignedToSlotNoResolve(<>8__1.card), (IOnCardAssignedToSlotNoResolve x) => x.OnCardAssignedToSlotNoResolve(<>8__1.card)); <>1__state = 4; return true; } break; IL_00e5: if (resolveTriggers && (Object)(object)<>8__1.slot2 != (Object)(object)<>8__1.card.Slot) { <>2__current = CustomTriggerFinder.TriggerInHand((IOnOtherCardAssignedToSlotInHand x) => x.RespondsToOtherCardAssignedToSlotInHand(<>8__1.card), (IOnOtherCardAssignedToSlotInHand x) => x.OnOtherCardAssignedToSlotInHand(<>8__1.card)); <>1__state = 3; return true; } goto IL_014c; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__9 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; public IEnumerator result; public bool resolveTriggers; private <>c__DisplayClass9_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass9_0(); <>8__1.card = card; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; if (resolveTriggers) { <>2__current = CustomTriggerFinder.TriggerInHand((IOnOtherCardResolveInHand x) => x.RespondsToOtherCardResolveInHand(<>8__1.card), (IOnOtherCardResolveInHand x) => x.OnOtherCardResolveInHand(<>8__1.card)); <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot attackingSlot; public CardSlot opposingSlot; public IEnumerator result; private <>c__DisplayClass3_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass3_0(); <>8__1.attackingSlot = attackingSlot; <>8__1.opposingSlot = opposingSlot; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostSingularSlotAttackSlot x) => x.RespondsToPostSingularSlotAttackSlot(<>8__1.attackingSlot, <>8__1.opposingSlot), (IOnPostSingularSlotAttackSlot x) => x.OnPostSingularSlotAttackSlot(<>8__1.attackingSlot, <>8__1.opposingSlot)); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int damage; public int numWeights; public bool toPlayer; public IEnumerator result; private <>c__DisplayClass8_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass8_0(); <>8__1.damage = damage; <>8__1.numWeights = numWeights; <>8__1.toPlayer = toPlayer; <>8__1.initialDamage = <>8__1.damage; <>8__1.initialToPlayer = <>8__1.toPlayer; CustomTriggerFinder.CollectDataAll(collectFromFacedown: false, (IOnPreScalesChangedRef x) => x.RespondsToPreScalesChangedRef(<>8__1.damage, <>8__1.numWeights, <>8__1.toPlayer), delegate(IOnPreScalesChangedRef x) { <>8__1.damage = x.CollectPreScalesChangedRef(<>8__1.damage, ref <>8__1.numWeights, ref <>8__1.toPlayer); if (<>8__1.damage < 0) { <>8__1.damage = -<>8__1.damage; <>8__1.toPlayer = !<>8__1.toPlayer; } return <>8__1.damage; }); <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPreScalesChanged x) => x.RespondsToPreScalesChanged(<>8__1.damage, <>8__1.toPlayer, <>8__1.initialDamage, <>8__1.initialToPlayer), (IOnPreScalesChanged x) => x.OnPreScalesChanged(<>8__1.damage, <>8__1.toPlayer, <>8__1.initialDamage, <>8__1.initialToPlayer)); <>1__state = 1; return true; case 1: <>1__state = -1; (scaleChangedDamage ?? (scaleChangedDamage = (scaleChangedCoroutine ?? (scaleChangedCoroutine = result?.GetType()))?.GetField("damage")))?.SetValue(result, <>8__1.damage); (scaleChangedToPlayer ?? (scaleChangedToPlayer = (scaleChangedCoroutine ?? (scaleChangedCoroutine = result?.GetType()))?.GetField("toPlayer")))?.SetValue(result, <>8__1.toPlayer); (scaleChangedNumWeights ?? (scaleChangedNumWeights = (scaleChangedCoroutine ?? (scaleChangedCoroutine = result?.GetType()))?.GetField("numWeights")))?.SetValue(result, <>8__1.numWeights); <>2__current = result; <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostScalesChanged x) => x.RespondsToPostScalesChanged(<>8__1.damage, <>8__1.toPlayer, <>8__1.initialDamage, <>8__1.initialToPlayer), (IOnPostScalesChanged x) => x.OnPostScalesChanged(<>8__1.damage, <>8__1.toPlayer, <>8__1.initialDamage, <>8__1.initialToPlayer)); <>1__state = 3; return true; case 3: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot slot; public IEnumerator result; private <>c__DisplayClass2_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass2_0(); <>8__1.slot = slot; <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPreSlotAttackSequence x) => x.RespondsToPreSlotAttackSequence(<>8__1.slot), (IOnPreSlotAttackSequence x) => x.OnPreSlotAttackSequence(<>8__1.slot)); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = result; <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnPostSlotAttackSequence x) => x.RespondsToPostSlotAttackSequence(<>8__1.slot), (IOnPostSlotAttackSequence x) => x.OnPostSlotAttackSequence(<>8__1.slot)); <>1__state = 3; return true; case 3: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TurnManager __instance; public IEnumerator result; private bool 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = __instance.Opponent.SkipNextTurn; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; if (!5__2) { <>2__current = CustomTriggerFinder.TriggerInHand((IOnTurnEndInHand x) => x.RespondsToTurnEndInHand(playerTurn: false), (IOnTurnEndInHand x) => x.OnTurnEndInHand(playerTurn: false)); <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__19 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = CustomTriggerFinder.TriggerInHand((IOnTurnEndInHand x) => x.RespondsToTurnEndInHand(playerTurn: true), (IOnTurnEndInHand x) => x.OnTurnEndInHand(playerTurn: true)); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__24 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator originalTrigger; public bool playerTurn; private IEnumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = originalTrigger; <>1__state = 1; return true; case 1: <>1__state = -1; <>7__wrap1 = CustomTriggerFinder.FindTriggersInQueue().GetEnumerator(); <>1__state = -3; break; case 2: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { IOnTurnEndInQueue current = <>7__wrap1.Current; if ((Object)((current is TriggerReceiver) ? current : null) != (Object)null && current.RespondsToTurnEndInQueue(playerTurn)) { <>2__current = current.OnTurnEndInQueue(playerTurn); <>1__state = 2; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__18 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool playerUpkeep; public IEnumerator result; private <>c__DisplayClass18_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass18_0(); <>8__1.playerUpkeep = playerUpkeep; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = CustomTriggerFinder.TriggerInHand((IOnUpkeepInHand x) => x.RespondsToUpkeepInHand(<>8__1.playerUpkeep), (IOnUpkeepInHand x) => x.OnUpkeepInHand(<>8__1.playerUpkeep)); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__25 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator sequence; public bool beforeCards; public Trigger trigger; public object[] otherArgs; private List.Enumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = sequence; <>1__state = 1; return true; case 1: { <>1__state = -1; if (!beforeCards) { break; } List list = new List(SlotModificationManager.Instance?.SlotReceivers?.Select((KeyValuePair> kvp) => kvp.Value.Item2) ?? Enumerable.Empty()); <>7__wrap1 = list.GetEnumerator(); <>1__state = -3; goto IL_010d; } case 2: { <>1__state = -3; goto IL_010d; } IL_010d: while (<>7__wrap1.MoveNext()) { SlotModificationBehaviour current = <>7__wrap1.Current; if ((Object)(object)current != (Object)null && GlobalTriggerHandler.ReceiverRespondsToTrigger(trigger, (TriggerReceiver)(object)current, otherArgs)) { <>2__current = Singleton.Instance.TriggerSequence(trigger, (TriggerReceiver)(object)current, otherArgs); <>1__state = 2; return true; } } <>m__Finally1(); break; } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } 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+d__16"); [IteratorStateMachine(typeof(d__0))] [HarmonyPostfix] [HarmonyPatch(typeof(PlayerHand), "AddCardToHand")] private static IEnumerator TriggerOnAddedToHand(IEnumerator result, PlayableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { result = result, card = card }; } [IteratorStateMachine(typeof(d__1))] [HarmonyPostfix] [HarmonyPatch(typeof(CombatPhaseManager), "DoCombatPhase")] private static IEnumerator TriggerOnBellRung(IEnumerator result, bool playerIsAttacker) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { result = result, playerIsAttacker = playerIsAttacker }; } [IteratorStateMachine(typeof(d__2))] [HarmonyPostfix] [HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSequence")] private static IEnumerator TriggerOnSlotAttackSequence(IEnumerator result, CardSlot slot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { result = result, slot = slot }; } [IteratorStateMachine(typeof(d__3))] [HarmonyPostfix] [HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSlot")] private static IEnumerator TriggerOnPostSingularSlotAttackSlot(IEnumerator result, CardSlot attackingSlot, CardSlot opposingSlot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { result = result, attackingSlot = attackingSlot, opposingSlot = opposingSlot }; } [IteratorStateMachine(typeof(d__8))] [HarmonyPostfix] [HarmonyPatch(typeof(LifeManager), "ShowDamageSequence")] private static IEnumerator TriggerOnScalesChanged(IEnumerator result, int damage, int numWeights, bool toPlayer) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { result = result, damage = damage, numWeights = numWeights, toPlayer = toPlayer }; } [IteratorStateMachine(typeof(d__9))] [HarmonyPostfix] [HarmonyPatch(typeof(BoardManager), "ResolveCardOnBoard")] private static IEnumerator TriggerOnOtherCardResolveInHand(IEnumerator result, PlayableCard card, bool resolveTriggers = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { result = result, card = card, resolveTriggers = resolveTriggers }; } [IteratorStateMachine(typeof(d__10))] [HarmonyPostfix] [HarmonyPatch(typeof(BoardManager), "AssignCardToSlot")] private static IEnumerator TriggerOnOtherCardAssignedToSlotInHand(IEnumerator result, PlayableCard card, bool resolveTriggers) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { result = result, card = card, resolveTriggers = resolveTriggers }; } [IteratorStateMachine(typeof(d__12))] [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "Die")] private static IEnumerator TriggerDeathTriggers(IEnumerator result, PlayableCard __instance, bool wasSacrifice, PlayableCard killer = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { result = result, __instance = __instance, wasSacrifice = wasSacrifice, killer = killer }; } [IteratorStateMachine(typeof(d__13))] [HarmonyPatch(typeof(ConsumableItemSlot), "ConsumeItem")] [HarmonyPostfix] private static IEnumerator TriggerItemUse(IEnumerator result, ConsumableItemSlot __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__13(0) { result = result, __instance = __instance }; } [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 __result, ref int __state) { List list = CustomTriggerFinder.FindGlobalTriggers(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(), new List(), 0, didRemoveDefaultSlot: false) - x2.GetTriggerPriority(__instance, OpposingSlotTriggerPriority.ReplacesDefaultOpposingSlot, new List(), new List(), 0, didRemoveDefaultSlot: false)); bool flag = false; bool didRemoveDefaultSlot = false; __state = 1; foreach (ISetupAttackSequence item in list) { if (item.RespondsToModifyAttackSlots(__instance, OpposingSlotTriggerPriority.ReplacesDefaultOpposingSlot, new List(), __result ?? new List(), __state, didRemoveDefaultSlot: false)) { flag = true; __result = item.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.ReplacesDefaultOpposingSlot, new List(), __result ?? new List(), ref __state, ref didRemoveDefaultSlot); didRemoveDefaultSlot = false; } } if (flag) { if (__instance.HasAbility((Ability)24)) { ProgressionData.SetAbilityLearned((Ability)24); __result.Remove(__instance.Slot.opposingSlot); __result.AddRange(Singleton.Instance.GetAdjacentSlots(__instance.Slot.opposingSlot)); } if (__instance.HasTriStrike()) { ProgressionData.SetAbilityLearned((Ability)25); __result.AddRange(Singleton.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); } } else if (__instance.HasAbility((Ability)33)) { __state = Mathf.Max(1, (__instance.OpponentCard ? Singleton.Instance.PlayerSlotsCopy : Singleton.Instance.OpponentSlotsCopy).FindAll((CardSlot x) => (Object)(object)x.Card != (Object)null && !__instance.CanAttackDirectly(x)).Count); } 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 __result, int __state) { List original = new List(__result); CardSlot opposingSlot = __instance.Slot.opposingSlot; bool flag = !__instance.HasTriStrike() && !__instance.HasAbility((Ability)24); bool flag2 = false; List list = new List(); foreach (IGetOpposingSlots item in __instance.FindTriggersOnCard()) { if ((Object)((item is TriggerReceiver) ? item : null) != (Object)null && item.RespondsToGetOpposingSlots()) { list.AddRange(item.GetOpposingSlots(__result, new List(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 list2 = CustomTriggerFinder.FindGlobalTriggers(findFacedown: true).ToList(); list2.RemoveAll((ISetupAttackSequence x) => (Object)((x is TriggerReceiver) ? x : null) == (Object)null); List 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(), __state, didRemoveOriginalSlot)) { __result = item2.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.Normal, original, __result ?? new List(), 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(), __state, didRemoveOriginalSlot)) { __result = item3.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.BringsBackOpposingSlot, original, __result ?? new List(), 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(), __state, didRemoveOriginalSlot)) { __result = item4.CollectModifyAttackSlots(__instance, OpposingSlotTriggerPriority.PostAdditionModification, original, __result ?? new List(), ref __state, ref didRemoveOriginalSlot); } } if (didRemoveOriginalSlot && __instance.HasTriStrike()) { __result.Add(__instance.Slot.opposingSlot); } __result.Sort((CardSlot a, CardSlot b) => a.Index - b.Index); } [IteratorStateMachine(typeof(d__18))] [HarmonyPostfix] [HarmonyPatch(typeof(TurnManager), "DoUpkeepPhase")] private static IEnumerator TriggerOnUpkeepInHand(IEnumerator result, bool playerUpkeep) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0) { result = result, playerUpkeep = playerUpkeep }; } [IteratorStateMachine(typeof(d__19))] [HarmonyPatch(typeof(TurnManager), "PlayerTurn")] [HarmonyPostfix] private static IEnumerator TriggerOnTurnEndInHandPlayer(IEnumerator result) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__19(0) { result = result }; } [IteratorStateMachine(typeof(d__20))] [HarmonyPostfix] [HarmonyPatch(typeof(TurnManager), "OpponentTurn")] private static IEnumerator TriggerOnTurnEndInHandOpponent(IEnumerator result, TurnManager __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0) { result = result, __instance = __instance }; } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable TriggerOnTurnEndInQueuePlayer(IEnumerable instructions) { return TriggerOnTurnEndInQueue(instructions, playerTurn: true); } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable TriggerOnTurnEndInQueueOpponent(IEnumerable instructions) { return TriggerOnTurnEndInQueue(instructions, playerTurn: false); } private static IEnumerable TriggerOnTurnEndInQueue(IEnumerable 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 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; } [IteratorStateMachine(typeof(d__24))] private static IEnumerator TriggerOnTurnEndInQueueCoro(IEnumerator originalTrigger, bool playerTurn) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__24(0) { originalTrigger = originalTrigger, playerTurn = playerTurn }; } [IteratorStateMachine(typeof(d__25))] [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 decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__25(0) { sequence = sequence, beforeCards = beforeCards, trigger = trigger, otherArgs = otherArgs }; } } [HarmonyPatch] public static class DoCombatPhasePatches { [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CombatPhaseManager __instance; public bool playerIsAttacker; public bool attackedWithSquirrel; public SpecialBattleSequencer specialSequencer; private bool 5__2; private int 5__3; private int 5__4; private bool 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (__instance.DamageDealtThisPhase != 0) { 5__2 = ((__instance.DamageDealtThisPhase < 0) ? (!playerIsAttacker) : playerIsAttacker); <>2__current = (object)new WaitForSeconds(0.4f); <>1__state = 1; return true; } break; case 1: <>1__state = -1; <>2__current = __instance.VisualizeDamageMovingToScales(5__2); <>1__state = 2; return true; case 2: { <>1__state = -1; 5__3 = 0; if (playerIsAttacker && __instance.DamageDealtThisPhase > 0) { 5__3 = Singleton.Instance.Balance + __instance.DamageDealtThisPhase - 5; if (attackedWithSquirrel && 5__3 >= 0) { AchievementManager.Unlock((Achievement)14); } 5__3 = Mathf.Max(0, 5__3); } int num = Math.Abs(__instance.DamageDealtThisPhase); 5__4 = num - 5__3; AscensionStatsData.TryIncreaseStat((Type)4, num); if (num >= 666) { AchievementManager.Unlock((Achievement)25); } 5__5 = (Object)(object)specialSequencer == (Object)null || !specialSequencer.PreventDamageAddedToScales; if (5__5) { <>2__current = Singleton.Instance.ShowDamageSequence(5__4, 5__4, !5__2, 0f, (GameObject)null, 0f, true); <>1__state = 3; return true; } goto IL_01b6; } case 3: <>1__state = -1; goto IL_01b6; case 4: <>1__state = -1; goto IL_01f8; case 5: { <>1__state = -1; RunState run = RunState.Run; run.currency += 5__3; <>2__current = __instance.VisualizeExcessLethalDamage(5__3, specialSequencer); <>1__state = 6; return true; } case 6: { <>1__state = -1; break; } IL_01b6: if ((Object)(object)specialSequencer != (Object)null) { <>2__current = specialSequencer.DamageAddedToScale(5__4 + 5__3, 5__2); <>1__state = 4; return true; } goto IL_01f8; IL_01f8: if (5__5 && 5__3 > 0 && Singleton.Instance.Opponent.NumLives == 1 && Singleton.Instance.Opponent.GiveCurrencyOnDefeat) { <>2__current = Singleton.Instance.Opponent.TryRevokeSurrender(); <>1__state = 5; return true; } break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } 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 5__4"; private const string name_CombatCurrent = "System.Object <>2__current"; [IteratorStateMachine(typeof(d__5))] public static IEnumerator NegativeDamageSupport(CombatPhaseManager __instance, bool playerIsAttacker, SpecialBattleSequencer specialSequencer, bool attackedWithSquirrel) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { __instance = __instance, playerIsAttacker = playerIsAttacker, specialSequencer = specialSequencer, attackedWithSquirrel = attackedWithSquirrel }; } public static List ModifyAttackingSlots(bool playerIsAttacker) { List originalSlots = Singleton.Instance.GetSlotsCopy(playerIsAttacker); List list = new List(originalSlots); List list2 = CustomTriggerFinder.FindTriggersOnBoard(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 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 SelfDamage(IEnumerable 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 list = new List(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 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 GetOpposingSlots(List originalSlots, List otherAddedSlots); bool RemoveDefaultAttackSlot(); } public interface ISetupAttackSequence { bool RespondsToModifyAttackSlots(PlayableCard card, OpposingSlotTriggerPriority modType, List originalSlots, List currentSlots, int attackCount, bool didRemoveDefaultSlot); List CollectModifyAttackSlots(PlayableCard card, OpposingSlotTriggerPriority modType, List originalSlots, List currentSlots, ref int attackCount, ref bool didRemoveDefaultSlot); int GetTriggerPriority(PlayableCard card, OpposingSlotTriggerPriority modType, List originalSlots, List 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 originalSlots, List currentSlots); List GetAttackingSlots(bool playerIsAttacker, List originalSlots, List currentSlots); int TriggerPriority(bool playerIsAttacker, List 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); } public interface IPostCardGettingAttacked { bool RespondsToPostCardGettingAttacked(PlayableCard target, PlayableCard attacker); IEnumerator OnPostCardGettingAttacked(PlayableCard target, PlayableCard attacker); int PostCardGettingAttackedPriority(PlayableCard target, PlayableCard attacker); } [HarmonyPatch] public static class SlotAttackSlotPatches { [CompilerGenerated] private sealed class <>c__DisplayClass11_0 { public PlayableCard attacker; public CardSlot opposingSlot; public int damage; internal bool b__0(IOnCardDealtDamageDirectly x) { return x.RespondsToCardDealtDamageDirectly(attacker, opposingSlot, damage); } internal IEnumerator b__1(IOnCardDealtDamageDirectly x) { return x.OnCardDealtDamageDirectly(attacker, opposingSlot, damage); } } [CompilerGenerated] private sealed class <>c__DisplayClass12_0 { public PlayableCard opposingCard; public PlayableCard attacker; internal int b__0(IPostCardGettingAttacked a, IPostCardGettingAttacked b) { return b.PostCardGettingAttackedPriority(opposingCard, attacker) - a.PostCardGettingAttackedPriority(opposingCard, attacker); } } [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard opposingCard; public PlayableCard attacker; private <>c__DisplayClass12_0 <>8__1; private List.Enumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>8__1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass12_0(); <>8__1.opposingCard = opposingCard; <>8__1.attacker = attacker; <>2__current = Singleton.Instance.TriggerCardsOnBoard((Trigger)7, false, new object[1] { <>8__1.opposingCard }); <>1__state = 1; return true; case 1: { <>1__state = -1; List list = CustomTriggerFinder.FindGlobalTriggers(findFacedown: true).ToList(); list.Sort((IPostCardGettingAttacked a, IPostCardGettingAttacked b) => b.PostCardGettingAttackedPriority(<>8__1.opposingCard, <>8__1.attacker) - a.PostCardGettingAttackedPriority(<>8__1.opposingCard, <>8__1.attacker)); <>7__wrap1 = list.GetEnumerator(); <>1__state = -3; break; } case 2: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { IPostCardGettingAttacked current = <>7__wrap1.Current; if (current != null && current.RespondsToPostCardGettingAttacked(<>8__1.opposingCard, <>8__1.attacker)) { <>2__current = current.OnPostCardGettingAttacked(<>8__1.opposingCard, <>8__1.attacker); <>1__state = 2; return true; } } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__11 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard attacker; public CardSlot opposingSlot; private <>c__DisplayClass11_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass11_0(); <>8__1.attacker = attacker; <>8__1.opposingSlot = opposingSlot; <>8__1.damage = CustomFields.Get(<>8__1.attacker, "modifiedAttack"); if (<>8__1.attacker.TriggerHandler.RespondsToTrigger((Trigger)20, new object[1] { <>8__1.damage })) { <>2__current = <>8__1.attacker.TriggerHandler.OnTrigger((Trigger)20, new object[1] { <>8__1.damage }); <>1__state = 1; return true; } goto IL_00e7; case 1: <>1__state = -1; goto IL_00e7; case 2: { <>1__state = -1; return false; } IL_00e7: <>2__current = CustomTriggerFinder.TriggerAll(triggerFacedown: false, (IOnCardDealtDamageDirectly x) => x.RespondsToCardDealtDamageDirectly(<>8__1.attacker, <>8__1.opposingSlot, <>8__1.damage), (IOnCardDealtDamageDirectly x) => x.OnCardDealtDamageDirectly(<>8__1.attacker, <>8__1.opposingSlot, <>8__1.damage)); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private 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"); public static int DamageToDealThisPhase(CardSlot attackingSlot, CardSlot opposingSlot) { int damage; int originalDamage = (damage = attackingSlot.Card.Attack); List list = CustomTriggerFinder.FindGlobalTriggers(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.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; } [IteratorStateMachine(typeof(d__11))] public static IEnumerator TriggerOnDirectDamageTriggers(PlayableCard attacker, CardSlot opposingSlot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0) { attacker = attacker, opposingSlot = opposingSlot }; } [IteratorStateMachine(typeof(d__12))] public static IEnumerator TriggerCardGettingAttackedTriggers(PlayableCard attacker, PlayableCard opposingCard) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { attacker = attacker, opposingCard = opposingCard }; } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable Transpiler(IEnumerable instructions) { List list = new List(instructions); object operand = list.First((CodeInstruction x) => x.opcode == OpCodes.Ldfld && x.operand.ToString() == "DiskCardGame.CombatPhaseManager+<>c__DisplayClass5_0 <>8__1").operand; object operand2 = list.First((CodeInstruction x) => x.opcode == OpCodes.Stfld && x.operand.ToString() == "DiskCardGame.CardSlot attackingSlot").operand; object operand3 = list.First((CodeInstruction x) => x.opcode == OpCodes.Ldfld && x.operand.ToString() == "DiskCardGame.CardSlot opposingSlot").operand; int startIndex = ModifyDirectDamageCheck(list, operand, operand2, operand3); startIndex = CallTriggerOnDirectDamage(list, startIndex, operand, operand2, operand3); OpposingCardNullCheck(list, startIndex, operand3, operand, operand2); return list; } private static void OpposingCardNullCheck(List codes, int start, object opposingSlotOp, object displayClassOp, object attackingSlotOp) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Expected O, but got Unknown int num = 8 + codes.FindIndex(start, (CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "Void SetAnimationPaused(Boolean)"); object obj = null; MethodInfo methodInfo = null; MethodInfo methodInfo2 = AccessTools.Method(typeof(SlotAttackSlotPatches), "TriggerCardGettingAttackedTriggers", new Type[2] { typeof(PlayableCard), typeof(PlayableCard) }, (Type[])null); codes.RemoveRange(num, codes.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Stfld) - num); codes.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(num++, new CodeInstruction(OpCodes.Ldfld, displayClassOp)); codes.Insert(num++, new CodeInstruction(OpCodes.Ldfld, attackingSlotOp)); codes.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)method_GetCard)); codes.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(num++, new CodeInstruction(OpCodes.Ldfld, opposingSlotOp)); codes.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)method_GetCard)); codes.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo2)); methodInfo = (MethodInfo)codes[codes.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Call && x.operand.ToString() == "Boolean op_Inequality(UnityEngine.Object, UnityEngine.Object)")].operand; obj = codes[codes.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Brfalse)].operand; num = 1 + codes.FindIndex(2 + codes.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Ldc_I4_M1), (CodeInstruction x) => x.opcode == OpCodes.Stfld); codes.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(num++, new CodeInstruction(OpCodes.Ldfld, opposingSlotOp)); codes.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)method_GetCard)); codes.Insert(num++, new CodeInstruction(OpCodes.Ldnull, (object)null)); codes.Insert(num++, new CodeInstruction(OpCodes.Call, (object)methodInfo)); codes.Insert(num++, new CodeInstruction(OpCodes.Brfalse, obj)); } private static int CallTriggerOnDirectDamage(List codes, int startIndex, object displayClassOperand, object attackingSlotOperand, object opposingSlotOp) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown int num = codes.FindIndex(startIndex, (CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "DiskCardGame.PlayableCard get_Card()") - 2; codes.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); num += 3; MethodInfo methodInfo = AccessTools.Method(typeof(SlotAttackSlotPatches), "TriggerOnDirectDamageTriggers", new Type[2] { typeof(PlayableCard), typeof(CardSlot) }, (Type[])null); codes.RemoveRange(num, codes.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Ldc_I4_7) - 2 - num); codes.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(num++, new CodeInstruction(OpCodes.Ldfld, opposingSlotOp)); codes.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo)); return num; } private static int ModifyDirectDamageCheck(List codes, object displayClassOperand, object attackingSlotOperand, object opposingSlotOperand) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown int startIndex = codes.FindIndex((CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "Boolean CanAttackDirectly(DiskCardGame.CardSlot)") + 2; MethodInfo methodInfo = AccessTools.Method(typeof(CustomFields), "Set", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(SlotAttackSlotPatches), "DamageToDealThisPhase", new Type[2] { typeof(CardSlot), typeof(CardSlot) }, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(CustomFields), "Get", new Type[2] { typeof(object), typeof(string) }, new Type[1] { typeof(int) }); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldfld, displayClassOperand)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldfld, attackingSlotOperand)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Callvirt, (object)method_GetCard)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldstr, (object)"modifiedAttack")); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldfld, displayClassOperand)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldfld, attackingSlotOperand)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Ldfld, opposingSlotOperand)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo2)); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Box, (object)typeof(int))); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Call, (object)methodInfo)); startIndex = codes.FindIndex(startIndex, (CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "Int32 get_Attack()"); codes[startIndex++] = new CodeInstruction(OpCodes.Ldstr, (object)"modifiedAttack"); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3)); startIndex = codes.FindIndex(startIndex, (CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "Int32 get_Attack()"); codes[startIndex++] = new CodeInstruction(OpCodes.Ldstr, (object)"modifiedAttack"); codes.Insert(startIndex++, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3)); return startIndex; } } [HarmonyPatch] public static class TakeDamagePatches { [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public PlayableCard attacker; public PlayableCard __instance; internal bool b__0(IOnOtherCardDealtDamageInHand x) { return x.RespondsToOtherCardDealtDamageInHand(attacker, attacker.Attack, __instance); } internal IEnumerator b__1(IOnOtherCardDealtDamageInHand x) { return x.OnOtherCardDealtDamageInHand(attacker, attacker.Attack, __instance); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard attacker; public PlayableCard __instance; private <>c__DisplayClass1_0 <>8__1; public int damage; public IEnumerator enumerator; private IEnumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>8__1 = null; <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass1_0(); <>8__1.attacker = attacker; <>8__1.__instance = __instance; <>7__wrap1 = <>8__1.__instance.FindTriggersOnCard().GetEnumerator(); <>1__state = -3; goto IL_00d5; case 1: <>1__state = -3; goto IL_00d5; case 2: <>1__state = -1; if ((Object)(object)<>8__1.__instance == (Object)null) { return false; } if (!<>8__1.__instance.HasShield() && (Object)(object)<>8__1.attacker != (Object)null) { <>2__current = CustomTriggerFinder.TriggerInHand((IOnOtherCardDealtDamageInHand x) => x.RespondsToOtherCardDealtDamageInHand(<>8__1.attacker, <>8__1.attacker.Attack, <>8__1.__instance), (IOnOtherCardDealtDamageInHand x) => x.OnOtherCardDealtDamageInHand(<>8__1.attacker, <>8__1.attacker.Attack, <>8__1.__instance)); <>1__state = 3; return true; } break; case 3: { <>1__state = -1; break; } IL_00d5: while (<>7__wrap1.MoveNext()) { IPreTakeDamage current = <>7__wrap1.Current; if (current.RespondsToPreTakeDamage(<>8__1.attacker, damage)) { <>2__current = current.OnPreTakeDamage(<>8__1.attacker, damage); <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; <>2__current = enumerator; <>1__state = 2; return true; } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string name_Damage = "System.Int32 damage"; private const string name_TriggerHandler = "DiskCardGame.CardTriggerHandler get_TriggerHandler()"; private const string name_CardAttacker = "DiskCardGame.PlayableCard attacker"; [HarmonyPrefix] [HarmonyPatch(typeof(PlayableCard), "TakeDamage")] private static bool AddModifyDamageTrigger(PlayableCard __instance, ref int damage, PlayableCard attacker) { int originalDamage = damage; List list = CustomTriggerFinder.FindGlobalTriggers(findFacedown: true).ToList(); list.Sort((IModifyDamageTaken a, IModifyDamageTaken b) => b.TriggerPriority(__instance, originalDamage, attacker) - a.TriggerPriority(__instance, originalDamage, attacker)); foreach (IModifyDamageTaken item in list) { if (item != null && item.RespondsToModifyDamageTaken(__instance, damage, attacker, originalDamage)) { damage = item.OnModifyDamageTaken(__instance, damage, attacker, originalDamage); } } if (damage < 0) { damage = 0; } return true; } [IteratorStateMachine(typeof(d__1))] [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "TakeDamage")] private static IEnumerator AddTakeDamageTriggers(IEnumerator enumerator, PlayableCard __instance, int damage, PlayableCard attacker) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { enumerator = enumerator, __instance = __instance, damage = damage, attacker = attacker }; } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable TakeDamageTranspiler(IEnumerable instructions) { //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Expected O, but got Unknown //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Expected O, but got Unknown //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Expected O, but got Unknown //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Expected O, but got Unknown //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Expected O, but got Unknown //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Expected O, but got Unknown //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Expected O, but got Unknown //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Expected O, but got Unknown //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Expected O, but got Unknown //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Expected O, but got Unknown //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Expected O, but got Unknown //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Expected O, but got Unknown //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Expected O, but got Unknown List list = new List(instructions); object obj = null; object obj2 = null; object obj3 = null; object obj4 = null; int num = -1; int num2 = -1; for (int i = 0; i < list.Count; i++) { if (num == -1 && list[i].operand?.ToString() == "Boolean HasShield()") { num = i + 2; obj = list[i + 1].operand; } else if (num2 == -1 && list[i].opcode == OpCodes.Br) { num2 = i; } else if (obj2 == null && list[i].operand?.ToString() == "System.Int32 damage") { obj2 = list[i].operand; } else if (obj3 == null && list[i].operand?.ToString() == "DiskCardGame.CardTriggerHandler get_TriggerHandler()" && list[i + 1].opcode == OpCodes.Ldc_I4_8) { i += 10; obj3 = list[i++].operand; list.Insert(i++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i++, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(i++, new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)); list.Insert(i++, new CodeInstruction(OpCodes.Cgt, (object)null)); list.Insert(i++, new CodeInstruction(OpCodes.Brfalse, obj3)); } else { if (!(list[i].operand?.ToString() == "DiskCardGame.PlayableCard attacker")) { continue; } obj4 = list[i].operand; if (num2 > 0) { list.Find((CodeInstruction x) => x.opcode == OpCodes.Switch); object operand = list.Find((CodeInstruction x) => x.opcode == OpCodes.Stfld && x.operand.ToString() == "System.Int32 <>1__state").operand; object operand2 = list.Find((CodeInstruction x) => x.opcode == OpCodes.Stfld && x.operand.ToString() == "System.Object <>2__current").operand; MethodBase methodBase = AccessTools.Method(typeof(ShieldManager), "TriggerBreakShield", new Type[3] { typeof(PlayableCard), typeof(int), typeof(PlayableCard) }, (Type[])null); list.RemoveRange(num, num2 - num); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(num++, new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Cgt, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Brfalse, obj)); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldfld, obj4)); list.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)methodBase)); list.Insert(num++, new CodeInstruction(OpCodes.Stfld, operand2)); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldc_I4_4, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Stfld, operand)); list.Insert(num++, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ret, (object)null)); } break; } } return list; } } } namespace InscryptionAPI.Totems { public class CustomIconTotemTopPiece : CompositeTotemPiece { protected virtual string IconGameObjectName => "Icon"; public override void SetData(ItemData data) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) ((CompositeTotemPiece)this).SetData(data); Texture2D tribeIcon = TribeManager.GetTribeIcon(((TotemTopData)data).prerequisites.tribe); GameObject val = ((Component)this).gameObject.FindChild(IconGameObjectName); if ((Object)(object)val != (Object)null) { base.emissiveRenderer = val.GetComponent(); if ((Object)(object)base.emissiveRenderer != (Object)null) { base.emissiveRenderer.material.mainTexture = (Texture)(object)tribeIcon; } else { InscryptionAPIPlugin.Logger.LogError((object)"Could not find Renderer on Icon GameObject to assign tribe icon!"); } } else { InscryptionAPIPlugin.Logger.LogError((object)"Could not find Icon GameObject to assign tribe icon or emission!"); } } } public static class TotemManager { internal enum TotemTopState { Vanilla, CustomTribes, AllTribes } [HarmonyPatch(typeof(BuildTotemSequencer), "GenerateTotemChoices", new Type[] { typeof(BuildTotemNodeData), typeof(int) })] private class ItemsUtil_AllConsumables { public static IEnumerable Transpiler(IEnumerable instructions) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown if (InscryptionAPIPlugin.configCustomTotemTopTypes.Value == TotemTopState.Vanilla) { return instructions; } List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode == OpCodes.Newobj)) { continue; } int num = i + 1; while (i < list.Count) { if (list[num].opcode == OpCodes.Stloc_0) { MethodInfo methodInfo = AccessTools.Method(typeof(ItemsUtil_AllConsumables), "AddCustomTribesToList", new Type[1] { typeof(List) }, (Type[])null); list.Insert(num + 1, new CodeInstruction(OpCodes.Ldloc_0, (object)null)); list.Insert(num + 2, new CodeInstruction(OpCodes.Call, (object)methodInfo)); return list; } num++; } } return list; } public static void AddCustomTribesToList(List list) { list.AddRange(from x in TribeManager.NewTribes where x.tribeChoice select x.tribe); InscryptionAPIPlugin.Logger.LogDebug((object)$"Total Tribes: {list.Count}"); List cardsWithTribes = CardManager.AllCardsCopy.FindAll((CardInfo x) => x.tribes.Count > 0); list.RemoveAll((Tribe x) => !cardsWithTribes.Exists((CardInfo ci) => ci.IsOfTribe(x))); InscryptionAPIPlugin.Logger.LogDebug((object)$"Tribes with 1 Card: {list.Count}"); } } [HarmonyPatch(typeof(ResourceBank), "Awake", new Type[] { })] private class ResourceBank_Awake { private static void Postfix(ResourceBank __instance) { if ((Object)(object)ResourceBank.Get("Prefabs/Items/TotemPieces/TotemTop_Custom") == (Object)null) { Initialize(); } } } [HarmonyPatch(typeof(Totem), "GetTopPiecePrefab", new Type[] { typeof(TotemTopData) })] private class Totem_GetTopPiecePrefab { private static bool Prefix(TotemTopData data, ref GameObject __result) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (TribeManager.IsCustomTribe(data.prerequisites.tribe)) { __result = totemTops.Find((CustomTotemTop a) => a.Tribe == data.prerequisites.tribe)?.Prefab ?? defaultTotemTop.Prefab; return false; } if (InscryptionAPIPlugin.configCustomTotemTopTypes.Value == TotemTopState.AllTribes) { __result = defaultTotemTop.Prefab; return false; } return true; } } [HarmonyPatch(typeof(Totem), "SetData", new Type[] { typeof(ItemData) })] private class Totem_SetData { private static void Postfix(Totem __instance, ItemData data) { ((Item)((Component)__instance.topPieceParent).GetComponentInChildren()).SetData((ItemData)(object)__instance.TotemItemData.top); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] private class TotemTopData_PrefabId { private static bool Prefix(TotemTopData __instance, ref string __result) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (TribeManager.IsCustomTribe(__instance.prerequisites.tribe)) { if (totemTops.Find((CustomTotemTop a) => a.Tribe == __instance.prerequisites.tribe) == null) { __result = "TotemPieces/TotemTop_Custom"; return false; } } else if (InscryptionAPIPlugin.configCustomTotemTopTypes.Value == TotemTopState.AllTribes) { __result = "TotemPieces/TotemTop_Custom"; return false; } return true; } } [HarmonyPatch] private class FixMissingAbilityInfo { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; Type type = Type.GetType("DiskCardGame.BuildTotemSequencer+<>c, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); <>2__current = AccessTools.Method(type, "b__26_0", (Type[])null, (Type[])null); <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__0(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2); } public static bool Prefix(Ability x, ref bool __result) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!RunState.Run.totemBottoms.Contains(x)) { AbilityInfo info = AbilitiesUtil.GetInfo(x); __result = (Object)(object)info != (Object)null && !info.metaCategories.Contains((AbilityMetaCategory)1); } else { __result = true; } return false; } } [HarmonyPatch] private class FixMissingAbilityInfo2 { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; Type type = Type.GetType("DiskCardGame.BuildTotemSequencer+<>c__DisplayClass26_0, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); <>2__current = AccessTools.Method(type, "b__1", (Type[])null, (Type[])null); <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__0(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2); } private static bool Prefix(Ability x) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)AbilitiesUtil.GetInfo(x) != (Object)null; } } public class CustomTotemTop { public string Name; public string GUID; public Type Type = typeof(CustomIconTotemTopPiece); public GameObject Prefab; public Tribe Tribe; } private const string CustomTotemTopID = "TotemPieces/TotemTop_Custom"; private const string CustomTotemTopResourcePath = "Prefabs/Items/TotemPieces/TotemTop_Custom"; private static CustomTotemTop defaultTotemTop = null; private static readonly List totemTops = new List(); public static readonly ReadOnlyCollection NewTotemTops = new ReadOnlyCollection(totemTops); public static CustomTotemTop DefaultTotemTop => defaultTotemTop; [Obsolete("Deprecated. Use NewTopPiece instead.")] public static CustomTotemTop NewTopPiece(string name, string guid, Tribe tribe, GameObject prefab = null) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Cannot load NewTopPiece for " + guid + "." + name + ". Prefab is null!")); return null; } return Add(new CustomTotemTop { Name = name, GUID = guid, Prefab = prefab, Tribe = tribe }); } public static CustomTotemTop NewTopPiece(string name, string guid, Tribe tribe, GameObject prefab) where T : CompositeTotemPiece { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Cannot load NewTopPiece for " + guid + "." + name + "; prefab is null!")); return null; } return Add(new CustomTotemTop { Name = name, GUID = guid, Type = typeof(T), Prefab = prefab, Tribe = tribe }); } private static CustomTotemTop Add(CustomTotemTop totem) { totemTops.Add(totem); return totem; } [Obsolete("Obsolete. Use SetDefaultTotemTop instead to ensure the totem top is set up correctly.")] public static void SetDefaultTotemTop(GameObject gameObject) { if (defaultTotemTop == null) { InitializeDefaultTotemTop(); } defaultTotemTop.Prefab = gameObject; Object.DontDestroyOnLoad((Object)(object)gameObject); } public static void SetDefaultTotemTop(GameObject gameObject) where T : CompositeTotemPiece { if (defaultTotemTop == null) { InitializeDefaultTotemTop(); } SetupTotemTopPrefab(gameObject, typeof(T)); defaultTotemTop.Prefab = gameObject; } private static void InitializeDefaultTotemTop() { if (AssetBundleHelper.TryGet(TextureHelper.GetResourceBytes("customtotemtop", InscryptionAPIPlugin.APIAssembly), "CustomTotemTop", out GameObject prefab)) { defaultTotemTop = NewTopPiece("DefaultTotemTop", "cyantist.inscryption.api", (Tribe)0, prefab); Object.DontDestroyOnLoad((Object)(object)prefab); } } private static void Initialize() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown if (InscryptionAPIPlugin.configCustomTotemTopTypes.Value == TotemTopState.Vanilla) { return; } if (defaultTotemTop == null) { InitializeDefaultTotemTop(); } foreach (CustomTotemTop totemTop in totemTops) { string path = "Prefabs/Items/TotemPieces/TotemTop_" + ((object)(Tribe)(ref totemTop.Tribe)).ToString(); if (totemTop == defaultTotemTop) { path = "Prefabs/Items/TotemPieces/TotemTop_Custom"; } GameObject prefab = totemTop.Prefab; if ((Object)(object)prefab == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Cannot load NewTopPiece for " + totemTop.GUID + "." + totemTop.Name + ". Prefab is null!")); } else { SetupTotemTopPrefab(prefab, totemTop.Type); ResourceBank.instance.resources.Add(new Resource { path = path, asset = (Object)(object)prefab }); } } } private static void SetupTotemTopPrefab(GameObject prefab, Type scriptType) { if ((Object)(object)prefab.GetComponent() == (Object)null) { prefab.AddComponent(scriptType); } if ((Object)(object)prefab.GetComponent() == (Object)null) { Animator obj = prefab.AddComponent(); obj.runtimeAnimatorController = Resources.Load("animation/items/ItemAnim"); obj.Rebind(); } Object.DontDestroyOnLoad((Object)(object)prefab); } } } namespace InscryptionAPI.TalkingCards { public abstract class CustomPaperTalkingCard : PaperTalkingCard, ITalkingCard { [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CustomPaperTalkingCard <>4__this; public bool forPositiveEffect; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown int num = <>1__state; CustomPaperTalkingCard customPaperTalkingCard = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = customPaperTalkingCard.<>n__0(forPositiveEffect); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public override Speaker SpeakerType => (Speaker)2; public abstract string CardName { get; } public abstract List Emotions { get; } public abstract FaceInfo FaceInfo { get; } public abstract SpecialTriggeredAbility DialogueAbility { get; } public override string OnDrawnFallbackDialogueId => ((TalkingCard)this).OnDrawnDialogueId; [IteratorStateMachine(typeof(d__12))] public override IEnumerator OnShownForCardSelect(bool forPositiveEffect) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this, forPositiveEffect = forPositiveEffect }; } [CompilerGenerated] [DebuggerHidden] private IEnumerator <>n__0(bool forPositiveEffect) { return ((TalkingCard)this).OnShownForCardSelect(forPositiveEffect); } } public abstract class CustomDiskTalkingCard : DiskTalkingCard, ITalkingCard { [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CustomDiskTalkingCard <>4__this; public bool forPositiveEffect; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown int num = <>1__state; CustomDiskTalkingCard customDiskTalkingCard = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = customDiskTalkingCard.<>n__0(forPositiveEffect); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public override Speaker SpeakerType => (Speaker)2; public abstract string CardName { get; } public abstract List Emotions { get; } public abstract FaceInfo FaceInfo { get; } public abstract SpecialTriggeredAbility DialogueAbility { get; } public override string OnDrawnFallbackDialogueId => ((TalkingCard)this).OnDrawnDialogueId; [IteratorStateMachine(typeof(d__12))] public override IEnumerator OnShownForCardSelect(bool forPositiveEffect) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this, forPositiveEffect = forPositiveEffect }; } [CompilerGenerated] [DebuggerHidden] private IEnumerator <>n__0(bool forPositiveEffect) { return ((TalkingCard)this).OnShownForCardSelect(forPositiveEffect); } } internal static class LogHelpers { internal static void LogError(string message) { InscryptionAPIPlugin.Logger.LogError((object)("TalkingCards: " + message)); } internal static void LogInfo(string message) { InscryptionAPIPlugin.Logger.LogInfo((object)("TalkingCards: " + message)); } } public static class TalkingCardManager { public static Sprite EmptyPortrait => GeneratePortrait.EmptyPortrait; public static void New() where T : ITalkingCard, new() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) ITalkingCard talkingCard = new T(); TalkingCardCreator.New(new FaceData(talkingCard.CardName, talkingCard.Emotions, talkingCard.FaceInfo), talkingCard.DialogueAbility); } public static void NewDisk() where T : ITalkingCard, new() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) ITalkingCard talkingCard = new T(); TalkingCardCreator.New(new FaceData(talkingCard.CardName, talkingCard.Emotions, talkingCard.FaceInfo), talkingCard.DialogueAbility, diskTalkingCard: true); } public static void Create(FaceData faceData, SpecialTriggeredAbility ability) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (faceData != null && faceData.CardName != null) { TalkingCardCreator.New(faceData, ability); } } public static void CreateDisk(FaceData faceData, SpecialTriggeredAbility ability, bool diskTalkingCard) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (faceData != null && faceData.CardName != null) { TalkingCardCreator.New(faceData, ability, diskTalkingCard); } } public static void Remove(FaceData faceData) { if (faceData.CardName != null) { TalkingCardCreator.Remove(faceData.CardName); } } } } namespace InscryptionAPI.TalkingCards.Helpers { public static class AssetHelpers { private static readonly Dictionary TextureCache = new Dictionary { { "_", EmptyAndTransparent() } }; public static readonly Vector2 PIVOT_BOTTOM = new Vector2(0.5f, 0f); public static readonly Vector2 PIVOT_CENTER = new Vector2(0.5f, 0.5f); public static string? GetFile(string file) { return Directory.GetFiles(Paths.PluginPath, file, SearchOption.AllDirectories).FirstOrDefault(); } public static Texture2D? MakeTexture(string? path) { if (path == null || path.IsWhiteSpace()) { return null; } if (TextureCache.ContainsKey(path)) { return TextureCache[path]; } string text = (Path.IsPathRooted(path) ? path : GetFile(path)); Texture2D val = ((text == null) ? null : MakeTexture(File.ReadAllBytes(text))); if ((Object)(object)val != (Object)null) { TextureCache.Add(path, val); } return val; } public static Texture2D MakeTexture(byte[] data) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); ImageConversion.LoadImage(val, data); ((Texture)val).filterMode = (FilterMode)0; return val; } public static Sprite? MakeSprite(string? path) { Texture2D val = MakeTexture(path); if (!((Object)(object)val == (Object)null)) { return MakeSprite(val); } return null; } public static Sprite MakeSprite(byte[] data) { return MakeSprite(MakeTexture(data)); } public static Sprite MakeSprite(Texture2D tex) { //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_0026: 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) Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height); Vector2 pIVOT_BOTTOM = PIVOT_BOTTOM; return Sprite.Create(tex, val, pIVOT_BOTTOM); } public static (Sprite?, Sprite?) MakeSpriteTuple((string? a, string? b)? tuple) { Sprite? item = MakeSprite(tuple?.a); Sprite item2 = MakeSprite(tuple?.b); return (item, item2); } public static T? ParseAsEnumValue(string? str) where T : Enum { if (str == null) { return default(T); } object obj = Enum.Parse(typeof(T), str); if (obj == null) { return default(T); } return (T)obj; } public static Color32 HexToColor(string hex) { //IL_0016: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Queue queue = new Queue(hex.Trim()); if (queue.Count == 0) { return default(Color32); } if (queue.Peek() == '#') { queue.Dequeue(); } if (queue.Count < 6) { LogHelpers.LogError("Invalid hexcode: " + hex); return Color32.op_Implicit(Color.white); } byte[] array = new byte[3]; for (int i = 0; i < 3; i++) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(queue.Dequeue()); stringBuilder.Append(queue.Dequeue()); byte b = Convert.ToByte(stringBuilder.ToString(), 16); array[i] = b; } return new Color32(array[0], array[1], array[2], byte.MaxValue); } internal static Texture2D EmptyAndTransparent() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(114, 94); Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); for (int i = 0; i < ((Texture)val).height; i++) { for (int j = 0; j < ((Texture)val).width; j++) { val.SetPixel(j, i, val2); } } val.Apply(); return val; } } internal class CardHelpers { public static CardInfo? Get(string name) { CardManager.SyncCardList(); try { return CardLoader.GetCardByName(name); } catch (Exception) { LogHelpers.LogError("Couldn't find a card of name " + (name ?? "(null)") + "!"); return null; } } } internal static class SpriteExtensions { internal static Sprite PivotBottom(this Sprite sprite) { //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_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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (sprite.pivot == AssetHelpers.PIVOT_BOTTOM) { return sprite; } Rect rect = sprite.rect; return Sprite.Create(sprite.texture, rect, AssetHelpers.PIVOT_BOTTOM); } } public static class StringExtensions { public static string SentenceCase(this string key) { if (string.IsNullOrWhiteSpace(key)) { return string.Empty; } if (key.Length <= 1) { return key.ToUpper(); } return char.ToUpper(key[0]) + key.Substring(1).ToLower(); } public static bool IsWhiteSpace(this string str) { if (str.Length != 0) { return str.All(char.IsWhiteSpace); } return true; } } } namespace InscryptionAPI.TalkingCards.Create { [HarmonyPatch] internal static class ColorManager { private static readonly Dictionary ColorsCache = new Dictionary(); private static readonly Regex ColorRegex = new Regex("^#([0-9a-fA-F]{6})$"); [HarmonyPatch(typeof(DialogueParser), "GetColorFromCode")] [HarmonyPostfix] private static void GetCustomColor(string code, ref Color __result) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) string stringValue = DialogueParser.GetStringValue(code, "c"); if (ColorRegex.IsMatch(stringValue)) { if (ColorsCache.ContainsKey(stringValue)) { __result = ColorsCache[stringValue]; return; } Color val = Color32.op_Implicit(AssetHelpers.HexToColor(stringValue)); ColorsCache.Add(stringValue, val); __result = val; } } } [HarmonyPatch] internal static class CustomVoice { private static readonly List _voices = new List(); public static void RegisterVoice(string filename) { AudioClip val = SoundManager.LoadAudioClip(filename); ((Object)val).name = filename; _voices.Add(val); } [HarmonyPatch(typeof(AudioController), "GetAudioClip")] [HarmonyPrefix] private static void AddVoiceIds(ref List ___SFX) { foreach (AudioClip voice in _voices) { if (!___SFX.Contains(voice)) { ___SFX.Add(voice); } } } } [Serializable] public class DialogueEventStrings { public string eventName { get; set; } public string[] mainLines { get; set; } public string[][] repeatLines { get; set; } public DialogueEventStrings(string eventName, string[] mainLines, string[][] repeatLines) { this.eventName = eventName; this.mainLines = mainLines; this.repeatLines = repeatLines; } public DialogueEvent CreateEvent(string cardName) { return DialogueManager.GenerateEvent("cyantist.inscryption.api", cardName + "_" + eventName, ((IEnumerable)mainLines).Select((Func)((string x) => x)).ToList(), repeatLines.Select((string[] x) => ((IEnumerable)x).Select((Func)((string y) => y)).ToList()).ToList(), (MaxRepeatsBehaviour)0, (Speaker)0); } } [HarmonyPatch] internal static class EmotionManager { public static readonly string[] EmotionNames = Enum.GetNames(typeof(Emotion)); [HarmonyPatch(typeof(SequentialText), "ConsumeCode")] [HarmonyPrefix] private static void CorrectEmotionNames(ref string code) { if (code.StartsWith("[e") && !code.StartsWith("[end")) { string stringValue = DialogueParser.GetStringValue(code, "e"); if (!EmotionNames.Contains(stringValue) && !int.TryParse(stringValue, out var _)) { code = "[e:" + stringValue.SentenceCase() + "]"; } } } } public class FaceData { public string CardName { get; } public List Emotions { get; } public EmotionData Neutral => Emotions.Find((EmotionData x) => (int)x.Emotion == 0); public FaceInfo? FaceInfo { get; set; } public FaceData(string cardName, List emotions, FaceInfo? faceInfo) { CardName = cardName; Emotions = emotions; FaceInfo = faceInfo; } } [Serializable] public class FaceInfo { private static string[] ValidVoiceIds => VoiceManager.ValidVoiceIds; public float? blinkRate { get; set; } public string? voiceId { get; set; } public float? voiceSoundPitch { get; set; } public string? customVoice { get; set; } public FaceInfo(float? blinkRate = null, string? voiceId = null, float? voiceSoundPitch = null, string? customVoice = null) { this.blinkRate = blinkRate; this.voiceId = voiceId; this.voiceSoundPitch = voiceSoundPitch; this.customVoice = customVoice; } internal float GetBlinkRate() { return Mathf.Clamp(blinkRate.GetValueOrDefault(1.5f), 0.1f, 10f); } internal float GetVoicePitch() { return Mathf.Clamp(voiceSoundPitch.GetValueOrDefault(1f), 0.1f, 10f); } private string? CustomVoice() { if (!VoiceManager.Add(customVoice)) { return null; } return customVoice; } internal string GetVoiceId() { string? text = CustomVoice(); if (text == null) { if (voiceId == null || !ValidVoiceIds.Contains(voiceId)) { return ValidVoiceIds.First(); } text = voiceId; } return text; } } public class EmotionData { public Emotion Emotion { get; } public Sprite Face { get; } public FaceAnim Eyes { get; } public FaceAnim Mouth { get; } public FaceAnim Emission { get; } public EmotionData(Emotion emotion, Sprite face, FaceAnim eyes, FaceAnim mouth, FaceAnim emission) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Emotion = emotion; Face = face.PivotBottom(); Eyes = eyes; Mouth = mouth; Emission = emission; } public EmotionData(Emotion emotion, string? face, (string? open, string? closed)? eyes, (string? open, string? closed)? mouth, (string? open, string? closed)? emission) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Emotion = emotion; Face = AssetHelpers.MakeSprite(face) ?? GeneratePortrait.EmptyPortrait; Eyes = (eyes.HasValue ? AssetHelpers.MakeSpriteTuple(eyes) : GeneratePortrait.EmptyPortraitTuple); Mouth = (mouth.HasValue ? AssetHelpers.MakeSpriteTuple(mouth) : GeneratePortrait.EmptyPortraitTuple); Emission = (emission.HasValue ? AssetHelpers.MakeSpriteTuple(emission) : GeneratePortrait.EmptyPortraitTuple); } public EmotionData(string? emotion, string? face, (string? open, string? closed)? eyes, (string? open, string? closed)? mouth, (string? open, string? closed)? emission) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Emotion = AssetHelpers.ParseAsEnumValue(emotion?.SentenceCase()); Face = AssetHelpers.MakeSprite(face) ?? GeneratePortrait.EmptyPortrait; Eyes = (eyes.HasValue ? AssetHelpers.MakeSpriteTuple(eyes) : GeneratePortrait.EmptyPortraitTuple); Mouth = (mouth.HasValue ? AssetHelpers.MakeSpriteTuple(mouth) : GeneratePortrait.EmptyPortraitTuple); Emission = (emission.HasValue ? AssetHelpers.MakeSpriteTuple(emission) : GeneratePortrait.EmptyPortraitTuple); } internal EmotionSprites MakeEmotion() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown return new EmotionSprites { emotion = Emotion, face = Face, eyesOpen = Eyes.Open, eyesClosed = Eyes.Closed, mouthOpen = Mouth.Open, mouthClosed = Mouth.Closed, eyesOpenEmission = Emission.Open, eyesClosedEmission = Emission.Closed }; } public static implicit operator EmotionData((Emotion emotion, Sprite sprite) x) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return new EmotionData(x.emotion, x.sprite, GeneratePortrait.EmptyPortraitTuple, GeneratePortrait.EmptyPortraitTuple, GeneratePortrait.EmptyPortraitTuple); } } public class FaceAnim { public Sprite Open { get; } public Sprite Closed { get; } public FaceAnim(Sprite? open, Sprite? closed) { Open = open?.PivotBottom() ?? GeneratePortrait.EmptyPortrait; Closed = closed?.PivotBottom() ?? GeneratePortrait.EmptyPortrait; } public FaceAnim(string? open, string? closed) { Open = AssetHelpers.MakeSprite(open) ?? GeneratePortrait.EmptyPortrait; Closed = AssetHelpers.MakeSprite(closed) ?? GeneratePortrait.EmptyPortrait; } public static implicit operator Sprite(FaceAnim x) { return x.Closed; } public static implicit operator FaceAnim((Sprite? open, Sprite? closed) x) { return new FaceAnim(x.open, x.closed); } } public interface ITalkingCard { string CardName { get; } List Emotions { get; } FaceInfo FaceInfo { get; } SpecialTriggeredAbility DialogueAbility { get; } } public static class TalkingCardCreator { [HarmonyPatch] private static class Patches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void GetFace(CardInfo __instance, ref GameObject __result) { if (AnimatedPortraits.ContainsKey(((Object)__instance).name)) { __instance.animatedPortrait = AnimatedPortraits[((Object)__instance).name]; __result = AnimatedPortraits[((Object)__instance).name]; } } } internal static Dictionary AnimatedPortraits = new Dictionary(); internal static Dictionary TalkingAbilities = new Dictionary(); internal static List AllDialogueAdded => DialogueDummy.AllDialogueAdded; internal static FaceInfo BasicInfo() { return new FaceInfo(1.5f, "female1_voice", 1f); } internal static void Remove(FaceData faceData) { if (faceData.CardName != null) { Remove(faceData.CardName); } } internal static void Remove(string cardName) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected I4, but got Unknown if (AnimatedPortraits.ContainsKey(cardName)) { CardInfo val = CardHelpers.Get(cardName); if (!((Object)(object)val == (Object)null)) { val.RemoveAppearances((Appearance)5); val.RemoveSpecialAbilities((SpecialTriggeredAbility)(int)TalkingAbilities[cardName]); Object.Destroy((Object)(object)AnimatedPortraits[cardName]); AnimatedPortraits.Remove(cardName); TalkingAbilities.Remove(cardName); } } } internal static void New(FaceData faceData, SpecialTriggeredAbility talkAbility, bool diskTalkingCard) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected I4, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) if (AnimatedPortraits.ContainsKey(faceData.CardName)) { LogHelpers.LogError("An animated portrait has already been added for card '" + faceData.CardName + "'!"); return; } GameObject val = GeneratePortrait.New(); CharacterFace component = val.GetComponent(); component.emotionSprites = faceData.Emotions.Select((EmotionData x) => x.MakeEmotion()).ToList(); FaceInfo faceInfo = faceData.FaceInfo ?? BasicInfo(); component.eyes.blinkRate = faceInfo.GetBlinkRate(); component.voiceSoundId = faceInfo.GetVoiceId(); component.voiceSoundPitch = faceInfo.GetVoicePitch(); CardInfo val2 = CardHelpers.Get(faceData.CardName); if ((Object)(object)val2 == (Object)null) { return; } AnimatedPortraits.Add(faceData.CardName, val); TalkingAbilities.Add(faceData.CardName, talkAbility); val2.AddSpecialAbilities((SpecialTriggeredAbility)(int)talkAbility); if (diskTalkingCard) { val2.AddAppearances((Appearance)10); SpriteRenderer[] componentsInChildren = val2.AnimatedPortrait.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].color = new Color(0f, 0.755f, 1f); } RecursiveSetLayer(val2.AnimatedPortrait, "CardOffscreenEmission"); val2.AnimatedPortrait.transform.localScale = new Vector3(1f, 1f, 1f); val2.AnimatedPortrait.transform.Find("Anim/Body").localPosition = new Vector3(0f, 0.2f, 0f); Object.Instantiate(((Component)CardLoader.GetCardByName("Angler_Talking").AnimatedPortrait.transform.Find("DialogueText")).gameObject, val2.AnimatedPortrait.transform); } else { val2.AddAppearances((Appearance)5); } } internal static void New(FaceData faceData, SpecialTriggeredAbility talkAbility) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 CardInfo? obj = CardHelpers.Get(faceData.CardName); New(faceData, talkAbility, obj != null && (int)obj.temple == 2); } private static void RecursiveSetLayer(GameObject obj, string layerName) { if (!((Object)(object)obj == (Object)null)) { obj.layer = LayerMask.NameToLayer(layerName); for (int i = 0; i < obj.transform.childCount; i++) { Transform child = obj.transform.GetChild(i); RecursiveSetLayer((child != null) ? ((Component)child).gameObject : null, layerName); } } } public static void AddToDialogueCache(string? id) { if (id != null) { AllDialogueAdded.Add(id); } } } [HarmonyPatch] internal static class VoiceManager { private static readonly List Voices = new List(); public static readonly string[] ValidVoiceIds = new string[3] { "female1_voice", "kobold_voice", "cat_voice" }; private static bool IsInvalidVoiceId(string? id) { if (id != null) { return ValidVoiceIds.Contains(id); } return true; } public static bool Add(string? soundPath, string? id) { if (string.IsNullOrWhiteSpace(soundPath)) { return false; } if (IsInvalidVoiceId(soundPath)) { LogHelpers.LogError("Invalid sound path: " + (soundPath ?? "(null)")); return false; } if (IsInvalidVoiceId(id)) { LogHelpers.LogError("Error: Voice ID \"" + (id ?? "(null)") + "\" isn't unique!"); return false; } AudioClip val = SoundManager.LoadAudioClip(soundPath); ((Object)val).name = id ?? soundPath; Voices.Add(val); return true; } public static bool Add(string? path) { return Add(path, path); } [HarmonyPatch(typeof(AudioController), "GetAudioClip")] [HarmonyPrefix] private static void AddVoiceIds(ref List ___SFX) { foreach (AudioClip voice in Voices) { if (!___SFX.Contains(voice)) { ___SFX.Add(voice); } } } } } namespace InscryptionAPI.TalkingCards.Animation { internal class DialogueDummy : PaperTalkingCard { [CompilerGenerated] private sealed class d__30 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DialogueDummy <>4__this; public bool forPositiveEffect; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__30(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown int num = <>1__state; DialogueDummy dialogueDummy = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = dialogueDummy.<>n__0(forPositiveEffect); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static List AllDialogueAdded = new List(); public const string DUMMY = "___dummy"; private static readonly DialogueEvent _dummyEvent = DialogueManager.GenerateEvent("cyantist.inscryption.api", "___dummy", new List(), new List>(), (MaxRepeatsBehaviour)0, (Speaker)0); public override string OnDrawnDialogueId => GetEventForCard("OnDrawn"); public override string OnPlayFromHandDialogueId => GetEventForCard("OnPlayFromHand"); public override string OnAttackedDialogueId => GetEventForCard("OnAttacked"); public override string OnBecomeSelectablePositiveDialogueId => GetEventForCard("OnBecomeSelectablePositive"); public override string OnBecomeSelectableNegativeDialogueId => GetEventForCard("OnBecomeSelectableNegative"); public override string OnSacrificedDialogueId => GetEventForCard("OnSacrificed"); public override string OnSelectedForDeckTrialDialogueId => GetEventForCard("OnSelectedForDeckTrial"); public override string OnSelectedForCardMergeDialogueId => GetEventForCard("OnSelectedForCardMerge"); public override string OnSelectedForCardRemoveDialogueId => GetEventForCard("OnSelectedForCardRemove"); public override string OnDiscoveredInExplorationDialogueId => GetEventForCard("OnDiscoveredInExploration"); public override string OnDrawnFallbackDialogueId { get { string eventForCard = GetEventForCard("OnDrawnFallback"); if (!(eventForCard == "___dummy")) { return eventForCard; } return GetEventForCard("OnDrawn"); } } public override Dictionary OnDrawnSpecialOpponentDialogueIds => new Dictionary { { (Type)3, GetEventForCard("ProspectorBoss") }, { (Type)4, GetEventForCard("AnglerBoss") }, { (Type)6, GetEventForCard("TrapperTraderBoss") }, { (Type)7, GetEventForCard("LeshyBoss") }, { (Type)18, GetEventForCard("RoyalBoss") }, { (Type)0, GetEventForCard("DefaultOpponent") } }; public override Speaker SpeakerType => (Speaker)2; public string GetEventForCard(string eventName) { string text = ((Object)((SpecialCardBehaviour)this).Card.Info).name + "_" + eventName; if (!AllDialogueAdded.Contains(text)) { return "___dummy"; } return text; } [IteratorStateMachine(typeof(d__30))] public override IEnumerator OnShownForCardSelect(bool forPositiveEffect) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__30(0) { <>4__this = this, forPositiveEffect = forPositiveEffect }; } [CompilerGenerated] [DebuggerHidden] private IEnumerator <>n__0(bool forPositiveEffect) { return ((TalkingCard)this).OnShownForCardSelect(forPositiveEffect); } } public static class GeneratePortrait { internal static AssetBundle? PortraitBundle; private static GameObject? FacePrefab; private static Transform? APIPortraits; public const string VoiceId = "female1_voice"; public const float BlinkRate = 1.5f; public const float VoicePitch = 1f; public static SpecialTriggeredAbility DialogueDummy = CreateDummyAbility(); public static readonly Sprite EmptyPortrait = AssetHelpers.MakeSprite(AssetHelpers.EmptyAndTransparent()); public static readonly (Sprite, Sprite) EmptyPortraitTuple = (EmptyPortrait, EmptyPortrait); private static bool hasInit = false; private static void InitTalkingCards() { LoadPrefab(); Portrait(); hasInit = true; } internal static GameObject New() { if (!hasInit) { InitTalkingCards(); } GameObject obj = Object.Instantiate(FacePrefab); Object.DontDestroyOnLoad((Object)(object)obj); obj.transform.SetParent(APIPortraits); return obj; } private static void LoadPrefab() { PortraitBundle = AssetBundle.LoadFromMemory(LoadResource("TalkingCardGenericPrefab")); } private static byte[] LoadResource(string resourceName) { using Stream stream = InscryptionAPIPlugin.APIAssembly.GetManifestResourceStream(resourceName); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } private static SpecialTriggeredAbility CreateDummyAbility() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) return SpecialTriggeredAbilityManager.Add("cyantist.inscryption.api", "TalkingCardAPI_", typeof(DialogueDummy)).Id; } private static void Portrait() { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown FacePrefab = PortraitBundle.LoadAsset("TalkingCardGenericPrefab"); Transform val = FacePrefab.transform.Find("Anim"); Transform val2 = ((Component)val).transform.Find("Body"); Transform val3 = val2.Find("Eyes"); Transform val4 = val2.Find("Mouth"); CharacterFace val5 = FacePrefab.AddComponent(); val5.anim = ((Component)val).gameObject.GetComponent(); val5.eyes = ((Component)val3).gameObject.AddComponent(); val5.mouth = ((Component)val4).gameObject.AddComponent(); val5.face = ((Component)val2).gameObject.GetComponent(); val5.face.sprite = EmptyPortrait; ((Component)val3).GetComponent().sprite = EmptyPortrait; ((Component)val4).GetComponent().sprite = EmptyPortrait; val5.emotionSprites = new List { new EmotionSprites { emotion = (Emotion)0, face = EmptyPortrait, eyesOpen = EmptyPortrait, mouthClosed = EmptyPortrait, eyesClosed = EmptyPortrait, eyesOpenEmission = EmptyPortrait, mouthOpen = EmptyPortrait } }; val5.eyes.blinkRate = 1.5f; val5.voiceSoundId = "female1_voice"; val5.voiceSoundPitch = 1f; int layer = LayerMask.NameToLayer("CardOffscreen"); Transform[] componentsInChildren = FacePrefab.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = layer; } FacePrefab.layer = layer; val5.eyes.emissionRenderer = ((Component)((Component)val5.eyes).transform.Find("Emission")).GetComponent(); ((Component)val5.eyes.emissionRenderer).gameObject.layer = LayerMask.NameToLayer("CardOffscreenEmission"); val5.eyes.emissionRenderer.sprite = EmptyPortrait; GameObject val6 = new GameObject("API_Portraits"); Object.DontDestroyOnLoad((Object)val6); APIPortraits = val6.transform; } } } namespace InscryptionAPI.Sound { [HarmonyPatch] public static class GramophoneManager { internal class TrackInfo { public string FilePath; public string Guid; public AudioClip Clip; public float Volume; public string AudioClipName => Guid + "_" + TrackName; public string TrackName { get { if (!((Object)(object)Clip != (Object)null)) { return Path.GetFileName(FilePath); } return ((Object)Clip).name; } } public TrackInfo(string guid, string filePath, float volume = 1f) { Guid = guid ?? string.Empty; FilePath = filePath; Volume = Mathf.Clamp(volume, 0f, 1f); } public TrackInfo(string guid, AudioClip clip, float volume = 1f) { Guid = guid ?? string.Empty; Clip = clip; Volume = Mathf.Clamp(volume, 0f, 1f); } } private static string APIGuid = "cyantist.inscryption.api"; internal static List NewGramophoneTracks = new List(); internal static List TracksToAdd = new List(); internal static List AlreadyAddedTracks = new List(); internal static int TrackIndex { get { return ModdedSaveManager.SaveData.GetValueAsInt(APIGuid, "GramophoneIndex"); } set { ModdedSaveManager.SaveData.SetValue(APIGuid, "GramophoneIndex", value); } } private static bool noNewTracks => NewGramophoneTracks.Count == 0; private static bool isLeshyCabin { 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(); return ((Scene)(ref activeScene)).name == "Part1_Cabin"; } } private static void InfoLog(string message) { InscryptionAPIPlugin.Logger.LogInfo((object)("GramophoneManager: " + message)); } private static void ErrorLog(string message) { InscryptionAPIPlugin.Logger.LogError((object)("GramophoneManager: " + message)); } public static void AddTrack(string guid, string path, float volume = 1f) { string text = (Path.IsPathRooted(path) ? path : SoundManager.GetAudioPath(path)); if (Utility.IsNullOrWhiteSpace(text)) { ErrorLog("Couldn't load audio track: File '" + (text ?? "(null)") + "' not found!"); return; } TrackInfo item = new TrackInfo(guid, text, volume); TracksToAdd.Add(item); } public static void AddTrack(string guid, AudioClip clip, float volume = 1f) { TrackInfo item = new TrackInfo(guid, clip, volume); TracksToAdd.Add(item); } [HarmonyPatch(typeof(AscensionMenuScreens), "TransitionToGame")] [HarmonyPrefix] private static void LoadGramophoneTracks() { if (TracksToAdd.Count == 0) { return; } List list = TracksToAdd.Where((TrackInfo x) => !AlreadyAddedTracks.Contains(x.AudioClipName)).ToList(); if (list.Count == 0) { return; } foreach (TrackInfo item in list) { AudioClip val = SoundManager.LoadAudioClip(item); if (!((Object)(object)val == (Object)null) && !NewGramophoneTracks.Contains(val)) { NewGramophoneTracks.Add(val); GramophoneInteractable.TRACK_IDS.Add(((Object)val).name); GramophoneInteractable.TRACK_VOLUMES.Add(item.Volume); AlreadyAddedTracks.Add(((Object)val).name); } } } [HarmonyPatch(typeof(AudioController), "GetLoop")] [HarmonyPrefix] private static void PatchGetLoop(List ___Loops) { if (noNewTracks || !isLeshyCabin) { return; } foreach (AudioClip newGramophoneTrack in NewGramophoneTracks) { if (!___Loops.Contains(newGramophoneTrack)) { ___Loops.Add(newGramophoneTrack); } } } [HarmonyPatch(typeof(AudioController), "GetLoopClip")] [HarmonyPrefix] private static void PatchGetLoopClip(List ___Loops) { if (noNewTracks || !isLeshyCabin) { return; } foreach (AudioClip newGramophoneTrack in NewGramophoneTracks) { if (!___Loops.Contains(newGramophoneTrack)) { ___Loops.Add(newGramophoneTrack); } } } [HarmonyPatch(typeof(GramophoneInteractable), "PlaySavedTrack")] [HarmonyPrefix] private static void PatchTrackIndex() { int gramophoneTrackIndex = AscensionSaveData.Data.gramophoneTrackIndex; if (gramophoneTrackIndex < 0 || gramophoneTrackIndex >= GramophoneInteractable.TRACK_IDS.Count) { AscensionSaveData.Data.gramophoneTrackIndex = 0; TrackIndex = 0; } } [HarmonyPatch(typeof(SaveManager), "SaveToFile")] [HarmonyPrefix] private static void PatchSaveToFile_Prefix(ref int __state) { if (!noNewTracks) { __state = AscensionSaveData.Data.gramophoneTrackIndex; TrackIndex = __state; AscensionSaveData.Data.gramophoneTrackIndex = 0; } } [HarmonyPatch(typeof(SaveManager), "SaveToFile")] [HarmonyPostfix] private static void PatchSaveToFile_Postfix(ref int __state) { if (!noNewTracks) { AscensionSaveData.Data.gramophoneTrackIndex = __state; } } [HarmonyPatch(typeof(SaveManager), "LoadFromFile")] [HarmonyPostfix] private static void PatchLoadFromFile() { if (!noNewTracks) { AscensionSaveData.Data.gramophoneTrackIndex = TrackIndex; } } } public static class SoundManager { public static Dictionary AudioTypes = new Dictionary { { ".mp3", (AudioType)13 }, { ".wav", (AudioType)20 }, { ".ogg", (AudioType)14 }, { ".aiff", (AudioType)2 }, { ".aif", (AudioType)2 } }; internal static string GetAudioPath(string filename) { return Directory.GetFiles(Paths.PluginPath, filename, SearchOption.AllDirectories).FirstOrDefault(); } internal static AudioType GetAudioType(string filename) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) string text = Path.GetExtension(filename)?.ToLower(); if (!AudioTypes.ContainsKey(text ?? "")) { return (AudioType)0; } return AudioTypes[text]; } private static void InfoLog(string message) { InscryptionAPIPlugin.Logger.LogInfo((object)("SoundManager: " + message)); } private static void ErrorLog(string message) { InscryptionAPIPlugin.Logger.LogError((object)("SoundManager: " + message)); } public static AudioClip LoadAudioClip(string path) { return LoadAudioClip(string.Empty, path); } internal static AudioClip LoadAudioClip(GramophoneManager.TrackInfo trackInfo) { if ((Object)(object)trackInfo.Clip != (Object)null) { return trackInfo.Clip; } return LoadAudioClip(trackInfo.Guid, trackInfo.FilePath); } public static AudioClip LoadAudioClip(string guid, string path) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!Path.IsPathRooted(path)) { path = GetAudioPath(path); } if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { path = "file://" + path; } string text = Path.GetFileName(path) ?? "(null)"; AudioType audioType = GetAudioType(path); if ((int)audioType == 0) { ErrorLog("Couldn't load file '" + text + "' as AudioClip; AudioType is unknown."); return null; } return LoadAudioClip_Sync(text, path, audioType, guid); } private static AudioClip LoadAudioClip_Sync(string filename, string path, AudioType audioType, string guid = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (guid == null) { guid = string.Empty; } UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, audioType); try { audioClip.SendWebRequest(); while (!audioClip.isDone) { } if (audioClip.isNetworkError || audioClip.isHttpError) { ErrorLog("Couldn't load file '" + filename + "' as AudioClip!"); ErrorLog(audioClip.error); return null; } AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip); if ((Object)(object)content != (Object)null) { ((Object)content).name = guid + "_" + filename; InfoLog($"Loaded '{filename}' as AudioClip. AudioType: {audioType}"); } return content; } finally { ((IDisposable)audioClip)?.Dispose(); } } } } namespace InscryptionAPI.Slots { public abstract class SlotModificationBehaviour : TriggerReceiver { [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public CardSlot Slot => ((Component)this).gameObject.GetComponent(); [IteratorStateMachine(typeof(d__2))] public virtual IEnumerator Setup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0); } [IteratorStateMachine(typeof(d__3))] public virtual IEnumerator Cleanup(SlotModificationManager.ModificationType replacement) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0); } } [HarmonyPatch] public static class SlotModificationExtensions { [CompilerGenerated] private sealed class <>c__DisplayClass7_0 { public SlotModificationBehaviour oldSlotModification; internal void b__1() { Object.Destroy((Object)(object)oldSlotModification); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot slot; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = slot.SetSlotModification(SlotModificationManager.ModificationType.NoModification); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardSlot slot; public SlotModificationManager.ModificationType modType; private <>c__DisplayClass7_0 <>8__1; private SlotModificationManager.Info 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>8__1 = new <>c__DisplayClass7_0(); if ((Object)(object)slot == (Object)null) { return false; } 5__2 = SlotModificationManager.AllModificationInfos.InfoByID(modType); SlotModificationInteractable slotModificationInteractable = ((Component)slot).GetComponent(); if (5__2 == null || modType == SlotModificationManager.ModificationType.NoModification || (5__2.SharedRulebook == SlotModificationManager.ModificationType.NoModification && string.IsNullOrEmpty(5__2.RulebookName))) { Object.Destroy((Object)(object)slotModificationInteractable); } else { if (slotModificationInteractable == null) { slotModificationInteractable = ((Component)slot).gameObject.AddComponent(); } slotModificationInteractable.AssignSlotModification((5__2.SharedRulebook != 0) ? 5__2.SharedRulebook : modType, slot); } <>8__1.oldSlotModification = ((Component)slot).GetComponent(); if ((Object)(object)<>8__1.oldSlotModification != (Object)null) { <>2__current = <>8__1.oldSlotModification.Cleanup(modType); <>1__state = 1; return true; } goto IL_0176; } case 1: <>1__state = -1; CustomCoroutine.WaitOnConditionThenExecute((Func)(() => Singleton.Instance.StackSize == 0), (Action)delegate { Object.Destroy((Object)(object)<>8__1.oldSlotModification); }); SlotModificationManager.Instance.SlotReceivers.Remove(slot); goto IL_0176; case 2: { <>1__state = -1; break; } IL_0176: if (5__2 != null && 5__2.SlotBehaviour != null) { SlotModificationBehaviour slotModificationBehaviour = ((Component)slot).gameObject.AddComponent(5__2.SlotBehaviour) as SlotModificationBehaviour; SlotModificationManager.Instance.SlotReceivers[slot] = new Tuple(modType, slotModificationBehaviour); <>2__current = slotModificationBehaviour.Setup(); <>1__state = 2; return true; } break; } CardTemple valueOrDefault = SaveManager.SaveFile.GetSceneAsCardTemple().GetValueOrDefault(); if (5__2 == null) { slot.ResetSlotTexture(); } else { CardSlot obj = slot; PixelCardSlot val = (PixelCardSlot)(object)((obj is PixelCardSlot) ? obj : null); if (val != null) { val.SetSlotSprite(5__2); } else if (5__2.Texture == null || !5__2.Texture.ContainsKey(valueOrDefault)) { slot.ResetSlotTexture(); } else { slot.SetTexture((Texture)(object)5__2.Texture[valueOrDefault]); } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static SlotModificationManager.Info InfoByID(this IEnumerable modInfos, SlotModificationManager.ModificationType mod) { return modInfos.FirstOrDefault((SlotModificationManager.Info x) => x.ModificationType == mod); } public static SlotModificationManager.ModificationType SetRulebook(this SlotModificationManager.ModificationType mod, string rulebookName, string rulebookDescription, Texture2D rulebookSprite, params SlotModificationManager.ModificationMetaCategory[] categories) { SlotModificationManager.Info info = SlotModificationManager.AllSlotModifications.InfoByID(mod); if (info != null) { info.RulebookName = rulebookName; info.RulebookDescription = rulebookDescription; info.RulebookSprite = rulebookSprite.ConvertTexture(); foreach (SlotModificationManager.ModificationMetaCategory item in categories) { if (!info.MetaCategories.Contains(item)) { info.MetaCategories.Add(item); } } } return mod; } public static SlotModificationManager.ModificationType SetRulebookP03Sprite(this SlotModificationManager.ModificationType mod, Texture2D spriteTexture) { SlotModificationManager.Info info = SlotModificationManager.AllSlotModifications.InfoByID(mod); if (info != null) { info.P03RulebookSprite = spriteTexture.ConvertTexture(); } return mod; } public static SlotModificationManager.ModificationType SetRulebookGrimoraSprite(this SlotModificationManager.ModificationType mod, Texture2D spriteTexture) { SlotModificationManager.Info info = SlotModificationManager.AllSlotModifications.InfoByID(mod); if (info != null) { info.GrimoraRulebookSprite = spriteTexture.ConvertTexture(); } return mod; } public static SlotModificationManager.ModificationType SetRulebookMagnificusSprite(this SlotModificationManager.ModificationType mod, Texture2D spriteTexture) { SlotModificationManager.Info info = SlotModificationManager.AllSlotModifications.InfoByID(mod); if (info != null) { info.MagnificusRulebookSprite = spriteTexture.ConvertTexture(); } return mod; } public static SlotModificationManager.ModificationType SetSharedRulebook(this SlotModificationManager.ModificationType mod, SlotModificationManager.ModificationType sharedRulebookType) { SlotModificationManager.Info info = SlotModificationManager.AllSlotModifications.InfoByID(mod); if (info != null) { info.SharedRulebook = sharedRulebookType; } return mod; } [IteratorStateMachine(typeof(d__6))] public static IEnumerator ClearSlotModification(this CardSlot slot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { slot = slot }; } [IteratorStateMachine(typeof(d__7))] public static IEnumerator SetSlotModification(this CardSlot slot, SlotModificationManager.ModificationType modType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { slot = slot, modType = modType }; } public static SlotModificationManager.ModificationType GetSlotModification(this CardSlot slot) { if (!((Object)(object)slot == (Object)null)) { if (!SlotModificationManager.Instance.SlotReceivers.ContainsKey(slot)) { return SlotModificationManager.ModificationType.NoModification; } return SlotModificationManager.Instance.SlotReceivers[slot].Item1; } return SlotModificationManager.ModificationType.NoModification; } private static void SetSlotSprite(this PixelCardSlot slot, SlotModificationManager.Info defn) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) if (defn == null) { InscryptionAPIPlugin.Logger.LogDebug((object)$"Resetting slot {((CardSlot)slot).Index} to default because mod info was null"); slot.ResetSlotSprite(); return; } if (defn.PixelBoardSlotSprites == null) { InscryptionAPIPlugin.Logger.LogDebug((object)$"Resetting slot {((CardSlot)slot).Index} to default because mod info did not contain pixel slot info"); slot.ResetSlotSprite(); return; } CachedGCBNPCDescriptor cachedGCBNPCDescriptor = GBCEncounterManager.Instance?.GetTriggeringNPC(); if (cachedGCBNPCDescriptor == null) { InscryptionAPIPlugin.Logger.LogDebug((object)$"Doing nothing to slot {((CardSlot)slot).Index} because the triggering NPC was null"); return; } if (!defn.PixelBoardSlotSprites.ContainsKey(cachedGCBNPCDescriptor.BattleBackgroundTheme)) { InscryptionAPIPlugin.Logger.LogDebug((object)$"Resetting slot {((CardSlot)slot).Index} to default because pixel slot info did not contain a definition for {cachedGCBNPCDescriptor.BattleBackgroundTheme}"); slot.ResetSlotSprite(); return; } BoardThemeSpriteSet val = defn.PixelBoardSlotSprites[cachedGCBNPCDescriptor.BattleBackgroundTheme]; if (val == null) { InscryptionAPIPlugin.Logger.LogDebug((object)$"Resetting slot {((CardSlot)slot).Index} to default because pixel slot info had a null definition for {cachedGCBNPCDescriptor.BattleBackgroundTheme}"); slot.ResetSlotSprite(); return; } SpecificSlotSprites val2 = val.specificSlotSprites.Find((SpecificSlotSprites s) => s.playerSlot == ((CardSlot)slot).IsPlayerSlot && s.index == ((CardSlot)slot).Index); if (val2 == null) { slot.SetSprites(val.slotDefault, val.slotHighlight, ((CardSlot)slot).IsPlayerSlot && val.flipPlayerSlotSpriteY, false); } else { slot.SetSprites(val2.slotDefault, val2.slotHighlight, ((CardSlot)slot).IsPlayerSlot && val.flipPlayerSlotSpriteY, false); } } private static void ResetSlotSprite(this PixelCardSlot slot) { CachedGCBNPCDescriptor triggeringNPC = GBCEncounterManager.Instance?.GetTriggeringNPC(); if (triggeringNPC == null) { return; } BoardThemeSpriteSet val = Singleton.Instance.themeSpriteSets.Find((BoardThemeSpriteSet s) => s.id == triggeringNPC.BattleBackgroundTheme); if (val != null) { SpecificSlotSprites val2 = val.specificSlotSprites.Find((SpecificSlotSprites s) => s.playerSlot == ((CardSlot)slot).IsPlayerSlot && s.index == ((CardSlot)slot).Index); if (val2 != null) { slot.SetSprites(val2.slotDefault, val2.slotHighlight, ((CardSlot)slot).IsPlayerSlot && val.flipPlayerSlotSpriteY, false); } else { slot.SetSprites(val.slotDefault, val.slotHighlight, ((CardSlot)slot).IsPlayerSlot && val.flipPlayerSlotSpriteY, false); } } } public static void ResetSlotTexture(this CardSlot slot) { //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) PixelCardSlot val = (PixelCardSlot)(object)((slot is PixelCardSlot) ? slot : null); if (val != null) { val.ResetSlotSprite(); return; } CardTemple valueOrDefault = SaveManager.SaveFile.GetSceneAsCardTemple().GetValueOrDefault(); Dictionary> dictionary = (slot.IsOpponentSlot() ? SlotModificationManager.OpponentOverrideSlots : SlotModificationManager.PlayerOverrideSlots); Texture texture = SlotModificationManager.DefaultSlotTextures[valueOrDefault]; if (dictionary.ContainsKey(valueOrDefault)) { List list = dictionary[valueOrDefault]; int num = slot.Index; if (num >= list.Count) { int count = Singleton.Instance.PlayerSlotsCopy.Count; num = ((slot.Index != count - 1) ? (list.Count - 2) : (list.Count - 1)); } if (num < 0) { num = 0; } if ((Object)(object)list[num] != (Object)null) { texture = list[num]; } } slot.SetTexture(texture); } } public abstract class SlotModificationGainAbilityBehaviour : SlotModificationBehaviour { [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SlotModificationGainAbilityBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown int num = <>1__state; SlotModificationGainAbilityBehaviour slotModificationGainAbilityBehaviour = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)slotModificationGainAbilityBehaviour.Slot.Card != (Object)null) { CardModificationInfo slotAbilityMod = slotModificationGainAbilityBehaviour.GetSlotAbilityMod(slotModificationGainAbilityBehaviour.Slot.Card); if (slotAbilityMod != null) { slotModificationGainAbilityBehaviour.Slot.Card.RemoveTemporaryMod(slotAbilityMod, true); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } } break; case 1: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard otherCard; public SlotModificationGainAbilityBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown int num = <>1__state; SlotModificationGainAbilityBehaviour slotModificationGainAbilityBehaviour = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; if ((Object)(object)otherCard == (Object)null || (Object)(object)otherCard.Slot == (Object)null) { return false; } bool flag = (Object)(object)slotModificationGainAbilityBehaviour.Slot.Card == (Object)(object)otherCard; CardModificationInfo slotAbilityMod = slotModificationGainAbilityBehaviour.GetSlotAbilityMod(otherCard); if (flag && slotAbilityMod == null) { slotAbilityMod = slotModificationGainAbilityBehaviour.GetSlotAbilityMod(otherCard, create: true); otherCard.AddTemporaryMod(slotAbilityMod); Singleton.Instance.ForceGemsUpdate(); } if (!flag && slotAbilityMod != null) { otherCard.RemoveTemporaryMod(slotAbilityMod, true); Singleton.Instance.ForceGemsUpdate(); } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SlotModificationGainAbilityBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown int num = <>1__state; SlotModificationGainAbilityBehaviour slotModificationGainAbilityBehaviour = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)slotModificationGainAbilityBehaviour.Slot.Card != (Object)null) { CardModificationInfo slotAbilityMod = slotModificationGainAbilityBehaviour.GetSlotAbilityMod(slotModificationGainAbilityBehaviour.Slot.Card); if (slotAbilityMod == null) { slotModificationGainAbilityBehaviour.Slot.Card.RemoveTemporaryMod(slotAbilityMod, true); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } } break; case 1: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } protected abstract Ability AbilityToGain { get; } private string TemporaryModId => $"SlotModification{AbilityToGain}{base.Slot.IsPlayerSlot}{base.Slot.Index}"; private CardModificationInfo GetSlotAbilityMod(PlayableCard card, bool create = false) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown if (card.temporaryMods == null) { card.temporaryMods = new List(); } CardModificationInfo val = ((IEnumerable)card.TemporaryMods).FirstOrDefault((Func)((CardModificationInfo m) => m != null && !string.IsNullOrEmpty(m.singletonId) && m.singletonId.Equals(TemporaryModId))); if (val == null && create) { val = new CardModificationInfo(AbilityToGain) { singletonId = TemporaryModId }; } return val; } public override bool RespondsToOtherCardAssignedToSlot(PlayableCard otherCard) { return true; } [IteratorStateMachine(typeof(d__6))] public override IEnumerator OnOtherCardAssignedToSlot(PlayableCard otherCard) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { <>4__this = this, otherCard = otherCard }; } [IteratorStateMachine(typeof(d__7))] public override IEnumerator Cleanup(SlotModificationManager.ModificationType replacement) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__8))] public override IEnumerator Setup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { <>4__this = this }; } } public class SlotModificationInteractable : AlternateInputInteractable { private CardSlot slot; public override CursorType CursorType => (CursorType)6; public SlotModificationManager.ModificationType ModType { get; set; } public void AssignSlotModification(SlotModificationManager.ModificationType modType, CardSlot cardSlot) { ModType = modType; slot = cardSlot; ((InteractableBase)this).SetEnabled(true); } public override void OnAlternateSelectStarted() { Singleton.Instance.OpenToItemPage("SlotModification_" + (int)ModType, false); } } [HarmonyPatch] public class SlotModificationManager : MonoBehaviour { public enum ModificationType { NoModification } public class Info { public List MetaCategories = new List(); public Dictionary RulebookDescriptionRedirects = new Dictionary(); public string Name { get; internal set; } public string ModGUID { get; internal set; } public string RulebookName { get; set; } public string RulebookDescription { get; set; } public Sprite RulebookSprite { get; set; } public Sprite P03RulebookSprite { get; set; } public Sprite GrimoraRulebookSprite { get; set; } public Sprite MagnificusRulebookSprite { get; set; } public ModificationType SharedRulebook { get; set; } public Dictionary Texture { get; internal set; } public Dictionary PixelBoardSlotSprites { get; internal set; } public ModificationType ModificationType { get; internal set; } public Type SlotBehaviour { get; internal set; } public Info(string name, string modGuid, Dictionary texture, Dictionary pixelSprites, ModificationType modType, Type behaviour, string rulebookName, string rulebookDescription, Sprite rulebookSprite, List categories) { Name = name; ModGUID = modGuid; Texture = texture; PixelBoardSlotSprites = pixelSprites; ModificationType = modType; SlotBehaviour = behaviour; RulebookName = rulebookName; RulebookDescription = rulebookDescription; RulebookSprite = rulebookSprite; MetaCategories = categories; } public Info Clone() { return new Info(Name, ModGUID, (Texture != null) ? new Dictionary(Texture) : null, (PixelBoardSlotSprites != null) ? new Dictionary(PixelBoardSlotSprites) : null, ModificationType, SlotBehaviour, RulebookName, RulebookDescription, RulebookSprite, MetaCategories) { RulebookDescriptionRedirects = new Dictionary(RulebookDescriptionRedirects), SharedRulebook = SharedRulebook, P03RulebookSprite = P03RulebookSprite, GrimoraRulebookSprite = GrimoraRulebookSprite, MagnificusRulebookSprite = MagnificusRulebookSprite }; } } public enum ModificationMetaCategory { Part1Rulebook = 0, Part3Rulebook = 2, GrimoraRulebook = 5, MagnificusRulebook = 6 } [CompilerGenerated] private sealed class d__43 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator sequence; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__43(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; foreach (Info item in AllModificationInfos.Where((Info m) => m.SlotBehaviour != null)) { Component component = ((Component)Singleton.Instance).gameObject.GetComponent(item.SlotBehaviour); if (!UnityExtensions.SafeIsUnityNull((Object)(object)component)) { Object.Destroy((Object)(object)component); } } <>2__current = sequence; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__42 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator sequence; private List.Enumerator <>7__wrap1; private CardSlot 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__42(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown try { SlotModificationInteractable component; switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = Singleton.Instance.AllSlots.GetEnumerator(); <>1__state = -3; goto IL_00b1; case 1: <>1__state = -3; goto IL_0090; case 2: <>1__state = -1; goto IL_0110; case 3: { <>1__state = -1; return false; } IL_00b1: if (<>7__wrap1.MoveNext()) { 5__3 = <>7__wrap1.Current; if (5__3.GetSlotModification() != 0) { <>2__current = 5__3.SetSlotModification(ModificationType.NoModification); <>1__state = 1; return true; } goto IL_0090; } <>m__Finally1(); if (Singleton.Instance.StackSize > 0) { <>2__current = (object)new WaitUntil((Func)(() => Singleton.Instance.StackSize == 0)); <>1__state = 2; return true; } goto IL_0110; IL_0110: foreach (KeyValuePair> slotReceiver in Instance.SlotReceivers) { Object.Destroy((Object)(object)slotReceiver.Value.Item2); } Instance.SlotReceivers.Clear(); <>2__current = sequence; <>1__state = 3; return true; IL_0090: component = ((Component)5__3).GetComponent(); if (!UnityExtensions.SafeIsUnityNull((Object)(object)component)) { Object.Destroy((Object)(object)component); } 5__3 = null; goto IL_00b1; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal readonly Dictionary> SlotReceivers = new Dictionary>(); internal static readonly ObservableCollection AllSlotModifications; private static readonly Color TRANSPARENT; private static readonly Dictionary> DEFAULT_COLORS; internal static readonly Dictionary DefaultSlotTextures; internal static readonly Dictionary> PlayerOverrideSlots; internal static readonly Dictionary> OpponentOverrideSlots; private static SlotModificationManager m_instance; public const string SLOT_PAGEID = "SlotModification_"; private static Vector3 PART_3_SCALE; public static List AllModificationInfos { get; private set; } public static List AllModificationTypes { get; private set; } public static SlotModificationManager Instance { get { if ((Object)(object)m_instance != (Object)null) { return m_instance; } Instantiate(); return m_instance; } set { m_instance = value; } } public static event Func, List> ModifySlotModificationList; static SlotModificationManager() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) AllSlotModifications = new ObservableCollection { new Info("NoModification", "cyantist.inscryption.api", null, null, ModificationType.NoModification, null, null, null, null, new List()) }; AllModificationInfos = new List(); AllModificationTypes = new List(); TRANSPARENT = new Color(0f, 0f, 0f, 0f); DEFAULT_COLORS = new Dictionary> { { (BoardTheme)2, new Tuple(ParseHtml("#446969"), ParseHtml("#B4FFEC")) }, { (BoardTheme)4, new Tuple(ParseHtml("#446969"), ParseHtml("#B4FFEC")) }, { (BoardTheme)0, new Tuple(ParseHtml("#FF9226"), ParseHtml("#F7C376")) }, { (BoardTheme)3, new Tuple(ParseHtml("#C1D080"), ParseHtml("#EEF4C6")) }, { (BoardTheme)1, new Tuple(ParseHtml("#C1D080"), ParseHtml("#EEF4C6")) }, { (BoardTheme)5, new Tuple(ParseHtml("#E14C89"), ParseHtml("#F779AD")) } }; DefaultSlotTextures = new Dictionary { { (CardTemple)0, ResourceBank.Get("Art/Cards/card_slot") }, { (CardTemple)2, ResourceBank.Get("Art/Cards/card_slot_tech") }, { (CardTemple)3, ResourceBank.Get("Art/Cards/card_slot_undead") }, { (CardTemple)1, ResourceBank.Get("Art/Cards/card_slot_wizard") } }; PlayerOverrideSlots = new Dictionary>(); OpponentOverrideSlots = new Dictionary>(); PART_3_SCALE = new Vector3(0.7f, 0.7f, 1f); AllSlotModifications.CollectionChanged += delegate { SyncSlotModificationList(); }; } public static void SyncSlotModificationList() { AllModificationInfos = AllSlotModifications.Select((Info x) => x.Clone()).ToList(); AllModificationInfos = SlotModificationManager.ModifySlotModificationList?.Invoke(AllModificationInfos) ?? AllModificationInfos; AllModificationTypes = AllSlotModifications.Select((Info x) => x.ModificationType).ToList(); } private static Color ParseHtml(string html) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (ColorUtility.TryParseHtmlString(html, ref result)) { return result; } return Color.white; } public static ModificationType New(string modGuid, string modificationName, Type behaviour, Dictionary slotTexture, Dictionary pixelBoardSlotSprites) { if (!behaviour.IsSubclassOf(typeof(SlotModificationBehaviour))) { throw new InvalidOperationException("Could not create new ModificationType " + modificationName + "; behaviour must be a subclass of SlotModificationBehaviour"); } ModificationType enumValue = GuidManager.GetEnumValue(modGuid, modificationName); AllSlotModifications.Add(new Info(modificationName, modGuid, slotTexture, pixelBoardSlotSprites, enumValue, behaviour, null, null, null, new List())); return enumValue; } public static ModificationType New(string modGuid, string modificationName, Type behaviour, Texture2D slotTexture, Dictionary pixelBoardSlotSprites) { Dictionary slotTexture2 = new Dictionary { [(CardTemple)0] = slotTexture, [(CardTemple)2] = slotTexture, [(CardTemple)1] = slotTexture, [(CardTemple)3] = slotTexture }; return New(modGuid, modificationName, behaviour, slotTexture2, pixelBoardSlotSprites); } public static ModificationType New(string modGuid, string modificationName, Type behaviour, Texture2D slotTexture, Texture2D pixelSlotTexture) { Dictionary pixelBoardSlotSprites = null; if ((Object)(object)pixelSlotTexture != (Object)null) { if (((Texture)pixelSlotTexture).width == 44 && ((Texture)pixelSlotTexture).height == 58) { pixelBoardSlotSprites = BuildAct2SpriteSetFromTexture(pixelSlotTexture); } else { if (((Texture)pixelSlotTexture).width != 220 || (((Texture)pixelSlotTexture).height != 116 && ((Texture)pixelSlotTexture).height != 232)) { throw new InvalidOperationException("Cannot create slot mod " + modGuid + "/" + modificationName + ". The pixel slot texture must either be a single slot (44x58) or a 5x2 sprite sheet (220x116) or a 5x4 sprite sheet (220x232)"); } pixelBoardSlotSprites = BuildAct2SpriteSetFromSpriteSheetTexture(pixelSlotTexture); } } return New(modGuid, modificationName, behaviour, slotTexture, pixelBoardSlotSprites); } public static ModificationType New(string modGuid, string modificationName, Type behaviour, Texture2D slotTexture) { return New(modGuid, modificationName, behaviour, slotTexture, (Texture2D)null); } public static ModificationType New(string modGuid, string modificationName, Type behaviour) { return New(modGuid, modificationName, behaviour, (Texture2D)null, (Texture2D)null); } private static void ConditionallyResetAllSlotTextures() { if (!((Object)(object)Singleton.m_Instance != (Object)null)) { return; } foreach (CardSlot item in Singleton.Instance.AllSlotsCopy) { if (item.GetSlotModification() == ModificationType.NoModification) { item.ResetSlotTexture(); } } } private static Texture2D ConvertAct2TextureColor(Texture2D tex, Color targetColor) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = TextureHelper.DuplicateTexture(tex); ((Texture)val).filterMode = (FilterMode)0; for (int i = 0; i < ((Texture)val).width; i++) { for (int j = 0; j < ((Texture)val).height; j++) { Color pixel = tex.GetPixel(i, j); if (pixel.a < 1f) { val.SetPixel(i, j, TRANSPARENT); } else if (pixel == Color.black) { val.SetPixel(i, j, Color.black); } else { val.SetPixel(i, j, targetColor); } } } val.Apply(); return val; } private static BoardThemeSpriteSet GetSpriteSetFromTexture(Texture2D tex, BoardTheme theme) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown int num = (((int)theme == 5) ? 4 : ((int)theme)); bool num2 = ((Texture)tex).height == 232; Sprite val = Sprite.Create(tex, new Rect(0f + (float)num * 44f, (float)((Texture)tex).height - 58f, 44f, 58f), new Vector2(0.5f, 0.5f)); Sprite val2 = Sprite.Create(tex, new Rect(0f + (float)num * 44f, (float)((Texture)tex).height - 116f, 44f, 58f), new Vector2(0.5f, 0.5f)); Sprite slotDefault = ((!num2) ? val : Sprite.Create(tex, new Rect(0f + (float)num * 44f, (float)((Texture)tex).height - 174f, 44f, 58f), new Vector2(0.5f, 0.5f))); Sprite slotHighlight = ((!num2) ? val2 : Sprite.Create(tex, new Rect(0f + (float)num * 44f, 0f, 44f, 58f), new Vector2(0.5f, 0.5f))); List list = new List(); if (num2) { for (int i = 0; i < 4; i++) { list.Add(new SpecificSlotSprites { playerSlot = false, index = i, slotDefault = slotDefault, slotHighlight = slotHighlight }); } } return new BoardThemeSpriteSet { id = theme, slotDefault = val, slotHighlight = val2, specificSlotSprites = list, flipPlayerSlotSpriteX = false, flipPlayerSlotSpriteY = false }; } public static Dictionary BuildAct2SpriteSetFromSpriteSheetTexture(Texture2D texture) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); List list = Enum.GetValues(typeof(BoardTheme)).Cast().ToList(); list.Remove((BoardTheme)4); list.Remove((BoardTheme)6); foreach (BoardTheme item in list) { dictionary[item] = GetSpriteSetFromTexture(texture, item); } return dictionary; } public static Dictionary BuildAct2SpriteSetFromTexture(Texture2D texture) { //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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); foreach (BoardTheme value in Enum.GetValues(typeof(BoardTheme))) { if ((int)value != 6) { Texture2D val2 = ConvertAct2TextureColor(texture, DEFAULT_COLORS[value].Item1); Texture2D val3 = ConvertAct2TextureColor(texture, DEFAULT_COLORS[value].Item2); BoardThemeSpriteSet val4 = new BoardThemeSpriteSet(); val4.id = value; val4.slotDefault = Sprite.Create(val2, new Rect(0f, 0f, 44f, 58f), new Vector2(0.5f, 0.5f)); val4.slotHighlight = Sprite.Create(val3, new Rect(0f, 0f, 44f, 58f), new Vector2(0.5f, 0.5f)); val4.specificSlotSprites = new List(); dictionary[value] = val4; } } return dictionary; } public static void OverrideDefaultSlotTexture(CardTemple temple, Texture playerSlot, Texture opponentSlot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) OverrideDefaultSlotTexture(temple, ((Object)(object)playerSlot == (Object)null) ? null : new List { playerSlot, playerSlot, playerSlot, playerSlot }, ((Object)(object)opponentSlot == (Object)null) ? null : new List { opponentSlot, opponentSlot, opponentSlot, opponentSlot }); } public static void OverrideDefaultSlotTexture(CardTemple temple, List playerSlots, List opponentSlots) { //IL_002f: 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) if (playerSlots != null && playerSlots.Any((Texture t) => (Object)(object)t != (Object)null)) { PlayerOverrideSlots[temple] = new List(playerSlots); } if (opponentSlots != null && opponentSlots.Any((Texture t) => (Object)(object)t != (Object)null)) { OpponentOverrideSlots[temple] = new List(opponentSlots); } ConditionallyResetAllSlotTextures(); } public static void ResetDefaultSlotTexture(CardTemple temple) { //IL_0005: 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_0012: 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) if (PlayerOverrideSlots.ContainsKey(temple)) { PlayerOverrideSlots.Remove(temple); } if (OpponentOverrideSlots.ContainsKey(temple)) { OpponentOverrideSlots.Remove(temple); } ConditionallyResetAllSlotTextures(); } private static void Instantiate() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_instance != (Object)null)) { GameObject val = new GameObject("SlotModificationManager"); val.transform.SetParent(((Component)Singleton.Instance).gameObject.transform); m_instance = val.AddComponent(); } } [IteratorStateMachine(typeof(d__42))] [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] [HarmonyPostfix] private static IEnumerator CleanupSlots(IEnumerator sequence) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__42(0) { sequence = sequence }; } [IteratorStateMachine(typeof(d__43))] [HarmonyPatch(typeof(BoardManager), "CleanUp")] [HarmonyPostfix] private static IEnumerator CleanUpModifiedSlots(IEnumerator sequence) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__43(0) { sequence = sequence }; } [HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })] [HarmonyPostfix] [HarmonyPriority(300)] private static void AddSlotModificationsToRuleBook(AbilityMetaCategory metaCategory, RuleBookInfo __instance, ref List __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown if (AllModificationInfos.Count == 0) { return; } List list = AllModificationInfos.Where((Info x) => RuleBookManager.SlotModShouldBeAdded(x, (ModificationMetaCategory)metaCategory)).ToList(); list.RemoveAll((Info x) => x.SharedRulebook != ModificationType.NoModification); if (list.Count == 0) { return; } int num = 1; PageRangeInfo val = __instance.pageRanges.Find((PageRangeInfo x) => (int)x.type == 5); PageRangeInfo val2 = __instance.pageRanges.Find((PageRangeInfo x) => (int)x.type == 0); GameObject pagePrefab = (val ?? val2).rangePrefab; int num2 = __result.FindLastIndex((RuleBookPageInfo rbi) => Object.op_Implicit((Object)(object)pagePrefab)) + 1; foreach (Info item in list) { RuleBookPageInfo val3 = new RuleBookPageInfo(); val3.pagePrefab = (SaveManager.SaveFile.IsPart1 ? val : val2).rangePrefab; val3.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION I - SLOT EFFECTS {0}"), num); val3.pageId = "SlotModification_" + (int)item.ModificationType; __result.Insert(num2, val3); num++; num2++; } } [HarmonyPrefix] [HarmonyPatch(typeof(ItemPage), "FillPage")] private static bool OverrideWithSlotInfo(ItemPage __instance, string headerText, params object[] otherArgs) { //IL_002c: 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_00ee: Unknown result type (might be due to invalid IL or missing references) if (!SaveManager.SaveFile.IsPart1) { return true; } ((Component)__instance.iconRenderer).transform.localScale = (SaveManager.SaveFile.IsPart3 ? PART_3_SCALE : Vector3.one); if (otherArgs[0] is string text && text.StartsWith("SlotModification_") && int.TryParse(text.Replace("SlotModification_", ""), out var result)) { if ((Object)(object)((RuleBookPage)__instance).headerTextMesh != (Object)null) { ((TMP_Text)((RuleBookPage)__instance).headerTextMesh).text = headerText; } Info info = AllModificationInfos.InfoByID((ModificationType)result); ((TMP_Text)__instance.nameTextMesh).text = Localization.Translate(info.RulebookName); ((TMP_Text)__instance.descriptionTextMesh).text = Localization.Translate(info.RulebookDescription); __instance.iconRenderer.sprite = info.RulebookSprite; ((Component)__instance.iconRenderer).transform.localScale = new Vector3(0.8f, 0.8f, 1f); InscryptionAPIPlugin.Logger.LogDebug((object)$"Create rulebook page for slot modification [{info.ModificationType}] ({info.RulebookName})."); return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(AbilityPage), "FillPage")] private static bool OverrideWithSlotInfo(AbilityPage __instance, string headerText, params object[] otherArgs) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) if (SaveManager.SaveFile.IsPart1) { return true; } ((Component)__instance.mainAbilityGroup.iconRenderer).transform.localScale = (SaveManager.SaveFile.IsPart3 ? PART_3_SCALE : Vector3.one); Transform val = ((Component)__instance.mainAbilityGroup).transform.Find("SlotRenderer"); if (val != null) { ((Component)val).gameObject.SetActive(false); } ((Component)((Component)__instance.mainAbilityGroup.iconRenderer).transform.parent).gameObject.SetActive(true); if (otherArgs.Length != 0 && otherArgs.Last() is string text && text.StartsWith("SlotModification_") && int.TryParse(text.Replace("SlotModification_", ""), out var result)) { if ((Object)(object)((RuleBookPage)__instance).headerTextMesh != (Object)null) { ((TMP_Text)((RuleBookPage)__instance).headerTextMesh).text = headerText; } Info info = AllModificationInfos.InfoByID((ModificationType)result); ((TMP_Text)__instance.mainAbilityGroup.nameTextMesh).text = Localization.Translate(info.RulebookName); ((TMP_Text)__instance.mainAbilityGroup.descriptionTextMesh).text = Localization.Translate(info.RulebookDescription); ((Component)((Component)__instance.mainAbilityGroup.iconRenderer).transform.parent).gameObject.SetActive(false); if (SaveManager.SaveFile.IsPart3) { if ((Object)(object)val == (Object)null) { val = Object.Instantiate(((Component)__instance.mainAbilityGroup.iconRenderer).transform.parent, ((Component)__instance.mainAbilityGroup).transform); ((Object)val).name = "SlotRenderer"; Transform obj = val; obj.localPosition += new Vector3(0.1f, -0.1f, 0f); val.localScale = new Vector3(0.6f, 0.6f, 0.6f); Object.Destroy((Object)(object)((Component)val.Find("Icon")).gameObject); } ((Component)val).gameObject.SetActive(true); ((Component)((Component)__instance.mainAbilityGroup.iconRenderer).transform.parent).gameObject.SetActive(false); ((Component)val).GetComponent().sprite = info.P03RulebookSprite ?? info.RulebookSprite; } else if (SaveManager.SaveFile.IsMagnificus) { if ((Object)(object)val == (Object)null) { val = Object.Instantiate(((Component)__instance.mainAbilityGroup.iconRenderer).transform.parent, ((Component)__instance.mainAbilityGroup).transform); ((Object)val).name = "SlotRenderer"; Transform obj2 = val; obj2.localPosition += new Vector3(0.1f, -0.1f, 0f); } ((Component)val).gameObject.SetActive(true); ((Component)((Component)__instance.mainAbilityGroup.iconRenderer).transform.parent).gameObject.SetActive(false); ((Renderer)((Component)val.GetChild(0)).GetComponent()).material.mainTexture = (Texture)(object)(info.MagnificusRulebookSprite ?? info.RulebookSprite).texture; } else { InscryptionAPIPlugin.Logger.LogDebug((object)"Slot modification page: WIP"); } ((Component)__instance.mainAbilityGroup.iconRenderer).transform.localScale = new Vector3(0.8f, 0.8f, 1f); return false; } return true; } } } namespace InscryptionAPI.Saves { public class ModdedSaveData { internal Dictionary> SaveData = new Dictionary>(); public T GetValueAsObject(string guid, string key) { if (SaveData == null) { SaveData = new Dictionary>(); } if (!SaveData.ContainsKey(guid)) { SaveData.Add(guid, new Dictionary()); } if (!SaveData[guid].ContainsKey(key)) { SaveData[guid].Add(key, null); } return (T)SaveData[guid][key]; } public bool TryGetGuidAndKey(string prefix, string enumValue, out string guid, out string key) { foreach (KeyValuePair> saveDatum in SaveData) { foreach (KeyValuePair item in saveDatum.Value) { if (item.Key.StartsWith(prefix, StringComparison.Ordinal) && item.Value.Equals(enumValue)) { string text = item.Key.Substring(prefix.Length + 1); int num = text.IndexOf('_'); guid = text.Substring(0, num); key = text.Substring(num + 1); return true; } } } guid = null; key = null; return false; } public string GetValue(string guid, string key) { return GetValueAsObject(guid, key)?.ToString(); } public int GetValueAsInt(string guid, string key) { int.TryParse(GetValue(guid, key), out var result); return result; } public float GetValueAsFloat(string guid, string key) { float.TryParse(GetValue(guid, key), out var result); return result; } public bool GetValueAsBoolean(string guid, string key) { bool.TryParse(GetValue(guid, key), out var result); return result; } public void SetValueAsObject(string guid, string key, T value) { if (SaveData == null) { SaveData = new Dictionary>(); } if (!SaveData.ContainsKey(guid)) { SaveData.Add(guid, new Dictionary()); } if (!SaveData[guid].ContainsKey(key)) { SaveData[guid].Add(key, value); } else { SaveData[guid][key] = value; } } public void SetValue(string guid, string key, object value) { SetValueAsObject(guid, key, value?.ToString()); } } [HarmonyPatch] public static class ModdedSaveManager { [Obsolete("Use 'saveFilePath' instead")] private static readonly string oldSaveFilePath; private static readonly string saveFilePath; internal static bool isSystemDirty; public static ModdedSaveData SaveData { get; private set; } public static ModdedSaveData RunState { get; private set; } static ModdedSaveManager() { oldSaveFilePath = Path.Combine(Paths.BepInExRootPath, "ModdedSaveFile.gwsave"); saveFilePath = Path.Combine(Paths.GameRootPath, "ModdedSaveFile.gwsave"); isSystemDirty = false; ReadDataFromFile(); } [HarmonyPatch(typeof(SaveManager), "SaveToFile")] [HarmonyPostfix] private static void SaveDataToFile() { string contents = SaveManager.ToJSON((object)(SaveData.SaveData, RunState.SaveData)); File.WriteAllText(saveFilePath, contents); } [HarmonyPatch(typeof(SaveManager), "LoadFromFile")] [HarmonyPostfix] private static void ReadDataFromFile() { if (isSystemDirty) { SaveDataToFile(); isSystemDirty = false; } bool flag = File.Exists(oldSaveFilePath); bool flag2 = File.Exists(saveFilePath); if (flag2 || flag) { if (flag2 && flag) { File.Delete(saveFilePath); } if (flag) { File.Move(oldSaveFilePath, saveFilePath); } (Dictionary>, Dictionary>) tuple = SaveManager.FromJSON<(Dictionary>, Dictionary>)>(File.ReadAllText(saveFilePath)); if (SaveData == null) { SaveData = new ModdedSaveData(); } if (RunState == null) { RunState = new ModdedSaveData(); } SaveData.SaveData = tuple.Item1; RunState.SaveData = tuple.Item2; } else { SaveData = new ModdedSaveData(); RunState = new ModdedSaveData(); } } [HarmonyPatch(typeof(AscensionSaveData), "NewRun")] [HarmonyPrefix] private static void ResetRunStateOnNewAscensionRun() { RunState = new ModdedSaveData(); } [HarmonyPatch(typeof(SaveFile), "NewPart1Run")] [HarmonyPrefix] private static void ResetRunStateOnPart1Run() { RunState = new ModdedSaveData(); } } public static class SaveFileExtensions { public static CardTemple? GetSceneAsCardTemple(this SaveFile save) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Invalid comparison between Unknown and I4 //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 if (save.IsGrimora) { return (CardTemple)1; } if (save.IsMagnificus) { return (CardTemple)3; } if (save.IsPart1) { return (CardTemple)0; } if (save.IsPart3) { return (CardTemple)2; } if (save.IsPart2) { CachedGCBNPCDescriptor triggeringNPC = GBCEncounterManager.Instance.GetTriggeringNPC(); if (triggeringNPC != null) { if ((int)triggeringNPC.BattleBackgroundTheme == 0) { return (CardTemple)0; } if ((int)triggeringNPC.BattleBackgroundTheme == 2) { return (CardTemple)2; } if ((int)triggeringNPC.BattleBackgroundTheme == 4) { return (CardTemple)2; } if ((int)triggeringNPC.BattleBackgroundTheme == 1) { return (CardTemple)1; } if ((int)triggeringNPC.BattleBackgroundTheme == 3) { return (CardTemple)3; } if ((int)triggeringNPC.BattleBackgroundTheme == 5) { return (CardTemple)2; } } Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name.ToLowerInvariant(); if (text.Contains("nature")) { return (CardTemple)0; } if (text.Contains("tech")) { return (CardTemple)2; } if (text.Contains("wizard")) { return (CardTemple)3; } if (text.Contains("undead")) { return (CardTemple)1; } } return null; } } } namespace InscryptionAPI.RuleBook { public class PageTextInteractable : AlternateInputInteractable { public PageRangeType redirectType; public string redirectId; public override CursorType CursorType => (CursorType)6; public void SetRedirect(PageRangeType rangeType, string pageId) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) redirectType = rangeType; redirectId = pageId; } public override void OnAlternateSelectStarted() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) Singleton.Instance.SetShown(true, (int)redirectType != 4); RuleBookPageInfo val = Singleton.Instance.PageData.Find((RuleBookPageInfo x) => !string.IsNullOrEmpty(x.pageId) && RuleBookManager.GetUnformattedPageId(x.pageId) == redirectId && ((int)redirectType != 0 || x.abilityPage)); int num = Singleton.Instance.PageData.IndexOf(val); InscryptionAPIPlugin.Logger.LogDebug((object)$"[PageTextSelected] Type:{redirectType} Id:{redirectId} Idx:[{num}] Null:{val == null}"); ((MonoBehaviour)Singleton.Instance).StopAllCoroutines(); ((MonoBehaviour)Singleton.Instance).StartCoroutine(Singleton.Instance.flipper.FlipToPage(num, 0.2f)); } } public static class RuleBookManager { public class RedirectInfo { public PageRangeType redirectType; public Color redirectTextColour; public string redirectPageId; public RedirectInfo(PageRangeType redirectType, Color redirectTextColour, string redirectPageId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) this.redirectType = redirectType; this.redirectTextColour = redirectTextColour; this.redirectPageId = redirectPageId; } } public class RuleBookPageInfoExt { public RuleBookPageInfo parentPageInfo; public Dictionary RulebookDescriptionRedirects = new Dictionary(); public RuleBookPageInfoExt(RuleBookPageInfo parentPageInfo, Dictionary redirects) { this.parentPageInfo = parentPageInfo; RulebookDescriptionRedirects = redirects; } } public class FullRuleBookRangeInfo { public readonly string ModGUID; public readonly PageRangeType PageTypeTemplate; public string HeaderPrefix; public string SubSectionName; public Func, int> GetStartingNumberFunc; public Func, int> GetInsertPositionFunc; public Func> CreatePagesFunc; public Action FillPageAction; public string FullHeaderText => HeaderPrefix + " - " + SubSectionName + " {0}"; public int GetStartingNumber(List pages) { return GetStartingNumberFunc(pages); } public int GetInsertPosition(PageRangeInfo currentPageRange, List pages) { return GetInsertPositionFunc(currentPageRange, pages); } public List CreatePages(RuleBookInfo instance, PageRangeInfo currentPageRange, AbilityMetaCategory metaCategory) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return CreatePagesFunc(instance, currentPageRange, metaCategory); } public void FillRuleBookPage(RuleBookPage instance, string pageId, params object[] otherArgs) { FillPageAction(instance, pageId, otherArgs); } public FullRuleBookRangeInfo(string modGuid, PageRangeType type, string headerPrefix, string subsectionName, Func, int> getStartingNumberFunc, Func, int> getInsertPositionFunc, Func> createPagesFunc, Action fillPageAct) { //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) ModGUID = modGuid; PageTypeTemplate = type; HeaderPrefix = headerPrefix ?? HeaderPrefixSimple("I"); SubSectionName = subsectionName; GetStartingNumberFunc = getStartingNumberFunc ?? ((Func, int>)((List x) => 1)); GetInsertPositionFunc = getInsertPositionFunc; CreatePagesFunc = createPagesFunc; FillPageAction = fillPageAct; } public FullRuleBookRangeInfo Clone() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return new FullRuleBookRangeInfo(ModGUID, PageTypeTemplate, HeaderPrefix, SubSectionName, GetStartingNumberFunc, GetInsertPositionFunc, CreatePagesFunc, FillPageAction); } } public static readonly List ConstructedPagesWithRedirects; public static readonly List CustomRedirectPages; internal static readonly ObservableCollection NewRuleBookInfos; private const string DEFAULT_HEADER_PREFIX = "APPENDIX XII, SUBSECTION {0}"; public const string HTML_REPLACE_STRING = "{1}"; public static List AllRuleBookInfos { get; private set; } public static event Func, List> ModifyRuleBookInfos; internal static void AddRedirectPage(RuleBookPageInfo pageInfo, Dictionary redirects) { ConstructedPagesWithRedirects.Add(new RuleBookPageInfoExt(pageInfo, redirects)); } static RuleBookManager() { ConstructedPagesWithRedirects = new List(); CustomRedirectPages = new List(); NewRuleBookInfos = new ObservableCollection(); NewRuleBookInfos.CollectionChanged += delegate { SyncRuleBookList(); }; } public static void SyncRuleBookList() { AllRuleBookInfos = NewRuleBookInfos.Select((FullRuleBookRangeInfo x) => x.Clone()).ToList(); AllRuleBookInfos = RuleBookManager.ModifyRuleBookInfos?.Invoke(AllRuleBookInfos) ?? AllRuleBookInfos; } public static FullRuleBookRangeInfo New(string modGuid, PageRangeType pageType, string subsectionName, Func, int> getInsertPositionFunc, Func> createPagesFunc, string headerPrefix = null, Func, int> getStartingNumberFunc = null, Action fillPageAction = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) FullRuleBookRangeInfo fullRuleBookRangeInfo = new FullRuleBookRangeInfo(modGuid, pageType, headerPrefix, subsectionName, getStartingNumberFunc, getInsertPositionFunc, createPagesFunc, fillPageAction); NewRuleBookInfos.Add(fullRuleBookRangeInfo); return fullRuleBookRangeInfo; } public static FullRuleBookRangeInfo New(string modGuid, PageRangeType pageType, string headerPrefix, string subsectionName, Func, int> getStartingNumberFunc, Func, int> getInsertPositionFunc, Func> createPagesFunc) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) FullRuleBookRangeInfo fullRuleBookRangeInfo = new FullRuleBookRangeInfo(modGuid, pageType, headerPrefix, subsectionName, getStartingNumberFunc, getInsertPositionFunc, createPagesFunc, null); NewRuleBookInfos.Add(fullRuleBookRangeInfo); return fullRuleBookRangeInfo; } public static FullRuleBookRangeInfo SetFillPage(this FullRuleBookRangeInfo info, Action action) { info.FillPageAction = action; return info; } public static FullRuleBookRangeInfo SetHeaderPrefix(this FullRuleBookRangeInfo info, string headerPrefix) { info.HeaderPrefix = headerPrefix; return info; } public static FullRuleBookRangeInfo SetHeaderPrefixSimple(this FullRuleBookRangeInfo info, string romanNumeral) { info.HeaderPrefix = HeaderPrefixSimple(romanNumeral); return info; } public static string HeaderPrefixSimple(string romanNumeral) { return $"APPENDIX XII, SUBSECTION {romanNumeral}"; } public static string ParseRedirectTextColours(Dictionary dictionary, string description) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) string text = description; if (dictionary.Count > 0) { foreach (string key in dictionary.Keys) { string arg = ColorUtility.ToHtmlStringRGB(dictionary[key].redirectTextColour); text = text.Replace(key, $"{key}"); } } return text; } public static string GetUnformattedPageId(string pageId) { int num = pageId.IndexOf("[API_"); if (num != -1) { int num2 = pageId.IndexOf(']'); if (num2 != -1) { return pageId.Remove(num, num2 - num + 1); } } return pageId; } public static void OpenToCustomPage(this RuleBookController instance, string pageId, bool offsetView = false) { int num = -1; instance.SetShown(true, offsetView); num = ((!pageId.StartsWith("[API_")) ? instance.PageData.IndexOf(instance.PageData.Find((RuleBookPageInfo x) => !string.IsNullOrEmpty(x.pageId) && GetUnformattedPageId(x.pageId) == pageId)) : instance.PageData.IndexOf(instance.PageData.Find((RuleBookPageInfo x) => !string.IsNullOrEmpty(x.pageId) && x.pageId == pageId))); ((MonoBehaviour)instance).StopAllCoroutines(); ((MonoBehaviour)instance).StartCoroutine(instance.flipper.FlipToPage(num, 0.2f)); } public static bool ItemShouldBeAdded(ConsumableItemData item, AbilityMetaCategory metaCategory) { //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_001b: Unknown result type (might be due to invalid IL or missing references) if (item.rulebookCategory != metaCategory) { return item.GetFullConsumableItemData()?.rulebookMetaCategories.Contains(metaCategory) ?? false; } return true; } public static bool BoonShouldBeAdded(BoonManager.FullBoon fullBoon, AbilityMetaCategory metaCategory) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fullBoon?.boon?.icon != (Object)null && fullBoon.appearInRulebook) { return fullBoon.metaCategories.Contains(metaCategory); } return false; } public static bool SlotModShouldBeAdded(SlotModificationManager.Info info, SlotModificationManager.ModificationMetaCategory category) { if (info.RulebookName != null) { return info.MetaCategories.Contains(category); } return false; } } [HarmonyPatch] public class RuleBookManagerPatches { public const string API_ID = "[API_"; [HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })] [HarmonyPostfix] [HarmonyPriority(200)] private static void AddCustomRuleBookSections(AbilityMetaCategory metaCategory, RuleBookInfo __instance, ref List __result) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (RuleBookManager.AllRuleBookInfos.Count == 0) { return; } foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges) { List list = RuleBookManager.AllRuleBookInfos.FindAll((RuleBookManager.FullRuleBookRangeInfo x) => x.PageTypeTemplate == pageRangeInfo.type); if (list.Count == 0) { continue; } foreach (RuleBookManager.FullRuleBookRangeInfo item in list) { int num = item.GetStartingNumber(__result); int num2 = item.GetInsertPosition(pageRangeInfo, __result); foreach (RuleBookPageInfo item2 in item.CreatePages(__instance, pageRangeInfo, metaCategory)) { if (!item2.pageId.StartsWith("[API_")) { item2.pageId = $"[API_{item.SubSectionName}]" + item2.pageId; } item2.pagePrefab = pageRangeInfo.rangePrefab; item2.headerText = string.Format(Localization.Translate(item.FullHeaderText), num); __result.Insert(num2, item2); num++; num2++; } } } } [HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })] [HarmonyPostfix] [HarmonyPriority(0)] private static void SyncRuleBookRedirectsForEachPage(List __result) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) RuleBookManager.ConstructedPagesWithRedirects.Clear(); foreach (RuleBookPageInfo info in __result) { Dictionary dictionary = null; RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.CustomRedirectPages.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == info); if (ruleBookPageInfoExt != null) { dictionary = ruleBookPageInfoExt.RulebookDescriptionRedirects; } else if ((int)info.ability > 0) { dictionary = AbilityManager.AllAbilities.AbilityByID(info.ability)?.RulebookDescriptionRedirects; } else if ((int)info.boon > 0) { dictionary = BoonManager.AllFullBoons.Find((BoonManager.FullBoon x) => x.boon.type == info.boon)?.RulebookDescriptionRedirects; } else if (!string.IsNullOrEmpty(info.pageId) && !info.pageId.StartsWith("[API_")) { string pureId = RuleBookManager.GetUnformattedPageId(info.pageId); StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.Find(delegate(StatIconManager.FullStatIcon x) { //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) SpecialStatIcon id = x.Id; return ((object)(SpecialStatIcon)(ref id)).ToString() == pureId; }); if (fullStatIcon != null) { dictionary = fullStatIcon.RulebookDescriptionRedirects; } else if (info.pageId.StartsWith("SlotModification_")) { string slotId = info.pageId.Replace("SlotModification_", ""); dictionary = SlotModificationManager.AllModificationInfos.Find((SlotModificationManager.Info x) => x.ModificationType.ToString() == slotId)?.RulebookDescriptionRedirects; } else { dictionary = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => ((Object)x.itemData).name == pureId)?.RulebookDescriptionRedirects; } } if (dictionary != null && dictionary.Count > 0) { RuleBookManager.AddRedirectPage(info, new Dictionary(dictionary)); } } } [HarmonyPrefix] [HarmonyPatch(typeof(AbilityPage), "FillPage")] [HarmonyPatch(typeof(StatIconPage), "FillPage")] [HarmonyPatch(typeof(BoonPage), "FillPage")] [HarmonyPatch(typeof(ItemPage), "FillPage")] private static bool FixFillPage(RuleBookPage __instance, string headerText, params object[] otherArgs) { if (otherArgs != null && otherArgs.Length != 0 && otherArgs.LastOrDefault() is string text && text.StartsWith("[API_")) { string sectionId = text.Replace("[API_", ""); RuleBookManager.FullRuleBookRangeInfo fullRuleBookRangeInfo = RuleBookManager.AllRuleBookInfos.Find((RuleBookManager.FullRuleBookRangeInfo x) => sectionId.StartsWith(x.SubSectionName)); if (fullRuleBookRangeInfo != null && fullRuleBookRangeInfo.FillPageAction != null) { if ((Object)(object)__instance.headerTextMesh != (Object)null) { ((TMP_Text)__instance.headerTextMesh).text = headerText; } List list = otherArgs.ToList(); list.PopLast(); fullRuleBookRangeInfo.FillRuleBookPage(__instance, RuleBookManager.GetUnformattedPageId(text), list.ToArray()); return false; } } return true; } [HarmonyTranspiler] [HarmonyPatch(typeof(PageContentLoader), "LoadPage")] private static IEnumerable LoadCustomPage(IEnumerable instructions) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown List list = new List(instructions); int num = list.IndexOf(list.Find((CodeInstruction x) => x.opcode == OpCodes.Stloc_0)); if (num != -1) { num += 2; list.RemoveRange(num, list.Count - num - 1); MethodInfo methodInfo = AccessTools.Method(typeof(RuleBookManagerPatches), "FillPage", new Type[2] { typeof(RuleBookPage), typeof(RuleBookPageInfo) }, (Type[])null); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Call, (object)methodInfo)); } return list; } public static void FillPage(RuleBookPage page, RuleBookPageInfo pageInfo) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) TextMeshPro val = null; AbilityPage val2 = (AbilityPage)(object)((page is AbilityPage) ? page : null); if (val2 != null) { ((RuleBookPage)val2).FillPage(pageInfo.headerText, new object[3] { pageInfo.ability, pageInfo.fillerAbilityIds, pageInfo.pageId }); val = val2.mainAbilityGroup.descriptionTextMesh; } else { BoonPage val3 = (BoonPage)(object)((page is BoonPage) ? page : null); if (val3 != null) { ((RuleBookPage)val3).FillPage(pageInfo.headerText, new object[2] { pageInfo.boon, pageInfo.pageId }); val = val3.descriptionTextMesh; } else { page.FillPage(pageInfo.headerText, new object[1] { pageInfo.pageId }); ItemPage val4 = (ItemPage)(object)((page is ItemPage) ? page : null); if (val4 != null) { val = val4.descriptionTextMesh; } else { StatIconPage val5 = (StatIconPage)(object)((page is StatIconPage) ? page : null); if (val5 != null) { val = val5.descriptionTextMesh; } } } } RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.ConstructedPagesWithRedirects.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt != null && (Object)(object)val != (Object)null) { ((TMP_Text)val).text = RuleBookManager.ParseRedirectTextColours(ruleBookPageInfoExt.RulebookDescriptionRedirects, ((TMP_Text)val).text); } } } public static class RuleBookRedirectExtensions { public static AbilityManager.FullAbility SetAbilityRedirect(this AbilityManager.FullAbility fullAbility, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullAbility.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)0, redirectColour, ((object)(Ability)(ref abilityRedirect)).ToString()); return fullAbility; } public static AbilityManager.FullAbility SetStatIconRedirect(this AbilityManager.FullAbility fullAbility, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullAbility.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)3, redirectColour, ((object)(SpecialStatIcon)(ref statIconRedirect)).ToString()); return fullAbility; } public static AbilityManager.FullAbility SetBoonRedirect(this AbilityManager.FullAbility fullAbility, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullAbility.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)4, redirectColour, ((object)(Type)(ref boonRedirect)).ToString()); return fullAbility; } public static AbilityManager.FullAbility SetItemRedirect(this AbilityManager.FullAbility fullAbility, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullAbility.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, itemNameRedirect); return fullAbility; } public static AbilityManager.FullAbility SetUniqueRedirect(this AbilityManager.FullAbility fullAbility, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullAbility.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)2, redirectColour, uniqueRedirect); return fullAbility; } public static AbilityManager.FullAbility SetSlotRedirect(this AbilityManager.FullAbility fullAbility, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullAbility.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, "SlotModification_" + slotMod); return fullAbility; } public static AbilityInfo SetAbilityRedirect(this AbilityInfo info, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) AbilityManager.FullAbility fullAbility = AbilityManager.BaseGameAbilities.Concat(AbilityManager.NewAbilities).FirstOrDefault((AbilityManager.FullAbility x) => x.Info.ability == info.ability); if (fullAbility != null) { fullAbility.SetAbilityRedirect(clickableText, abilityRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the AbilityInfo hasn't been added to the API yet.")); return info; } public static AbilityInfo SetStatIconRedirect(this AbilityInfo info, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) AbilityManager.FullAbility fullAbility = AbilityManager.BaseGameAbilities.Concat(AbilityManager.NewAbilities).FirstOrDefault((AbilityManager.FullAbility x) => x.Info.ability == info.ability); if (fullAbility != null) { fullAbility.SetStatIconRedirect(clickableText, statIconRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the AbilityInfo hasn't been added to the API yet.")); return info; } public static AbilityInfo SetBoonRedirect(this AbilityInfo info, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) AbilityManager.FullAbility fullAbility = AbilityManager.BaseGameAbilities.Concat(AbilityManager.NewAbilities).FirstOrDefault((AbilityManager.FullAbility x) => x.Info.ability == info.ability); if (fullAbility != null) { fullAbility.SetBoonRedirect(clickableText, boonRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the AbilityInfo hasn't been added to the API yet.")); return info; } public static AbilityInfo SetItemRedirect(this AbilityInfo info, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) AbilityManager.FullAbility fullAbility = AbilityManager.BaseGameAbilities.Concat(AbilityManager.NewAbilities).FirstOrDefault((AbilityManager.FullAbility x) => x.Info.ability == info.ability); if (fullAbility != null) { fullAbility.SetItemRedirect(clickableText, itemNameRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the AbilityInfo hasn't been added to the API yet.")); return info; } public static AbilityInfo SetUniqueRedirect(this AbilityInfo info, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) AbilityManager.FullAbility fullAbility = AbilityManager.BaseGameAbilities.Concat(AbilityManager.NewAbilities).FirstOrDefault((AbilityManager.FullAbility x) => x.Info.ability == info.ability); if (fullAbility != null) { fullAbility.SetUniqueRedirect(clickableText, uniqueRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the AbilityInfo hasn't been added to the API yet.")); return info; } public static AbilityInfo SetSlotRedirect(this AbilityInfo info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) AbilityManager.FullAbility fullAbility = AbilityManager.BaseGameAbilities.Concat(AbilityManager.NewAbilities).FirstOrDefault((AbilityManager.FullAbility x) => x.Info.ability == info.ability); if (fullAbility != null) { fullAbility.SetSlotRedirect(clickableText, slotMod, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the AbilityInfo hasn't been added to the API yet.")); return info; } public static StatIconManager.FullStatIcon SetAbilityRedirect(this StatIconManager.FullStatIcon fullIcon, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullIcon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)0, redirectColour, ((object)(Ability)(ref abilityRedirect)).ToString()); return fullIcon; } public static StatIconManager.FullStatIcon SetStatIconRedirect(this StatIconManager.FullStatIcon fullIcon, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullIcon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)3, redirectColour, ((object)(SpecialStatIcon)(ref statIconRedirect)).ToString()); return fullIcon; } public static StatIconManager.FullStatIcon SetBoonRedirect(this StatIconManager.FullStatIcon fullIcon, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullIcon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)4, redirectColour, ((object)(Type)(ref boonRedirect)).ToString()); return fullIcon; } public static StatIconManager.FullStatIcon SetItemRedirect(this StatIconManager.FullStatIcon fullIcon, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullIcon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, itemNameRedirect); return fullIcon; } public static StatIconManager.FullStatIcon SetUniqueRedirect(this StatIconManager.FullStatIcon fullIcon, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullIcon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)2, redirectColour, uniqueRedirect); return fullIcon; } public static StatIconManager.FullStatIcon SetSlotRedirect(this StatIconManager.FullStatIcon fullIcon, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullIcon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, "SlotModification_" + slotMod); return fullIcon; } public static StatIconInfo SetAbilityRedirect(this StatIconInfo info, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.Find((StatIconManager.FullStatIcon x) => x.Id == info.iconType); if (fullStatIcon != null) { fullStatIcon.SetAbilityRedirect(clickableText, abilityRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the StatIconInfo hasn't been added to the API yet.")); return info; } public static StatIconInfo SetStatIconRedirect(this StatIconInfo info, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.Find((StatIconManager.FullStatIcon x) => x.Id == info.iconType); if (fullStatIcon != null) { fullStatIcon.SetStatIconRedirect(clickableText, statIconRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the StatIconInfo hasn't been added to the API yet.")); return info; } public static StatIconInfo SetBoonRedirect(this StatIconInfo info, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.Find((StatIconManager.FullStatIcon x) => x.Id == info.iconType); if (fullStatIcon != null) { fullStatIcon.SetBoonRedirect(clickableText, boonRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the StatIconInfo hasn't been added to the API yet.")); return info; } public static StatIconInfo SetItemRedirect(this StatIconInfo info, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.Find((StatIconManager.FullStatIcon x) => x.Id == info.iconType); if (fullStatIcon != null) { fullStatIcon.SetItemRedirect(clickableText, itemNameRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the StatIconInfo hasn't been added to the API yet.")); return info; } public static StatIconInfo SetUniqueRedirect(this StatIconInfo info, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.Find((StatIconManager.FullStatIcon x) => x.Id == info.iconType); if (fullStatIcon != null) { fullStatIcon.SetUniqueRedirect(clickableText, uniqueRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the StatIconInfo hasn't been added to the API yet.")); return info; } public static StatIconInfo SetSlotRedirect(this StatIconInfo info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.Find((StatIconManager.FullStatIcon x) => x.Id == info.iconType); if (fullStatIcon != null) { fullStatIcon.SetSlotRedirect(clickableText, slotMod, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the StatIconInfo hasn't been added to the API yet.")); return info; } public static BoonManager.FullBoon SetAbilityRedirect(this BoonManager.FullBoon fullBoon, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullBoon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)0, redirectColour, ((object)(Ability)(ref abilityRedirect)).ToString()); return fullBoon; } public static BoonManager.FullBoon SetStatIconRedirect(this BoonManager.FullBoon fullBoon, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullBoon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)3, redirectColour, ((object)(SpecialStatIcon)(ref statIconRedirect)).ToString()); return fullBoon; } public static BoonManager.FullBoon SetBoonRedirect(this BoonManager.FullBoon fullBoon, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullBoon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)4, redirectColour, ((object)(Type)(ref boonRedirect)).ToString()); return fullBoon; } public static BoonManager.FullBoon SetItemRedirect(this BoonManager.FullBoon fullBoon, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullBoon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, itemNameRedirect); return fullBoon; } public static BoonManager.FullBoon SetUniqueRedirect(this BoonManager.FullBoon fullBoon, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullBoon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)2, redirectColour, uniqueRedirect); return fullBoon; } public static BoonManager.FullBoon SetSlotRedirect(this BoonManager.FullBoon fullBoon, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullBoon.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, "SlotModification_" + slotMod); return fullBoon; } public static BoonData SetAbilityRedirect(this BoonData info, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) BoonManager.FullBoon fullBoon = BoonManager.AllFullBoons.Find((BoonManager.FullBoon x) => x.boon.type == info.type); if (fullBoon != null) { fullBoon.SetAbilityRedirect(clickableText, abilityRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the BoonData hasn't been added to the API yet.")); return info; } public static BoonData SetStatIconRedirect(this BoonData info, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) BoonManager.FullBoon fullBoon = BoonManager.AllFullBoons.Find((BoonManager.FullBoon x) => x.boon.type == info.type); if (fullBoon != null) { fullBoon.SetStatIconRedirect(clickableText, statIconRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the BoonData hasn't been added to the API yet.")); return info; } public static BoonData SetBoonRedirect(this BoonData info, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) BoonManager.FullBoon fullBoon = BoonManager.AllFullBoons.Find((BoonManager.FullBoon x) => x.boon.type == info.type); if (fullBoon != null) { fullBoon.SetBoonRedirect(clickableText, boonRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the BoonData hasn't been added to the API yet.")); return info; } public static BoonData SetItemRedirect(this BoonData info, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) BoonManager.FullBoon fullBoon = BoonManager.AllFullBoons.Find((BoonManager.FullBoon x) => x.boon.type == info.type); if (fullBoon != null) { fullBoon.SetItemRedirect(clickableText, itemNameRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the BoonData hasn't been added to the API yet.")); return info; } public static BoonData SetUniqueRedirect(this BoonData info, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) BoonManager.FullBoon fullBoon = BoonManager.AllFullBoons.Find((BoonManager.FullBoon x) => x.boon.type == info.type); if (fullBoon != null) { fullBoon.SetUniqueRedirect(clickableText, uniqueRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the BoonData hasn't been added to the API yet.")); return info; } public static BoonData SetSlotRedirect(this BoonData info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) BoonManager.FullBoon fullBoon = BoonManager.AllFullBoons.Find((BoonManager.FullBoon x) => x.boon.type == info.type); if (fullBoon != null) { fullBoon.SetSlotRedirect(clickableText, slotMod, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the BoonData hasn't been added to the API yet.")); return info; } public static ConsumableItemManager.FullConsumableItemData SetAbilityRedirect(this ConsumableItemManager.FullConsumableItemData fullItem, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullItem.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)0, redirectColour, ((object)(Ability)(ref abilityRedirect)).ToString()); return fullItem; } public static ConsumableItemManager.FullConsumableItemData SetStatIconRedirect(this ConsumableItemManager.FullConsumableItemData fullItem, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullItem.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)3, redirectColour, ((object)(SpecialStatIcon)(ref statIconRedirect)).ToString()); return fullItem; } public static ConsumableItemManager.FullConsumableItemData SetBoonRedirect(this ConsumableItemManager.FullConsumableItemData fullItem, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullItem.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)4, redirectColour, ((object)(Type)(ref boonRedirect)).ToString()); return fullItem; } public static ConsumableItemManager.FullConsumableItemData SetItemRedirect(this ConsumableItemManager.FullConsumableItemData fullItem, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullItem.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, itemNameRedirect); return fullItem; } public static ConsumableItemManager.FullConsumableItemData SetUniqueRedirect(this ConsumableItemManager.FullConsumableItemData fullItem, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullItem.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)2, redirectColour, uniqueRedirect); return fullItem; } public static ConsumableItemManager.FullConsumableItemData SetSlotRedirect(this ConsumableItemManager.FullConsumableItemData fullItem, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) fullItem.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, "SlotModification_" + slotMod); return fullItem; } public static ConsumableItemData SetAbilityRedirect(this ConsumableItemData info, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) ConsumableItemManager.FullConsumableItemData fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)info); if (fullConsumableItemData != null) { fullConsumableItemData.SetAbilityRedirect(clickableText, abilityRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the ConsumableItemData hasn't been added to the API yet.")); return info; } public static ConsumableItemData SetStatIconRedirect(this ConsumableItemData info, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) ConsumableItemManager.FullConsumableItemData fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)info); if (fullConsumableItemData != null) { fullConsumableItemData.SetStatIconRedirect(clickableText, statIconRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the ConsumableItemData hasn't been added to the API yet.")); return info; } public static ConsumableItemData SetBoonRedirect(this ConsumableItemData info, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) ConsumableItemManager.FullConsumableItemData fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)info); if (fullConsumableItemData != null) { fullConsumableItemData.SetBoonRedirect(clickableText, boonRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the ConsumableItemData hasn't been added to the API yet.")); return info; } public static ConsumableItemData SetItemRedirect(this ConsumableItemData info, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) ConsumableItemManager.FullConsumableItemData fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)info); if (fullConsumableItemData != null) { fullConsumableItemData.SetItemRedirect(clickableText, itemNameRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the ConsumableItemData hasn't been added to the API yet.")); return info; } public static ConsumableItemData SetUniqueRedirect(this ConsumableItemData info, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) ConsumableItemManager.FullConsumableItemData fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)info); if (fullConsumableItemData != null) { fullConsumableItemData.SetUniqueRedirect(clickableText, uniqueRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the ConsumableItemData hasn't been added to the API yet.")); return info; } public static ConsumableItemData SetSlotRedirect(this ConsumableItemData info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) ConsumableItemManager.FullConsumableItemData fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)info); if (fullConsumableItemData != null) { fullConsumableItemData.SetSlotRedirect(clickableText, slotMod, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the ConsumableItemData hasn't been added to the API yet.")); return info; } public static SlotModificationManager.Info SetAbilityRedirect(this SlotModificationManager.Info slotInfo, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) slotInfo.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)0, redirectColour, ((object)(Ability)(ref abilityRedirect)).ToString()); return slotInfo; } public static SlotModificationManager.Info SetStatIconRedirect(this SlotModificationManager.Info slotInfo, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) slotInfo.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)3, redirectColour, ((object)(SpecialStatIcon)(ref statIconRedirect)).ToString()); return slotInfo; } public static SlotModificationManager.Info SetBoonRedirect(this SlotModificationManager.Info slotInfo, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) slotInfo.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)4, redirectColour, ((object)(Type)(ref boonRedirect)).ToString()); return slotInfo; } public static SlotModificationManager.Info SetItemRedirect(this SlotModificationManager.Info slotInfo, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) slotInfo.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, itemNameRedirect); return slotInfo; } public static SlotModificationManager.Info SetUniqueRedirect(this SlotModificationManager.Info slotInfo, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) slotInfo.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)2, redirectColour, uniqueRedirect); return slotInfo; } public static SlotModificationManager.Info SetSlotRedirect(this SlotModificationManager.Info slotInfo, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) slotInfo.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, "SlotModification_" + slotMod); return slotInfo; } public static SlotModificationManager.ModificationType SetAbilityRedirect(this SlotModificationManager.ModificationType info, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SlotModificationManager.Info info2 = SlotModificationManager.AllSlotModifications.InfoByID(info); if (info2 != null) { info2.SetAbilityRedirect(clickableText, abilityRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the SlotModificationManager.ModificationType hasn't been added to the API yet.")); return info; } public static SlotModificationManager.ModificationType SetStatIconRedirect(this SlotModificationManager.ModificationType info, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SlotModificationManager.Info info2 = SlotModificationManager.AllSlotModifications.InfoByID(info); if (info2 != null) { info2.SetStatIconRedirect(clickableText, statIconRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the SlotModificationManager.ModificationType hasn't been added to the API yet.")); return info; } public static SlotModificationManager.ModificationType SetBoonRedirect(this SlotModificationManager.ModificationType info, string clickableText, Type boonRedirect, Color redirectColour) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SlotModificationManager.Info info2 = SlotModificationManager.AllSlotModifications.InfoByID(info); if (info2 != null) { info2.SetBoonRedirect(clickableText, boonRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the ConsumableItemData hasn't been added to the API yet.")); return info; } public static SlotModificationManager.ModificationType SetItemRedirect(this SlotModificationManager.ModificationType info, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) SlotModificationManager.Info info2 = SlotModificationManager.AllSlotModifications.InfoByID(info); if (info2 != null) { info2.SetItemRedirect(clickableText, itemNameRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the SlotModificationManager.ModificationType hasn't been added to the API yet.")); return info; } public static SlotModificationManager.ModificationType SetUniqueRedirect(this SlotModificationManager.ModificationType info, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) SlotModificationManager.Info info2 = SlotModificationManager.AllSlotModifications.InfoByID(info); if (info2 != null) { info2.SetUniqueRedirect(clickableText, uniqueRedirect, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the SlotModificationManager.ModificationType hasn't been added to the API yet.")); return info; } public static SlotModificationManager.ModificationType SetSlotRedirect(this SlotModificationManager.ModificationType info, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) SlotModificationManager.Info info2 = SlotModificationManager.AllSlotModifications.InfoByID(info); if (info2 != null) { info2.SetSlotRedirect(clickableText, slotMod, redirectColour); return info; } InscryptionAPIPlugin.Logger.LogError((object)("Can't set rulebook redirect for " + clickableText + " because the SlotModificationManager.ModificationType hasn't been added to the API yet.")); return info; } public static RuleBookPageInfo SetAbilityRedirect(this RuleBookPageInfo pageInfo, string clickableText, Ability abilityRedirect, Color redirectColour) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.CustomRedirectPages.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt == null) { ruleBookPageInfoExt = new RuleBookManager.RuleBookPageInfoExt(pageInfo, new Dictionary()); RuleBookManager.CustomRedirectPages.Add(ruleBookPageInfoExt); } ruleBookPageInfoExt.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)0, redirectColour, ((object)(Ability)(ref abilityRedirect)).ToString()); return pageInfo; } public static RuleBookPageInfo SetStatIconRedirect(this RuleBookPageInfo pageInfo, string clickableText, SpecialStatIcon statIconRedirect, Color redirectColour) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.CustomRedirectPages.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt == null) { ruleBookPageInfoExt = new RuleBookManager.RuleBookPageInfoExt(pageInfo, new Dictionary()); RuleBookManager.CustomRedirectPages.Add(ruleBookPageInfoExt); } ruleBookPageInfoExt.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)3, redirectColour, ((object)(SpecialStatIcon)(ref statIconRedirect)).ToString()); return pageInfo; } public static RuleBookPageInfo SetBoonRedirect(this RuleBookPageInfo pageInfo, string clickableText, Type boonRedirect, Color redirectColour) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.CustomRedirectPages.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt == null) { ruleBookPageInfoExt = new RuleBookManager.RuleBookPageInfoExt(pageInfo, new Dictionary()); RuleBookManager.CustomRedirectPages.Add(ruleBookPageInfoExt); } ruleBookPageInfoExt.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)4, redirectColour, ((object)(Type)(ref boonRedirect)).ToString()); return pageInfo; } public static RuleBookPageInfo SetItemRedirect(this RuleBookPageInfo pageInfo, string clickableText, string itemNameRedirect, Color redirectColour) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.CustomRedirectPages.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt == null) { ruleBookPageInfoExt = new RuleBookManager.RuleBookPageInfoExt(pageInfo, new Dictionary()); RuleBookManager.CustomRedirectPages.Add(ruleBookPageInfoExt); } ruleBookPageInfoExt.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, itemNameRedirect); return pageInfo; } public static RuleBookPageInfo SetUniqueRedirect(this RuleBookPageInfo pageInfo, string clickableText, string uniqueRedirect, Color redirectColour) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.CustomRedirectPages.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt == null) { ruleBookPageInfoExt = new RuleBookManager.RuleBookPageInfoExt(pageInfo, new Dictionary()); RuleBookManager.CustomRedirectPages.Add(ruleBookPageInfoExt); } ruleBookPageInfoExt.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)2, redirectColour, uniqueRedirect); return pageInfo; } public static RuleBookPageInfo SetSlotRedirect(this RuleBookPageInfo pageInfo, string clickableText, SlotModificationManager.ModificationType slotMod, Color redirectColour) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.CustomRedirectPages.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt == null) { ruleBookPageInfoExt = new RuleBookManager.RuleBookPageInfoExt(pageInfo, new Dictionary()); RuleBookManager.CustomRedirectPages.Add(ruleBookPageInfoExt); } ruleBookPageInfoExt.RulebookDescriptionRedirects[clickableText] = new RuleBookManager.RedirectInfo((PageRangeType)5, redirectColour, "SlotModification_" + slotMod); return pageInfo; } } public class RuleBookRedirectManager : Singleton { public readonly List createdInteractableObjects = new List(); public readonly List currentActiveInteractables = new List(); public int currentActivePageIndex = -1; public Vector3 currentPageTopLeft; public Vector3 descriptionTopLeft; public float[] currentPageLengths; public float[] descriptionLengths; public Camera RuleBookCamera; public Camera PixelCamera; public Transform currentTopPage; private void Start() { RuleBookCamera = Singleton.Instance.rigParent.GetComponentInChildren(); PixelCamera = Singleton.Instance.pixelCamera; } public void ClearActiveInteractables() { currentActiveInteractables.Clear(); createdInteractableObjects.RemoveAll((GameObject x) => (Object)(object)x == (Object)null); createdInteractableObjects.ForEach(delegate(GameObject x) { x.SetActive(false); }); } public void UpdateActiveInteractables(TextMeshPro description, GameObject currentPageObj, Dictionary redirects) { //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) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ((Renderer)((Component)currentPageObj.transform.Find("Border")).GetComponent()).bounds; Bounds bounds2; Vector3 val = default(Vector3); if (SaveManager.SaveFile.IsPart3) { bounds2 = ((Renderer)((Component)currentTopPage).GetComponent()).bounds; currentPageTopLeft = new Vector3(-1.129529f, 6.869874f, -5.502338f); ((Vector3)(ref val))..ctor(-1.129529f, 5.6181f, -6.449201f); descriptionTopLeft = new Vector3(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).max.y, (((Bounds)(ref bounds)).max.z + ((Bounds)(ref bounds)).min.z) / 2f); currentPageLengths = new float[2] { ((Bounds)(ref bounds2)).size.x - 0.4f, ((Bounds)(ref bounds2)).size.y - 0.4f }; if (descriptionLengths == null) { descriptionLengths = new float[2] { ((Bounds)(ref bounds)).size.y, currentPageLengths[1] / currentPageLengths[0] * ((Bounds)(ref bounds)).size.y }; } } else { bounds2 = ((Component)currentTopPage).GetComponent().sharedMesh.bounds; descriptionTopLeft = new Vector3(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.y, (((Bounds)(ref bounds)).max.z + ((Bounds)(ref bounds)).min.z) / 2f); currentPageTopLeft = ((Component)currentTopPage).transform.TransformPoint(((Bounds)(ref bounds2)).max); val = ((Component)currentTopPage).transform.TransformPoint(new Vector3(((Bounds)(ref bounds2)).max.x, ((Bounds)(ref bounds2)).min.y, ((Bounds)(ref bounds2)).min.z)); currentPageLengths = new float[2] { 2.95f, 1.97f }; if (descriptionLengths == null) { descriptionLengths = new float[2] { ((Bounds)(ref bounds)).size.x, currentPageLengths[1] / currentPageLengths[0] * ((Bounds)(ref bounds)).size.x }; } } float zLength = val.z - currentPageTopLeft.z; ClearActiveInteractables(); CreateInteractables(redirects, description, zLength); currentActiveInteractables.ForEach(delegate(GameObject x) { x.SetActive(true); }); } public void CreateInteractableObject(Vector3 worldPosition, Vector3 colliderSize, string keyText, RuleBookManager.RedirectInfo redirectInfo) { //IL_005c: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) GameObject val = createdInteractableObjects.Find((GameObject x) => !currentActiveInteractables.Contains(x)); if ((Object)(object)val == (Object)null) { InscryptionAPIPlugin.Logger.LogDebug((object)"Creating new page interactable"); val = GameObject.CreatePrimitive((PrimitiveType)3); ((InteractableBase)val.AddComponent()).coll = (Collider)(object)val.GetComponent(); createdInteractableObjects.Add(val); } val.GetComponent().SetRedirect(redirectInfo.redirectType, redirectInfo.redirectPageId); Vector3 position = PixelCamera.ScreenToWorldPoint(RuleBookCamera.WorldToScreenPoint(worldPosition)); ((Object)val).name = "RuleBookPageInteractable (" + keyText + ")"; val.transform.SetParent(((Component)PixelCamera).transform); val.transform.position = position; val.transform.localScale = colliderSize; val.transform.localRotation = Quaternion.identity; currentActiveInteractables.Add(val); } private void CreateInteractables(Dictionary redirectInfos, TextMeshPro description, float zLength) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) float num = -1f; float x2 = description.transform.localScale.x; foreach (string key in redirectInfos.Keys) { foreach (List wordIndece in GetWordIndeces(((TMP_Text)description).textInfo, key)) { int currentLine = -1; List list = new List(); List list2 = new List(); Vector3 bottomLeft = Vector3.zero; Vector3 topRight = Vector3.zero; foreach (int item in wordIndece) { TMP_WordInfo val = ((TMP_Text)description).textInfo.wordInfo[item]; List range = ((TMP_Text)description).textInfo.characterInfo.ToList().GetRange(val.firstCharacterIndex, val.lastCharacterIndex - val.firstCharacterIndex + 1); if (num == -1f) { num = range[0].topLeft.y - range[0].bottomLeft.y; } while (range.Count > 0) { if (currentLine == -1) { currentLine = range[0].lineNumber; bottomLeft = range[0].bottomLeft; } List list3 = range.FindAll((TMP_CharacterInfo x) => x.lineNumber == currentLine); range.RemoveAll(list3.Contains); if (list3.Count > 0) { topRight = list3.Last().topRight; } if (range.Count > 0) { CreateColliderSizeAndPosition(description.transform, num, zLength, bottomLeft, topRight, list, list2); currentLine = -1; } } } if (currentLine != -1) { CreateColliderSizeAndPosition(description.transform, num, zLength, bottomLeft, topRight, list, list2); } for (int i = 0; i < list.Count; i++) { _ = list[i]; _ = list2[i]; CreateInteractableObject(list2[i], list[i] * x2 * x2, key, redirectInfos[key]); } } } } public static IEnumerable> GetWordIndeces(TMP_TextInfo textInfo, string key) { string[] array = key.Split(); TMP_WordInfo[] wordInfo = textInfo.wordInfo; List> list = new List>(); for (int i = 0; i < wordInfo.Length; i++) { if (wordInfo[i].characterCount == 0 || !(((TMP_WordInfo)(ref wordInfo[i])).GetWord() == array[0])) { continue; } int num = -1; List list2 = new List { i }; for (int j = 1; j < array.Length; j++) { num = j; if (wordInfo[i + num].characterCount != 0 && ((TMP_WordInfo)(ref wordInfo[i + num])).GetWord() == array[j]) { list2.Add(i + num); } } if (num != -1) { i += num; } list.Add(list2); } return list; } private void CreateColliderSizeAndPosition(Transform textMesh, float sizeY, float zLength, Vector3 bottomLeft, Vector3 topRight, List colliderSizes, List colliderPositions) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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) //IL_0027: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) Vector3 val = textMesh.TransformPoint(bottomLeft); Vector3 val2 = textMesh.TransformPoint(topRight); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor((val2.x + val.x) / 2f, (val2.y + val.y) / 2f, val.z + 0.01f); float num2; float num3; float num4; float num5; if (SaveManager.SaveFile.IsPart3) { float num = (descriptionTopLeft.y - val3.y) / descriptionLengths[0]; num2 = currentPageTopLeft.x + currentPageLengths[0] * num; num3 = (descriptionTopLeft.x - val3.x) / descriptionLengths[1]; num4 = zLength * num3; num5 = currentPageTopLeft.y - currentPageLengths[1] * num3 - num4 * num3; } else { float num = (val3.x - descriptionTopLeft.x) / descriptionLengths[0]; num2 = currentPageTopLeft.x + currentPageLengths[0] * num; num3 = (descriptionTopLeft.y - val3.y) / descriptionLengths[1]; num4 = zLength * num3; num5 = currentPageTopLeft.y - currentPageLengths[1] * num3 - num4 * num3; } Vector3 item = default(Vector3); ((Vector3)(ref item))..ctor(num2, num5, currentPageTopLeft.z + (num4 + num4 * num3)); colliderPositions.Add(item); colliderSizes.Add(new Vector3(topRight.x - bottomLeft.x + sizeY / 2f, sizeY * 3f / 2f, 0.001f)); } } [HarmonyPatch] public static class RulebookRedirectPatches { [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int pageIndex; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; rulebookShowFlipIndex = pageIndex; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; rulebookShowFlipIndex = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static int rulebookShowFlipIndex = -1; [HarmonyPostfix] [HarmonyPatch(typeof(RuleBookController), "Start")] private static void CreateRedirectManager(RuleBookController __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { Singleton.m_Instance = ((Component)__instance).gameObject.AddComponent(); } } [HarmonyPrefix] [HarmonyPatch(typeof(RuleBookController), "SetShown")] private static void ResetInteractables(RuleBookController __instance, bool shown) { if (__instance.rigParent.activeSelf != shown) { Singleton.Instance.ClearActiveInteractables(); } } [IteratorStateMachine(typeof(d__2))] [HarmonyPostfix] [HarmonyPatch(typeof(RulebookPageFlipper), "ShowFlipToPage")] private static IEnumerator ResetTrueTopIndex(IEnumerator enumerator, int pageIndex) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { enumerator = enumerator, pageIndex = pageIndex }; } [HarmonyPrefix] [HarmonyPatch(typeof(RulebookPageFlipper), "RenderPages")] private static bool RetrieveRuleBookTopPage(Transform topPage) { Singleton.Instance.currentTopPage = topPage.Find("Plane01"); return true; } [HarmonyPostfix] [HarmonyPatch(typeof(PageFlipper), "LoadPageContent")] private static void AddInteractablesToTopPage(PageFlipper __instance, PageContentLoader loader, int index) { if (__instance.currentPageIndex != Singleton.Instance.currentActivePageIndex) { Singleton.Instance.ClearActiveInteractables(); } if (index != __instance.currentPageIndex) { return; } RuleBookPageInfo pageInfo = __instance.PageData[__instance.currentPageIndex]; RuleBookManager.RuleBookPageInfoExt ruleBookPageInfoExt = RuleBookManager.ConstructedPagesWithRedirects.Find((RuleBookManager.RuleBookPageInfoExt x) => x.parentPageInfo == pageInfo); if (ruleBookPageInfoExt == null || ruleBookPageInfoExt.RulebookDescriptionRedirects.Count == 0) { return; } if (__instance is TabletPageFlipper && (Object)(object)Singleton.Instance.currentTopPage == (Object)null) { RuleBookRedirectManager instance = Singleton.Instance; RuleBookRedirectManager instance2 = Singleton.Instance; instance.currentTopPage = instance2.currentTopPage ?? (instance2.currentTopPage = ((Component)Singleton.Instance.rigParent.transform.Find("Tablet").Find("Anim")).transform); } else if (__instance is RulebookPageFlipper && rulebookShowFlipIndex != -1 && index != rulebookShowFlipIndex) { return; } RuleBookPage component = loader.currentPageObj.GetComponent(); AbilityPage val = (AbilityPage)(object)((component is AbilityPage) ? component : null); TextMeshPro val2; if (val != null) { val2 = val.mainAbilityGroup.descriptionTextMesh; } else { StatIconPage val3 = (StatIconPage)(object)((component is StatIconPage) ? component : null); if (val3 != null) { val2 = val3.descriptionTextMesh; } else { BoonPage val4 = (BoonPage)(object)((component is BoonPage) ? component : null); if (val4 != null) { val2 = val4.descriptionTextMesh; } else { ItemPage val5 = (ItemPage)(object)((component is ItemPage) ? component : null); val2 = ((val5 == null) ? ((Component)loader.currentPageObj.transform.Find("Description")).GetComponent() : val5.descriptionTextMesh); } } } if ((Object)(object)val2 != (Object)null) { ((TMP_Text)val2).ForceMeshUpdate(false, false); Singleton.Instance.UpdateActiveInteractables(val2, loader.currentPageObj, ruleBookPageInfoExt.RulebookDescriptionRedirects); } Singleton.Instance.currentActivePageIndex = __instance.currentPageIndex; } } } namespace InscryptionAPI.Resource { public static class ResourceBankManager { public class ResourceData { public string PluginGUID; public Resource Resource; public bool OverrideExistingResource; } [HarmonyPatch(typeof(ResourceBank), "Awake", new Type[] { })] internal class ResourceBank_Awake { public static void Postfix(ResourceBank __instance) { Dictionary dictionary = new Dictionary(); foreach (Resource resource in __instance.resources) { string path = resource.path; if (!dictionary.ContainsKey(path)) { dictionary[path] = resource; } } foreach (ResourceData customResource in CustomResources) { string path2 = customResource.Resource.path; if (dictionary.TryGetValue(path2, out var value)) { if (customResource.OverrideExistingResource) { value.asset = customResource.Resource.asset; continue; } InscryptionAPIPlugin.Logger.LogWarning((object)$"Cannot add new resource at path {path2} because it already exists with asset {value.asset}!"); } else { dictionary[path2] = customResource.Resource; } __instance.resources.Add(customResource.Resource); } } } private static readonly List CustomResources = new List(); public static ResourceData Add(string pluginGUID, string path, Object unityObject, bool overrideExistingAsset = false) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown return Add(pluginGUID, new Resource { path = path, asset = unityObject }, overrideExistingAsset); } public static ResourceData Add(string pluginGUID, Resource resource, bool overrideExistingAsset = false) { if (resource == null) { InscryptionAPIPlugin.Logger.LogError((object)(pluginGUID + " cannot add null resources!")); return null; } if (string.IsNullOrEmpty(resource.path)) { InscryptionAPIPlugin.Logger.LogError((object)$"{pluginGUID} Attempting to add resource with empty path! '{resource.path}' and asset {resource.asset}"); return null; } ResourceData resourceData = new ResourceData { PluginGUID = pluginGUID, Resource = resource, OverrideExistingResource = overrideExistingAsset }; CustomResources.Add(resourceData); return resourceData; } public static ResourceData AddScaleWeightPrefab(string pluginGUID, string resourceName, GameObject prefab, bool overrideExistingAsset = false) { return Add(pluginGUID, "Prefabs/Environment/ScaleWeights/" + resourceName, (Object)(object)prefab, overrideExistingAsset); } public static ResourceData AddCardBattleIdleEvent(string pluginGUID, string resourceName, GameObject eventPrefab, bool overrideExistingAsset = false) { return Add(pluginGUID, "Prefabs/Environment/CardBattleIdleEvents/" + resourceName, (Object)(object)eventPrefab, overrideExistingAsset); } public static ResourceData AddFirstPersonAnimation(string pluginGUID, string resourceName, GameObject animPrefab, bool overrideExistingAsset = false) { return Add(pluginGUID, "Prefabs/FirstPersonAnimations/" + resourceName, (Object)(object)animPrefab, overrideExistingAsset); } public static ResourceData AddTableEffect(string pluginGUID, string resourceName, GameObject tableEffectPrefab, bool overrideExistingAsset = false) { return Add(pluginGUID, "Prefabs/Environment/TableEffects/" + resourceName, (Object)(object)tableEffectPrefab, overrideExistingAsset); } public static ResourceData AddMapScenery(string pluginGUID, string resourceName, GameObject sceneryPrefab, bool overrideExistingAsset = false) { return Add(pluginGUID, SceneryData.PREFABS_ROOT + resourceName, (Object)(object)sceneryPrefab, overrideExistingAsset); } public static ResourceData AddAbilityIcon(string pluginGUID, string resourceName, Texture iconTexture, bool overrideExistingAsset = false) { return Add(pluginGUID, "Art/Cards/AbilityIcons/" + resourceName, (Object)(object)iconTexture, overrideExistingAsset); } public static ResourceData AddDecal(string pluginGUID, string resourceName, Texture decalTexture, bool overrideExistingAsset = false) { return Add(pluginGUID, "Art/Cards/Decals/" + resourceName, (Object)(object)decalTexture, overrideExistingAsset); } } } namespace InscryptionAPI.Regions { public class Part1RegionData { private int tier; private RegionData region; public string GUID { get; private set; } public int Tier { get { return tier; } private set { tier = value; } } public RegionData Region { get { return region; } private set { region = value; } } public int MinTerrain { get; set; } public int MaxTerrain { get; set; } public bool AllowTerrainOnEnemySide { get; set; } public bool AllowTerrainOnPlayerSide { get; set; } public bool RemoveDefaultReachTerrain { get; set; } public bool DoNotForceReachTerrain { get; set; } public bool AllowLockedTerrainCards { get; set; } public bool AllowSacrificableTerrainCards { get; set; } public bool CanAppearRandomly { get; set; } public Part1RegionData(RegionData region, int tier) { Assembly callingAssembly = Assembly.GetCallingAssembly(); GUID = TypeManager.GetModIdFromCallstack(callingAssembly); AllowSacrificableTerrainCards = false; AllowLockedTerrainCards = false; MinTerrain = -2; MaxTerrain = 3; AllowTerrainOnEnemySide = true; AllowTerrainOnPlayerSide = true; RemoveDefaultReachTerrain = false; DoNotForceReachTerrain = false; CanAppearRandomly = true; this.region = region; this.tier = tier; } } public static class RegionExtensions { public static RegionData SetCanAppearRandomly(this RegionData data, bool canAppear) { Part1RegionData part1RegionData = RegionManager.NewRegions.FirstOrDefault((Part1RegionData x) => (Object)(object)x.Region == (Object)(object)data); if (part1RegionData != null) { part1RegionData.CanAppearRandomly = canAppear; } else { InscryptionAPIPlugin.Logger.LogWarning((object)("Could not find custom region for RegionData [" + ((Object)data).name + "]!")); } return data; } public static RegionData RegionByName(this IEnumerable regions, string name) { return regions.FirstOrDefault((Func)((RegionData x) => ((Object)x).name == name)); } public static RegionData SetName(this RegionData region, string name) { ((Object)region).name = name; return region; } public static RegionData AddTerrainCards(this RegionData region, params string[] cards) { region.terrainCards = region.terrainCards ?? new List(); foreach (string name in cards) { CardInfo item = CardManager.AllCardsCopy.CardByName(name); if (!region.terrainCards.Contains(item)) { region.terrainCards.Add(item); } } return region; } public static RegionData AddLikelyCards(this RegionData region, params string[] cards) { region.likelyCards = region.likelyCards ?? new List(); foreach (string name in cards) { CardInfo item = CardManager.AllCardsCopy.CardByName(name); if (!region.likelyCards.Contains(item)) { region.likelyCards.Add(item); } } return region; } public static RegionData AddConsumableItems(this RegionData region, params string[] consumables) { region.consumableItems = region.consumableItems ?? new List(); foreach (string text in consumables) { region.consumableItems.Add(ItemsUtil.GetConsumableByName(text)); } return region; } public static RegionData AddConsumableItems(this RegionData region, params ConsumableItemData[] consumables) { region.consumableItems = region.consumableItems ?? new List(); foreach (ConsumableItemData item in consumables) { region.consumableItems.Add(item); } return region; } public static RegionData AddDominantTribes(this RegionData region, params Tribe[] tribes) { //IL_001e: 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) region.dominantTribes = region.dominantTribes ?? new List(); foreach (Tribe item in tribes) { region.dominantTribes.Add(item); } return region; } public static RegionData SetBoardColor(this RegionData region, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) region.boardLightColor = color; return region; } public static RegionData SetCardsColor(this RegionData region, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) region.cardsLightColor = color; return region; } public static EncounterBuilderBlueprintData CreateEncounter(this RegionData region, string name = null) { EncounterBuilderBlueprintData encounterBuilderBlueprintData = ScriptableObject.CreateInstance(); encounterBuilderBlueprintData.SetBasic(name, region); return encounterBuilderBlueprintData; } public static RegionData AddEncounters(this RegionData region, params EncounterBlueprintData[] encounters) { region.encounters = region.encounters ?? new List(); foreach (EncounterBlueprintData val in encounters) { bool flag = false; for (int j = 0; j < region.encounters.Count; j++) { if (((Object)region.encounters[j]).name.Equals(val)) { region.encounters[j] = val; flag = true; break; } } if (!flag) { region.encounters.Add(val); } } return region; } public static RegionData SetBossPrepCondition(this RegionData region, StoryEventCondition condition) { region.bossPrepCondition = condition; return region; } public static RegionData SetBossPrepEncounter(this RegionData region, EncounterBlueprintData encounter) { region.bossPrepEncounter = encounter; return region; } public static RegionData AddBosses(this RegionData region, params Type[] bosses) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) region.bosses = region.bosses ?? new List(); foreach (Type item in bosses) { if (!region.bosses.Contains(item)) { region.bosses.Add(item); } } return region; } public static RegionData SetDustParticlesEnabled(this RegionData region, bool enabled) { region.dustParticlesDisabled = !enabled; return region; } public static RegionData SetFogEnabled(this RegionData region, bool enabled) { region.fogEnabled = enabled; return region; } public static RegionData SetFogAlpha(this RegionData region, float alpha) { region.fogAlpha = alpha; return region; } public static RegionData SetMapEmission(this RegionData region, Texture texture) { region.mapEmission = texture; return region; } public static RegionData SetMapEmission(this RegionData region, Texture2D texture) { region.mapEmission = (Texture)(object)texture; return region; } public static RegionData SetMapEmissionColor(this RegionData region, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) region.mapEmissionColor = color; return region; } public static RegionData SetSilenceCabinAmbience(this RegionData region, bool enabled) { region.silenceCabinAmbience = enabled; return region; } public static RegionData SetAmbientLoopId(this RegionData region, string id) { region.ambientLoopId = id; return region; } public static RegionData AddFillerScenery(this RegionData region, params FillerSceneryEntry[] fillerScenery) { region.fillerScenery = region.fillerScenery ?? new List(); foreach (FillerSceneryEntry item in fillerScenery) { region.fillerScenery.Add(item); } return region; } public static RegionData AddScarceScenery(this RegionData region, params ScarceSceneryEntry[] scarceScenery) { region.scarceScenery = region.scarceScenery ?? new List(); foreach (ScarceSceneryEntry item in scarceScenery) { region.scarceScenery.Add(item); } return region; } public static RegionData SetFogProfile(this RegionData region, VolumetricFogProfile fogProfile) { region.fogProfile = fogProfile; return region; } public static RegionData SetMapAlbedo(this RegionData region, Texture mapAlbedo) { region.mapAlbedo = mapAlbedo; return region; } public static RegionData SetMapParticlesPrefabs(this RegionData region, params GameObject[] particles) { region.mapParticlesPrefabs = region.mapParticlesPrefabs ?? new List(); foreach (GameObject item in particles) { region.mapParticlesPrefabs.Add(item); } return region; } public static RegionData Build(this RegionData region, bool ignoreTerrainWarning = false, bool ignoreTribesWarning = false, bool ignoreEncountersWarning = false, bool ignoreBossesWarning = false) { if (!ignoreTerrainWarning && (region.terrainCards == null || region.terrainCards.Count == 0)) { InscryptionAPIPlugin.Logger.LogWarning((object)("Region " + ((Object)region).name + " does not have any terrain cards!")); } if (!ignoreTribesWarning && (region.dominantTribes == null || region.dominantTribes.Count == 0)) { InscryptionAPIPlugin.Logger.LogWarning((object)("Region " + ((Object)region).name + " does not have any dominant tribes!")); } if (!ignoreEncountersWarning && (region.encounters == null || region.encounters.Count == 0)) { InscryptionAPIPlugin.Logger.LogWarning((object)("Region " + ((Object)region).name + " does not have any encounters!")); } if (!ignoreBossesWarning && (region.bosses == null || region.bosses.Count == 0)) { InscryptionAPIPlugin.Logger.LogWarning((object)("Region " + ((Object)region).name + " does not have any bosses!")); } return region; } } [HarmonyPatch] public static class RegionManager { [HarmonyPatch(typeof(MapDataReader), "SpawnMapObjects", new Type[] { typeof(MapData), typeof(int), typeof(Vector2) })] public class MapDataReader_SpawnMapObjects { public static IEnumerable Transpiler(IEnumerable instructions) { List list = new List(instructions); MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => GetSpawnedMapObjectRenderer(null))); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Callvirt && list[i].operand.ToString() == "UnityEngine.Renderer GetComponent[Renderer]()") { list[i].operand = methodInfo; } } return list; } private static Renderer GetSpawnedMapObjectRenderer(GameObject gameObject) { Renderer result = default(Renderer); if (gameObject.TryGetComponent(ref result)) { return result; } Renderer componentInChildren = gameObject.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("[RegionManager] Map object " + ((Object)gameObject).name + " does not have a renderer attached!")); } return componentInChildren; } } public static readonly ReadOnlyCollection BaseGameRegions; public static readonly ObservableCollection NewRegions; public static List AllRegionsCopy { get; private set; } public static event Func, List> ModifyRegionsList; private static List ReorderBaseRegions() { List list = Resources.LoadAll("Data").ToList(); return new List { list[2], list[6], list[1], list[3], list[4], list[5], list[0] }; } private static List GenerateBasePart1RegionData() { return (from x in ReorderBaseRegions() select new Part1RegionData(x, 0)).ToList(); } internal static void ReplaceBlueprintInCore(EncounterBlueprintData newData) { foreach (RegionData item in NewRegions.Select((Part1RegionData s) => s.Region).Concat(BaseGameRegions)) { if (item.encounters != null) { for (int i = 0; i < item.encounters.Count; i++) { if (((Object)item.encounters[i]).name.Equals(((Object)newData).name)) { item.encounters[i] = newData; } } } if ((Object)(object)item.bossPrepEncounter != (Object)null && ((Object)item.bossPrepEncounter).name.Equals(((Object)newData).name)) { item.bossPrepEncounter = newData; } } } private static RegionData CloneRegion(this RegionData data) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown RegionData val = (RegionData)Object.Internal_CloneSingle((Object)(object)data); ((Object)val).name = ((Object)data).name; return val; } public static void SyncRegionList() { List list = (from x in BaseGameRegions.Concat(NewRegions.Select((Part1RegionData x) => x.Region)) select x.CloneRegion()).ToList(); AllRegionsCopy = RegionManager.ModifyRegionsList?.Invoke(list) ?? list; int i; for (i = 0; i < RegionProgression.Instance.regions.Count; i++) { RegionData val = ((IEnumerable)AllRegionsCopy).FirstOrDefault((Func)((RegionData rd) => ((Object)rd).name.Equals(((Object)RegionProgression.Instance.regions[i]).name))); if ((Object)(object)val != (Object)null) { RegionProgression.Instance.regions[i] = val; } } RegionData ascensionFinalRegion = ((IEnumerable)AllRegionsCopy).FirstOrDefault((Func)((RegionData rd) => ((Object)rd).name.Equals(((Object)RegionProgression.Instance.ascensionFinalRegion).name))); RegionProgression.Instance.ascensionFinalRegion = ascensionFinalRegion; RegionData ascensionFinalBossRegion = ((IEnumerable)AllRegionsCopy).FirstOrDefault((Func)((RegionData rd) => ((Object)rd).name.Equals(((Object)RegionProgression.Instance.ascensionFinalBossRegion).name))); RegionProgression.Instance.ascensionFinalBossRegion = ascensionFinalBossRegion; } static RegionManager() { BaseGameRegions = new ReadOnlyCollection(ReorderBaseRegions()); NewRegions = new ObservableCollection(); AllRegionsCopy = BaseGameRegions.ToList(); InscryptionAPIPlugin.ScriptableObjectLoaderLoad += delegate(Type type) { if (type == typeof(RegionData)) { ScriptableObjectLoader.allData = AllRegionsCopy; } }; NewRegions.CollectionChanged += delegate { SyncRegionList(); }; } public static void Add(RegionData newRegion, int tier) { if (!NewRegions.Select((Part1RegionData x) => x.Region).Contains(newRegion)) { NewRegions.Add(new Part1RegionData(newRegion, tier)); } } public static void Remove(RegionData region) { NewRegions.Remove(NewRegions.Where((Part1RegionData x) => (Object)(object)x.Region == (Object)(object)region).First()); } public static RegionData New(string name, int tier, bool addToPool = true) { RegionData val = ScriptableObject.CreateInstance(); ((Object)val).name = name; Add(val, tier); if (!addToPool) { val.SetCanAppearRandomly(canAppear: false); } return val; } public static RegionData FromTierFull(string name, int originalTier, int newTier, bool addToPool = true) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown RegionData val = (RegionData)Object.Internal_CloneSingle((Object)(object)ResourceBank.Get("Data/Map/RegionProgression").regions[originalTier]); ((Object)val).name = name; if (addToPool) { Add(val, newTier); } return val; } public static RegionData FromTierFull(string name, int originalTier, bool addToPool = true) { return FromTierFull(name, originalTier, originalTier, addToPool); } public static RegionData FromTierBasic(string name, int originalTier, int newTier, bool addToPool = true) { RegionData obj = FromTierFull(name, originalTier, newTier, addToPool); obj.encounters = new List(); obj.bossPrepCondition = null; obj.consumableItems = new List(); obj.dominantTribes = new List(); obj.likelyCards = new List(); obj.terrainCards = new List(); return obj; } public static RegionData FromTierBasic(string name, int originalTier, bool addToPool = true) { return FromTierBasic(name, originalTier, originalTier, addToPool); } [HarmonyPrefix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static bool CurrentMapPrefix(RunState __instance, ref RegionData __result) { if (SaveManager.SaveFile.IsPart3 || SaveManager.SaveFile.IsGrimora) { __result = ResourceBank.Get("Data/Map/Regions/!TEST_PART3"); return false; } if (SaveFile.IsAscension) { if (RunState.Run.regionTier == RegionProgression.Instance.regions.Count - 1) { if (AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)15)) { __result = RegionProgression.Instance.ascensionFinalBossRegion; } else { __result = RegionProgression.Instance.ascensionFinalRegion; } return false; } __result = AllRegionsCopy[RunState.Run.regionOrder[RunState.Run.regionTier]]; return false; } __result = AllRegionsCopy[RunState.Run.regionTier]; return false; } [HarmonyPatch(typeof(EncounterBuilder), "BuildTerrainCondition")] [HarmonyPrefix] private static bool ApplyTerrainCustomization(ref StartCondition __result, ref bool reachTerrainOnPlayerSide, int randomSeed) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown Part1RegionData customregion = NewRegions.ToList()?.Find((Part1RegionData x) => (Object)(object)x.Region == (Object)(object)RunState.CurrentMapRegion); if (customregion != null) { reachTerrainOnPlayerSide &= !customregion.DoNotForceReachTerrain; __result = new StartCondition(); int num = SeededRandom.Range(customregion.MinTerrain, customregion.MaxTerrain, randomSeed++); int num2 = 0; int num3 = 0; for (int i = 0; i < num; i++) { bool flag; if (customregion.AllowTerrainOnEnemySide && customregion.AllowTerrainOnPlayerSide) { flag = SeededRandom.Bool(randomSeed++); if (flag && num2 == 1) { flag = false; } else if (!flag && num3 == 1) { flag = true; } } else { flag = customregion.AllowTerrainOnPlayerSide; } CardInfo[] array = (flag ? __result.cardsInPlayerSlots : __result.cardsInOpponentSlots); CardInfo[] array2 = (flag ? __result.cardsInOpponentSlots : __result.cardsInPlayerSlots); int num4 = SeededRandom.Range(0, array.Length, randomSeed++); bool flag2 = false; for (int j = 0; j < ((array.Length >= array2.Length) ? array.Length : array2.Length); j++) { if ((Object)(object)array[j] == (Object)null && (Object)(object)array2[j] == (Object)null) { flag2 = true; } } if (!flag2) { break; } while ((Object)(object)array[num4] != (Object)null || (Object)(object)array2[num4] != (Object)null) { num4 = SeededRandom.Range(0, array.Length, randomSeed++); } if (flag & reachTerrainOnPlayerSide) { CardInfo val = RunState.CurrentMapRegion.terrainCards.Find((CardInfo x) => x.HasAbility((Ability)23)); if ((Object)(object)val == (Object)null && !customregion.RemoveDefaultReachTerrain) { val = CardLoader.GetCardByName("Tree"); } if ((Object)(object)val != (Object)null) { array[num4] = CardLoader.GetCardByName(((Object)val).name); } } else { List list = RunState.CurrentMapRegion.terrainCards.FindAll((CardInfo x) => (ConceptProgressionTree.Tree.CardUnlocked(x, true) || customregion.AllowLockedTerrainCards) && (x.traits.Contains((Trait)12) || customregion.AllowSacrificableTerrainCards)); if (list.Count > 0) { array[num4] = CardLoader.GetCardByName(((Object)list[SeededRandom.Range(0, list.Count, randomSeed++)]).name); } } if (flag) { num2++; } else { num3++; } } return false; } return true; } [HarmonyPatch(typeof(MapDataReader), "SpawnAndPlaceElement")] [HarmonyPrefix] private static bool MapDataReader_SpawnAndPlaceElement(ref MapDataReader __instance, ref GameObject __result, MapElementData data, Vector2 sampleRange, bool isScenery) { //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) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; string prefabPath = __instance.GetPrefabPath(data); GameObject val2 = ResourceBank.Get(prefabPath); if ((Object)(object)val2 == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("[RegionManager] Could not find object " + prefabPath + " to spawn in region!")); val2 = Resources.Load("prefabs/map/mapscenery/TreasureChest"); } if (!isScenery) { val = Object.Instantiate(val2); } else { MapElement val3 = val2.GetComponent(); if ((Object)(object)val3 == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("[RegionManager] " + ((Object)val2).name + " at path " + prefabPath + " does not have a mapElement component!")); val3 = val2.AddComponent(); } val = ((Component)((PooledObject)val3).GetPooledInstance()).gameObject; } val.transform.SetParent(isScenery ? __instance.sceneryParent : __instance.nodesParent); val.transform.localPosition = __instance.GetRealPosFromDataPos(data.position, sampleRange); if (isScenery) { MapElement component = val.GetComponent(); __instance.scenery.Add(component); component.Data = data; } __result = val; return false; } private static List GetAllRegionsForMapGeneration() { List list = new List(RegionProgression.Instance.regions); list.RemoveAt(list.Count - 1); list.AddRange(from x in NewRegions where x.CanAppearRandomly select x into a select a.Region); list.ForEach(delegate(RegionData x) { InscryptionAPIPlugin.Logger.LogInfo((object)((Object)x).name); }); return list; } [HarmonyPrefix] [HarmonyPatch(typeof(AscensionSaveData), "RollCurrentRunRegionOrder")] private static bool RollCurrentRunRegionOrder(AscensionSaveData __instance) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00a7: 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_00a4: Unknown result type (might be due to invalid IL or missing references) List allRegionsForMapGeneration = GetAllRegionsForMapGeneration(); allRegionsForMapGeneration = CustomList.Randomize((IEnumerable)allRegionsForMapGeneration).ToList(); List selectedRegions = new List(); List list = new List(); while (selectedRegions.Count < 3) { List list2 = allRegionsForMapGeneration.Where((RegionData a) => !selectedRegions.Contains(a)).ToList(); RegionData val = null; val = ((list2.Count != 0) ? list2[0] : allRegionsForMapGeneration[0]); selectedRegions.Add(val); Type val2 = GetRandomAvailableOpponent(val, list); if ((int)val2 == 0) { val2 = val.bosses.GetRandom(); } list.Add(val2); } int[] array = new int[3]; for (int i = 0; i < selectedRegions.Count; i++) { RegionData region = selectedRegions[i]; int num = AllRegionsCopy.FindIndex((RegionData a) => ((Object)a).name == ((Object)region).name); if (num == -1) { InscryptionAPIPlugin.Logger.LogError((object)("Could not get index of region " + ((Object)region).name + " in all regions list!")); foreach (RegionData item in AllRegionsCopy) { InscryptionAPIPlugin.Logger.LogError((object)(" " + ((Object)item).name)); } num = 0; } array[i] = num; } OpponentManager.RunStateOpponents = list; __instance.currentRun.regionOrder = array; return false; } private static Type GetRandomAvailableOpponent(RegionData regionData, List selectedOpponents) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) List list = regionData.bosses.Where((Type a) => !selectedOpponents.Contains(a)).ToList(); if (list.Count == 0) { return (Type)0; } return list.GetRandom(); } } } namespace InscryptionAPI.PixelCard { [HarmonyPatch] public static class GBCPackManager { public static event Func, List> ModifyGBCPacks; [HarmonyTranspiler] [HarmonyPatch(typeof(PackOpeningUI), "AssignInfoToCards")] private static IEnumerable RemoveSingletons(IEnumerable instructions) { List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Call && list[i].operand.ToString().Contains("GetPixelCards")) { MethodInfo operand = AccessTools.Method(typeof(GBCPackManager), "ModifyPixelCards", (Type[])null, (Type[])null); list[i].operand = operand; break; } } return list; } private static List ModifyPixelCards() { List pixelCards = CardLoader.GetPixelCards(); pixelCards.RemoveAll((CardInfo x) => x.onePerDeck && SaveManager.SaveFile.gbcData.collection.cardIds.Contains(((Object)x).name)); return GBCPackManager.ModifyGBCPacks?.Invoke(pixelCards) ?? pixelCards; } } public class PixelAppearanceBehaviour : CardAppearanceBehaviour { public override void ApplyAppearance() { } public virtual Sprite PixelAppearance() { return null; } public virtual Sprite OverridePixelPortrait() { return null; } public virtual Sprite OverrideBackground() { return null; } public virtual void OnAppearanceApplied() { } } public class PixelGemificationBorder : MonoBehaviour { public Card card; public GameObject OrangeGemLit; public GameObject GreenGemLit; public GameObject BlueGemLit; private void Start() { card = ((Component)this).GetComponentInParent(); UpdateGemGlow(); } private void Update() { //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 (((Scene)(ref activeScene)).name == "GBC_CardBattle") { UpdateGemGlow(); } } private void UpdateGemGlow() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Singleton.Instance)) { Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "GBC_CardBattle" && ((PlayableCard)/*isinst with value type is only supported in some contexts*/).OpponentCard) { if (Object.op_Implicit((Object)(object)Singleton.Instance)) { ((Renderer)OrangeGemLit.GetComponent()).enabled = Singleton.Instance.HasGem((GemType)1); ((Renderer)BlueGemLit.GetComponent()).enabled = Singleton.Instance.HasGem((GemType)2); ((Renderer)GreenGemLit.GetComponent()).enabled = Singleton.Instance.HasGem((GemType)0); } } else { ((Renderer)OrangeGemLit.GetComponent()).enabled = Singleton.Instance.HasGem((GemType)1); ((Renderer)BlueGemLit.GetComponent()).enabled = Singleton.Instance.HasGem((GemType)2); ((Renderer)GreenGemLit.GetComponent()).enabled = Singleton.Instance.HasGem((GemType)0); } } else { ((Renderer)OrangeGemLit.GetComponent()).enabled = false; ((Renderer)BlueGemLit.GetComponent()).enabled = false; ((Renderer)GreenGemLit.GetComponent()).enabled = false; } } } [HarmonyPatch] public static class PixelCardManager { public class PixelDecalData { public string PluginGUID; public string TextureName; public Texture2D DecalTexture; } private class DecalIdentifier : MonoBehaviour { } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; foreach (CardInfo card in ((CardCollectionInfo)SaveManager.SaveFile.gbcData.deck).Cards) { card.Mods.RemoveAll((CardModificationInfo x) => x.IsTemporaryDecal()); } <>2__current = this.enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static readonly List CustomPixelDecals = new List(); public static Sprite PixelGemifiedDecal; public static Sprite PixelGemifiedOrangeLit; public static Sprite PixelGemifiedBlueLit; public static Sprite PixelGemifiedGreenLit; public static PixelDecalData AddGBCDecal(string pluginGUID, string textureName, Texture2D texture) { PixelDecalData pixelDecalData = new PixelDecalData { PluginGUID = pluginGUID, TextureName = textureName, DecalTexture = texture }; if (!CustomPixelDecals.Contains(pixelDecalData)) { CustomPixelDecals.Add(pixelDecalData); } return pixelDecalData; } internal static void Initialise() { PixelGemifiedDecal = TextureHelper.GetImageAsSprite("PixelGemifiedDecal.png", InscryptionAPIPlugin.APIAssembly, TextureHelper.SpriteType.PixelDecal, (FilterMode)0); PixelGemifiedOrangeLit = TextureHelper.GetImageAsSprite("PixelGemifiedOrange.png", InscryptionAPIPlugin.APIAssembly, TextureHelper.SpriteType.PixelDecal, (FilterMode)0); PixelGemifiedGreenLit = TextureHelper.GetImageAsSprite("PixelGemifiedGreen.png", InscryptionAPIPlugin.APIAssembly, TextureHelper.SpriteType.PixelDecal, (FilterMode)0); PixelGemifiedBlueLit = TextureHelper.GetImageAsSprite("PixelGemifiedBlue.png", InscryptionAPIPlugin.APIAssembly, TextureHelper.SpriteType.PixelDecal, (FilterMode)0); } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void GetCorrectCardComponentInAct2(CardAppearanceBehaviour __instance, ref Card __result) { if (SaveManager.SaveFile.IsPart2) { __result = ((Component)__instance).GetComponentInParent(); } } [IteratorStateMachine(typeof(d__5))] [HarmonyPostfix] [HarmonyPatch(typeof(PixelBoardManager), "CleanUp")] private static IEnumerator ClearTempDecals(IEnumerator enumerator) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { enumerator = enumerator }; } [HarmonyPatch(typeof(PixelCardDisplayer), "UpdateBackground")] [HarmonyPostfix] private static void PixelUpdateBackground(PixelCardDisplayer __instance, CardInfo info) { //IL_001a: 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) foreach (Appearance appearance in info.appearanceBehaviour) { CardAppearanceBehaviourManager.FullCardAppearanceBehaviour fullCardAppearanceBehaviour = CardAppearanceBehaviourManager.AllAppearances.Find((CardAppearanceBehaviourManager.FullCardAppearanceBehaviour x) => x.Id == appearance); if (fullCardAppearanceBehaviour?.AppearanceBehaviour == null) { continue; } Component val = ((Component)__instance).gameObject.GetComponent(fullCardAppearanceBehaviour.AppearanceBehaviour); if (val == null) { val = ((Component)__instance).gameObject.AddComponent(fullCardAppearanceBehaviour.AppearanceBehaviour); } Sprite val2 = (val as PixelAppearanceBehaviour)?.OverrideBackground(); if ((Object)(object)val2 != (Object)null) { SpriteRenderer component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.sprite = val2; } } Object.Destroy((Object)(object)val); } } [HarmonyPatch(typeof(PixelCardDisplayer), "DisplayInfo")] [HarmonyPostfix] private static void DecalPatches(PixelCardDisplayer __instance, PlayableCard playableCard) { //IL_0017: 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) if (!(((Object)((Component)__instance).gameObject).name == "PixelSnap")) { Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name == "GBC_CardBattle") || !(((Object)((Component)__instance).gameObject).name != "CardPreviewPanel")) { return; } } AddDecalToCard(in __instance, playableCard); } private static void AddDecalToCard(in PixelCardDisplayer instance, PlayableCard playableCard) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) PixelCardDisplayer obj = instance; object obj2; if (obj == null) { obj2 = null; } else { GameObject gameObject = ((Component)obj).gameObject; if (gameObject == null) { obj2 = null; } else { Transform transform = gameObject.transform; obj2 = ((transform != null) ? transform.Find("CardElements") : null); } } Transform cardElements = (Transform)obj2; if ((Object)(object)cardElements == (Object)null) { return; } List list = new List(); foreach (Transform item in ((Component)cardElements).transform) { Transform val = item; object obj3; if (val == null) { obj3 = null; } else { GameObject gameObject2 = ((Component)val).gameObject; obj3 = ((gameObject2 != null) ? gameObject2.GetComponent() : null); } if (Object.op_Implicit((Object)obj3)) { list.Add(val); } } for (int num = list.Count - 1; num >= 0; num--) { list[num].parent = null; Object.Destroy((Object)(object)((Component)list[num]).gameObject); } if (((CardDisplayer)instance).info.Gemified && (Object)(object)cardElements.Find("PixelGemifiedBorder") == (Object)null) { PixelGemificationBorder pixelGemificationBorder = CreateDecal(in cardElements, PixelGemifiedDecal, "PixelGemifiedBorder").AddComponent(); pixelGemificationBorder.BlueGemLit = CreateDecal(in cardElements, PixelGemifiedBlueLit, "PixelGemifiedBlue"); pixelGemificationBorder.GreenGemLit = CreateDecal(in cardElements, PixelGemifiedGreenLit, "PixelGemifiedGreen"); pixelGemificationBorder.OrangeGemLit = CreateDecal(in cardElements, PixelGemifiedOrangeLit, "PixelGemifiedOrange"); } foreach (Appearance item2 in ((CardDisplayer)instance).info.appearanceBehaviour) { Appearance appearance = item2; CardAppearanceBehaviourManager.FullCardAppearanceBehaviour fullCardAppearanceBehaviour = CardAppearanceBehaviourManager.AllAppearances.Find((CardAppearanceBehaviourManager.FullCardAppearanceBehaviour x) => x.Id == appearance); if (fullCardAppearanceBehaviour?.AppearanceBehaviour == null) { continue; } Component val2 = ((Component)instance).gameObject.GetComponent(fullCardAppearanceBehaviour.AppearanceBehaviour); if (val2 == null) { val2 = ((Component)instance).gameObject.AddComponent(fullCardAppearanceBehaviour.AppearanceBehaviour); } if (val2 is PixelAppearanceBehaviour pixelAppearanceBehaviour) { pixelAppearanceBehaviour.OnAppearanceApplied(); Sprite val3 = pixelAppearanceBehaviour.PixelAppearance(); Transform val4 = cardElements.Find(((object)(Appearance)(ref appearance)).ToString() + "_Displayer"); if ((Object)(object)val3 != (Object)null && (Object)(object)val4 == (Object)null) { CreateDecal(in cardElements, val3, ((object)(Appearance)(ref appearance)).ToString() + "_Displayer"); } Sprite val5 = pixelAppearanceBehaviour.OverridePixelPortrait(); if ((Object)(object)val5 != (Object)null) { ((CardDisplayer)instance).SetPortrait(val5); } } Object.Destroy((Object)(object)val2); } if ((Object)(object)playableCard == (Object)null) { return; } List> list2 = new List>(); foreach (CardModificationInfo mod in ((Card)playableCard).Info.Mods) { foreach (string decalId in mod.DecalIds) { PixelDecalData pixelDecalData = CustomPixelDecals.Find((PixelDecalData x) => x.TextureName == decalId); if (pixelDecalData != null) { list2.Add(new Tuple(pixelDecalData.DecalTexture, pixelDecalData.TextureName)); } } } foreach (Tuple item3 in list2) { Sprite sprite = item3.Item1.ConvertTexture(TextureHelper.SpriteType.PixelDecal, (FilterMode)0); CreateDecal(in cardElements, sprite, item3.Item2); } } private static GameObject CreateDecal(in Transform cardElements, Sprite sprite, string name) { //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_0014: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(cardElements, false); val.layer = LayerMask.NameToLayer("GBCUI"); val.AddComponent(); SpriteRenderer val2 = val.AddComponent(); val2.sprite = sprite; Transform obj = cardElements; object obj2; if (obj == null) { obj2 = null; } else { Transform obj3 = obj.Find("Portrait"); if (obj3 == null) { obj2 = null; } else { GameObject gameObject = ((Component)obj3).gameObject; obj2 = ((gameObject != null) ? gameObject.GetComponent() : null); } } SpriteRenderer val3 = (SpriteRenderer)obj2; if ((Object)(object)val3 != (Object)null) { ((Renderer)val2).sortingLayerID = ((Renderer)val3).sortingLayerID; ((Renderer)val2).sortingOrder = ((Renderer)val3).sortingOrder; } return val; } } } namespace InscryptionAPI.Pelts { public static class PeltManager { private class VanillaPeltData : PeltData { public override int BuyPrice => GetBasePeltData().Find((Tuple a) => a.Item1 == peltCardName).Item2; } public class PeltData { public string pluginGuid; public string peltCardName; public string peltTierName; public bool isSoldByTrapper = true; public Func> CardChoices; public Func BuyPriceAdjustment = (int basePrice) => basePrice + RunState.CurrentRegionTier; public Action ModifyCardChoiceAtTrader; public int baseBuyPrice; public int maxBuyPrice; public int extraAbilitiesToAdd; public int choicesOfferedByTrader = 8; public int bossDefeatedPriceReduction = 2; public int expensivePeltsPriceMultiplier = 2; public virtual int BuyPrice { get { int num = ((!StoryEventsData.EventCompleted((StoryEvent)22)) ? 1 : ((bossDefeatedPriceReduction <= 0) ? 1 : bossDefeatedPriceReduction)); int num2 = ((!AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)7)) ? 1 : ((expensivePeltsPriceMultiplier <= 0) ? 1 : expensivePeltsPriceMultiplier)); int num3 = BuyPriceAdjustment(baseBuyPrice) / num * num2; if (maxBuyPrice > 0) { num3 = Mathf.Min(maxBuyPrice, num3); } return Mathf.Max(1, num3); } } } internal static List AllNewPelts = new List(); private static List BasePelts = null; internal static string[] BasePeltNames { get; } = new string[3] { "PeltHare", "PeltWolf", "PeltGolden" }; internal static int[] BasePeltPrices { get { int num = ((!AscensionSaveData.Data.ChallengeIsActive((AscensionChallenge)7)) ? 1 : 2); int num2 = ((!Singleton.Instance.buyPeltsSequencer.TrapperBossDefeated) ? 1 : 2); return new int[3] { 2 / num2 * num, (4 + RunState.CurrentRegionTier) / num2 * num, Mathf.Min(20, (7 + RunState.CurrentRegionTier * 2) / num2 * num) }; } } internal static List AllPelts() { if (BasePelts == null) { BasePelts = CreateBasePelts(); } return BasePelts.Concat(AllNewPelts).ToList(); } internal static List> GetBasePeltData() { List> list = new List>(); for (int i = 0; i < BasePeltNames.Length; i++) { string item = BasePeltNames[i]; list.Add(new Tuple(item, BasePeltPrices[i])); } return list; } private static List CreateBasePelts() { List list = new List(); for (int i = 0; i < BasePeltNames.Length; i++) { VanillaPeltData item = new VanillaPeltData { peltCardName = BasePeltNames[i], choicesOfferedByTrader = 8, extraAbilitiesToAdd = 0, isSoldByTrapper = true, CardChoices = () => CardLoader.GetUnlockedCards((CardMetaCategory)1, (CardTemple)0) }; list.Add(item); } list[1].extraAbilitiesToAdd = 1; list[2].choicesOfferedByTrader = 4; list[2].CardChoices = () => CardLoader.GetUnlockedCards((CardMetaCategory)3, (CardTemple)0); return list; } public static PeltData New(string pluginGuid, CardInfo peltCardInfo, Func> getCardChoices, int baseBuyPrice, int extraAbilitiesToAdd = 0, int choicesOfferedByTrader = 8) { return New(pluginGuid, peltCardInfo, baseBuyPrice, extraAbilitiesToAdd, choicesOfferedByTrader, getCardChoices); } public static PeltData New(string pluginGuid, CardInfo peltCardInfo, int baseBuyPrice, int extraAbilitiesToAdd, int choicesOfferedByTrader, Func> getCardChoices) { if (getCardChoices == null) { throw new ArgumentNullException("CardChoices function cannot be null!"); } PeltData obj = new PeltData { pluginGuid = pluginGuid, peltCardName = ((Object)peltCardInfo).name, peltTierName = GetTierNameFromPelt(peltCardInfo.displayedName), CardChoices = getCardChoices, baseBuyPrice = baseBuyPrice, extraAbilitiesToAdd = extraAbilitiesToAdd, choicesOfferedByTrader = choicesOfferedByTrader }; Add(obj); return obj; } public static void Add(PeltData data) { if (Utility.IsNullOrWhiteSpace(data.peltCardName)) { InscryptionAPIPlugin.Logger.LogError((object)"Couldn't create CustomPeltData - missing card name!"); return; } if (data.pluginGuid == null) { data.pluginGuid = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); } if (!AllNewPelts.Contains(data)) { AllNewPelts.Add(data); } } public static List AllPeltsAvailableAtTrader() { List list = new List(); list.AddRange(from x in AllPelts() where x.isSoldByTrapper select x); return list; } public static int GetCostOfPelt(string peltName) { return GetPelt(peltName)?.BuyPrice ?? 1; } public static PeltData GetPelt(string peltName) { return AllPelts().Find((PeltData a) => a.peltCardName == peltName); } internal static void CreateDialogueEvents() { foreach (PeltData item in AllPeltsAvailableAtTrader()) { string text = item.peltTierName ?? GetTierNameFromData(item); string dialogueId = "TraderPelts" + text; if (!DialogueManager.CustomDialogue.Exists((DialogueManager.Dialogue x) => x.DialogueEvent.id == dialogueId)) { if (text.Contains("pelt") || text.Contains("pelt")) { DialogueManager.GenerateEvent("cyantist.inscryption.api", dialogueId, new List { text + "pelts..." }, null, (MaxRepeatsBehaviour)0, (Speaker)0); } else { DialogueManager.GenerateEvent("cyantist.inscryption.api", dialogueId, new List { text + "..." }, null, (MaxRepeatsBehaviour)0, (Speaker)0); } } } } public static string GetTierNameFromPelt(string cardName) { string text = ""; if (cardName.Contains("pelt") || cardName.Contains("pelt")) { text = cardName.ToLowerInvariant().Replace("pelt", "").Replace("pelts", ""); return StringExtensions.ToTitleCase(text.Split(new char[1] { '_' }).Last()); } text = cardName.ToLowerInvariant(); return StringExtensions.ToTitleCase(text.Split(new char[1] { '_' }).Last()); } public static string GetTierNameFromData(PeltData peltData) { return peltData.peltTierName ?? GetTierNameFromPelt(peltData.peltCardName); } } } namespace InscryptionAPI.Pelts.Extensions { public static class PeltExtensions { public static PeltManager.PeltData SetPluginGuid(this PeltManager.PeltData peltData, string pluginGuid) { peltData.pluginGuid = pluginGuid; return peltData; } public static PeltManager.PeltData SetBuyPrice(this PeltManager.PeltData peltData, int baseBuyPrice, int maxBuyPrice = 0) { peltData.baseBuyPrice = baseBuyPrice; if (maxBuyPrice > 0) { peltData.maxBuyPrice = maxBuyPrice; } return peltData; } public static PeltManager.PeltData SetMaxBuyPrice(this PeltManager.PeltData peltData, int maxBuyPrice) { if (maxBuyPrice > 0) { peltData.maxBuyPrice = maxBuyPrice; } return peltData; } public static PeltManager.PeltData SetBuyPriceModifiers(this PeltManager.PeltData peltData, int bossPriceCut = 2, int challengePriceHike = 2) { peltData.bossDefeatedPriceReduction = bossPriceCut; peltData.expensivePeltsPriceMultiplier = challengePriceHike; return peltData; } public static PeltManager.PeltData SetBuyPriceAdjustment(this PeltManager.PeltData peltData, Func buyPriceAdjustment) { peltData.BuyPriceAdjustment = buyPriceAdjustment; return peltData; } public static PeltManager.PeltData SetModifyCardChoiceAtTrader(this PeltManager.PeltData peltData, Action modifyCardChoiceAtTrader) { peltData.ModifyCardChoiceAtTrader = modifyCardChoiceAtTrader; return peltData; } public static PeltManager.PeltData SetIsSoldByTrapper(this PeltManager.PeltData peltData, bool soldByTrapper = true) { peltData.isSoldByTrapper = soldByTrapper; return peltData; } public static PeltManager.PeltData SetNumberOfTraderChoices(this PeltManager.PeltData peltData, int numOfChoices) { peltData.choicesOfferedByTrader = numOfChoices; return peltData; } public static PeltManager.PeltData SetCardChoices(this PeltManager.PeltData peltData, Func> getCardChoices) { peltData.CardChoices = getCardChoices; return peltData; } public static PeltManager.PeltData SetTierName(this PeltManager.PeltData peltData, string tierName) { peltData.peltTierName = tierName; return peltData; } } } namespace InscryptionAPI.Pelts.Patches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal class BuyPeltsSequencer_PeltPrices { private static void Postfix(ref int[] __result) { __result = BuyPeltsSequencer_BuyPelts.PeltsAvailableAtTrader.Select((PeltManager.PeltData a) => a.BuyPrice).ToArray(); } } [HarmonyPatch] internal class BuyPeltsSequencer_BuyPelts { internal static List PeltsAvailableAtTrader = new List(); [HarmonyPrefix] [HarmonyPatch(typeof(BuyPeltsSequencer), "BuyPelts")] private static bool SetUpForCustomPelts(BuyPeltsSequencer __instance) { //IL_0032: 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) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (PeltManager.AllNewPelts.Count == 0) { PeltsAvailableAtTrader.Clear(); PeltsAvailableAtTrader.AddRange(PeltManager.AllPelts()); return true; } Vector3 localPosition = ((Component)__instance.deckPile).transform.localPosition; ((Component)__instance.deckPile).transform.localPosition = new Vector3(5.5f, localPosition.y, localPosition.z); ((Component)__instance.purchasedPile).transform.position = __instance.PELT_CARDS_ANCHOR - __instance.PELT_SPACING; Vector3 localPosition2 = ((Component)__instance.weightOrganizeAnchor).transform.localPosition; ((Component)__instance.weightOrganizeAnchor).transform.localPosition = new Vector3(-1.5f, localPosition2.y, localPosition2.z); PeltsAvailableAtTrader.Clear(); GeneratePeltChoices(); return true; } private static void GeneratePeltChoices() { int currentRandomSeed = SaveManager.SaveFile.GetCurrentRandomSeed(); List list = PeltManager.AllPeltsAvailableAtTrader(); list.RemoveAll((PeltManager.PeltData a) => a.CardChoices().Count == 0); if (list.Count > 8) { List list2 = new List(8) { PeltManager.GetPelt("PeltHare") }; List list3 = new List(list); list3.Remove(list2[0]); List rares = list3.FindAll((PeltManager.PeltData a) => CardLoader.GetCardByName(a.peltCardName).appearanceBehaviour.Contains((Appearance)6)).ToList(); List list4 = list3.FindAll((PeltManager.PeltData a) => !rares.Contains(a)); for (int i = 0; i < 3; i++) { if (rares.Count <= 0) { break; } PeltManager.PeltData seededRandom = rares.GetSeededRandom(currentRandomSeed++); rares.Remove(seededRandom); list2.Add(seededRandom); } while (list2.Count < 8 && list4.Count > 0) { PeltManager.PeltData seededRandom2 = list4.GetSeededRandom(currentRandomSeed++); list4.Remove(seededRandom2); list2.Add(seededRandom2); } while (list2.Count < 8 && rares.Count > 0) { PeltManager.PeltData seededRandom3 = rares.GetSeededRandom(currentRandomSeed++); rares.Remove(seededRandom3); list2.Add(seededRandom3); } PeltsAvailableAtTrader.AddRange(list2); } else { PeltsAvailableAtTrader.AddRange(list); } PeltsAvailableAtTrader.Sort(delegate(PeltManager.PeltData a, PeltManager.PeltData b) { int buyPrice = a.BuyPrice; int buyPrice2 = b.BuyPrice; int num = buyPrice - buyPrice2; if (num != 0) { return num; } int count = a.CardChoices().Count; int count2 = b.CardChoices().Count; return count - count2; }); } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown Type? type = Type.GetType("DiskCardGame.BuyPeltsSequencer, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); Type type2 = Type.GetType("DiskCardGame.BuyPeltsSequencer+d__22, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); FieldInfo fieldInfo = AccessTools.Field(type, "peltsForSale"); FieldInfo fieldInfo2 = AccessTools.Field(type2, "5__2"); List x = null; MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => PopulatePeltsForSaleList(ref x))); MethodInfo methodInfo2 = SymbolExtensions.GetMethodInfo((Expression)(() => GetTotalPelts())); List list = new List(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.opcode == OpCodes.Stfld && val.operand == fieldInfo) { list.Insert(++i, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(++i, new CodeInstruction(OpCodes.Ldflda, (object)fieldInfo)); list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); } else if (val.opcode == OpCodes.Ldfld && val.operand == fieldInfo2) { CodeInstruction val2 = list[i + 1]; if (val2.opcode == OpCodes.Ldc_I4_3) { val2.opcode = OpCodes.Call; val2.operand = methodInfo2; } } } return list; } private static void PopulatePeltsForSaleList(ref List peltsForSale) { peltsForSale.Clear(); for (int i = 0; i < PeltsAvailableAtTrader.Count; i++) { peltsForSale.Add(null); } } private static int GetTotalPelts() { return PeltsAvailableAtTrader.Count; } } [HarmonyPatch(typeof(BuyPeltsSequencer), "CreatePelt", new Type[] { typeof(int), typeof(int), typeof(float) })] internal class BuyPeltsSequencer_CreatePelt { private static IEnumerable Transpiler(IEnumerable instructions) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown Vector3 r = default(Vector3); MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => AdjustPosition(1, ref r))); MethodInfo methodInfo2 = AccessTools.PropertyGetter(typeof(CardLoader), "PeltNames"); MethodInfo methodInfo3 = SymbolExtensions.GetMethodInfo((Expression)(() => GetCardByName())); List list = new List(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.opcode == OpCodes.Stloc_3) { list.Insert(++i, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); list.Insert(++i, new CodeInstruction(OpCodes.Ldloca, (object)3)); list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); } else if (val.opcode == OpCodes.Call && val.operand == methodInfo2) { val.operand = methodInfo3; } } return list; } private static string[] GetCardByName() { return BuyPeltsSequencer_BuyPelts.PeltsAvailableAtTrader.Select((PeltManager.PeltData a) => a.peltCardName).ToArray(); } private static void AdjustPosition(int index, ref Vector3 vector) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) int count = BuyPeltsSequencer_BuyPelts.PeltsAvailableAtTrader.Count; float num = 3f; float num2 = 1.6f; float num3 = -2f; if (count > 6) { num += 1f; num2 -= 0.3f; } vector = Singleton.Instance.buyPeltsSequencer.PELT_CARDS_ANCHOR; vector.x += num2 * ((float)index % num); vector.z += num3 * (float)Mathf.FloorToInt((float)index / num); } } [HarmonyPatch] public class BuyPeltsSequencer_GiveFreePeltSequence { [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => Singleton.Instance.buyPeltsSequencer.GainPelt((SelectableCard)null))); MethodInfo methodInfo2 = SymbolExtensions.GetMethodInfo((Expression)(() => ChangeFreeCard(null))); List list = new List(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.opcode == OpCodes.Call && val.operand == methodInfo) { list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); } } return list; } public static CardInfo ChangeFreeCard(CardInfo currentFreeCard) { return CardLoader.GetCardByName("PeltHare"); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal class CardLoader_PeltNames { public static void Postfix(ref string[] __result) { __result = (from a in PeltManager.AllPelts() select a.peltCardName).ToArray(); } } [HarmonyPatch] internal class TradePeltsDialogue { [HarmonyPostfix] [HarmonyPatch(typeof(TradePeltsSequencer), "GetTierName")] private static void AddCustomTierNames(int tier, ref string __result) { if (tier >= 3) { __result = PeltManager.GetTierNameFromData(PeltManager.AllPelts()[tier]); } } } [HarmonyPatch(typeof(TradePeltsSequencer), "GetTradeCardInfos", new Type[] { typeof(int), typeof(bool) })] internal static class TradePeltsSequencer_GetTradeCardInfos { private static IEnumerable Transpiler(IEnumerable instructions) { //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Expected O, but got Unknown //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Expected O, but got Unknown List list = new List(instructions); List y = null; MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => GetCardOptions(1, ref y))); int t = 0; MethodInfo methodInfo2 = SymbolExtensions.GetMethodInfo((Expression)(() => numCards(1, ref t))); MethodInfo methodInfo3 = SymbolExtensions.GetMethodInfo((Expression)(() => abilityCount(1, 1))); int num = -1; int num2 = -1; CodeInstruction val = null; for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Call && list[i].operand != null && list[i].operand.ToString() == "SaveFile get_SaveFile()") { num = i + 1; } if (list[i].opcode == OpCodes.Call && list[i].operand != null && list[i].operand.ToString() == "System.Collections.Generic.List`1[DiskCardGame.CardInfo] GetDistinctCardsFromPool(Int32, Int32, System.Collections.Generic.List`1[DiskCardGame.CardInfo], Int32, Boolean)") { num2 = i - 1; val = list[i - 1]; } } if (num < 0) { InscryptionAPIPlugin.Logger.LogError((object)"[TradePeltsSequencer_GetTradeCardInfos] Did not find index for indexFinishedCalculations!"); } else if (num2 < 0) { InscryptionAPIPlugin.Logger.LogError((object)"[TradePeltsSequencer_GetTradeCardInfos] Did not find index for numAbilitiesIndex!"); } else { int num3 = 0; list.Insert(num + num3++, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); list.Insert(num + num3++, new CodeInstruction(OpCodes.Ldloca, (object)1)); list.Insert(num + num3++, new CodeInstruction(OpCodes.Call, (object)methodInfo)); list.Insert(num + num3++, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); list.Insert(num + num3++, new CodeInstruction(OpCodes.Ldloca, (object)2)); list.Insert(num + num3++, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); num3++; val.opcode = OpCodes.Ldarg_1; list.Insert(num2 + num3++, new CodeInstruction(OpCodes.Call, (object)methodInfo3)); list.Insert(num2 + num3++, new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)); } return list; } public static void Postfix(ref List __result, int tier, bool mergedPelt) { PeltManager.PeltData peltData = PeltManager.AllPelts()[tier]; if (peltData.ModifyCardChoiceAtTrader == null) { return; } foreach (CardInfo item in __result) { peltData.ModifyCardChoiceAtTrader(item); } } private static void GetCardOptions(int tier, ref List cards) { PeltManager.PeltData peltData = PeltManager.AllPelts()[tier]; List list = peltData.CardChoices(); if (list.Count == 0) { InscryptionAPIPlugin.Logger.LogWarning((object)("No cards specified for pelt '" + peltData.peltCardName + "', using fallback card.")); list.Add(CardLoader.GetCardByName("Amalgam")); } cards = list; } private static void numCards(int tier, ref int numCards) { PeltManager.PeltData peltData = PeltManager.AllPelts()[tier]; numCards = Mathf.Min(8, peltData.choicesOfferedByTrader); } private static int abilityCount(int abilityCount, int tier) { return PeltManager.AllPelts()[tier].extraAbilitiesToAdd; } } [HarmonyPatch] public class TradePeltsSequencer_TradePelts { [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int cardsPerRow; public TradePeltsSequencer __instance; public List cards; public bool rareCards; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < cards.Count) { float num = 5__2 % cardsPerRow; float num2 = ((5__2 < cardsPerRow) ? 1 : 0); GameObject obj = Object.Instantiate(((CardChoicesSequencer)__instance).selectableCardPrefab, ((Component)__instance).transform); obj.gameObject.SetActive(true); SelectableCard component = obj.GetComponent(); ((Card)component).SetInfo(cards[5__2]); SpecialCardBehaviour[] components = obj.GetComponents(); for (int i = 0; i < components.Length; i++) { components[i].OnShownForCardChoiceNode(); } int num3 = ((num2 == 0f && cards.Count - cardsPerRow < cardsPerRow) ? (cards.Count - cardsPerRow) : cardsPerRow); float num4 = (float)(4 - num3) * (__instance.CARD_SPACING.x / 2f); Vector3 val = __instance.CARDS_ANCHOR + new Vector3(num4 + __instance.CARD_SPACING.x * num, 0f, __instance.CARD_SPACING.y * num2); if (rareCards) { val.z = -2f; } Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(90f, 90f, 90f); ((Component)component).transform.position = val + new Vector3(0f, 0.25f, 3f); ((Component)component).transform.eulerAngles = val2 + new Vector3(0f, 0f, -7.5f + Random.value * 7.5f); Tween.Position(((Component)component).transform, val, 0.15f, 0f, Tween.EaseOut, (LoopType)0, (Action)null, (Action)null, true); Tween.Rotation(((Component)component).transform, val2, 0.15f, 0f, Tween.EaseOut, (LoopType)0, (Action)null, (Action)null, true); __instance.tradeCards.Add(component); ((InteractableBase)component).SetEnabled(false); ((Card)component).Anim.PlayQuickRiffleSound(); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TradePeltsSequencer instance; public int tier; public bool hasMergedPelt; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; List tradeCardInfos = instance.GetTradeCardInfos(tier, hasMergedPelt); bool flag = tradeCardInfos.Count <= 4; <>2__current = instance.CreateTradeCards(tradeCardInfos, flag ? tradeCardInfos.Count : ((tradeCardInfos.Count + 1) / 2), flag); <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly string Current = "System.Object <>2__current"; private static readonly string GetTradeCardInfos = "System.Collections.Generic.List`1[DiskCardGame.CardInfo] GetTradeCardInfos(Int32, Boolean)"; [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable CapCreatedPeltCards(IEnumerable instructions) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown List list = new List(instructions); int num = list.FindIndex(0, (CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == GetTradeCardInfos); if (num != -1) { num -= 7; list.RemoveAt(num + 1); num = list.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == GetTradeCardInfos); int num2 = list.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Stfld && x.operand.ToString() == Current); list.RemoveRange(num, num2 - num); MethodInfo methodInfo = AccessTools.Method(typeof(TradePeltsSequencer_TradePelts), "CreateTradeCardsFixRows", new Type[3] { typeof(TradePeltsSequencer), typeof(int), typeof(bool) }, (Type[])null); list.Insert(num, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo)); } return list; } [IteratorStateMachine(typeof(d__1))] private static IEnumerator CreateTradeCardsFixRows(TradePeltsSequencer instance, int tier, bool hasMergedPelt) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { instance = instance, tier = tier, hasMergedPelt = hasMergedPelt }; } [HarmonyPrefix] [HarmonyPatch(typeof(TradePeltsSequencer), "CreateTradeCards")] private static bool DisableVanillaCreateTradeCards(ref IEnumerator __result, TradePeltsSequencer __instance, List cards, int cardsPerRow, bool rareCards) { __result = CentreCreateTradeCards(__instance, cards, cardsPerRow, rareCards); return false; } [IteratorStateMachine(typeof(d__3))] public static IEnumerator CentreCreateTradeCards(TradePeltsSequencer __instance, List cards, int cardsPerRow, bool rareCards) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { __instance = __instance, cards = cards, cardsPerRow = cardsPerRow, rareCards = rareCards }; } } [HarmonyPatch] public class TradePeltsSequencer_CreatePeltCards { private static readonly string SetNumPelts = "System.Int32 5__3"; private static readonly string SetCardInfos = "System.Collections.Generic.List`1[DiskCardGame.CardInfo] 5__2"; private static readonly Type classType = Type.GetType("DiskCardGame.TradePeltsSequencer+d__19, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); private static readonly Type display19ClassType = Type.GetType("DiskCardGame.TradePeltsSequencer+<>c__DisplayClass19_0, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable CapCreatedPeltCards(IEnumerable instructions) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown List list = new List(instructions); int num = list.FindIndex(0, (CodeInstruction x) => x.opcode == OpCodes.Stfld && x.operand.ToString() == SetCardInfos); if (num != -1) { num = list.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Ldc_I4_2); int num2 = list.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Stfld && x.operand.ToString() == SetNumPelts); if (num2 != -1) { num2--; list.RemoveAt(num2); MethodInfo methodInfo = AccessTools.Method(typeof(TradePeltsSequencer_CreatePeltCards), "NumPelts", new Type[2] { typeof(int), typeof(int) }, (Type[])null); list.Insert(num2, new CodeInstruction(OpCodes.Call, (object)methodInfo)); num2 -= 3; list.RemoveRange(num, num2 - num); } } return list; } public static int NumPelts(int tier, int cardChoiceCount) { return Mathf.Min(PeltManager.AllPelts()[tier].choicesOfferedByTrader, cardChoiceCount); } } } namespace InscryptionAPI.Nodes { public abstract class CustomCardChoiceNodeSequencer : CardChoicesSequencer, ICustomNodeSequencer, IInherit, IDestroyOnEnd, IDoNotReturnToMapOnEnd { public virtual CardChoicesSequencer InheritTarget => (CardChoicesSequencer)(object)EasyAccess.CardSingleChoices; public virtual Vector3 PositionOffset => Vector3.zero; public virtual Quaternion RotationOffset => Quaternion.identity; public virtual Vector3 DeckPilePositionOffset => Vector3.zero; public virtual Quaternion DeckPileRotationOffset => Quaternion.identity; public virtual bool DeckPileInheritsOffsets => false; public virtual bool ShouldInherit => true; public abstract IEnumerator DoCustomSequence(CustomSpecialNodeData node); public virtual void Inherit(CustomSpecialNodeData node) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_0145: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) CardChoicesSequencer inheritTarget = InheritTarget; if (!ShouldInherit || !((Object)(object)inheritTarget != (Object)null)) { return; } ((Component)this).transform.position = ((Component)inheritTarget).transform.position + PositionOffset; Transform transform = ((Component)this).transform; Quaternion val = ((Component)inheritTarget).transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles; val = RotationOffset; transform.rotation = Quaternion.Euler(eulerAngles + ((Quaternion)(ref val)).eulerAngles); if ((Object)(object)inheritTarget.deckPile != (Object)null) { base.deckPile = Object.Instantiate(inheritTarget.deckPile, ((Component)inheritTarget.deckPile).transform.position, ((Component)inheritTarget.deckPile).transform.rotation); Vector3 position = ((Component)base.deckPile).transform.position; Quaternion rotation = ((Component)base.deckPile).transform.rotation; ((Component)base.deckPile).transform.parent = ((Component)this).transform; ((Component)base.deckPile).transform.position = position + DeckPilePositionOffset + (DeckPileInheritsOffsets ? PositionOffset : Vector3.zero); Transform transform2 = ((Component)base.deckPile).transform; Vector3 eulerAngles2 = ((Quaternion)(ref rotation)).eulerAngles; val = DeckPileRotationOffset; Vector3 val2 = eulerAngles2 + ((Quaternion)(ref val)).eulerAngles; Vector3 val3; if (!DeckPileInheritsOffsets) { val3 = Vector3.zero; } else { val = RotationOffset; val3 = ((Quaternion)(ref val)).eulerAngles; } transform2.rotation = Quaternion.Euler(val2 + val3); } base.selectableCardPrefab = inheritTarget.selectableCardPrefab; if ((Object)(object)inheritTarget.gamepadGrid != (Object)null) { base.gamepadGrid = Object.Instantiate(inheritTarget.gamepadGrid, ((Component)inheritTarget.gamepadGrid).transform.position, ((Component)inheritTarget.gamepadGrid).transform.rotation); Vector3 localPosition = ((Component)base.gamepadGrid).transform.localPosition; Quaternion localRotation = ((Component)base.gamepadGrid).transform.localRotation; ((Component)base.gamepadGrid).transform.parent = ((Component)this).transform; ((Component)base.gamepadGrid).transform.localPosition = localPosition; ((Component)base.gamepadGrid).transform.localRotation = localRotation; } } public virtual bool ShouldDestroyOnEnd(CustomSpecialNodeData node) { return false; } public virtual bool ShouldNotReturnToMapOnEnd(CustomSpecialNodeData node) { return false; } } public abstract class CustomNodeSequencer : ManagedBehaviour, ICustomNodeSequencer, IInherit, IDestroyOnEnd, IDoNotReturnToMapOnEnd { public abstract IEnumerator DoCustomSequence(CustomSpecialNodeData node); public virtual void Inherit(CustomSpecialNodeData node) { } public virtual bool ShouldDestroyOnEnd(CustomSpecialNodeData node) { return false; } public virtual bool ShouldNotReturnToMapOnEnd(CustomSpecialNodeData node) { return false; } } public class CustomSpecialNodeData : SpecialNodeData { internal static Texture2D mapeventmissing; private readonly Dictionary runtimeData = new Dictionary(); public readonly string name; public readonly string guid; public override string PrefabPath => "Prefabs/Map/MapNodesPart1/MapNode_TradePelts"; public NewNodeManager.FullNode Node => NewNodeManager.addedNodes.Find((NewNodeManager.FullNode x) => x != null && x.guid == guid && x.name == name); public override List GenerationPrerequisiteConditions => Node?.generationPrerequisites ?? new List(); public override List ForceGenerationConditions => Node?.forceGenerationConditions ?? new List(); public CustomSpecialNodeData(NewNodeManager.FullNode node) { name = node.name; guid = node.guid; } internal void OnPreGeneration() { Node?.onPreNodeGeneration?.Invoke(this); } internal void OnPostGeneration(MapNode2D node) { if (Node != null && Node.nodeAnimation != null && Node.nodeAnimation.Count > 0) { AnimatingSprite componentInChildren = ((Component)node).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.textureFrames = new List(Node.nodeAnimation); componentInChildren.SetTexture(componentInChildren.textureFrames[0]); } } else if (Node == null) { try { AnimatingSprite componentInChildren2 = ((Component)node).GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { if (mapeventmissing == null) { mapeventmissing = TextureHelper.GetImageAsTexture("mapevent_missing.png", Assembly.GetExecutingAssembly(), (FilterMode)0); } componentInChildren2.textureFrames = new List { mapeventmissing }; componentInChildren2.SetTexture(mapeventmissing); } } catch { } } Node?.onPostNodeGeneration?.Invoke(this, node); } public void Set(string key, object value) { if (runtimeData.ContainsKey(key)) { runtimeData[key] = value; } else { runtimeData.Add(key, value); } } public object Get(string key) { if (runtimeData.TryGetValue(key, out var value)) { return value; } return null; } public T Get(string key) { if (runtimeData.TryGetValue(key, out var value) && value is T) { return (T)value; } return default(T); } } public static class EasyAccess { public static SpecialNodeHandler NodeHandler => Singleton.Instance; public static CardSingleChoicesSequencer CardSingleChoices => NodeHandler.cardChoiceSequencer; public static CardMergeSequencer CardMerge => NodeHandler.cardMerger; public static DuplicateMergeSequencer DuplicateMerge => NodeHandler.duplicateMerger; public static CardRemoveSequencer CardRemove => NodeHandler.cardRemoveSequencer; public static CardStatBoostSequencer CardStatBoost => NodeHandler.cardStatBoostSequencer; public static GainConsumablesSequencer GainConsumables => NodeHandler.gainConsumablesSequencer; public static BuildTotemSequencer BuildTotem => NodeHandler.buildTotemSequencer; public static BuyPeltsSequencer BuyPelts => NodeHandler.buyPeltsSequencer; public static TradePeltsSequencer TradePelts => NodeHandler.tradePeltsSequencer; public static DeckTrialSequencer DeckTrial => NodeHandler.deckTrialSequencer; public static BoulderChoiceSequencer BoulderChoice => NodeHandler.boulderChoiceSequencer; public static ChooseEyeballSequencer ChooseEyeball => NodeHandler.chooseEyeballSequencer; public static RareCardChoicesSequencer RareCardChoices => NodeHandler.rareCardChoiceSequencer; public static VictoryFeastSequencer VictoryFeast => NodeHandler.victoryFeastSequencer; public static CopyCardSequencer CopyCard => NodeHandler.copyCardSequencer; } public interface ICustomNodeSequencer { IEnumerator DoCustomSequence(CustomSpecialNodeData nodeData); } public interface IDestroyOnEnd { bool ShouldDestroyOnEnd(CustomSpecialNodeData nodeData); } public interface IDoNotReturnToMapOnEnd { bool ShouldNotReturnToMapOnEnd(CustomSpecialNodeData nodeData); } public interface IInherit { void Inherit(CustomSpecialNodeData nodeData); } internal class MissingNodeSequencer : CustomNodeSequencer { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("Huh. I don't remember leaving that \"MISSING\" here.", -2.5f, 0.5f, (Emotion)5, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("It seems like whatever was here before... Left.", -2.5f, 0.5f, (Emotion)5, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("And it doesn't look like it's going to come back anytime soon.", -2.5f, 0.5f, (Emotion)5, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("Oh well.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 4; return true; case 4: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public override IEnumerator DoCustomSequence(CustomSpecialNodeData node) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0); } } internal class MissingSequenceSequencer : CustomNodeSequencer { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("Hmm. The event picture is here, but it doesn't seem to mean anything?", -2.5f, 0.5f, (Emotion)5, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("Perhaps I forgot to write what this event does.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = Singleton.Instance.ShowUntilInput("Oh well.", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true); <>1__state = 3; return true; case 3: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public override IEnumerator DoCustomSequence(CustomSpecialNodeData node) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0); } } public static class NewNodeManager { public class FullNode { public List generationPrerequisites = new List(); public List forceGenerationConditions = new List(); public Action onPreNodeGeneration; public Action onPostNodeGeneration; public GameObject sequencerPrefab; public GameObject nodePrefab; public Type nodeSequencerType; public List nodeAnimation = new List(); public GenerationType generationType; public string guid; public string name; public FullNode SetName(string newName) { name = newName; return this; } public FullNode SetGuid(string newGuid) { guid = newGuid; return this; } public FullNode SetGenerationType(GenerationType newGenerationType) { generationType = newGenerationType; return this; } public FullNode SetNodeAnimation(List newNodeAnimation) { nodeAnimation = new List(newNodeAnimation); return this; } public FullNode SetNodeSequencerType(Type newNodeSequencerType) { nodeSequencerType = newNodeSequencerType; return this; } public FullNode SetNodeSequencerType() where T : ICustomNodeSequencer { nodeSequencerType = typeof(T); return this; } public FullNode SetNodePrefab(GameObject newNodePrefab) { nodePrefab = newNodePrefab; return this; } public FullNode SetSequencerPrefab(GameObject newSequencerPrefab) { sequencerPrefab = newSequencerPrefab; return this; } public FullNode SetOnPostNodeGeneration(Action newOnPostNodeGeneration) { onPostNodeGeneration = newOnPostNodeGeneration; return this; } public FullNode SetOnPreNodeGeneration(Action newOnPreNodeGeneration) { onPreNodeGeneration = newOnPreNodeGeneration; return this; } public FullNode SetGenerationPrerequisites(List newGenerationPrerequisites) { generationPrerequisites = newGenerationPrerequisites; return this; } public FullNode SetForceGenerationConditions(List newForceGenerationConditions) { forceGenerationConditions = newForceGenerationConditions; return this; } public static bool SequencerTypeIsValid(Type type) { if (type != null && !type.IsAbstract && type.IsSubclassOf(typeof(Component))) { return type.GetInterfaces().Contains(typeof(ICustomNodeSequencer)); } return false; } public Type GetSequencerType() { if (!SequencerTypeIsValid(nodeSequencerType)) { GameObject obj = nodePrefab; if (obj == null) { return null; } return obj.GetComponent()?.GetType(); } return nodeSequencerType; } public bool IsValidSequencerType() { return SequencerTypeIsValid(GetSequencerType()); } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ICustomNodeSequencer sequencer; public CustomSpecialNodeData node; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = sequencer.DoCustomSequence(node); <>1__state = 1; return true; case 1: <>1__state = -1; if (sequencer is IDestroyOnEnd destroyOnEnd && destroyOnEnd.ShouldDestroyOnEnd(node)) { Object.Destroy((Object)(object)((Component)((destroyOnEnd is Component) ? destroyOnEnd : null)).gameObject); } if (sequencer is IDoNotReturnToMapOnEnd doNotReturnToMapOnEnd && doNotReturnToMapOnEnd.ShouldNotReturnToMapOnEnd(node)) { return false; } Singleton.Instance.TransitionToGameState((GameState)1, (NodeData)null); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static readonly List addedNodes = new List(); public static readonly ReadOnlyCollection NewNodes = new ReadOnlyCollection(addedNodes); public static FullNode New(string guid, string name, GenerationType generationType = GenerationType.None, List nodeAnimation = null, List generationPrerequisites = null, List forceGenerationConditions = null, Action onPreGeneration = null, Action onPostGeneration = null, GameObject sequencerPrefab = null, GameObject nodePrefab = null) where T : ICustomNodeSequencer { return New(guid, name, generationType, typeof(T), nodeAnimation, generationPrerequisites, forceGenerationConditions, onPreGeneration, onPostGeneration, sequencerPrefab, nodePrefab); } public static FullNode New(string guid, string name, GenerationType generationType = GenerationType.None, Type nodeSequencerType = null, List nodeAnimation = null, List generationPrerequisites = null, List forceGenerationConditions = null, Action onPreGeneration = null, Action onPostGeneration = null, GameObject sequencerPrefab = null, GameObject nodePrefab = null) { FullNode fullNode = new FullNode(); fullNode.guid = guid; fullNode.name = name; fullNode.nodeSequencerType = nodeSequencerType; fullNode.generationType = generationType; if (nodeAnimation != null) { fullNode.nodeAnimation = new List(nodeAnimation); } if (generationPrerequisites != null) { fullNode.generationPrerequisites = new List(generationPrerequisites); } if (forceGenerationConditions != null) { fullNode.forceGenerationConditions = new List(forceGenerationConditions); } fullNode.onPreNodeGeneration = onPreGeneration; fullNode.onPostNodeGeneration = onPostGeneration; fullNode.sequencerPrefab = sequencerPrefab; fullNode.nodePrefab = nodePrefab; addedNodes.Add(fullNode); return fullNode; } [IteratorStateMachine(typeof(d__5))] internal static IEnumerator CustomNodeSequence(ICustomNodeSequencer sequencer, CustomSpecialNodeData node) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { sequencer = sequencer, node = node }; } internal static void DoMissingSequenceSequence(this SpecialNodeHandler hand) { //IL_0088: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < ((Component)hand).transform.childCount; i++) { Transform child = ((Component)hand).transform.GetChild(i); if ((Object)(object)child != (Object)null) { list.Add(child); } } Transform? obj = list.Find((Transform x) => (Object)(object)((Component)x).GetComponent() != (Object)null); MissingSequenceSequencer missingSequenceSequencer = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)missingSequenceSequencer != (Object)null) { ((MonoBehaviour)hand).StartCoroutine(CustomNodeSequence(missingSequenceSequencer, null)); return; } GameObject val = new GameObject("MissingSequenceSequencer"); val.transform.parent = ((Component)hand).transform; val.transform.localPosition = Vector3.zero; missingSequenceSequencer = val.AddComponent(); if ((Object)(object)missingSequenceSequencer != (Object)null) { ((MonoBehaviour)hand).StartCoroutine(CustomNodeSequence(missingSequenceSequencer, null)); } } internal static void DoMissingNodeSequence(this SpecialNodeHandler hand) { //IL_0088: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < ((Component)hand).transform.childCount; i++) { Transform child = ((Component)hand).transform.GetChild(i); if ((Object)(object)child != (Object)null) { list.Add(child); } } Transform? obj = list.Find((Transform x) => (Object)(object)((Component)x).GetComponent() != (Object)null); MissingNodeSequencer missingNodeSequencer = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)missingNodeSequencer != (Object)null) { ((MonoBehaviour)hand).StartCoroutine(CustomNodeSequence(missingNodeSequencer, null)); return; } GameObject val = new GameObject("MissingNodeSequencer"); val.transform.parent = ((Component)hand).transform; val.transform.localPosition = Vector3.zero; missingNodeSequencer = val.AddComponent(); if ((Object)(object)missingNodeSequencer != (Object)null) { ((MonoBehaviour)hand).StartCoroutine(CustomNodeSequence(missingNodeSequencer, null)); } } } public class NumChallengesOfTypeActive : SelectionCondition { public AscensionChallenge challenge; public int numChallenges; public bool greaterThanNumActive; public NumChallengesOfTypeActive(AscensionChallenge challenge, int numChallenges, bool greaterThanNumActive) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.challenge = challenge; this.numChallenges = numChallenges; this.greaterThanNumActive = greaterThanNumActive; } public override bool Satisfied(int gridY, List previousNodes) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (greaterThanNumActive) { return numChallenges >= AscensionSaveData.Data.GetNumChallengesOfTypeActive(challenge); } return numChallenges <= AscensionSaveData.Data.GetNumChallengesOfTypeActive(challenge); } } public class ChallengeIsActive : SelectionCondition { public AscensionChallenge challenge; public bool exclude; public ChallengeIsActive(AscensionChallenge challenge, bool exclude) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.challenge = challenge; this.exclude = exclude; } public override bool Satisfied(int gridY, List previousNodes) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) bool flag = AscensionSaveData.Data.ChallengeIsActive(challenge); if (!flag || !exclude) { if (!exclude) { return !flag; } return false; } return true; } } public enum GenerationType { None = 0, SpecialCardChoice = 1, SpecialEvent = 2, RegionStart = 4, PreBoss = 8, PostBoss = 0x10 } public class Not : SelectionCondition { private readonly SelectionCondition condition; public Not(SelectionCondition selectionCondition) { condition = selectionCondition; } public override bool Satisfied(int gridY, List previousNodes) { return !condition.Satisfied(gridY, previousNodes); } } public class And : SelectionCondition { private readonly SelectionCondition condition1; private readonly SelectionCondition condition2; public And(SelectionCondition selectionCondition1, SelectionCondition selectionCondition2) { condition1 = selectionCondition1; condition2 = selectionCondition2; } public override bool Satisfied(int gridY, List previousNodes) { if (condition1.Satisfied(gridY, previousNodes)) { return condition2.Satisfied(gridY, previousNodes); } return false; } } public class True : SelectionCondition { public override bool Satisfied(int gridY, List previousNodes) { return true; } } public class False : SelectionCondition { public override bool Satisfied(int gridY, List previousNodes) { return false; } } public class CustomPreviousNodesContent : SelectionCondition { private readonly string name; private readonly string guid; private bool doesContain; public CustomPreviousNodesContent(string guid, string name, bool doesContain) { this.name = name; this.guid = guid; this.doesContain = doesContain; } public override bool Satisfied(int gridY, List previousNodes) { return previousNodes.Exists((NodeData x) => x != null && x is CustomSpecialNodeData && (x as CustomSpecialNodeData).name == name && (x as CustomSpecialNodeData).guid == guid) == doesContain; } } public class CustomPreviousRowContent : SelectionCondition { private readonly string name; private readonly string guid; private bool doesContain; public CustomPreviousRowContent(string guid, string name, bool doesContain) { this.name = name; this.guid = guid; this.doesContain = doesContain; } public override bool Satisfied(int gridY, List previousNodes) { return previousNodes.Exists((NodeData x) => x != null && x.gridY == gridY - 1 && x is CustomSpecialNodeData && (x as CustomSpecialNodeData).name == name && (x as CustomSpecialNodeData).guid == guid) == doesContain; } } public class Func : SelectionCondition { private readonly Func, bool> func; public Func(Func, bool> del) { func = del; } public override bool Satisfied(int gridY, List previousNodes) { if (func == null) { return true; } return func(gridY, previousNodes); } } } namespace InscryptionAPI.Masks { public class CustomMask { public readonly Mask ID; public readonly string Name; public readonly string GUID; public readonly bool Override; public List MaterialOverrides { get; private set; } public MaskManager.ModelType ModelType { get; private set; } public Type BehaviourType { get; private set; } = typeof(MaskBehaviour); public CustomMask(string GUID, string Name, Mask ID, bool isOverride) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) this.GUID = GUID; this.Name = Name; this.ID = ID; Override = isOverride; } public CustomMask AddMaterialOverride(MaterialOverride materialOverride) { if (MaterialOverrides == null) { MaterialOverrides = new List(); } MaterialOverrides.Add(materialOverride); return this; } public CustomMask SetModelType(MaskManager.ModelType modelType) { ModelType = modelType; return this; } public CustomMask SetMaskBehaviour(Type type) { if (!type.IsSubclassOf(typeof(MaskBehaviour))) { InscryptionAPIPlugin.Logger.LogError((object)("Could not add type " + type?.ToString() + " to mask " + ToString() + ". It is not of type MaskBehaviour!")); return this; } BehaviourType = type; return this; } public override string ToString() { return GUID + "_" + Name; } } public class MaskBehaviour : MonoBehaviour { protected CustomMask maskData; public virtual void Initialize(CustomMask mask) { maskData = mask; OverrideTexture(mask); } protected virtual void OverrideTexture(CustomMask mask) { if (mask.MaterialOverrides == null || mask.MaterialOverrides.Count == 0) { return; } MeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren(); Material[] materials = ((Renderer)componentInChildren).materials; if (mask.MaterialOverrides.Count > materials.Length) { InscryptionAPIPlugin.Logger.LogWarning((object)$"{maskData.Name} has been given {mask.MaterialOverrides.Count} Textures to override with but the model only has {materials.Length}!"); } for (int i = 0; i < Mathf.Min(materials.Length, mask.MaterialOverrides.Count); i++) { MaterialOverride materialOverride = mask.MaterialOverrides[i]; if (materialOverride != null) { Material material = materials[i]; if (materialOverride.OverrideMainTexture) { OverrideMainTexture(materialOverride, material); } if (materialOverride.OverrideEmission) { OverrideEmission(materialOverride, material); } if (materialOverride.OverrideMetallicMap) { OverrideMetallicMap(materialOverride, material); } if (materialOverride.OverrideHeightMap) { OverrideHeightMap(materialOverride, material); } if (materialOverride.OverrideDetailMask) { OverrideDetailMask(materialOverride, material); } if (materialOverride.OverrideOcclusionMap) { OverrideOcclusionMap(materialOverride, material); } if (materialOverride.OverrideNormalMap) { OverrideNormalMap(materialOverride, material); } if (materialOverride.Metallic.HasValue) { OverrideMetallic(materialOverride, material); } if (materialOverride.Smoothness.HasValue) { OverrideSmoothnessValue(materialOverride, material); } if (materialOverride.Height.HasValue) { OverrideHeightValue(materialOverride, material); } } } ((Renderer)componentInChildren).materials = materials; } protected virtual void OverrideHeightValue(MaterialOverride materialOverride, Material material) { material.SetFloat("_Parallax", materialOverride.Height.Value); } protected virtual void OverrideSmoothnessValue(MaterialOverride materialOverride, Material material) { material.SetFloat("_Glossiness", materialOverride.Smoothness.Value); } protected virtual void OverrideMetallic(MaterialOverride materialOverride, Material material) { material.SetFloat("_Metallic", materialOverride.Metallic.Value); } protected virtual void OverrideNormalMap(MaterialOverride materialOverride, Material material) { material.SetTexture("_BumpMap", (Texture)(object)materialOverride.Emission); } protected virtual void OverrideOcclusionMap(MaterialOverride materialOverride, Material material) { material.SetTexture("_OcclusionMap", (Texture)(object)materialOverride.Emission); } protected virtual void OverrideDetailMask(MaterialOverride materialOverride, Material material) { material.SetTexture("_DetailMask", (Texture)(object)materialOverride.Emission); } protected virtual void OverrideHeightMap(MaterialOverride materialOverride, Material material) { material.SetTexture("_ParallaxMap", (Texture)(object)materialOverride.Emission); } protected virtual void OverrideMetallicMap(MaterialOverride materialOverride, Material material) { material.SetTexture("_MetallicGlossMap", (Texture)(object)materialOverride.Emission); } protected virtual void OverrideEmission(MaterialOverride materialOverride, Material material) { material.SetTexture("_EmissionMap", (Texture)(object)materialOverride.Emission); } protected virtual void OverrideMainTexture(MaterialOverride materialOverride, Material material) { material.mainTexture = (Texture)(object)materialOverride.MainTexture; } } public static class MaskManager { public enum ModelType { Prospector = 1, Woodcarver = 2, Angler = 3, Trapper = 4, Trader = 5, Doctor = 6, FlatMask = 101, Sphere = 102 } public static Mask NoMask = (Mask)(-1); private static Dictionary> MaskLookup = new Dictionary>(); public static Dictionary TypeToPrefabLookup = new Dictionary(); public static List BaseMasks = GenerateBaseMasks(); public static List CustomMasks = new List(); public static ModelType RegisterPrefab(string pluginGUID, string prefabName, ResourceLookup resource) { ModelType enumValue = GuidManager.GetEnumValue(pluginGUID, prefabName); TypeToPrefabLookup[enumValue] = resource; return enumValue; } public static CustomMask Add(string guid, string name, string texturePath = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Mask enumValue = GuidManager.GetEnumValue(guid, name); CustomMask customMask = AddCustomMask(guid, name, enumValue, ModelType.FlatMask, isOverride: false); if (!string.IsNullOrEmpty(texturePath)) { MaterialOverride materialOverride = new MaterialOverride(); materialOverride.ChangeMainTexture(TextureHelper.GetImageAsTexture(texturePath, (FilterMode)0)); customMask.AddMaterialOverride(materialOverride); } return customMask; } public static CustomMask AddRandom(string guid, string name, Mask maskType, string texturePath = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) CustomMask customMask = AddCustomMask(guid, name, maskType, ModelType.FlatMask, isOverride: false); if (!string.IsNullOrEmpty(texturePath)) { MaterialOverride materialOverride = new MaterialOverride(); materialOverride.ChangeMainTexture(TextureHelper.GetImageAsTexture(texturePath, (FilterMode)0)); customMask.AddMaterialOverride(materialOverride); } return customMask; } public static CustomMask Override(string guid, string name, Mask maskType, string texturePath = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) CustomMask customMask = AddCustomMask(guid, name, maskType, ModelType.FlatMask, isOverride: true); if (!string.IsNullOrEmpty(texturePath)) { MaterialOverride materialOverride = new MaterialOverride(); materialOverride.ChangeMainTexture(TextureHelper.GetImageAsTexture(texturePath, (FilterMode)0)); customMask.AddMaterialOverride(materialOverride); } return customMask; } public static CustomMask AddCustomMask(string guid, string name, Mask maskType, ModelType modelType, bool isOverride) { //IL_0002: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) CustomMask customMask = new CustomMask(guid, name, maskType, isOverride); customMask.SetModelType(modelType); CustomMasks.Add(customMask); if (!MaskLookup.TryGetValue(maskType, out var value)) { value = new List(); MaskLookup[maskType] = value; } value.Add(customMask); return customMask; } internal static CustomMask GetRandomMask(Mask maskType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!MaskLookup.TryGetValue(maskType, out var value)) { InscryptionAPIPlugin.Logger.LogWarning((object)("No mask defined of type: " + ((object)(Mask)(ref maskType)).ToString())); return BaseMasks[0]; } if (value.Count == 0) { InscryptionAPIPlugin.Logger.LogWarning((object)("No masks found for type " + ((object)(Mask)(ref maskType)).ToString())); return BaseMasks[0]; } CustomMask customMask = value.FindLast((CustomMask a) => a.Override); if (customMask == null) { int index = Random.RandomRangeInt(0, value.Count); customMask = value[index]; } return customMask; } private static List GenerateBaseMasks() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00ee: Unknown result type (might be due to invalid IL or missing references) InitializeDefaultModel("maskFlat", "CustomMask", ModelType.FlatMask); List list = new List(); foreach (Mask value2 in Enum.GetValues(typeof(Mask))) { Mask val = value2; ResourceLookup resourceLookup = new ResourceLookup(); resourceLookup.FromResourceBank("Prefabs/Opponents/Leshy/Masks/Mask" + ((object)(Mask)(ref val)).ToString()); if (!Enum.TryParse(((object)(Mask)(ref val)).ToString(), out var result)) { InscryptionAPIPlugin.Logger.LogWarning((object)("Could not get default mask for type " + ((object)(Mask)(ref val)).ToString())); } else { TypeToPrefabLookup[result] = resourceLookup; } CustomMask customMask = new CustomMask("", ((object)(Mask)(ref val)).ToString(), val, isOverride: false); customMask.SetModelType(result); list.Add(customMask); if (!MaskLookup.TryGetValue(val, out var value)) { value = new List(); MaskLookup[val] = value; } value.Add(customMask); } return list; } private static void InitializeDefaultModel(string assetBundlePath, string prefabName, ModelType modelType) { ResourceLookup resourceLookup = new ResourceLookup(); resourceLookup.FromAssetBundleInAssembly(assetBundlePath, prefabName); TypeToPrefabLookup[modelType] = resourceLookup; } internal static Mask BossToMask(Type opponentType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown return (Mask)((opponentType - 3) switch { 0 => 0, 1 => 2, 2 => 1, 3 => 4, _ => 1, }); } internal static void InitializeMaskClone(GameObject clone, CustomMask data) { MaskBehaviour maskBehaviour = default(MaskBehaviour); if (!clone.TryGetComponent(ref maskBehaviour)) { maskBehaviour = (MaskBehaviour)(object)clone.AddComponent(data.BehaviourType); } clone.SetActive(true); maskBehaviour.Initialize(data); } } [HarmonyPatch(typeof(LeshyAnimationController), "SpawnMask", new Type[] { typeof(Mask), typeof(bool) })] internal static class LeshyAnimationController_SpawnMask { [HarmonyPrefix] internal static bool Prefix(LeshyAnimationController __instance, Mask mask, bool justHead) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.CurrentMask != (Object)null) { Object.Destroy((Object)(object)__instance.CurrentMask); if (!justHead) { Object.Destroy((Object)(object)__instance.currentHeldMask); } } CustomMask customMask; GameObject val = GetPrefab(mask, out customMask); if ((Object)(object)val == (Object)null) { val = MaskManager.TypeToPrefabLookup[MaskManager.ModelType.Prospector].Get(); } __instance.CurrentMask = Object.Instantiate(val, __instance.maskParent); if ((Object)(object)__instance.CurrentMask != (Object)null) { MaskManager.InitializeMaskClone(__instance.CurrentMask, customMask); } if (!justHead) { __instance.currentHeldMask = Object.Instantiate(val, __instance.heldMaskParent); if ((Object)(object)__instance.currentHeldMask != (Object)null) { MaskManager.InitializeMaskClone(__instance.currentHeldMask, customMask); } } return false; } private static GameObject GetPrefab(Mask maskType, out CustomMask customMask) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) customMask = MaskManager.GetRandomMask(maskType); if (customMask == null) { InscryptionAPIPlugin.Logger.LogError((object)("[LeshyAnimationController_SpawnMask] Couldn't get mask for " + ((object)(Mask)(ref maskType)).ToString())); return null; } if (!MaskManager.TypeToPrefabLookup.TryGetValue(customMask.ModelType, out var value)) { InscryptionAPIPlugin.Logger.LogError((object)("[LeshyAnimationController_SpawnMask] Couldn't get resource for custom mask: " + customMask.GUID + " " + customMask.Name)); return null; } if (value == null) { InscryptionAPIPlugin.Logger.LogError((object)("[LeshyAnimationController_SpawnMask] Got resource for custom mask but resource is null!: " + customMask.GUID + " " + customMask.Name)); return null; } GameObject val = value.Get(); if ((Object)(object)val == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("[LeshyAnimationController_SpawnMask] Got custom mask but prefab is null for: " + customMask.GUID + " " + customMask.Name)); return null; } return val; } } } namespace InscryptionAPI.Localizing { public static class LocalizationManager { public class CustomLanguage { public string PluginGUID; public string LanguageName; public string LanguageCode; public string PathToStringTable; public Language Language; } public class CustomTranslation { public string PluginGUID; public Translation Translation; } private class CachedReplacement { public Language language; public FontReplacement replacement; } public enum FontReplacementType { Liberation, Marksman, Misc3D, DaggerSquare, HeavyWeight } [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(Localization), "ReadCSVFileIntoTranslationData")] [HarmonyPostfix] private static void Localization_ReadCSVFileIntoTranslationData(Language language) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!AlreadyLoadedLanguages.Contains(language)) { AlreadyLoadedLanguages.Add(language); } foreach (CustomTranslation customTranslation in CustomTranslations) { InsertTranslation(customTranslation); } OnLanguageLoaded?.Invoke(language); } [HarmonyPatch(typeof(Localization), "TrySetToSystemLanguage")] [HarmonyPrefix] private static void Localization_TrySetToSystemLanguage() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) foreach (CustomLanguage allLanguage in AllLanguages) { string languageName = allLanguage.LanguageName; SystemLanguage systemLanguage = Application.systemLanguage; if (languageName == ((object)(SystemLanguage)(ref systemLanguage)).ToString()) { Localization.CurrentLanguage = allLanguage.Language; break; } } } [HarmonyPatch(typeof(OptionsUI), "OnSetLanguageButtonPressed")] [HarmonyPrefix] private static bool OptionsUI_OnSetLanguageButtonPressed(OptionsUI __instance) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (__instance.languageField.Value >= 12) { Localization.CurrentLanguage = NewLanguages[__instance.languageField.Value - 12].Language; } else { Localization.CurrentLanguage = (Language)__instance.languageField.Value; } ((InteractableBase)__instance.setLanguageButton).SetEnabled(false); Singleton.Instance.SetEnabled(false); CustomCoroutine.WaitThenExecute(0.1f, (Action)delegate { MenuController.ReturnToStartScreen(); StartScreenController.startedGame = false; }, true); return false; } [HarmonyPatch(typeof(Localization), "ReadCSVFileIntoTranslationData")] [HarmonyPrefix] private static bool Localization_ReadCSVFileIntoTranslationData(Localization __instance, Language language) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((int)language >= 12) { ImportStringTable(NewLanguages.Find((CustomLanguage a) => a.Language == language).PathToStringTable, language); return false; } return true; } [HarmonyPatch(typeof(FontReplacementData), "Initialize")] [HarmonyPostfix] private static void FontReplacementData_Initialize() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) foreach (CachedReplacement temporaryFontReplacement in TemporaryFontReplacements) { AddFontReplacement(temporaryFontReplacement.language, temporaryFontReplacement.replacement); } TemporaryFontReplacements.Clear(); } [HarmonyPatch(typeof(OptionsUI), "OnLanguageChanged")] [HarmonyPostfix] private static void OptionsUI_OnLanguageChanged(OptionsUI __instance, int newValue) { int num = AllLanguages.FindIndex((CustomLanguage a) => a.Language == Localization.CurrentLanguage); ((Component)__instance.setLanguageButton).gameObject.SetActive(newValue != num); } [HarmonyPatch(typeof(OptionsUI), "InitializeLanguageField")] [HarmonyPrefix] private static bool OptionsUI_InitializeLanguageField(OptionsUI __instance) { __instance.languageField.AssignTextItems(new List(AllLanguageNames)); int num = AllLanguages.FindIndex((CustomLanguage a) => a.Language == Localization.CurrentLanguage); __instance.languageField.ShowValue(num, true); return false; } [HarmonyPatch(typeof(OptionsUI), "InitializeLanguageField")] [HarmonyPatch(typeof(OptionsUI), "OnLanguageChanged")] private static List Transpiler(IEnumerable instructions) { FieldInfo fieldInfo = AccessTools.Field(typeof(LocalizedLanguageNames), "NAMES"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(LocalizedLanguageNames), "SET_LANGUAGE_BUTTON_TEXT"); FieldInfo operand = AccessTools.Field(typeof(LocalizationManager), "AllLanguageNames"); FieldInfo operand2 = AccessTools.Field(typeof(LocalizationManager), "AllLanguageButtonText"); List list = new List(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.operand == fieldInfo) { val.operand = operand; } else if (val.operand == fieldInfo2) { val.operand = operand2; } } return list; } } public static string[] AllLanguageNames; public static string[] AllLanguageButtonText; public static List AllLanguages; public static List NewLanguages; public static List CustomTranslations; public static Action OnLanguageLoaded; private static List AlreadyLoadedLanguages; private static bool FontReplacementDataInitialized; private static List TemporaryFontReplacements; static LocalizationManager() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected I4, but got Unknown AllLanguageNames = new string[0]; AllLanguageButtonText = new string[0]; AllLanguages = new List(); NewLanguages = new List(); CustomTranslations = new List(); OnLanguageLoaded = null; AlreadyLoadedLanguages = new List(); FontReplacementDataInitialized = false; TemporaryFontReplacements = new List(); AllLanguageNames = LocalizedLanguageNames.NAMES.ToArray(); AllLanguageButtonText = LocalizedLanguageNames.SET_LANGUAGE_BUTTON_TEXT.ToArray(); foreach (Language item2 in from Language l in Enum.GetValues(typeof(Language)) where (int)l < 12 select l) { Language current = item2; CustomLanguage customLanguage = new CustomLanguage { PluginGUID = "cyantist.inscryption.api", LanguageName = ((object)(Language)(ref current)).ToString(), Language = current }; CustomLanguage customLanguage2 = customLanguage; customLanguage2.LanguageCode = (int)current switch { 0 => "en", 1 => "fr", 2 => "it", 3 => "de", 4 => "es", 5 => "pt", 6 => "tr", 7 => "ru", 8 => "ja", 9 => "ko", 10 => "zhcn", 11 => "zhtw", _ => "UNKNOWN", }; CustomLanguage item = customLanguage; AllLanguages.Add(item); } } public static Language NewLanguage(string pluginGUID, string languageName, string code, string resetButtonText, string stringTablePath = null, List fontReplacements = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Language enumValue = GuidManager.GetEnumValue(pluginGUID, languageName); CustomLanguage item = new CustomLanguage { PluginGUID = pluginGUID, LanguageName = languageName, Language = enumValue, LanguageCode = code, PathToStringTable = stringTablePath }; AllLanguages.Add(item); NewLanguages.Add(item); AllLanguageNames = CollectionExtensions.AddToArray(AllLanguageNames, languageName); AllLanguageButtonText = CollectionExtensions.AddToArray(AllLanguageButtonText, resetButtonText); if (fontReplacements != null) { foreach (FontReplacement fontReplacement in fontReplacements) { AddFontReplacement(enumValue, fontReplacement); } } return enumValue; } public static void AddFontReplacement(Language language, FontReplacement replacement) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)FontReplacementData.instance == (Object)null) { TemporaryFontReplacements.Add(new CachedReplacement { language = language, replacement = replacement }); return; } LanguageFontReplacements val = FontReplacementData.instance.languageFontReplacements.Find((LanguageFontReplacements a) => a.languages.Contains(language)); if (val == null) { val = new LanguageFontReplacements(); val.name = ((object)(Language)(ref language)).ToString(); val.fontReplacements = new List(); val.languages = new List { language }; FontReplacementData.instance.languageFontReplacements.Add(val); } val.fontReplacements.Add(replacement); } public static FontReplacement GetFontReplacementForFont(FontReplacementType type, Font font = null, TMP_FontAsset tmpFont = null) { FontReplacement val; switch (type) { case FontReplacementType.Liberation: val = Resources.Load("data/localization/fontreplacement/LIBERATION_to_DAGGERSQUARE"); break; case FontReplacementType.Marksman: val = Resources.Load("data/localization/fontreplacement/MARKSMAN_to_CHINESE-PIXEL"); break; case FontReplacementType.Misc3D: val = Resources.Load("data/localization/fontreplacement/MISC3D_to_JP-SCRIPT"); break; case FontReplacementType.DaggerSquare: val = Resources.Load("data/localization/fontreplacement/DAGGERSQUARE_to_JP-SANS"); break; case FontReplacementType.HeavyWeight: val = Resources.Load("data/localization/fontreplacement/HEAVYWEIGHT_to_VICIOUSHUNGER"); break; default: InscryptionAPIPlugin.Logger.LogError((object)("Unknown font replacement type: " + type.ToString().ToUpper())); return null; } if ((Object)(object)val == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Could not find font replacement for " + type.ToString().ToUpper())); return null; } val = Object.Instantiate(val); if ((Object)(object)font != (Object)null || (Object)(object)tmpFont != (Object)null) { val.replacementFont = font; val.replacementTMPFont = tmpFont; } return val; } private static void ImportStringTable(string stringTablePath, Language language) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_0137: 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_00f6: Unknown result type (might be due to invalid IL or missing references) string s = File.ReadAllText(stringTablePath); try { using StringReader stringReader = new StringReader(s); CSVParser val = new CSVParser((TextReader)stringReader, ','); List list = new List(); int num = 0; while (val.NextLine(list)) { if (list.Count < 3) { continue; } string text = list[0]; bool num2 = text.EndsWith("_F"); Translation val2; if (num2) { val2 = Localization.translations[num - 1]; } else if (num < Localization.translations.Count) { val2 = Localization.translations[num]; } else { val2 = new Translation(); Localization.translations.Add(val2); } if (string.IsNullOrEmpty(val2.id)) { val2.id = text; val2.englishString = list[1]; val2.englishStringFormatted = Localization.FormatString(list[1]); } if (num2) { if (!string.IsNullOrEmpty(list[2]) && val2.values[language] != list[2]) { val2.femaleGenderValues.Add(language, list[2]); } continue; } if (text != val2.id) { InscryptionAPIPlugin.Logger.LogInfo((object)("Mismatched Translation! Starting at: " + val2.id)); } val2.values.Add(language, list[2]); num++; } } catch { InscryptionAPIPlugin.Logger.LogInfo((object)("No Translation File for " + ((object)(Language)(ref language)).ToString())); } } public static CustomTranslation Translate(string pluginGUID, string id, string englishString, string translatedString, Language language) { //IL_0086: 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_0026: Expected O, but got Unknown CustomTranslation customTranslation = Get(englishString, id); bool num = customTranslation == null; if (num) { customTranslation = new CustomTranslation { PluginGUID = pluginGUID, Translation = new Translation() }; customTranslation.Translation.id = id; customTranslation.Translation.englishString = id; customTranslation.Translation.englishStringFormatted = ((!string.IsNullOrEmpty(englishString)) ? Localization.FormatString(englishString) : null); customTranslation.Translation.values = new Dictionary(); customTranslation.Translation.femaleGenderValues = new Dictionary(); } customTranslation.Translation.values[language] = translatedString; if (num) { return Add(customTranslation); } if (AlreadyLoadedLanguages.Count > 0) { InsertTranslation(customTranslation); } return customTranslation; } public static CustomTranslation Add(CustomTranslation translation) { CustomTranslations.Add(translation); if (AlreadyLoadedLanguages.Count > 0) { InsertTranslation(translation); } return translation; } public static CustomTranslation Get(string englishText, string id) { CustomTranslation customTranslation = null; if (!string.IsNullOrEmpty(englishText)) { customTranslation = CustomTranslations.Find((CustomTranslation a) => a.Translation.englishString == englishText); } if (customTranslation == null && !string.IsNullOrEmpty(id)) { customTranslation = CustomTranslations.Find((CustomTranslation a) => a.Translation.id == id); } return customTranslation; } private static void InsertTranslation(CustomTranslation customTranslation) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00d1: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_011f: Unknown result type (might be due to invalid IL or missing references) Translation val = null; val = (string.IsNullOrEmpty(customTranslation.Translation.englishStringFormatted) ? Localization.Translations.Find((Translation a) => a.id == customTranslation.Translation.id) : Localization.Translations.Find((Translation a) => a.englishStringFormatted == customTranslation.Translation.englishStringFormatted)); if (val == null) { val = new Translation { id = customTranslation.Translation.id, englishString = customTranslation.Translation.englishString, englishStringFormatted = customTranslation.Translation.englishStringFormatted, values = new Dictionary(), femaleGenderValues = new Dictionary() }; Localization.Translations.Add(val); } foreach (Language alreadyLoadedLanguage in AlreadyLoadedLanguages) { if (customTranslation.Translation.values.TryGetValue(alreadyLoadedLanguage, out var value)) { val.values[alreadyLoadedLanguage] = value; } if (customTranslation.Translation.femaleGenderValues.TryGetValue(alreadyLoadedLanguage, out var value2)) { val.femaleGenderValues[alreadyLoadedLanguage] = value2; } } } public static string LanguageToCode(Language language) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return AllLanguages.Find((CustomLanguage a) => a.Language == language)?.LanguageCode; } public static Language CodeToLanguage(string code) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) return (Language)(((??)AllLanguages.Find((CustomLanguage a) => a.LanguageCode == code)?.Language) ?? 12); } public static void ExportAllToCSV() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder("id"); for (int i = 0; i < AllLanguages.Count; i++) { stringBuilder.Append("," + AllLanguages[i]); } int count = Localization.Translations.Count; for (int j = 0; j < count; j++) { Translation val = Localization.Translations[j]; stringBuilder.Append("\n" + val.id); for (int k = 0; k < AllLanguages.Count; k++) { Language language = AllLanguages[k].Language; stringBuilder.Append(","); string value; if ((int)language == 0) { stringBuilder.Append(val.englishString); } else if (val.values.TryGetValue(language, out value)) { stringBuilder.Append(value); } } } string text = Path.Combine(InscryptionAPIPlugin.Directory, "localisation_table.csv"); File.WriteAllText(text, stringBuilder.ToString()); InscryptionAPIPlugin.Logger.LogInfo((object)("Exported .csv file to " + text)); } [Obsolete("Use Translate() instead")] public static CustomTranslation New(string pluginGUID, string id, string englishString, string translatedString, Language language) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return Translate(pluginGUID, id, englishString, translatedString, language); } } } namespace InscryptionAPI.Items { public class ResourceLookup : ICloneable { public string ResourcePath { get; private set; } public string ResourceBankID { get; private set; } public GameObject Prefab { get; private set; } public void FromAssetBundle(string assetBundlePath, string assetBundlePrefabName) { if (AssetBundleHelper.TryGet(assetBundlePath, assetBundlePrefabName, out GameObject prefab)) { Prefab = prefab; } } public void FromAssetBundle(AssetBundle assetBundle, string assetBundlePrefabName) { if (AssetBundleHelper.TryGet(assetBundle, assetBundlePrefabName, out GameObject prefab)) { Prefab = prefab; } } public void FromAssetBundleInAssembly(string assetBundlePath, string assetBundlePrefabName) { if (AssetBundleHelper.TryGet(TextureHelper.GetResourceBytes(assetBundlePath, typeof(T).Assembly), assetBundlePrefabName, out GameObject prefab)) { Prefab = prefab; } } public void FromResources(string resourcePath) { ResourcePath = resourcePath; } public void FromResourceBank(string resourceBankID) { ResourceBankID = resourceBankID; } public void FromPrefab(GameObject prefab) { Prefab = prefab; } public virtual T Get() where T : Object { if (!string.IsNullOrEmpty(ResourcePath)) { return Resources.Load(ResourcePath); } if (!string.IsNullOrEmpty(ResourceBankID)) { return ResourceBank.Get(ResourceBankID); } if ((Object)(object)Prefab != (Object)null) { if (((object)Prefab).GetType() == typeof(T)) { return (T)(object)Prefab; } if (typeof(T).IsSubclassOf(typeof(Component))) { return Prefab.GetComponent(); } InscryptionAPIPlugin.Logger.LogError((object)("No way to get Type " + typeof(T)?.ToString() + " from prefab " + ((Object)Prefab).name)); return default(T); } InscryptionAPIPlugin.Logger.LogError((object)"ResourceLookup not setup correctly!"); return default(T); } public override string ToString() { return $"ResourceLookup(ResourcePath:{ResourcePath}, ResourceBankID:{ResourceBankID}, Prefab:{Prefab})"; } public object Clone() { return (ResourceLookup)MemberwiseClone(); } } public static class ConsumableItemManager { public class FullConsumableItemData { public ConsumableItemData itemData; public Dictionary RulebookDescriptionRedirects = new Dictionary(); public List rulebookMetaCategories = new List(); public FullConsumableItemData(ConsumableItemData data) { itemData = data; } } internal enum ConsumableState { Vanilla, Custom, All } public enum ModelType { BasicRune = 1, BasicRuneWithVeins, HoveringRune, CardInABottle } private static Sprite cardinbottleSprite; private static ConsumableItemResource defaultItemModel = null; private static ModelType defaultItemModelType = ModelType.HoveringRune; internal static Dictionary prefabIDToResourceLookup = new Dictionary(); private static Dictionary typeToPrefabLookup = new Dictionary(); private static HashSet defaultModelTypes = new HashSet(); internal static readonly List allNewItems = new List(); private static readonly List baseConsumableItemsDatas = new List(); public static ReadOnlyCollection NewConsumableItemDatas = new ReadOnlyCollection(allNewItems); internal static readonly List allFullItemDatas = new List(); public static ConsumableItemData New(string pluginGUID, string rulebookName, string rulebookDescription, Texture2D rulebookSprite, Type itemType, GameObject prefab) { ConsumableItemResource consumableItemResource = new ConsumableItemResource(); consumableItemResource.FromPrefab(prefab); ModelType modelType = RegisterPrefab(pluginGUID, rulebookName, consumableItemResource); Object.DontDestroyOnLoad((Object)(object)prefab); prefab.SetActive(false); return New(pluginGUID, rulebookName, rulebookDescription, rulebookSprite, itemType, modelType); } public static ConsumableItemData New(string pluginGUID, string rulebookName, string rulebookDescription, Texture2D rulebookSprite, Type itemType, ConsumableItemResource resource) { ModelType modelType = RegisterPrefab(pluginGUID, rulebookName, resource); return New(pluginGUID, rulebookName, rulebookDescription, rulebookSprite, itemType, modelType); } public static ConsumableItemData New(string pluginGUID, string rulebookName, string rulebookDescription, Texture2D rulebookSprite, Type itemType, ModelType modelType) { ConsumableItemData data = ScriptableObject.CreateInstance(); data.SetRulebookName(rulebookName); data.SetRulebookDescription(rulebookDescription); data.SetRulebookSprite(rulebookSprite.ConvertTexture()); data.SetRegionSpecific(regionSpecific: false); data.SetNotRandomlyGiven(notRandomlyGiven: false); data.SetPrefabModelType(modelType); data.SetPickupSoundId("stone_object_up"); data.SetPlacedSoundId("stone_object_hit"); data.SetExamineSoundId("stone_object_hit"); data.SetComponentType(itemType); data.SetPowerLevel(1); return Add(pluginGUID, data); } public static ConsumableItemData NewCardInABottle(string pluginGUID, string cardName, Texture2D rulebookTexture = null) { CardInfo cardByName = CardLoader.GetCardByName(cardName); if ((Object)(object)cardByName == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("[NewCardInABottle] Could not get card using name " + cardName)); return null; } return NewCardInABottle(pluginGUID, cardByName, rulebookTexture); } public static ConsumableItemData NewCardInABottle(string pluginGUID, CardInfo cardInfo, Texture2D rulebookTexture = null) { if ((Object)(object)cardInfo == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)"[NewCardInABottle] CardInfo is null!"); return null; } ConsumableItemData data = Object.Instantiate(Resources.Load("data/consumables/FrozenOpossumBottle")); data.SetRulebookName(cardInfo.displayedName + " Bottle"); data.SetRulebookDescription("A " + cardInfo.displayedName + " is created in your hand. [define:" + ((Object)cardInfo).name + "]"); data.SetRegionSpecific(regionSpecific: false); data.SetNotRandomlyGiven(notRandomlyGiven: false); data.SetLearnItemDescription(""); data.SetPrefabModelType(ModelType.CardInABottle); data.SetComponentType(typeof(CardBottleItem)); data.SetCardWithinBottle(((Object)cardInfo).name); Sprite rulebookSprite; if ((Object)(object)rulebookTexture != (Object)null) { rulebookSprite = rulebookTexture.ConvertTexture(); } else { if (cardinbottleSprite == null) { cardinbottleSprite = TextureHelper.GetImageAsTexture("rulebookitemicon_cardinbottle.png", Assembly.GetExecutingAssembly(), (FilterMode)0).ConvertTexture(); } rulebookSprite = cardinbottleSprite; } data.SetRulebookSprite(rulebookSprite); return Add(pluginGUID, data); } public static ConsumableItemData Add(string pluginGUID, ConsumableItemData data) { string prefabID = (((Object)data).name = pluginGUID + "_" + data.rulebookName); data.SetPrefabID(prefabID); data.SetModPrefix(pluginGUID); allNewItems.Add(data); allFullItemDatas.Add(new FullConsumableItemData(data)); return data; } public static ModelType RegisterPrefab(string pluginGUID, string rulebookName, ConsumableItemResource resource) { ModelType enumValue = GuidManager.GetEnumValue(pluginGUID, rulebookName); typeToPrefabLookup[enumValue] = resource; return enumValue; } private static void InitializeDefaultModels() { LoadDefaultModelFromBundle("runeroundedbottom", "RuneRoundedBottom", ModelType.BasicRune); LoadDefaultModelFromBundle("customitem", "RuneRoundedBottomVeins", ModelType.BasicRuneWithVeins); LoadDefaultModelFromBundle("customhoveringitem", "RuneHoveringItem", ModelType.HoveringRune); LoadDefaultModelFromResources("prefabs/items/FrozenOpossumBottleItem", ModelType.CardInABottle); } private static void LoadDefaultModelFromBundle(string assetBundlePath, string prefabName, ModelType type) { ConsumableItemResource consumableItemResource = new ConsumableItemResource(); consumableItemResource.FromAssetBundleInAssembly(assetBundlePath, prefabName); typeToPrefabLookup[type] = consumableItemResource; defaultModelTypes.Add(type); } private static void LoadDefaultModelFromResources(string resourcePath, ModelType type) { ConsumableItemResource consumableItemResource = new ConsumableItemResource(); consumableItemResource.FromResources(resourcePath); typeToPrefabLookup[type] = consumableItemResource; defaultModelTypes.Add(type); } private static void InitializeConsumableItemDataPrefab(ConsumableItemData item) { ModelType prefabModelType = item.GetPrefabModelType(); if (!typeToPrefabLookup.TryGetValue(prefabModelType, out var value)) { value = defaultItemModel; InscryptionAPIPlugin.Logger.LogWarning((object)$"Could not find ModelType {prefabModelType} for ConsumableItemData {item.rulebookName}!"); } if (value == null) { value = defaultItemModel; InscryptionAPIPlugin.Logger.LogError((object)("Prefab missing for ConsumableItemData " + item.rulebookName + "! Using default instead.")); } string text = "Prefabs/Items/" + ((ItemData)item).prefabId; prefabIDToResourceLookup[text.ToLowerInvariant()] = value; } private static bool CanUseBaseModel(ConsumableItemData data, GameObject gameObject) { if ((Object)(object)data.rulebookSprite != (Object)null) { return (Object)(object)gameObject.GetComponent() == (Object)null; } return false; } private static void MoveComponent(Component sourceComp, Component targetComp) { FieldInfo[] fields = ((object)sourceComp).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); for (int i = 0; i < fields.Length; i++) { object value = fields[i].GetValue(sourceComp); fields[i].SetValue(targetComp, value); } } internal static void Initialize() { baseConsumableItemsDatas.Clear(); baseConsumableItemsDatas.AddRange(ItemsUtil.AllConsumables.FindAll((ConsumableItemData a) => (Object)(object)a != (Object)null && string.IsNullOrEmpty(a.GetModPrefix()))); foreach (ConsumableItemData itemData in baseConsumableItemsDatas) { if (!allFullItemDatas.Exists((FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)itemData)) { allFullItemDatas.Add(new FullConsumableItemData(itemData)); } } if (InscryptionAPIPlugin.configCustomItemTypes.Value == ConsumableState.Vanilla) { return; } if (defaultItemModel == null) { InitializeDefaultModels(); defaultItemModel = typeToPrefabLookup[defaultItemModelType]; } foreach (ConsumableItemData allNewItem in allNewItems) { InitializeConsumableItemDataPrefab(allNewItem); } if (InscryptionAPIPlugin.configCustomItemTypes.Value != ConsumableState.All) { return; } foreach (ConsumableItemData baseConsumableItemsData in baseConsumableItemsDatas) { string text = "Prefabs/Items/" + ((ItemData)baseConsumableItemsData).prefabId; GameObject val = ResourceBank.Get(text); if ((Object)(object)val == (Object)null) { InscryptionAPIPlugin.Logger.LogWarning((object)("Couldn't override item " + baseConsumableItemsData.rulebookName + ". Couldn't get prefab from ResourceBank")); } else if (CanUseBaseModel(baseConsumableItemsData, val)) { baseConsumableItemsData.SetComponentType(((object)val.GetComponent()).GetType()); baseConsumableItemsData.SetPrefabModelType(defaultItemModelType); ((ConsumableItemResource)defaultItemModel.Clone()).PreSetupCallback = delegate(GameObject clone, ConsumableItemData data) { ConsumableItem component = ResourceBank.Get("Prefabs/Items/" + ((ItemData)data).prefabId).GetComponent(); ConsumableItem targetComp = clone.AddComponent(); MoveComponent((Component)(object)component, (Component)(object)targetComp); }; prefabIDToResourceLookup[text.ToLowerInvariant()] = defaultItemModel; } } } internal static ConsumableItem SetupPrefab(ConsumableItemData data, GameObject prefab, Type itemType, ModelType modelType) { ((Object)prefab).name = "Custom Item (" + data.rulebookName + ")"; if (defaultModelTypes.Contains(modelType) && modelType != ModelType.CardInABottle) { if ((Object)(object)data.rulebookSprite != (Object)null) { GameObject val = prefab.gameObject.FindChild("Icon"); if ((Object)(object)val != (Object)null) { Renderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.material.mainTexture = (Texture)(object)data.rulebookSprite.texture; } else { InscryptionAPIPlugin.Logger.LogError((object)"Could not find Renderer on Icon GameObject to assign tribe icon!"); } } else { InscryptionAPIPlugin.Logger.LogError((object)"Could not find Icon GameObject to assign tribe icon!"); } } else { InscryptionAPIPlugin.Logger.LogError((object)("Could not change icon for " + data.rulebookName + ". No sprite defined!")); } } Animator val2 = prefab.GetComponentInChildren(); if ((Object)(object)val2 == (Object)null) { Transform child = prefab.transform.GetChild(0); if ((Object)(object)child != (Object)null) { val2 = ((Component)child).gameObject.AddComponent(); } else { InscryptionAPIPlugin.Logger.LogError((object)"Could not add Animator. Missing a child game object!. Make sure you have a GameObject called Anim!"); } } if ((Object)(object)val2 != (Object)null && (Object)(object)val2.runtimeAnimatorController == (Object)null) { val2.runtimeAnimatorController = Resources.Load("animation/items/ItemAnim"); val2.Rebind(); } ConsumableItem val3 = prefab.GetComponent(); if ((Object)(object)val3 == (Object)null) { Component obj = prefab.AddComponent(itemType); val3 = (ConsumableItem)(object)((obj is ConsumableItem) ? obj : null); if ((Object)(object)val3 == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)"Type given is not a ConsumableItem! You may encounter unexpected bugs"); } } Transform parent = prefab.transform.parent; prefab.transform.SetParent((Transform)null); Object.DontDestroyOnLoad((Object)(object)prefab); prefab.transform.SetParent(parent); return val3; } } [HarmonyPatch] public static class ConsumableItemPatches { [HarmonyPatch] internal class ConsumableItemSlot_ConsumeItem { [CompilerGenerated] private sealed class d__4 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = AccessTools.Method(ConsumableItemSlot_ConsumeItem_Class, "MoveNext", (Type[])null, (Type[])null); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__4(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static Type ConsumableItemSlot_ConsumeItem_Class = Type.GetType("DiskCardGame.ConsumableItemSlot+d__15, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); private static MethodInfo SwitchToViewMethod = AccessTools.Method(typeof(ViewManager), "SwitchToView", new Type[3] { typeof(View), typeof(bool), typeof(bool) }, (Type[])null); private static MethodInfo CustomSwitchToViewMethod = AccessTools.Method(typeof(ConsumableItemSlot_ConsumeItem), "SwitchToView", new Type[4] { typeof(ViewManager), typeof(View), typeof(bool), typeof(bool) }, (Type[])null); internal static ItemData currentItemData = null; [IteratorStateMachine(typeof(d__4))] public static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(-2); } public static IEnumerable Transpiler(IEnumerable instructions) { List list = new List(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.operand == SwitchToViewMethod) { val.operand = CustomSwitchToViewMethod; i++; } } return list; } public static void SwitchToView(ViewManager instance, View view, bool immediate, bool lockAfter) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)currentItemData != (Object)null) { ItemData obj = currentItemData; ConsumableItemData val = (ConsumableItemData)(object)((obj is ConsumableItemData) ? obj : null); if (val != null && val.CanActivateOutsideBattles()) { return; } } instance.SwitchToView(view, immediate, lockAfter); } } [HarmonyPostfix] [HarmonyPatch(typeof(ResourceBank), "Awake", new Type[] { })] private static void ResourceBank_Awake(ResourceBank __instance) { ConsumableItemManager.Initialize(); } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void ItemsUtil_AllConsumables(ref List __result) { __result.AddRange(ConsumableItemManager.allNewItems); } [HarmonyPrefix] [HarmonyPatch(typeof(ConsumableItem), "CanActivate", new Type[] { })] private static bool ConsumableItem_CanActivate(ConsumableItem __instance, ref bool __result) { ItemData data = ((Item)__instance).Data; ConsumableItemData val = (ConsumableItemData)(object)((data is ConsumableItemData) ? data : null); if (val != null && val.CanActivateOutsideBattles() && !GameFlowManager.IsCardBattle) { __result = __instance.ExtraActivationPrerequisitesMet(); return false; } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(ConsumableItemSlot), "ConsumeItem")] private static IEnumerator ConsumableItemSlot_ConsumeItemEnumerator(IEnumerator result, ConsumableItemSlot __instance) { ConsumableItemSlot_ConsumeItem.currentItemData = ((Item)__instance.Consumable).Data; return result; } [HarmonyPrefix] [HarmonyPatch(typeof(ItemSlot), "CreateItem", new Type[] { typeof(ItemData), typeof(bool) })] private static bool ItemSlot_CreateItem(ItemSlot __instance, ItemData data, bool skipDropAnimation) { //IL_0119: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.Item != (Object)null) { Object.Destroy((Object)(object)((Component)__instance.Item).gameObject); } string text = "Prefabs/Items/" + data.PrefabId; GameObject val = null; if (ConsumableItemManager.prefabIDToResourceLookup.TryGetValue(text.ToLowerInvariant(), out var value)) { ConsumableItemData val2 = (ConsumableItemData)(object)((data is ConsumableItemData) ? data : null); if (val2 != null) { GameObject val3 = ((ResourceLookup)value).Get(); if ((Object)(object)val3 == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Failed to get " + val2.rulebookName + " model from ConsumableItemAssetGetter " + value)); } else { val = Object.Instantiate(val3, ((Component)__instance).transform); } value.PreSetupCallback?.Invoke(val, val2); ConsumableItemManager.SetupPrefab(val2, val, val2.GetComponentType(), val2.GetPrefabModelType()); goto IL_0104; } } val = Object.Instantiate(ResourceBank.Get(text), ((Component)__instance).transform); if ((Object)(object)val == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Failed to get " + ((Object)data).name + " model from ResourceBank " + text)); } goto IL_0104; IL_0104: if (!val.activeSelf) { val.SetActive(true); } val.transform.localPosition = Vector3.zero; __instance.Item = val.GetComponent(); __instance.Item.SetData(data); if (skipDropAnimation) { __instance.Item.PlayEnterAnimation(true); } Item item = __instance.Item; CardBottleItem val4 = (CardBottleItem)(object)((item is CardBottleItem) ? item : null); if (val4 != null) { ConsumableItemData val5 = (ConsumableItemData)(object)((data is ConsumableItemData) ? data : null); if (val5 != null) { string cardWithinBottle = val5.GetCardWithinBottle(); if (!string.IsNullOrEmpty(cardWithinBottle)) { CardInfo cardByName = CardLoader.GetCardByName(cardWithinBottle); if ((Object)(object)cardByName != (Object)null) { val4.cardInfo = cardByName; ((Card)((Component)val4).GetComponentInChildren()).SetInfo(cardByName); ((Behaviour)((Component)val4).gameObject.GetComponent()).enabled = false; } else { InscryptionAPIPlugin.Logger.LogError((object)("Could not get card for bottled card item: " + cardWithinBottle)); } } } } return false; } [HarmonyTranspiler] [HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData")] private static IEnumerable ConstructItemPageData(IEnumerable instructions) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown List list = new List(instructions); int num = list.FindIndex((CodeInstruction x) => x.opcode == OpCodes.Ldfld && x.operand.ToString() == "System.Collections.Generic.List`1[DiskCardGame.ConsumableItemData] allConsumables"); if (num != -1) { num -= 3; int num2 = list.FindIndex(num, (CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "System.Collections.Generic.List`1[DiskCardGame.RuleBookPageInfo] ConstructPages(DiskCardGame.PageRangeInfo, Int32, Int32, System.Func`2[System.Int32,System.Boolean], System.Action`3[DiskCardGame.RuleBookPageInfo,DiskCardGame.PageRangeInfo,System.Int32], System.String)"); MethodInfo methodInfo = AccessTools.Method(typeof(ConsumableItemPatches), "ConstructItemPages", new Type[3] { typeof(RuleBookInfo), typeof(PageRangeInfo), typeof(AbilityMetaCategory) }, (Type[])null); list.RemoveRange(num, num2 - num + 1); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldloc_3, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); list.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo)); } return list; } public static List ConstructItemPages(RuleBookInfo instance, PageRangeInfo pageRange, AbilityMetaCategory metaCategory) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) List allConsumables = ItemsUtil.AllConsumables; return instance.ConstructPages(pageRange, allConsumables.Count, 0, (Func)((int index) => RuleBookManager.ItemShouldBeAdded(allConsumables[index], metaCategory)), (Action)instance.FillItemPage, Localization.Translate("APPENDIX XII, SUBSECTION IX - ITEMS {0}")); } } public class ConsumableItemResource : ResourceLookup { public Action PreSetupCallback; } } namespace InscryptionAPI.Items.Extensions { public static class ConsumableItemDataExtensions { private class ConsumableItemDataExt { public readonly Dictionary TypeMap = new Dictionary(); public readonly Dictionary StringMap = new Dictionary(); } private static readonly ConditionalWeakTable ExtensionProperties = new ConditionalWeakTable(); public static ConsumableItemData SetPowerLevel(this ConsumableItemData data, int powerLevel) { data.powerLevel = powerLevel; return data; } public static ConsumableItemData SetLearnItemDescription(this ConsumableItemData data, string description) { data.description = description; return data; } public static ConsumableItemData SetRulebookCategory(this ConsumableItemData data, AbilityMetaCategory rulebookCategory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) data.rulebookCategory = rulebookCategory; return data; } public static ConsumableItemData AddExtraRulebookCategories(this ConsumableItemData data, params AbilityMetaCategory[] rulebookCategories) { //IL_0014: 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_0029: Unknown result type (might be due to invalid IL or missing references) ConsumableItemManager.FullConsumableItemData fullConsumableItemData = data.GetFullConsumableItemData(); if (fullConsumableItemData != null) { foreach (AbilityMetaCategory item in rulebookCategories) { if (!fullConsumableItemData.rulebookMetaCategories.Contains(item)) { fullConsumableItemData.rulebookMetaCategories.Add(item); } } } return data; } public static ConsumableItemManager.FullConsumableItemData GetFullConsumableItemData(this ConsumableItemData data, bool fallBackToName = true) { ConsumableItemManager.FullConsumableItemData fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => (Object)(object)x.itemData == (Object)(object)data); if (fullConsumableItemData == null && fallBackToName) { fullConsumableItemData = ConsumableItemManager.allFullItemDatas.Find((ConsumableItemManager.FullConsumableItemData x) => x.itemData.GetModPrefix() == data.GetModPrefix() && x.itemData.rulebookName == data.rulebookName); } return fullConsumableItemData; } public static ConsumableItemData SetRulebookName(this ConsumableItemData data, string rulebookName) { data.rulebookName = rulebookName; return data; } public static ConsumableItemData SetRulebookDescription(this ConsumableItemData data, string rulebookDescription) { data.rulebookDescription = rulebookDescription; return data; } public static ConsumableItemData SetRulebookSprite(this ConsumableItemData data, Sprite rulebookSprite) { data.rulebookSprite = rulebookSprite; return data; } public static ConsumableItemData SetRegionSpecific(this ConsumableItemData data, bool regionSpecific) { data.regionSpecific = regionSpecific; return data; } public static ConsumableItemData SetNotRandomlyGiven(this ConsumableItemData data, bool notRandomlyGiven) { data.notRandomlyGiven = notRandomlyGiven; return data; } public static ConsumableItemData SetComponentType(this ConsumableItemData data, Type type) { data.SetExtendedProperty("ComponentType", type.FullName + ", " + type.Assembly.FullName); return data; } public static ConsumableItemData SetCanActivateOutsideBattles(this ConsumableItemData data, bool alwaysActivatable) { data.SetExtendedProperty("CanActivateOutsideBattles", alwaysActivatable); return data; } public static ConsumableItemData SetPrefabID(this ConsumableItemData data, string prefabID) { ((ItemData)data).prefabId = prefabID; return data; } public static ConsumableItemData SetPickupSoundId(this ConsumableItemData data, string pickupSoundId) { ((ItemData)data).pickupSoundId = pickupSoundId; return data; } public static ConsumableItemData SetPlacedSoundId(this ConsumableItemData data, string placedSoundId) { ((ItemData)data).placedSoundId = placedSoundId; return data; } public static ConsumableItemData SetExamineSoundId(this ConsumableItemData data, string examineSoundId) { ((ItemData)data).examineSoundId = examineSoundId; return data; } public static ConsumableItemData SetAct1(this ConsumableItemData data) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) data.rulebookCategory = (AbilityMetaCategory)0; return data; } public static ConsumableItemData SetAct3(this ConsumableItemData data) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) data.rulebookCategory = (AbilityMetaCategory)2; return data; } public static ConsumableItemData SetAscensionUnlocked(this ConsumableItemData data) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) data.rulebookCategory = (AbilityMetaCategory)8; return data; } public static ConsumableItemData SetCardWithinBottle(this ConsumableItemData data, string cardName) { data.SetExtendedProperty("CardWithinBottle", cardName); return data; } public static string GetCardWithinBottle(this ConsumableItemData data) { return data.GetExtendedProperty("CardWithinBottle"); } public static ConsumableItemData SetPrefabModelType(this ConsumableItemData data, ConsumableItemManager.ModelType modelType) { data.SetExtendedProperty("PrefabModelType", (int)modelType); return data; } public static ConsumableItemManager.ModelType GetPrefabModelType(this ConsumableItemData data) { int? extendedPropertyAsInt = data.GetExtendedPropertyAsInt("PrefabModelType"); if (!extendedPropertyAsInt.HasValue) { return (ConsumableItemManager.ModelType)0; } return (ConsumableItemManager.ModelType)extendedPropertyAsInt.Value; } public static Type GetComponentType(this ConsumableItemData data) { return Type.GetType(data.GetExtendedProperty("ComponentType")); } public static bool CanActivateOutsideBattles(this ConsumableItemData data) { bool? extendedPropertyAsBool = data.GetExtendedPropertyAsBool("CanActivateOutsideBattles"); if (extendedPropertyAsBool.HasValue) { return extendedPropertyAsBool.Value; } return false; } internal static ConsumableItemData SetModPrefix(this ConsumableItemData data, string modPrefix) { data.SetExtendedProperty("ModPrefix", modPrefix); return data; } public static string GetModPrefix(this ConsumableItemData data) { return data.GetExtendedProperty("ModPrefix"); } internal static Dictionary GetConsumableItemDataExtensionTable(this ConsumableItemData data) { return ExtensionProperties.GetOrCreateValue(data).StringMap; } public static ConsumableItemData SetExtendedProperty(this ConsumableItemData data, string propertyName, object value) { data.GetConsumableItemDataExtensionTable()[propertyName] = value?.ToString(); return data; } public static string GetExtendedProperty(this ConsumableItemData data, string propertyName) { data.GetConsumableItemDataExtensionTable().TryGetValue(propertyName, out var value); return value; } public static int? GetExtendedPropertyAsInt(this ConsumableItemData data, string propertyName) { data.GetConsumableItemDataExtensionTable().TryGetValue(propertyName, out var value); if (!int.TryParse(value, out var result)) { return null; } return result; } public static float? GetExtendedPropertyAsFloat(this ConsumableItemData data, string propertyName) { data.GetConsumableItemDataExtensionTable().TryGetValue(propertyName, out var value); if (!float.TryParse(value, out var result)) { return null; } return result; } public static bool? GetExtendedPropertyAsBool(this ConsumableItemData data, string propertyName) { data.GetConsumableItemDataExtensionTable().TryGetValue(propertyName, out var value); if (!bool.TryParse(value, out var result)) { return null; } return result; } } } namespace InscryptionAPI.Guid { [HarmonyPatch] public static class TypeManager { private static readonly Dictionary TypeCache = new Dictionary(); private static readonly Dictionary ModIds = new Dictionary(); internal static void Add(string key, Type value) { if (TypeCache.ContainsKey(key)) { if (!(TypeCache[key] == value)) { Replace(key, value); } } else { TypeCache.Add(key, value); } } internal static void Replace(string key, Type value) { if (TypeCache.ContainsKey(key)) { TypeCache.Remove(key); } Add(key, value); } private static string GetModIdFromAssembly(Assembly assembly) { if (ModIds.ContainsKey(assembly.FullName)) { return ModIds[assembly.FullName]; } Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { foreach (BepInPlugin customAttribute in ((MemberInfo)types[i]).GetCustomAttributes()) { if (!(customAttribute.GUID == "cyantist.inscryption.api")) { ModIds.Add(assembly.FullName, customAttribute.GUID); return customAttribute.GUID; } } } ModIds.Add(assembly.FullName, null); return null; } public static string GetModIdFromCallstack(Assembly callingAssembly) { string modIdFromAssembly = GetModIdFromAssembly(callingAssembly); if (!string.IsNullOrEmpty(modIdFromAssembly)) { return modIdFromAssembly; } StackFrame[] frames = new StackTrace().GetFrames(); for (int i = 0; i < frames.Length; i++) { string modIdFromAssembly2 = GetModIdFromAssembly(frames[i].GetMethod().DeclaringType.Assembly); if (!string.IsNullOrEmpty(modIdFromAssembly2)) { return modIdFromAssembly2; } } return null; } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(CustomType), "GetType", new Type[] { typeof(string), typeof(string) })] public static Type OriginalGetType(string nameSpace, string typeName) { throw new NotImplementedException(); } [HarmonyPatch(typeof(CustomType), "GetType", new Type[] { typeof(string), typeof(string) })] [HarmonyPrefix] private static bool GetCustomType(string nameSpace, string typeName, ref Type __result) { if (TypeCache.ContainsKey(typeName)) { __result = TypeCache[typeName]; return false; } if (int.TryParse(typeName, out var enumValue)) { Type enumType = GuidManager.GetEnumType(enumValue); if (enumType == typeof(Ability)) { AbilityManager.FullAbility fullAbility = AbilityManager.AllAbilities.FirstOrDefault((AbilityManager.FullAbility fab) => (int)fab.Id == enumValue); if (fullAbility != null) { __result = fullAbility.AbilityBehavior; TypeCache.Add(typeName, __result); return false; } } if (enumType == typeof(SpecialStatIcon)) { StatIconManager.FullStatIcon fullStatIcon = StatIconManager.AllStatIcons.FirstOrDefault((StatIconManager.FullStatIcon fab) => (int)fab.Id == enumValue); if (fullStatIcon != null) { __result = fullStatIcon.VariableStatBehavior; TypeCache.Add(typeName, __result); return false; } } if (enumType == typeof(SpecialTriggeredAbility)) { SpecialTriggeredAbilityManager.FullSpecialTriggeredAbility fullSpecialTriggeredAbility = SpecialTriggeredAbilityManager.AllSpecialTriggers.FirstOrDefault((SpecialTriggeredAbilityManager.FullSpecialTriggeredAbility fab) => (int)fab.Id == enumValue); if (fullSpecialTriggeredAbility != null) { __result = fullSpecialTriggeredAbility.AbilityBehaviour; TypeCache.Add(typeName, __result); return false; } } if (enumType == typeof(Appearance)) { CardAppearanceBehaviourManager.FullCardAppearanceBehaviour fullCardAppearanceBehaviour = CardAppearanceBehaviourManager.AllAppearances.FirstOrDefault((CardAppearanceBehaviourManager.FullCardAppearanceBehaviour fab) => (int)fab.Id == enumValue); if (fullCardAppearanceBehaviour != null) { __result = fullCardAppearanceBehaviour.AppearanceBehaviour; TypeCache.Add(typeName, __result); return false; } } } __result = AccessTools.TypeByName(nameSpace + "." + typeName); TypeCache.Add(typeName, __result); return false; } } public static class GuidManager { private static readonly Dictionary reverseMapper = new Dictionary(); private static readonly object lockObject = new object(); public const int START_INDEX = 1000; public const string MAX_DATA = "maximumStoredValueForEnum"; public static string GetFullyQualifiedName(string guid, string value) { return guid + "_" + value; } public static Type GetEnumType(int number) { reverseMapper.TryGetValue(number, out var value); return value; } public unsafe static List GetValues() where T : unmanaged, Enum { List list = new List(); foreach (T value2 in Enum.GetValues(typeof(T))) { list.Add(value2); } string value = typeof(T).Name + "_"; foreach (KeyValuePair item3 in ModdedSaveManager.SaveData.SaveData["cyantist.inscryption.api"]) { if (item3.Key.StartsWith(value)) { int num = int.Parse((string)item3.Value); T item2 = *(T*)(&num); list.Add(item2); } } return list; } public unsafe static T GetEnumValue(string guid, string value) where T : unmanaged, Enum { if (sizeof(T) != 4) { throw new NotSupportedException("Cannot manage values of type " + typeof(T).Name + " in GuidManager.GetEnumValue"); } string key = typeof(T).Name + "_" + guid + "_" + value; int num = ModdedSaveManager.SaveData.GetValueAsInt("cyantist.inscryption.api", key); if (num == 0) { lock (lockObject) { num = ModdedSaveManager.SaveData.GetValueAsInt("cyantist.inscryption.api", "maximumStoredValueForEnum"); if (num < 1000) { num = 1000; } ModdedSaveManager.SaveData.SetValue("cyantist.inscryption.api", "maximumStoredValueForEnum", num + 1); ModdedSaveManager.SaveData.SetValue("cyantist.inscryption.api", key, num); ModdedSaveManager.isSystemDirty = true; } } reverseMapper[num] = typeof(T); return *(T*)(&num); } public static bool TryGetGuidAndKeyEnumValue(T value, out string guid, out string key) where T : Enum { string prefix = typeof(T).Name ?? ""; return ModdedSaveManager.SaveData.TryGetGuidAndKey(prefix, value.ToString(), out guid, out key); } } } namespace InscryptionAPI.Encounters { public static class AIManager { public class FullAI { public readonly string Id; public readonly Type AI; public FullAI(string id, Type aiType) { Id = id; AI = aiType; TypeManager.Add(Id.ToString(), AI); } } public static readonly ReadOnlyCollection BaseGameAIs; private static readonly ObservableCollection NewAIs; public static List AllAIs { get; private set; } static AIManager() { BaseGameAIs = new ReadOnlyCollection(GenBaseGameAIsList()); NewAIs = new ObservableCollection(); AllAIs = BaseGameAIs.ToList(); NewAIs.CollectionChanged += delegate { AllAIs = BaseGameAIs.Concat(NewAIs).ToList(); }; } private static List GenBaseGameAIsList() { List list = new List(); foreach (Type item in from type in typeof(AI).Assembly.GetTypes() where type.IsSubclassOf(typeof(AI)) select type) { list.Add(new FullAI(item.Name, item)); } return list; } public static FullAI Add(string guid, string aiName, Type sequencer) { FullAI fullAI = new FullAI("AI_" + GuidManager.GetFullyQualifiedName(guid, aiName), sequencer); NewAIs.Add(fullAI); return fullAI; } } public class CachedGCBNPCDescriptor { public string ID { get; set; } public CardTemple BossTemple { get; set; } public bool IsBoss { get; set; } public BoardTheme BattleBackgroundTheme { get; set; } public DialogueSpeaker DialogueSpeaker { get; set; } public CachedGCBNPCDescriptor(CardBattleNPC npc) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) ID = npc.ID; BossTemple = npc.BossTemple; IsBoss = npc.IsBoss; BattleBackgroundTheme = npc.BattleBackgroundTheme; DialogueSpeaker = npc.DialogueSpeaker; } } public class CustomNodeData : SpecialNodeData { public delegate bool NodeGenerationCondition(int gridY, List previousNodes); private class DelegateCondition : SelectionCondition { private NodeGenerationCondition internalDelegate; public DelegateCondition(NodeGenerationCondition condition) { internalDelegate = condition; } public override bool Satisfied(int gridY, List previousNodes) { return internalDelegate(gridY, previousNodes); } } private List prerequisiteConditions = new List(); private List forceGenerationConditions = new List(); [SerializeField] internal string guid; public override List GenerationPrerequisiteConditions => prerequisiteConditions; public override List ForceGenerationConditions => forceGenerationConditions; public sealed override string PrefabPath => "Prefabs/Map/MapNodesPart1/MapNode_BuyPelts@" + guid; public CustomNodeData() { ((NodeData)this).connectedNodes = new List(); } public virtual void Initialize() { } protected void AddGenerationPrerequisite(Func condition) { ((NodeData)this).GenerationPrerequisiteConditions.Add((SelectionCondition)(object)new DelegateCondition((int y, List nodes) => condition())); } protected void AddGenerationPrerequisite(NodeGenerationCondition condition) { ((NodeData)this).GenerationPrerequisiteConditions.Add((SelectionCondition)(object)new DelegateCondition(condition)); } protected void AddForceGenerationCondition(Func condition) { ((NodeData)this).ForceGenerationConditions.Add((SelectionCondition)(object)new DelegateCondition((int y, List nodes) => condition())); } protected void AddForceGenerationCondition(NodeGenerationCondition condition) { ((NodeData)this).ForceGenerationConditions.Add((SelectionCondition)(object)new DelegateCondition(condition)); } } public class EncounterBuilderBlueprintData : EncounterBlueprintData { internal RegionData region; public void SetBasic(string name, RegionData region) { this.region = region; ((Object)this).name = name; if (region.encounters == null) { region.encounters = new List(); } region.encounters.Add((EncounterBlueprintData)(object)this); } } public static class EncounterBuilder { public static RegionData Build(this EncounterBuilderBlueprintData blueprint) { return blueprint.region; } } [HarmonyPatch] public static class EncounterExtensions { [CompilerGenerated] private sealed class d__23 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardBattleNPC triggeringNPC; public IEnumerator sequence; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; LAST_KNOWN_NPC.Remove(GBCEncounterManager.Instance); LAST_KNOWN_NPC.Add(GBCEncounterManager.Instance, new CachedGCBNPCDescriptor(triggeringNPC)); <>2__current = sequence; <>1__state = 1; return true; case 1: <>1__state = -1; LAST_KNOWN_NPC.Remove(GBCEncounterManager.Instance); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static ConditionalWeakTable LAST_KNOWN_NPC = new ConditionalWeakTable(); public static OpponentManager.FullOpponent OpponentById(this IEnumerable opponents, Type id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return opponents.FirstOrDefault((OpponentManager.FullOpponent o) => o.Id == id); } public static OpponentManager.FullOpponent SetOpponent(this OpponentManager.FullOpponent opp, Type opponentType) { opp.Opponent = opponentType; return opp; } public static OpponentManager.FullOpponent SetSequencer(this OpponentManager.FullOpponent opp, string sequenceId) { opp.SpecialSequencerId = sequenceId; return opp; } public static OpponentManager.FullOpponent SetNewSequencer(this OpponentManager.FullOpponent opp, string pluginGuid, string sequencerName, Type sequencerType) { SpecialSequenceManager.FullSpecialSequencer fullSpecialSequencer = SpecialSequenceManager.Add(pluginGuid, sequencerName, sequencerType); opp.SpecialSequencerId = fullSpecialSequencer.Id; return opp; } public static T SetDifficulty(this T blueprint, int min, int max) where T : EncounterBlueprintData { ((EncounterBlueprintData)blueprint).minDifficulty = min; ((EncounterBlueprintData)blueprint).maxDifficulty = max; return blueprint; } public static T AddDominantTribes(this T blueprint, params Tribe[] tribes) where T : EncounterBlueprintData { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) EncounterBlueprintData val = (EncounterBlueprintData)(object)blueprint; if (val.dominantTribes == null) { val.dominantTribes = new List(); } foreach (Tribe item in tribes) { ((EncounterBlueprintData)blueprint).dominantTribes.Add(item); } return blueprint; } [Obsolete("regionSpecific is unused.")] public static T SetRegionSpecific(this T blueprint, bool enabled) where T : EncounterBlueprintData { ((EncounterBlueprintData)blueprint).regionSpecific = enabled; return blueprint; } public static T AddRandomReplacementCards(this T blueprint, params string[] cards) where T : EncounterBlueprintData { EncounterBlueprintData val = (EncounterBlueprintData)(object)blueprint; if (val.randomReplacementCards == null) { val.randomReplacementCards = new List(); } foreach (string name in cards) { CardInfo item = CardManager.AllCardsCopy.CardByName(name); if (!((EncounterBlueprintData)blueprint).randomReplacementCards.Contains(item)) { ((EncounterBlueprintData)blueprint).randomReplacementCards.Add(item); } } return blueprint; } public static T SetRedundantAbilities(this T blueprint, params Ability[] abilities) where T : EncounterBlueprintData { ((EncounterBlueprintData)blueprint).redundantAbilities = abilities.ToList(); return blueprint; } public static T SetUnlockedCardPrerequisites(this T blueprint, params string[] cards) where T : EncounterBlueprintData { EncounterBlueprintData val = (EncounterBlueprintData)(object)blueprint; if (val.unlockedCardPrerequisites == null) { val.unlockedCardPrerequisites = new List(); } foreach (string name in cards) { CardInfo item = CardManager.AllCardsCopy.CardByName(name); if (!((EncounterBlueprintData)blueprint).unlockedCardPrerequisites.Contains(item)) { ((EncounterBlueprintData)blueprint).unlockedCardPrerequisites.Add(item); } } return blueprint; } public static T AddTurnMods(this T blueprint, params TurnModBlueprint[] turnMods) where T : EncounterBlueprintData { ((EncounterBlueprintData)blueprint).turnMods = turnMods.ToList(); return blueprint; } public static CardBlueprint SetDifficulty(this CardBlueprint card, int min, int max) { card.minDifficulty = min; card.maxDifficulty = max; return card; } public static CardBlueprint SetReplacement(this CardBlueprint blueprint, string replacementName, int requiredDifficulty = 0, bool replaceWithDifficulty = true) { blueprint.difficultyReplace = replaceWithDifficulty; blueprint.difficultyReq = requiredDifficulty; blueprint.replacement = CardManager.AllCardsCopy.CardByName(replacementName); return blueprint; } public static List SetTurnDifficulty(this List list, int min, int max) { foreach (CardBlueprint item in list) { item.SetDifficulty(min, max); } return list; } public static List[] DuplicateTurn(this List list, int amount) { List[] array = new List[1 + amount]; for (int i = 0; i < 1 + amount; i++) { CollectionExtensions.AddToArray>(array, list); } return array; } public static TurnBuilder CreateTurn(this T blueprint) where T : EncounterBlueprintData { TurnBuilder turnBuilder = new TurnBuilder(); turnBuilder.SetBlueprint(blueprint); return turnBuilder; } public static T AddTurn(this T blueprint, params CardBlueprint[] cards) where T : EncounterBlueprintData { blueprint.AddTurn(cards?.ToList() ?? new List()); return blueprint; } public static T AddTurn(this T blueprint, List turn = null) where T : EncounterBlueprintData { EncounterBlueprintData val = (EncounterBlueprintData)(object)blueprint; if (val.turns == null) { val.turns = new List>(); } ((EncounterBlueprintData)blueprint).turns.Add(turn ?? new List()); return blueprint; } public static T AddTurns(this T blueprint, params List[] turns) where T : EncounterBlueprintData { foreach (List turn in turns) { blueprint.AddTurn(turn); } return blueprint; } public static T AddTurns(this T blueprint, List> turns) where T : EncounterBlueprintData { EncounterBlueprintData val = (EncounterBlueprintData)(object)blueprint; if (val.turns == null) { val.turns = new List>(); } foreach (List turn in turns) { blueprint.AddTurn(turn); } return blueprint; } public static T DuplicateTurns(this T blueprint, int amount) where T : EncounterBlueprintData { List> list = new List>(); for (int i = 0; i < 1 + amount; i++) { foreach (List turn in ((EncounterBlueprintData)blueprint).turns) { list.Add(turn); } } ((EncounterBlueprintData)blueprint).turns = list; return blueprint; } public static T SyncTurnDifficulties(this T blueprint, int minDifficulty, int maxDifficulty) where T : EncounterBlueprintData { foreach (List turn in ((EncounterBlueprintData)blueprint).turns) { turn.SetTurnDifficulty(minDifficulty, maxDifficulty); } return blueprint; } [IteratorStateMachine(typeof(d__23))] [HarmonyPatch(typeof(GBCEncounterManager), "EncounterSequence")] [HarmonyPostfix] private static IEnumerator CaptureLastKnownTriggeringNPC(IEnumerator sequence, CardBattleNPC triggeringNPC) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__23(0) { sequence = sequence, triggeringNPC = triggeringNPC }; } public static CachedGCBNPCDescriptor GetTriggeringNPC(this GBCEncounterManager mgr) { if (LAST_KNOWN_NPC.TryGetValue(mgr, out var value)) { return value; } return null; } } public static class EncounterManager { public static readonly ReadOnlyCollection BaseGameEncounters; public static readonly ObservableCollection NewEncounters; public static List AllEncountersCopy { get; private set; } public static event Func, List> ModifyEncountersList; private static EncounterBlueprintData CloneAndReplace(this EncounterBlueprintData data) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) EncounterBlueprintData val = (EncounterBlueprintData)Object.Internal_CloneSingle((Object)(object)data); ((Object)val).name = ((Object)data).name; if (val.dominantTribes == null || val.dominantTribes.Count == 0) { List list = (from ci in (from cb in val.turns.SelectMany((List l) => l) select cb.card).Concat(from cb in data.turns.SelectMany((List l) => l) select cb.replacement).Concat(data.randomReplacementCards) where (Object)(object)ci != (Object)null && ci.tribes != null select ci).SelectMany((CardInfo ci) => ci.tribes).ToList(); if (list.Count > 0) { val.dominantTribes = new List { (from t in list group t by t into g orderby g.Count() descending select g).First().Key }; } else { val.dominantTribes = new List { (Tribe)6 }; } } RegionManager.ReplaceBlueprintInCore(val); return val; } public static void SyncEncounterList() { List list = (from x in BaseGameEncounters.Concat(NewEncounters) select x.CloneAndReplace()).ToList(); AllEncountersCopy = EncounterManager.ModifyEncountersList?.Invoke(list) ?? list; } static EncounterManager() { BaseGameEncounters = new ReadOnlyCollection(Resources.LoadAll("Data")); NewEncounters = new ObservableCollection(); AllEncountersCopy = BaseGameEncounters.ToList(); InscryptionAPIPlugin.ScriptableObjectLoaderLoad += delegate(Type type) { if (type == typeof(EncounterBlueprintData)) { ScriptableObjectLoader.allData = AllEncountersCopy; } }; NewEncounters.CollectionChanged += delegate { SyncEncounterList(); }; } public static void Add(EncounterBlueprintData newEncounter) { if (!NewEncounters.Contains(newEncounter)) { NewEncounters.Add(newEncounter); } } public static void Remove(EncounterBlueprintData encounter) { NewEncounters.Remove(encounter); } public static EncounterBlueprintData New(string name, bool addToPool = true) { EncounterBlueprintData val = ScriptableObject.CreateInstance(); ((Object)val).name = name; if (addToPool) { Add(val); } return val; } public static CardBlueprint NewCardBlueprint(string cardName, int randomReplaceChance = 0, bool difficultyReplace = false, int difficultyReplaceReq = 0, string replacement = null, int minDifficulty = 1, int maxDifficulty = 20) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown return new CardBlueprint { card = CardManager.AllCardsCopy.CardByName(cardName), randomReplaceChance = randomReplaceChance, minDifficulty = minDifficulty, maxDifficulty = maxDifficulty, difficultyReplace = difficultyReplace, difficultyReq = difficultyReplaceReq, replacement = CardManager.AllCardsCopy.CardByName(replacement) }; } public static List CreateTurn(string cardName) { return CreateTurn(NewCardBlueprint(cardName)); } public static List CreateTurn(params string[] cardNames) { List list = new List(); foreach (string cardName in cardNames) { list.Add(NewCardBlueprint(cardName)); } return CreateTurn(list.ToArray()); } public static List CreateTurn(CardBlueprint card = null) { List list = new List(); if (card != null) { list.Add(card); } return list; } public static List CreateTurn(params CardBlueprint[] cards) { List list = new List(); foreach (CardBlueprint item in cards) { list.Add(item); } return list; } } public interface ICustomExhaustSequence { bool RespondsToCustomExhaustSequence(CardDrawPiles drawPiles); IEnumerator DoCustomExhaustSequence(CardDrawPiles drawPiles); } public interface ICustomNodeSequence { IEnumerator ExecuteCustomSequence(CustomNodeData nodeData); } [HarmonyPatch] [Obsolete("NodeManager is deprecated, use NewNodeManager instead.")] public static class NodeManager { [Flags] public enum NodePosition { NotGenerated = 0, Act1Available = 1, MapStart = 2, CardChoiceRandom = 4, SpecialEventRandom = 8, PreBoss = 0x10, PostBoss = 0x20 } public class NodeInfo { public Texture2D[] animatedMapNode { get; set; } public NodePosition nodePosition { get; set; } public Type sequencerType { get; set; } public Type nodeDataType { get; set; } public string guid { get; internal set; } public string ModGUID { get; internal set; } public CustomNodeData BuildNode() { CustomNodeData obj = Activator.CreateInstance(nodeDataType) as CustomNodeData; obj.guid = guid; obj.Initialize(); return obj; } } private static List AllNodes = new List(); public static NodeInfo Add(Texture2D[] animatedMapNode, NodePosition nodeType) where S : MonoBehaviour, ICustomNodeSequence { return Add(animatedMapNode, nodeType); } public static NodeInfo Add(Texture2D[] animatedMapNode, NodePosition nodeType) where S : MonoBehaviour, ICustomNodeSequence where N : CustomNodeData { if (animatedMapNode.Length != 4) { throw new InvalidDataException("There must be exactly four animated map textures"); } NodeInfo nodeInfo = new NodeInfo { animatedMapNode = animatedMapNode, nodePosition = nodeType, sequencerType = typeof(S), nodeDataType = typeof(N), guid = typeof(S).FullName }; nodeInfo.ModGUID = TypeManager.GetModIdFromCallstack(typeof(S).Assembly); AllNodes.Add(nodeInfo); return nodeInfo; } [HarmonyPatch(typeof(SpecialNodeHandler), "StartSpecialNodeSequence")] [HarmonyPrefix] private static bool CustomNodeGenericSelect(ref SpecialNodeHandler __instance, SpecialNodeData nodeData) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) if (nodeData is CustomSpecialNodeData customSpecialNodeData) { if (customSpecialNodeData.Node == null) { __instance.DoMissingNodeSequence(); } else if (customSpecialNodeData.Node.IsValidSequencerType()) { List list = new List(); for (int i = 0; i < ((Component)__instance).transform.childCount; i++) { Transform child = ((Component)__instance).transform.GetChild(i); if ((Object)(object)child != (Object)null) { list.Add(child); } } Type target = customSpecialNodeData.Node.GetSequencerType(); Transform? obj = list.Find((Transform x) => (Object)(object)((Component)x).GetComponent(target) != (Object)null); ICustomNodeSequencer customNodeSequencer = ((obj != null) ? ((Component)obj).GetComponent() : null); if (customNodeSequencer != null) { ((MonoBehaviour)__instance).StartCoroutine(NewNodeManager.CustomNodeSequence(customNodeSequencer, customSpecialNodeData)); } else { GameObject val; if ((Object)(object)customSpecialNodeData.Node.sequencerPrefab != (Object)null) { val = Object.Instantiate(customSpecialNodeData.Node.sequencerPrefab, ((Component)__instance).transform); } else { val = new GameObject(target.Name); val.transform.parent = ((Component)__instance).transform; } val.transform.localPosition = Vector3.zero; customNodeSequencer = ((!(customSpecialNodeData.Node.nodeSequencerType != null)) ? (val.GetComponent(target) as ICustomNodeSequencer) : ((val.GetComponent(customSpecialNodeData.Node.nodeSequencerType) ?? val.AddComponent(customSpecialNodeData.Node.nodeSequencerType)) as ICustomNodeSequencer)); if (customNodeSequencer != null) { if (customNodeSequencer is IInherit inherit) { inherit.Inherit(customSpecialNodeData); } ((MonoBehaviour)__instance).StartCoroutine(NewNodeManager.CustomNodeSequence(customNodeSequencer, customSpecialNodeData)); } else { __instance.DoMissingSequenceSequence(); } } } else { __instance.DoMissingSequenceSequence(); } return false; } CustomNodeData genericNode = nodeData as CustomNodeData; if (genericNode != null) { NodeInfo nodeInfo = AllNodes.FirstOrDefault((NodeInfo ni) => ni.guid == genericNode.guid); if (nodeInfo == null) { return true; } Type sequencerType = nodeInfo.sequencerType; if (sequencerType == null) { return true; } ICustomNodeSequence customNodeSequence = ((Component)__instance).gameObject.GetComponent(sequencerType) as ICustomNodeSequence; if (customNodeSequence == null) { customNodeSequence = ((Component)__instance).gameObject.AddComponent(sequencerType) as ICustomNodeSequence; } ((MonoBehaviour)__instance).StartCoroutine(customNodeSequence.ExecuteCustomSequence(genericNode)); return false; } return true; } [HarmonyPatch(typeof(MapDataReader), "GetPrefabPath")] [HarmonyPostfix] private static void TrimPrefabPath(ref string __result) { if (Enumerable.Contains(__result, '@')) { __result = __result.Substring(0, __result.IndexOf('@')); } } [HarmonyPatch(typeof(MapDataReader), "SpawnAndPlaceElement")] [HarmonyPrefix] private static bool CreateNodePrefab(MapDataReader __instance, ref GameObject __result, MapElementData data, Vector2 sampleRange, bool isScenery) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!isScenery && data is CustomSpecialNodeData customSpecialNodeData && (Object)(object)customSpecialNodeData.Node?.nodePrefab != (Object)null) { GameObject val = Object.Instantiate(customSpecialNodeData.Node.nodePrefab); val.transform.SetParent(__instance.nodesParent); val.transform.localPosition = __instance.GetRealPosFromDataPos(data.position, sampleRange); __result = val; return false; } return true; } [HarmonyPatch(typeof(MapDataReader), "SpawnAndPlaceElement")] [HarmonyPostfix] private static void TransformMapNode(ref GameObject __result, MapElementData data, bool isScenery) { if (isScenery) { return; } if (data is CustomSpecialNodeData) { (data as CustomSpecialNodeData).OnPostGeneration(__result.GetComponentInChildren()); return; } if (Enumerable.Contains(data.PrefabPath, '@')) { string guid = data.PrefabPath.Substring(data.PrefabPath.IndexOf('@') + 1); NodeInfo nodeInfo = AllNodes.FirstOrDefault((NodeInfo ni) => ni.guid == guid); if (nodeInfo == null) { return; } Texture2D[] animatedMapNode = nodeInfo.animatedMapNode; if (animatedMapNode == null) { return; } AnimatingSprite componentInChildren = __result.GetComponentInChildren(); bool flag = false; for (int i = 0; i < componentInChildren.textureFrames.Count; i++) { if (((Object)componentInChildren.textureFrames[i]).name != $"InscryptionAPI_{guid}_{i + 1}") { componentInChildren.textureFrames[i] = animatedMapNode[i]; flag = true; } } if (flag) { componentInChildren.IterateFrame(); } return; } BossBattleNodeData boss = (BossBattleNodeData)(object)((data is BossBattleNodeData) ? data : null); if (boss != null) { AnimatingSprite componentInChildren2 = __result.GetComponentInChildren(); OpponentManager.FullOpponent fullOpponent = OpponentManager.NewOpponents.ToList().Find((OpponentManager.FullOpponent x) => x.Id == boss.bossType); if ((Object)(object)componentInChildren2 != (Object)null && fullOpponent != null && fullOpponent.NodeAnimation != null && fullOpponent.NodeAnimation.Count > 0) { componentInChildren2.textureFrames = new List(fullOpponent.NodeAnimation); componentInChildren2.SetTexture(componentInChildren2.textureFrames[0]); } } } [HarmonyPatch(typeof(MapGenerator), "ChooseSpecialNodeFromPossibilities")] [HarmonyPrefix] private static void AddNodePossibilities(List possibilities) { NodePosition type = NodePosition.NotGenerated; if (possibilities.Exists((NodeData nd) => nd is GainConsumablesNodeData)) { type = NodePosition.SpecialEventRandom; } else if (possibilities.Exists((NodeData nd) => nd is BuyPeltsNodeData)) { type = NodePosition.CardChoiceRandom; } if (type == NodePosition.NotGenerated) { return; } foreach (NodeInfo item in AllNodes.Where((NodeInfo ni) => ni.nodePosition.HasFlag(type))) { possibilities.Add((NodeData)(object)item.BuildNode()); } GenerationType generationType = ((type != NodePosition.SpecialEventRandom) ? GenerationType.SpecialCardChoice : GenerationType.SpecialEvent); foreach (NewNodeManager.FullNode newNode in NewNodeManager.NewNodes) { if (newNode != null && newNode.generationType.HasFlag(generationType)) { possibilities.Add((NodeData)(object)new CustomSpecialNodeData(newNode)); } } } private static void LinkNodes(List nodes, int startY, List previousNodes) { int num = 0; while (num < nodes.Count) { if (!nodes[num].MapGenerationPrequisitesMet(startY + num, (num == 0) ? previousNodes : previousNodes.Concat(nodes.Take(num)).ToList())) { nodes.RemoveAt(num); continue; } nodes[num].gridY = startY + num; nodes[num].gridX = 1; ((MapElementData)nodes[num]).id = MapGenerator.GetNewID(); if (num > 0) { if (nodes[num - 1].connectedNodes == null) { nodes[num - 1].connectedNodes = new List(); } nodes[num - 1].connectedNodes.Add(nodes[num]); } num++; } } private static bool ValidFor(this NodePosition nodePosition, NodePosition flagMatch) { if (nodePosition.HasFlag(flagMatch)) { if (!SaveFile.IsAscension) { return nodePosition.HasFlag(NodePosition.Act1Available); } return true; } return false; } private static NodeData GetLastNodeBeforeCustomFront(List nodes) { if (MapGenerator.ForceFirstNodeTraderForAscension(1)) { return nodes.First((NodeData n) => n.gridY == 1); } return nodes.First((NodeData n) => n.gridY == 0); } [HarmonyPatch(typeof(MapGenerator), "GenerateNodes")] [HarmonyPostfix] private static void AddStartEndCustomNodes(ref List __result) { int frontStart = ((!MapGenerator.ForceFirstNodeTraderForAscension(1)) ? 1 : 2); List frontNodes = new List(); foreach (NodeInfo item in AllNodes.Where((NodeInfo ni) => ni.nodePosition.ValidFor(NodePosition.MapStart))) { frontNodes.Add((NodeData)(object)item.BuildNode()); } foreach (NewNodeManager.FullNode newNode in NewNodeManager.NewNodes) { if (newNode != null && newNode.generationType.HasFlag(GenerationType.RegionStart)) { frontNodes.Add((NodeData)(object)new CustomSpecialNodeData(newNode)); } } LinkNodes(frontNodes, frontStart, new List()); if (frontNodes.Count > 0) { foreach (NodeData item2 in __result.Where((NodeData n) => n.gridY >= frontStart).ToList()) { item2.gridY += frontNodes.Count; } NodeData lastNodeBeforeCustomFront = GetLastNodeBeforeCustomFront(__result); lastNodeBeforeCustomFront.connectedNodes.Clear(); lastNodeBeforeCustomFront.connectedNodes.Add(frontNodes[0]); foreach (NodeData item3 in __result.Where((NodeData n) => n.gridY == frontStart + frontNodes.Count)) { frontNodes[frontNodes.Count - 1].connectedNodes.Add(item3); } __result = __result.Where((NodeData n) => n.gridY < frontStart).Concat(frontNodes).Concat(__result.Where((NodeData n) => n.gridY >= frontStart)) .ToList(); } List list = new List(); foreach (NodeInfo item4 in AllNodes.Where((NodeInfo ni) => ni.nodePosition.ValidFor(NodePosition.PreBoss))) { list.Add((NodeData)(object)item4.BuildNode()); } int bossY = __result.Select((NodeData n) => n.gridY).Max(); NodeData bossBattleNode = __result.First((NodeData n) => n.gridY == bossY); foreach (NewNodeManager.FullNode newNode2 in NewNodeManager.NewNodes) { if (newNode2 != null && newNode2.generationType.HasFlag(GenerationType.PreBoss)) { list.Add((NodeData)(object)new CustomSpecialNodeData(newNode2)); } } LinkNodes(list, bossY, new List(__result.Where((NodeData n) => n.gridY < bossY))); if (list.Count > 0) { foreach (NodeData item5 in __result.Where((NodeData n) => n.connectedNodes.Contains(bossBattleNode)).ToList()) { item5.connectedNodes.Clear(); item5.connectedNodes.Add(list[0]); } bossBattleNode.gridY = list[list.Count - 1].gridY + 1; list[list.Count - 1].connectedNodes.Add(bossBattleNode); __result = __result.Where((NodeData n) => n != bossBattleNode).Concat(list).ToList(); __result.Add(bossBattleNode); } List list2 = new List(); foreach (NodeInfo item6 in AllNodes.Where((NodeInfo ni) => ni.nodePosition.ValidFor(NodePosition.PostBoss))) { list2.Add((NodeData)(object)item6.BuildNode()); } foreach (NewNodeManager.FullNode newNode3 in NewNodeManager.NewNodes) { if (newNode3 != null && newNode3.generationType.HasFlag(GenerationType.PostBoss)) { list2.Add((NodeData)(object)new CustomSpecialNodeData(newNode3)); } } LinkNodes(list2, bossBattleNode.gridY + 1, new List(__result)); if (list2.Count > 0) { bossBattleNode.connectedNodes = new List(); bossBattleNode.connectedNodes.Add(list2[0]); __result = __result.Concat(list2).ToList(); } } [HarmonyPatch(typeof(MapGenerator), "GenerateMap")] [HarmonyPostfix] private static void FixMapLength(ref MapData __result, int gridWidth, RegionData region) { if ((Object)(object)region.predefinedNodes == (Object)null) { __result.gridLength = __result.nodeData.Select((NodeData n) => n.gridY).Max() + 1; __result.mapLength = (float)__result.gridLength * 0.185f; MapGenerator.PositionNodes(__result.nodeData, __result.mapLength, gridWidth, __result.gridLength); } } } [HarmonyPatch] public static class OpponentManager { public class FullOpponent { public readonly Type Id; public Mask MaskType = MaskManager.NoMask; public Type Opponent; public string SpecialSequencerId; public List NodeAnimation = new List(); public FullOpponent(Type id, Type opponent, string specialSequencerId) : this(id, opponent, specialSequencerId, null) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) public FullOpponent(Type id, Type opponent, string specialSequencerId, List nodeAnimation) { //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_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) Id = id; SpecialSequencerId = specialSequencerId; Opponent = opponent; if (nodeAnimation != null) { NodeAnimation = new List(nodeAnimation); } } } [HarmonyPatch] private class MapGenerator_CreateNode { [CompilerGenerated] private sealed class d__2 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = AccessTools.Method(typeof(MapGenerator), "CreateNode", (Type[])null, (Type[])null); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__2(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly MethodInfo ProcessMethodInfo = AccessTools.Method(typeof(MapGenerator_CreateNode), "ProcessBossType", new Type[1] { typeof(NodeData) }, (Type[])null); internal static ItemData currentItemData = null; [IteratorStateMachine(typeof(d__2))] public static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(-2); } public static IEnumerable Transpiler(IEnumerable instructions) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown FieldInfo fieldInfo = AccessTools.Field(typeof(BossBattleNodeData), "bossType"); List list = new List(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.opcode == OpCodes.Stfld && val.operand == fieldInfo) { list.Insert(++i, new CodeInstruction(OpCodes.Ldloc_0, (object)null)); list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)ProcessMethodInfo)); break; } } return list; } public static void ProcessBossType(NodeData nodeData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) BossBattleNodeData val = (BossBattleNodeData)nodeData; List runStateOpponents = RunStateOpponents; if (runStateOpponents.Count == 0) { runStateOpponents.Add((Type)3); runStateOpponents.Add((Type)4); runStateOpponents.Add((Type)6); } val.bossType = runStateOpponents[RunState.CurrentRegionTier]; } } [HarmonyPatch] internal class SpawnScenery_Patches { [HarmonyPrefix] [HarmonyPatch(typeof(Part1BossOpponent), "SpawnScenery")] private static bool DisableTableScenery(Part1BossOpponent __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (InscryptionAPIPlugin.configHideAct1BossScenery.Value) { __instance.sceneryObject = new GameObject("TemporaryScenary"); __instance.sceneryObject.AddComponent(); if (__instance is PirateSkullBossOpponent) { __instance.sceneryObject.AddComponent(); } return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(PirateSkullBossCannons), "AimCannons")] [HarmonyPatch(typeof(PirateSkullBossCannons), "FireLeftSide")] [HarmonyPatch(typeof(PirateSkullBossCannons), "FireRightSide")] [HarmonyPatch(typeof(PirateSkullBossCannons), "ResetLeftSide")] [HarmonyPatch(typeof(PirateSkullBossCannons), "ResetRightSide")] private static bool DisableCannonAnims() { if (InscryptionAPIPlugin.configHideAct1BossScenery.Value) { return false; } return true; } } [HarmonyPatch] internal class PreventCallsOnScenary_Patches { [CompilerGenerated] private sealed class d__2 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = AccessTools.Method(StartNewPhaseSequence, "MoveNext", (Type[])null, (Type[])null); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__2(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly Type StartNewPhaseSequence = Type.GetType("DiskCardGame.TrapperTraderBossOpponent+d__6, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"); private static readonly MethodInfo PlayAnimationInfo = AccessTools.Method(typeof(PreventCallsOnScenary_Patches), "PlayAnimation", new Type[2] { typeof(Animation), typeof(string) }, (Type[])null); [IteratorStateMachine(typeof(d__2))] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(-2); } private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldstr && list[i].operand == "knives_table_exit") { list[i + 1] = new CodeInstruction(OpCodes.Call, (object)PlayAnimationInfo); break; } } return list; } private static bool PlayAnimation(Animation animation, string key) { if (InscryptionAPIPlugin.configHideAct1BossScenery.Value) { InscryptionAPIPlugin.Logger.LogInfo((object)"PlayAnimation false"); return false; } InscryptionAPIPlugin.Logger.LogInfo((object)"PlayAnimation true"); return animation.Play(key); } } [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardDrawPiles __instance; public IEnumerator enumerator; private ICustomExhaustSequence 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; Opponent opponent = Singleton.Instance.Opponent; 5__2 = opponent as ICustomExhaustSequence; if (5__2 != null && 5__2.RespondsToCustomExhaustSequence(__instance)) { Singleton.Instance.SwitchToView((View)5, false, true); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } <>2__current = enumerator; <>1__state = 3; return true; } case 1: <>1__state = -1; <>2__current = 5__2.DoCustomExhaustSequence(__instance); <>1__state = 2; return true; case 2: { <>1__state = -1; Singleton.Instance.SwitchToView((View)1, false, false); Singleton.Instance.Controller.LockState = (ViewLockState)0; CardDrawPiles _instance = __instance; _instance.turnsSinceExhausted++; break; } case 3: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static readonly ReadOnlyCollection BaseGameOpponents; internal static readonly ObservableCollection NewOpponents; public static List AllOpponents { get; private set; } public static List RunStateOpponents { get { List list = new List(); string value = ModdedSaveManager.RunState.GetValue("cyantist.inscryption.api", "PreviousBosses"); if (value != null) { if (!Enumerable.Contains(value, ',')) { list.Add((Type)int.Parse(value)); } else { IEnumerable collection = from a in value.Split(new char[1] { ',' }) select (Type)int.Parse(a); list.AddRange(collection); } } return list; } set { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected I4, but got Unknown string text = ""; for (int i = 0; i < value.Count; i++) { if (i > 0) { text += ","; } text += (int)value[i]; } ModdedSaveManager.RunState.SetValue("cyantist.inscryption.api", "PreviousBosses", text); } } private static List GenBaseGameOpponents() { //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_0059: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) bool flag = true; try { OriginalGetSequencerIdForBoss((Type)3); } catch (NotImplementedException) { flag = false; } List list = new List(); Assembly assembly = typeof(Opponent).Assembly; foreach (Type value in Enum.GetValues(typeof(Type))) { Type val = value; string specialSequencerId = (flag ? OriginalGetSequencerIdForBoss(val) : BossBattleSequencer.GetSequencerIdForBoss(val)); Type opponent = assembly.GetType("DiskCardGame." + ((object)(Type)(ref val)).ToString() + "Opponent") ?? assembly.GetType("GBC." + ((object)(Type)(ref val)).ToString() + "Opponent"); FullOpponent item = new FullOpponent(val, opponent, specialSequencerId) { MaskType = MaskManager.BossToMask(val) }; list.Add(item); } return list; } static OpponentManager() { BaseGameOpponents = new ReadOnlyCollection(GenBaseGameOpponents()); NewOpponents = new ObservableCollection(); AllOpponents = BaseGameOpponents.ToList(); NewOpponents.CollectionChanged += delegate { AllOpponents = BaseGameOpponents.Concat(NewOpponents).ToList(); }; } public static FullOpponent Add(string guid, string opponentName, string sequencerID, Type opponentType) { return Add(guid, opponentName, sequencerID, opponentType, null); } public static FullOpponent Add(string guid, string opponentName, string sequencerID, Type opponentType, List nodeAnimation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) FullOpponent fullOpponent = new FullOpponent(GuidManager.GetEnumValue(guid, opponentName), opponentType, sequencerID, nodeAnimation); NewOpponents.Add(fullOpponent); return fullOpponent; } [HarmonyPrefix] [HarmonyPatch(typeof(Opponent), "SpawnOpponent")] private static bool ReplaceSpawnOpponent(EncounterData encounterData, ref Opponent __result) { //IL_0013: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if ((int)encounterData.opponentType == 0 || !ProgressionData.LearnedMechanic((MechanicsConcept)7)) { return true; } GameObject val = new GameObject { name = "Opponent" }; Component obj = val.AddComponent(AllOpponents.First((FullOpponent o) => o.Id == encounterData.opponentType).Opponent); __result = (Opponent)(object)((obj is Opponent) ? obj : null); string text = (string.IsNullOrWhiteSpace(encounterData.aiId) ? "AI" : encounterData.aiId); ? val2 = __result; object? obj2 = Activator.CreateInstance(CustomType.GetType("DiskCardGame", text)); ((Opponent)val2).AI = (AI)((obj2 is AI) ? obj2 : null); __result.NumLives = __result.StartingLives; __result.OpponentType = encounterData.opponentType; __result.TurnPlan = __result.ModifyTurnPlan(encounterData.opponentTurnPlan); __result.Blueprint = encounterData.Blueprint; __result.Difficulty = encounterData.Difficulty; __result.ExtraTurnsToSurrender = SeededRandom.Range(0, 3, SaveManager.SaveFile.GetCurrentRandomSeed()); return false; } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(BossBattleSequencer), "GetSequencerIdForBoss")] public static string OriginalGetSequencerIdForBoss(Type bossType) { throw new NotImplementedException(); } [HarmonyPrefix] [HarmonyPatch(typeof(BossBattleSequencer), "GetSequencerIdForBoss")] private static bool ReplaceGetSequencerId(Type bossType, ref string __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) __result = AllOpponents.First((FullOpponent o) => o.Id == bossType).SpecialSequencerId; return false; } [HarmonyPrefix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static bool ReplacePrefabPath(ref string __result, Type ___bossType) { string text = "Prefabs/Map/MapNodesPart1/MapNode_" + ((object)(Type)(ref ___bossType)).ToString(); GameObject val = ResourceBank.Get(text); __result = (((Object)(object)val != (Object)null) ? text : "Prefabs/Map/MapNodesPart1/MapNode_ProspectorBoss"); return false; } [HarmonyPatch(typeof(Opponent), "CreateCard")] [HarmonyPrefix] private static bool CloneCardInfo(ref CardInfo cardInfo) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown cardInfo = (CardInfo)cardInfo.Clone(); return true; } [IteratorStateMachine(typeof(d__20))] [HarmonyPostfix] [HarmonyPatch(typeof(CardDrawPiles), "ExhaustedSequence")] private static IEnumerator CustomBossExhaustionSequence(IEnumerator enumerator, CardDrawPiles __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0) { enumerator = enumerator, __instance = __instance }; } } public static class SpecialSequenceManager { public class FullSpecialSequencer { public readonly string Id; private Type _specialSequencer; public Type SpecialSequencer { get; private set; } public FullSpecialSequencer(string id, Type specialSequencer) { Id = id; SpecialSequencer = specialSequencer; TypeManager.Add(Id.ToString(), specialSequencer); } } public static readonly ReadOnlyCollection BaseGameSpecialSequencers; private static readonly ObservableCollection NewSpecialSequencers; public static List AllSpecialSequencers { get; private set; } static SpecialSequenceManager() { BaseGameSpecialSequencers = new ReadOnlyCollection(GenBaseGameSpecialSequencersList()); NewSpecialSequencers = new ObservableCollection(); AllSpecialSequencers = BaseGameSpecialSequencers.ToList(); NewSpecialSequencers.CollectionChanged += delegate { AllSpecialSequencers = BaseGameSpecialSequencers.Concat(NewSpecialSequencers).ToList(); }; } private static List GenBaseGameSpecialSequencersList() { List list = new List(); foreach (Type item in from type in typeof(SpecialBattleSequencer).Assembly.GetTypes() where type.IsSubclassOf(typeof(SpecialBattleSequencer)) select type) { list.Add(new FullSpecialSequencer(item.Name, item)); } return list; } public static FullSpecialSequencer Add(string guid, string sequencerName, Type sequencer) { FullSpecialSequencer fullSpecialSequencer = new FullSpecialSequencer("SpecialSequencer_" + GuidManager.GetFullyQualifiedName(guid, sequencerName), sequencer); NewSpecialSequencers.Add(fullSpecialSequencer); return fullSpecialSequencer; } } public class TurnBuilder where T : EncounterBlueprintData { internal T blueprint; internal List cards; public TurnBuilder() { cards = new List(); } public void SetBlueprint(T blueprint) { this.blueprint = blueprint; EncounterBlueprintData val = (EncounterBlueprintData)(object)blueprint; if (val.turns == null) { val.turns = new List>(); } ((EncounterBlueprintData)blueprint).turns.Add(cards); } } public static class TurnExtensions { public static TurnBuilder AddCardBlueprint(this TurnBuilder turnBuilder, string card, int randomReplaceChance = 0, int minDifficulty = 1, int maxDifficulty = 20, bool difficultyReplace = false, int difficultyReplaceReq = 0, string replacement = null) where T : EncounterBlueprintData { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002a: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown turnBuilder.cards.Add(new CardBlueprint { card = CardManager.AllCardsCopy.CardByName(card), randomReplaceChance = randomReplaceChance, minDifficulty = minDifficulty, maxDifficulty = maxDifficulty, difficultyReplace = difficultyReplace, difficultyReq = difficultyReplaceReq, replacement = CardManager.AllCardsCopy.CardByName(replacement) }); return turnBuilder; } public static T Build(this TurnBuilder turnBuilder) where T : EncounterBlueprintData { return turnBuilder.blueprint; } } } namespace InscryptionAPI.Dialogue { public struct CustomLine { public Face p03Face; public Emotion emotion; public LetterAnimation letterAnimation; public Speaker speaker; public string text; public string specialInstruction; public StoryEvent storyCondition; public bool storyConditionMustBeMet; public CustomLine() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) p03Face = (Face)0; emotion = (Emotion)0; letterAnimation = (LetterAnimation)0; speaker = (Speaker)0; text = null; specialInstruction = null; storyCondition = (StoryEvent)0; storyConditionMustBeMet = false; } public Line ToLine(List speakers, Speaker defaultSpeaker = 0) { //IL_0001: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0064: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown if ((int)speaker == 0) { speaker = defaultSpeaker; } if (!speakers.Contains(speaker)) { speakers.Add(speaker); } return new Line { p03Face = p03Face, emotion = emotion, letterAnimation = letterAnimation, speakerIndex = speakers.IndexOf(speaker), text = (text ?? ""), specialInstruction = (specialInstruction ?? ""), storyCondition = storyCondition, storyConditionMustBeMet = storyConditionMustBeMet }; } public static implicit operator CustomLine(string str) { CustomLine result = new CustomLine(); result.text = str; return result; } } public static class DialogueManager { public class Dialogue { public DialogueEvent DialogueEvent; public string PluginGUID; } public class DialogueColor { public Color Color; public string ColorCode; public string PluginGUID; } [HarmonyPatch(typeof(DialogueDataUtil), "ReadDialogueData", new Type[] { })] public class DialogueDataUtil_ReadDialogueData { public static void Postfix() { List list = DialogueDataUtil.data.events.Select((DialogueEvent a) => a.id).ToList(); foreach (Dialogue item in CustomDialogue) { if (list.Contains(item.DialogueEvent.id)) { InscryptionAPIPlugin.Logger.LogWarning((object)("Attempting to add dialogue with id that already exists: " + item.DialogueEvent.id)); } DialogueDataUtil.data.events.Add(item.DialogueEvent); } } } [HarmonyPatch(typeof(DialogueParser), "GetColorFromCode", new Type[] { typeof(string), typeof(Color) })] public class DialogueParser_GetColorFromCode { public static bool Prefix(DialogueParser __instance, string code, Color defaultColor, ref Color __result) { //IL_001c: 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) string stringValue = DialogueParser.GetStringValue(code, "c"); if (ColorLookup.TryGetValue(stringValue, out var value)) { __result = value; return false; } return true; } } [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string eventId; public Style style; public DialogueSpeaker speaker; public string[] variableStrings; public ScreenPosition screenPosition; public bool adjustAudioVolume; public MessageAdvanceMode advanceMode; public EventIntersectMode intersectMode; public Action newLineCallback; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (SaveManager.SaveFile.IsPart2) { <>2__current = Singleton.Instance.PlayDialogueEvent(eventId, style, speaker, variableStrings, screenPosition, adjustAudioVolume); <>1__state = 1; return true; } <>2__current = Singleton.Instance.PlayDialogueEvent(eventId, advanceMode, intersectMode, variableStrings, newLineCallback); <>1__state = 2; return true; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static List CustomDialogue = new List(); public static List CustomDialogueColor = new List(); public static Dictionary ColorLookup = new Dictionary(); public static Dialogue Add(string pluginGUID, DialogueEvent dialogueEvent) { Dialogue dialogue = new Dialogue { PluginGUID = pluginGUID, DialogueEvent = dialogueEvent }; CustomDialogue.RemoveAll((Dialogue d) => d.DialogueEvent.id == dialogueEvent.id); CustomDialogue.Add(dialogue); DialogueDataUtil.Data?.events?.RemoveAll((DialogueEvent d) => d.id == dialogueEvent.id); DialogueDataUtil.Data?.events?.Add(dialogueEvent); return dialogue; } public static DialogueColor AddColor(string pluginGUID, string code, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) DialogueColor dialogueColor = new DialogueColor { PluginGUID = pluginGUID, ColorCode = code, Color = color }; ColorLookup[code] = color; CustomDialogueColor.Add(dialogueColor); return dialogueColor; } public static DialogueEvent GenerateEvent(string pluginGUID, string name, List mainLines, List> repeatLines = null, MaxRepeatsBehaviour afterMaxRepeats = 0, Speaker defaultSpeaker = 0) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //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) DialogueEvent val = new DialogueEvent(); List speakers = new List { (Speaker)0 }; val.id = name; val.mainLines = new LineSet((mainLines != null) ? mainLines.ConvertAll((CustomLine x) => x.ToLine(speakers, defaultSpeaker)) : new List()); val.repeatLines = ((repeatLines != null) ? repeatLines.ConvertAll((Converter, LineSet>)((List x) => new LineSet(x.ConvertAll((CustomLine x2) => x2.ToLine(speakers, defaultSpeaker))))) : new List()); val.maxRepeatsBehaviour = afterMaxRepeats; val.speakers = new List(speakers); Add(pluginGUID, val); return val; } public static DialogueEvent GenerateTraderPeltsEvent(string pluginGUID, PeltManager.PeltData peltData, List lines, List> repeatLines = null) { return GenerateTraderPeltsEvent(pluginGUID, peltData.peltTierName ?? PeltManager.GetTierNameFromData(peltData), lines, repeatLines); } public static DialogueEvent GenerateTraderPeltsEvent(string pluginGUID, string peltTierName, List lines, List> repeatLines = null) { return GenerateEvent(pluginGUID, "TraderPelts" + peltTierName, lines, repeatLines, (MaxRepeatsBehaviour)0, (Speaker)0); } public static DialogueEvent GenerateRegionIntroductionEvent(string pluginGUID, RegionData regionData, List lines, List> repeatLines = null) { return GenerateRegionIntroductionEvent(pluginGUID, ((Object)regionData).name, lines, repeatLines); } public static DialogueEvent GenerateRegionIntroductionEvent(string pluginGUID, string regionName, List lines, List> repeatLines = null) { return GenerateEvent(pluginGUID, "Region" + regionName, lines, repeatLines, (MaxRepeatsBehaviour)0, (Speaker)0); } [IteratorStateMachine(typeof(d__12))] public static IEnumerator PlayDialogueEventSafe(string eventId, MessageAdvanceMode advanceMode = 0, EventIntersectMode intersectMode = 0, DialogueSpeaker speaker = null, Style style = 4, ScreenPosition screenPosition = 2, string[] variableStrings = null, Action newLineCallback = null, bool adjustAudioVolume = true) { //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) //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) //IL_0023: 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_002b: 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { eventId = eventId, advanceMode = advanceMode, intersectMode = intersectMode, speaker = speaker, style = style, screenPosition = screenPosition, variableStrings = variableStrings, newLineCallback = newLineCallback, adjustAudioVolume = adjustAudioVolume }; } public static Style GetStyleFromTemple(CardTemple temple) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (Style)temple; } public static Style GetStyleFromAmbition() { if (!StoryEventsData.EventCompleted((StoryEvent)39)) { if (!StoryEventsData.EventCompleted((StoryEvent)40)) { if (!StoryEventsData.EventCompleted((StoryEvent)41)) { return (Style)3; } return (Style)2; } return (Style)0; } return (Style)1; } } } namespace InscryptionAPI.CardCosts { [HarmonyPatch] public static class CardCostManager { public class FullCardCost { public string ModGUID; public string CostName; public Type CostBehaviour; public bool CanBeNegative; public ResourceType ResourceType; public int[] ChoiceAmounts; public Func GetCostTexture; public Func GetPixelCostTexture; public Func GetCostTier; public Func, bool> GetCanBePlayedByTurn2WithHand; public Func GetRewardBackTexture; public Texture RewardBackTexture(int amount) { if (GetRewardBackTexture == null) { return null; } return GetRewardBackTexture(amount); } public Texture2D CostTexture(int amount, CardInfo cardInfo, PlayableCard playableCard) { if (GetCostTexture == null) { return null; } return GetCostTexture(amount, cardInfo, playableCard); } public Texture2D PixelCostTexture(int amount, CardInfo cardInfo, PlayableCard playableCard) { if (GetPixelCostTexture == null) { return null; } return GetPixelCostTexture(amount, cardInfo, playableCard); } public int CostTier(int amount) { if (GetCostTier == null) { return 0; } return GetCostTier(amount); } public bool CanBePlayedByTurn2WithHand(int amount, CardInfo card, List hand) { if (GetCanBePlayedByTurn2WithHand == null) { return true; } return GetCanBePlayedByTurn2WithHand(amount, card, hand); } public FullCardCost(string modGUID, string costName, Type costBehaviour, Func getCostTexture, Func getPixelCostTexture, Func getCostTier, Func, bool> getCanBePlayedByTurn2WithHand, Func getRewardBackTexture, bool canBeNegative, ResourceType resourceType, int[] choiceAmounts) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) ModGUID = modGUID; CostName = costName; CostBehaviour = costBehaviour; GetCostTexture = getCostTexture; GetPixelCostTexture = getPixelCostTexture; CanBeNegative = canBeNegative; GetCostTier = getCostTier; GetCanBePlayedByTurn2WithHand = getCanBePlayedByTurn2WithHand; GetRewardBackTexture = getRewardBackTexture; ResourceType = resourceType; ChoiceAmounts = choiceAmounts; TypeManager.Add(costName, costBehaviour); } public FullCardCost(string modGUID, string costName, Type costBehaviour, Func getCostTexture, Func getPixelCostTexture) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) ModGUID = modGUID; CostName = costName; CostBehaviour = costBehaviour; GetCostTexture = getCostTexture; GetPixelCostTexture = getPixelCostTexture; CanBeNegative = false; GetCostTier = null; GetCanBePlayedByTurn2WithHand = null; GetRewardBackTexture = null; ResourceType = (ResourceType)0; ChoiceAmounts = null; TypeManager.Add(costName, costBehaviour); } public FullCardCost Clone() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) return new FullCardCost(ModGUID, CostName, CostBehaviour, GetCostTexture, GetPixelCostTexture, GetCostTier, GetCanBePlayedByTurn2WithHand, GetRewardBackTexture, CanBeNegative, ResourceType, ChoiceAmounts); } } [CompilerGenerated] private sealed class <>c__DisplayClass34_0 { public SelectableCard card; internal bool b__0(FullCardCost x) { //IL_0001: 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) return x.ResourceType == card.ChoiceInfo.resourceType; } } [CompilerGenerated] private sealed class d__34 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SelectableCard card; public IEnumerator enumerator; public CardSingleChoicesSequencer __instance; private <>c__DisplayClass34_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Invalid comparison between Unknown and I4 //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>8__1 = new <>c__DisplayClass34_0(); <>8__1.card = card; if ((int)<>8__1.card.ChoiceInfo.resourceType <= 2) { <>2__current = enumerator; <>1__state = 1; return true; } CardInfo info = null; if ((int)<>8__1.card.ChoiceInfo.resourceType == 3) { info = GetRandomChoosableEnergyCard(SaveManager.SaveFile.GetCurrentRandomSeed()); } else if ((int)<>8__1.card.ChoiceInfo.resourceType == 4) { int resourceAmount = <>8__1.card.ChoiceInfo.resourceAmount; info = GetRandomChoosableMoxCard(SaveManager.SaveFile.GetCurrentRandomSeed(), (GemType)(resourceAmount switch { 3 => 2, 2 => 1, _ => 0, })); } else { List list = AllCustomCosts.FindAll((FullCardCost x) => x.ResourceType == <>8__1.card.ChoiceInfo.resourceType); if (list.Count > 0) { info = ((list.Count != 1 || list[0].ChoiceAmounts == null || list[0].ChoiceAmounts.Length == 0) ? GetRandomChoosableCustomCostCard(SaveManager.SaveFile.GetCurrentRandomSeed(), list) : GetRandomChoosableCustomCostCardWithAmounts(SaveManager.SaveFile.GetCurrentRandomSeed(), list[0], <>8__1.card.ChoiceInfo.resourceAmount)); } } ((Card)<>8__1.card).SetInfo(info); ((Card)<>8__1.card).SetFaceDown(false, false); ((Card)<>8__1.card).SetInteractionEnabled(false); <>2__current = __instance.TutorialTextSequence(<>8__1.card); <>1__state = 2; return true; } case 1: <>1__state = -1; return false; case 2: <>1__state = -1; ((Card)<>8__1.card).SetCardbackToDefault(); <>2__current = __instance.WaitForCardToBeTaken(<>8__1.card); <>1__state = 3; return true; case 3: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__31 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; public PlayerHand instance; public CardSlot lastSelectedSlot; private int 5__2; private int 5__3; private Dictionary 5__4; private List.Enumerator <>7__wrap4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 4) { try { } finally { <>m__Finally1(); } } 5__4 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = card.BonesCost(); 5__3 = card.EnergyCost; 5__4 = new Dictionary(); foreach (CustomCardCost customCardCost in ((Card)(object)card).GetCustomCardCosts()) { 5__4.Add(customCardCost.CostName, card.GetCustomCostAmount(customCardCost.CostName)); } <>2__current = instance.PlayCardOnSlot(card, lastSelectedSlot); <>1__state = 1; return true; case 1: <>1__state = -1; if (5__2 > 0) { int num = Mathf.Min(5__2, card.BonesCost()); <>2__current = Singleton.Instance.SpendBones(num); <>1__state = 2; return true; } goto IL_012c; case 2: <>1__state = -1; goto IL_012c; case 3: <>1__state = -1; goto IL_0174; case 4: { <>1__state = -3; break; } IL_012c: if (5__3 > 0) { int num2 = Mathf.Min(5__3, card.EnergyCost); <>2__current = Singleton.Instance.SpendEnergy(num2); <>1__state = 3; return true; } goto IL_0174; IL_0174: <>7__wrap4 = ((Card)(object)card).GetCustomCardCosts().GetEnumerator(); <>1__state = -3; break; } while (<>7__wrap4.MoveNext()) { CustomCardCost current2 = <>7__wrap4.Current; if (5__4.ContainsKey(current2.CostName)) { int cardCost = Mathf.Min(5__4[current2.CostName], card.GetCustomCostAmount(current2.CostName)); <>2__current = current2.OnPlayed(cardCost, card); <>1__state = 4; return true; } } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap4).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static readonly ObservableCollection NewCosts; public static Hint notEnoughSameColourGemsHint; public static DialogueEvent notEnoghSameColourGemsEvent; public static List AllCustomCosts { get; private set; } public static event Func, List> ModifyCustomCostList; static CardCostManager() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown AllCustomCosts = new List(); NewCosts = new ObservableCollection(); notEnoughSameColourGemsHint = new Hint("Hint_NotEnoughSameColourGemsHint", 2); notEnoghSameColourGemsEvent = DialogueManager.GenerateEvent("cyantist.inscryption.api", "Hint_NotEnoughSameColourGemsHint", new List { "You don't have enough [v:1] gems for that." }, new List> { new List { "Not enough [v:1] gems on the table? Then you can't play it." }, new List { "You need more [v:1] gems on the board in order to play that [v:0]." }, new List { "Play the required [v:1] gems... then you can play that." } }, (MaxRepeatsBehaviour)0, (Speaker)0); NewCosts.CollectionChanged += delegate { SyncCustomCostList(); }; } public static void SyncCustomCostList() { AllCustomCosts = NewCosts.Select((FullCardCost a) => a.Clone()).ToList(); AllCustomCosts = CardCostManager.ModifyCustomCostList?.Invoke(AllCustomCosts) ?? AllCustomCosts; } public static FullCardCost CostByBehaviour(this IEnumerable customCosts, Type costBehaviour) { return customCosts.FirstOrDefault((FullCardCost x) => x.CostBehaviour == costBehaviour); } public static FullCardCost Register(string modGUID, string costName, Type costBehaviour, Func getCostTexture, Func getPixelCostTexture) { FullCardCost fullCardCost = new FullCardCost(modGUID, costName, costBehaviour, getCostTexture, getPixelCostTexture); NewCosts.Add(fullCardCost); return fullCardCost; } public static FullCardCost SetCostTier(this FullCardCost fullCardCost, Func getCostTier) { fullCardCost.GetCostTier = getCostTier; return fullCardCost; } public static FullCardCost SetChoiceAmounts(this FullCardCost fullCardCost, params int[] choiceAmounts) { fullCardCost.ChoiceAmounts = choiceAmounts; return fullCardCost; } public static FullCardCost SetCanBePlayedByTurn2WithHand(this FullCardCost fullCardCost, Func, bool> getCanBePlayedByTurn2WithHand) { fullCardCost.GetCanBePlayedByTurn2WithHand = getCanBePlayedByTurn2WithHand; return fullCardCost; } public static FullCardCost SetCanBeNegative(this FullCardCost fullCardCost, bool canBeNegative) { fullCardCost.CanBeNegative = canBeNegative; return fullCardCost; } public static FullCardCost SetFoundAtChoiceNodes(this FullCardCost fullCardCost, bool isChoice, Texture rewardBack) { return fullCardCost.SetFoundAtChoiceNodes(isChoice, (int i) => rewardBack, null); } public static FullCardCost SetFoundAtChoiceNodes(this FullCardCost fullCardCost, bool isChoice, Func rewardBackFunc, params int[] choiceAmounts) { //IL_001e: 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_0015: Unknown result type (might be due to invalid IL or missing references) if (isChoice) { fullCardCost.ResourceType = GuidManager.GetEnumValue(fullCardCost.ModGUID, fullCardCost.CostName); } else { fullCardCost.ResourceType = (ResourceType)0; } fullCardCost.GetRewardBackTexture = rewardBackFunc; fullCardCost.SetChoiceAmounts(choiceAmounts); return fullCardCost; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "CanPlay")] private static void CanPlayCustomCosts(ref bool __result, ref PlayableCard __instance) { if (__instance.BloodCost() > Singleton.Instance.AvailableSacrificeValue || __instance.BonesCost() > Singleton.Instance.PlayerBones || __instance.EnergyCost > Singleton.Instance.PlayerEnergy || !__instance.GemsCostRequirementMet() || !Singleton.Instance.SacrificesCreateRoomForCard(__instance, Singleton.Instance.PlayerSlotsCopy)) { return; } foreach (CustomCardCost customCardCost in ((Card)(object)__instance).GetCustomCardCosts()) { FullCardCost fullCardCost = AllCustomCosts.CostByBehaviour(((object)customCardCost).GetType()); if (!customCardCost.CostSatisfied(__instance.GetCustomCost(fullCardCost), __instance)) { __result = false; return; } } __result = true; } [HarmonyPrefix] [HarmonyPatch(typeof(PlayableCard), "GemsCostRequirementMet")] private static bool ReplaceCostRequirementMet(PlayableCard __instance, ref bool __result) { __result = NewGemsCostRequirementMet(__instance); return false; } public static bool NewGemsCostRequirementMet(PlayableCard card) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) List list = new List(Singleton.Instance.gems); foreach (GemType item in card.GemsCost()) { if (list.Contains(item)) { list.Remove(item); continue; } return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(HintsHandler), "OnNonplayableCardClicked")] private static bool CannotAffordCustomCostHints(ref PlayableCard card) { //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if (card.GemsCost().Count > 0 && !card.GemsCost().Exists((GemType x) => !Singleton.Instance.HasGem(x))) { List list = card.GemsCost(); foreach (GemType gem in Singleton.Instance.gems) { list.Remove(gem); } if (list.Count > 0) { GemType val = list[0]; if (SaveManager.SaveFile.IsPart2) { string arg = HintsHandler.GetDialogueColorCodeForGem(val) + Localization.Translate(((object)(GemType)(ref val)).ToString()) + "[c:]"; string text = string.Format(Localization.Translate("You do not have the {0} Gem to play that. Gain Gems by playing Mox cards."), arg); ((MonoBehaviour)CustomCoroutine.Instance).StartCoroutine(Singleton.Instance.ShowUntilInput(text, (Style)4, (DialogueSpeaker)null, (ScreenPosition)0, 0f, true, false, (Prompt)null, false, (Emotion)0)); } else if ((Object)(object)Singleton.m_Instance != (Object)null) { notEnoughSameColourGemsHint.TryPlayDialogue(new string[2] { ((Card)card).Info.DisplayedNameLocalized, HintsHandler.GetColorCodeForGem(val) + Localization.Translate(((object)(GemType)(ref val)).ToString()) + "" }); } return false; } } foreach (CustomCardCost customCardCost in ((Card)(object)card).GetCustomCardCosts()) { FullCardCost fullCardCost = AllCustomCosts.CostByBehaviour(((object)customCardCost).GetType()); int customCost = card.GetCustomCost(fullCardCost); if (customCardCost.CostSatisfied(customCost, card)) { continue; } if (SaveManager.SaveFile.IsPart2) { ((MonoBehaviour)CustomCoroutine.Instance).StartCoroutine(Singleton.Instance.ShowUntilInput(customCardCost.CostUnsatisfiedHint(customCost, card), DialogueManager.GetStyleFromAmbition(), (DialogueSpeaker)null, (ScreenPosition)2, 0f, true, false, (Prompt)null, true, (Emotion)0)); } else if ((Object)(object)Singleton.m_Instance != (Object)null) { if (customCardCost.PlayHintFrequency > 0 && customCardCost.playHintAttempts % customCardCost.PlayHintFrequency == 0) { ((MonoBehaviour)CustomCoroutine.Instance).StartCoroutine(Singleton.Instance.ShowUntilInput(customCardCost.CostUnsatisfiedHint(customCost, card), -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true)); } customCardCost.playHintAttempts++; } return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(Card), "SetInfo")] private static void AttachCustomCardCosts(Card __instance, CardInfo info) { LinqExtensions.ForEach((IEnumerable)((Component)__instance).GetComponents(), (Action)delegate(CustomCardCost x) { Object.Destroy((Object)(object)x); }); foreach (Type item in from x in info.GetCustomCosts() select x.CostBehaviour) { ((Component)__instance).gameObject.AddComponent(item); } } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void CustomCostTiers(CardInfo __instance, ref int __result) { __result = __instance.BloodCost + Mathf.CeilToInt((float)__instance.BonesCost / 3f) + Mathf.RoundToInt((float)__instance.EnergyCost / 2f) + __instance.GemsCost.Count; foreach (FullCardCost customCost in __instance.GetCustomCosts()) { __result += customCost.CostTier(__instance.GetCustomCost(customCost)); } } [HarmonyPostfix] [HarmonyPatch(typeof(Deck), "CardCanBePlayedByTurn2WithHand")] private static void CustomCardsCanBePlayedByTurn2(ref bool __result, CardInfo card, List hand) { if (!__result) { return; } foreach (FullCardCost customCost in card.GetCustomCosts()) { if (!customCost.CanBePlayedByTurn2WithHand(card.GetCustomCost(customCost), card, hand)) { __result = false; break; } } } [HarmonyPrefix] [HarmonyPatch(typeof(HintsHandler), "OnGBCNonPlayableCardPressed")] private static bool MultiMonoColourMoxSupport(PlayableCard card) { //IL_002c: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (card.GemsCost().Count > 0) { List list = card.GemsCost(); foreach (GemType gem in Singleton.Instance.gems) { list.Remove(gem); } if (list.Count > 0) { GemType val = list[0]; string arg = HintsHandler.GetDialogueColorCodeForGem(val) + Localization.Translate(((object)(GemType)(ref val)).ToString()) + "[c:]"; string text = string.Format(Localization.Translate("You do not have the {0} Gem to play that. Gain Gems by playing Mox cards."), arg); ((MonoBehaviour)CustomCoroutine.Instance).StartCoroutine(Singleton.Instance.ShowUntilInput(text, (Style)4, (DialogueSpeaker)null, (ScreenPosition)0, 0f, true, false, (Prompt)null, false, (Emotion)0)); return false; } } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(HintsHandler), "OnNonplayableCardClicked")] private static bool MultipleSameColourMoxSupport(PlayableCard card) { //IL_002c: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (card.GemsCost().Count > 0) { List list = card.GemsCost(); foreach (GemType gem in Singleton.Instance.gems) { list.Remove(gem); } if (list.Count > 0) { GemType val = list[0]; HintsHandler.notEnoughGemsHint.TryPlayDialogue(new string[2] { ((Card)card).Info.DisplayedNameLocalized, HintsHandler.GetColorCodeForGem(val) + Localization.Translate(((object)(GemType)(ref val)).ToString()) + "" }); return false; } } return true; } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable FixDialogueSoftlock(IEnumerable instructions) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown List list = new List(instructions); int num = list.FindIndex((CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "System.Collections.IEnumerator PlayCardOnSlot(DiskCardGame.PlayableCard, DiskCardGame.CardSlot)"); if (num > 0) { MethodInfo methodInfo = AccessTools.Method(typeof(CardCostManager), "PlaySelectedCardToSlot", new Type[3] { typeof(PlayerHand), typeof(PlayableCard), typeof(CardSlot) }, (Type[])null); list[num] = new CodeInstruction(OpCodes.Callvirt, (object)methodInfo); } int num2 = list.FindIndex((CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "Int32 get_BonesCost()") - 3; if (num2 > 0) { int num3 = list.FindIndex(num2, (CodeInstruction x) => x.opcode == OpCodes.Ldc_I4_6) + 4; list.RemoveRange(num2, num3 - num2); } int num4 = list.FindIndex((CodeInstruction x) => x.opcode == OpCodes.Callvirt && x.operand.ToString() == "Int32 get_EnergyCost()") - 2; if (num4 > 0) { int num5 = list.FindIndex(num4, (CodeInstruction x) => x.opcode == OpCodes.Ldc_I4_7) + 4; list.RemoveRange(num4, num5 - num4); } return list; } [IteratorStateMachine(typeof(d__31))] public static IEnumerator PlaySelectedCardToSlot(PlayerHand instance, PlayableCard card, CardSlot lastSelectedSlot) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__31(0) { instance = instance, card = card, lastSelectedSlot = lastSelectedSlot }; } [HarmonyPostfix] [HarmonyPatch(typeof(CardSingleChoicesSequencer), "GetCardbackTexture")] private static void GetCustomCostCardbackTexture(ref Texture __result, CardChoice choice) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if ((int)choice.resourceType > 4) { FullCardCost fullCardCost = AllCustomCosts.FirstOrDefault((FullCardCost x) => x.ResourceType == choice.resourceType); if (fullCardCost != null) { __result = fullCardCost.RewardBackTexture(choice.resourceAmount); } } } [HarmonyPostfix] [HarmonyPatch(typeof(Part1CardChoiceGenerator), "GenerateCostChoices")] private static void GenerateCustomCostChoices(ref List __result, int randomSeed) { //IL_0017: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_012a: Expected O, but got Unknown List list = __result; if ((Object)(object)GetRandomChoosableEnergyCard(randomSeed++) != (Object)null) { list.Add(new CardChoice { resourceType = (ResourceType)3 }); } int randomMoxIndex = GetRandomMoxIndex(randomSeed++); if (randomMoxIndex > 0) { list.Add(new CardChoice { resourceType = (ResourceType)4, resourceAmount = randomMoxIndex }); } foreach (ResourceType resource in GuidManager.GetValues()) { List list2 = AllCustomCosts.FindAll((FullCardCost x) => x.ResourceType == resource); if (list2.Count <= 0) { continue; } if (list2.Count == 1 && list2[0].ChoiceAmounts != null && list2[0].ChoiceAmounts.Length != 0) { if ((Object)(object)GetRandomChoosableCustomCostCardWithAmounts(randomSeed++, list2[0], list2[0].ChoiceAmounts) != (Object)null) { int[] choiceAmounts = list2[0].ChoiceAmounts; foreach (int resourceAmount in choiceAmounts) { list.Add(new CardChoice { resourceType = resource, resourceAmount = resourceAmount }); } } } else if ((Object)(object)GetRandomChoosableCustomCostCard(randomSeed++, list2) != (Object)null) { list.Add(new CardChoice { resourceType = resource }); } } while (list.Count > 3) { list.RemoveAt(SeededRandom.Range(0, list.Count, randomSeed++)); } if (InscryptionAPIPlugin.configRandomChoiceOrder.Value) { list = CustomList.Randomize((IEnumerable)list).ToList(); } __result = list; } [IteratorStateMachine(typeof(d__34))] [HarmonyPostfix] [HarmonyPatch(typeof(CardSingleChoicesSequencer), "CostChoiceChosen")] private static IEnumerator CustomCostChoiceChosen(IEnumerator enumerator, CardSingleChoicesSequencer __instance, SelectableCard card) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__34(0) { enumerator = enumerator, __instance = __instance, card = card }; } public static CardInfo GetRandomChoosableEnergyCard(int randomSeed) { List list = CardLoader.GetUnlockedCards((CardMetaCategory)0, (CardTemple)0).FindAll((CardInfo x) => x.energyCost > 0); if (list.Count != 0) { return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]); } return null; } public static CardInfo GetRandomChoosableMoxCard(int randomSeed, GemType gem) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) List list = CardLoader.GetUnlockedCards((CardMetaCategory)0, (CardTemple)0).FindAll((CardInfo x) => x.gemsCost.Count > 0 && x.gemsCost.Contains(gem)); if (list.Count != 0) { return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]); } return null; } public static CardInfo GetRandomChoosableCustomCostCard(int randomSeed, List customCosts) { List list = CardLoader.GetUnlockedCards((CardMetaCategory)0, (CardTemple)0).FindAll((CardInfo x) => x.GetCustomCosts().Exists((FullCardCost y) => customCosts.Contains(y))); InscryptionAPIPlugin.Logger.LogDebug((object)$"Custom costs to search for: {customCosts.Count}. Found {list.Count} card(s)."); if (list.Count != 0) { return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]); } return null; } public static CardInfo GetRandomChoosableCustomCostCardWithAmounts(int randomSeed, FullCardCost customCost, params int[] costAmounts) { List list = CardLoader.GetUnlockedCards((CardMetaCategory)0, (CardTemple)0).FindAll((CardInfo x) => costAmounts.Contains(x.GetCustomCost(customCost))); InscryptionAPIPlugin.Logger.LogDebug((object)$"Choice amounts for {customCost.CostName}: {costAmounts.Length}. Found {list.Count} card(s)."); if (list.Count != 0) { return CardLoader.Clone(list[SeededRandom.Range(0, list.Count, randomSeed)]); } return null; } public static int GetRandomMoxIndex(int randomSeed) { List list = CardLoader.GetUnlockedCards((CardMetaCategory)0, (CardTemple)0).FindAll((CardInfo x) => x.gemsCost.Count > 0); if (list.Count == 0) { return 0; } List list2 = new List(); if (list.Exists((CardInfo x) => x.gemsCost.Contains((GemType)0))) { list2.Add(1); } if (list.Exists((CardInfo x) => x.gemsCost.Contains((GemType)1))) { list2.Add(2); } if (list.Exists((CardInfo x) => x.gemsCost.Contains((GemType)2))) { list2.Add(3); } return list2[SeededRandom.Range(0, list2.Count, randomSeed)]; } } public abstract class CustomCardCost : ManagedBehaviour { [CompilerGenerated] private sealed class d__9 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public int playHintAttempts; public abstract string CostName { get; } public virtual int PlayHintFrequency { get; } = 1; public virtual bool CostSatisfied(int cardCost, PlayableCard playableCard) { return true; } public virtual string CostUnsatisfiedHint(int cardCost, PlayableCard playableCard) { return null; } public virtual int CostStatPointValue(int cardCost, PlayableCard playableCard) { return 0; } [IteratorStateMachine(typeof(d__9))] public virtual IEnumerator OnPlayed(int cardCost, PlayableCard playableCard) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0); } } } namespace InscryptionAPI.Helpers { [Obsolete("Use DialogueManager.GenerateEvent or InscryptionAPI.Dialogue.CustomLine instead.")] public struct CustomLine { public Face p03Face; public Emotion emotion; public LetterAnimation letterAnimation; public Speaker speaker; public string text; public string specialInstruction; public StoryEvent storyCondition; public bool storyConditionMustBeMet; public CustomLine() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) p03Face = (Face)0; emotion = (Emotion)0; letterAnimation = (LetterAnimation)0; speaker = (Speaker)0; text = null; specialInstruction = null; storyCondition = (StoryEvent)0; storyConditionMustBeMet = false; } public Line ToLine(List speakers, Speaker defaultSpeaker = 0) { //IL_0001: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0064: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown if ((int)speaker == 0) { speaker = defaultSpeaker; } if (!speakers.Contains(speaker)) { speakers.Add(speaker); } return new Line { p03Face = p03Face, emotion = emotion, letterAnimation = letterAnimation, speakerIndex = speakers.IndexOf(speaker), text = (text ?? ""), specialInstruction = (specialInstruction ?? ""), storyCondition = storyCondition, storyConditionMustBeMet = storyConditionMustBeMet }; } public static implicit operator CustomLine(string str) { CustomLine result = new CustomLine(); result.text = str; return result; } } [Obsolete("Use DialogueManager instead")] public static class DialogueEventGenerator { [Obsolete("Use DialogueManager.GenerateEvent instead")] public static DialogueEvent GenerateEvent(string name, List mainLines, List> repeatLines = null, MaxRepeatsBehaviour afterMaxRepeats = 0, Speaker defaultSpeaker = 0) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0077: 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) DialogueEvent val = new DialogueEvent(); List speakers = new List { (Speaker)0 }; val.id = name; val.mainLines = new LineSet((mainLines != null) ? mainLines.ConvertAll((CustomLine x) => x.ToLine(speakers, defaultSpeaker)) : new List()); val.repeatLines = ((repeatLines != null) ? repeatLines.ConvertAll((Converter, LineSet>)((List x) => new LineSet(x.ConvertAll((CustomLine x2) => x2.ToLine(speakers, defaultSpeaker))))) : new List()); val.maxRepeatsBehaviour = afterMaxRepeats; val.speakers = new List(speakers); DialogueManager.Add(TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()), val); return val; } } public static class AssetBundleHelper { public static bool TryGet(AssetBundle bundle, string prefabName, out T prefab) where T : Object { if ((Object)(object)bundle == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Tried getting prefab from " + prefabName + " but the assetbundle is null!")); prefab = default(T); return false; } prefab = bundle.LoadAsset(prefabName); bundle.Unload(false); if ((Object)(object)prefab == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Tried getting prefab '" + prefabName + "' from asset bundle but failed! Is the prefab name or type wrong?")); return false; } return true; } public static bool TryGet(string pathToAssetBundle, string prefabName, out T prefab) where T : Object { AssetBundle val = AssetBundle.LoadFromFile(pathToAssetBundle); if ((Object)(object)val == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Tried getting asset bundle at path: '" + pathToAssetBundle + "' but failed! Is the path wrong?")); prefab = default(T); return false; } prefab = val.LoadAsset(prefabName); val.Unload(false); if ((Object)(object)prefab == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Tried getting prefab '" + prefabName + "' from asset bundle at path: '" + pathToAssetBundle + "' but failed! Is the prefab name or type wrong?")); return false; } return true; } public static bool TryGet(byte[] resources, string prefabName, out T prefab) where T : Object { AssetBundle val = AssetBundle.LoadFromMemory(resources); if ((Object)(object)val == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)"Tried getting asset bundle from bytes but failed! Is the path wrong?"); prefab = default(T); return false; } prefab = val.LoadAsset(prefabName); val.Unload(false); if ((Object)(object)prefab == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Tried getting prefab '" + prefabName + "' from asset bundle from bytes' but failed! Is the prefab name or type wrong?")); return false; } return true; } } public static class CustomFields { private static ConditionalWeakTable> objectFields = new ConditionalWeakTable>(); public static T Get(object obj, string field) { if (!HasField(obj, field)) { Set(obj, field, default(T)); } objectFields.TryGetValue(obj, out var value); return (T)value[field]; } public static T GetStatic(string field) { return Get(typeof(C), field); } public static T GetStatic(string field, Type classType) { return Get(classType, field); } public static void Set(object obj, string field, object value) { if (!objectFields.TryGetValue(obj, out var value2)) { value2 = new Dictionary(); objectFields.Add(obj, value2); } value2[field] = value; } public static void SetStatic(string field, object value) { Set(typeof(C), field, value); } public static void SetStatic(string field, object value, Type classType) { Set(classType, field, value); } public static bool HasField(object obj, string field) { if (!objectFields.TryGetValue(obj, out var value)) { return false; } return value.ContainsKey(field); } public static bool HasStaticField(string field) { return HasField(typeof(C), field); } public static bool HasStaticField(string field, Type classType) { return HasField(classType, field); } } public class MaterialOverride { public Texture2D MainTexture; public bool OverrideMainTexture; public Texture2D Emission; public bool OverrideEmission; public Texture2D NormalMap; public bool OverrideNormalMap; public Texture2D HeightMap; public bool OverrideHeightMap; public Texture2D MetallicMap; public bool OverrideMetallicMap; public Texture2D OcclusionMap; public bool OverrideOcclusionMap; public Texture2D DetailMask; public bool OverrideDetailMask; public float? Metallic; public float? Smoothness; public float? Height; public MaterialOverride ChangeMainTexture(Texture2D tex) { MainTexture = tex; OverrideMainTexture = true; return this; } public MaterialOverride ChangeEmission(Texture2D tex) { Emission = tex; OverrideEmission = true; return this; } public MaterialOverride ChangeNormalMap(Texture2D tex) { NormalMap = tex; OverrideNormalMap = true; return this; } public MaterialOverride ChangeHeightMap(Texture2D tex) { HeightMap = tex; OverrideHeightMap = true; return this; } public MaterialOverride ChangeMetallicMap(Texture2D tex) { MetallicMap = tex; OverrideMetallicMap = true; return this; } public MaterialOverride ChangeOcclusionMap(Texture2D tex) { OcclusionMap = tex; OverrideOcclusionMap = true; return this; } public MaterialOverride ChangeDetailMask(Texture2D tex) { DetailMask = tex; OverrideMainTexture = true; return this; } } public static class ResourcesManagerHelpers { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourcesManager instance; public int amount; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = instance.RemoveMaxEnergy(amount, preventable: true); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool preventable; public ResourcesManager instance; public int amount; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; if (preventable && instance.preventNextEnergyLoss) { instance.preventNextEnergyLoss = false; return false; } 5__2 = Mathf.Min(instance.PlayerMaxEnergy, amount); ResourcesManager obj = instance; obj.PlayerMaxEnergy -= 5__2; if (instance.PlayerEnergy > instance.PlayerMaxEnergy) { ResourcesManager obj2 = instance; obj2.PlayerEnergy -= 5__2; <>2__current = instance.ShowSpendEnergy(5__2); <>1__state = 1; return true; } goto IL_00d0; } case 1: <>1__state = -1; goto IL_00d0; case 2: { <>1__state = -1; return false; } IL_00d0: <>2__current = instance.ShowRemoveMaxEnergy(5__2); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ResourcesManager instance; public int amount; private PixelResourcesManager 5__2; private int 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; ref PixelResourcesManager reference = ref 5__2; ResourcesManager obj = instance; reference = (PixelResourcesManager)(object)((obj is PixelResourcesManager) ? obj : null); 5__3 = instance.PlayerMaxEnergy + amount - 1; break; } case 1: <>1__state = -1; 5__3--; break; } if (5__3 >= instance.PlayerMaxEnergy) { if ((Object)(object)5__2 != (Object)null) { AudioController.Instance.PlaySound2D("crushBlip3", (MixerGroup)0, 0.4f, 0f, new Pitch(0.9f + (float)(instance.PlayerMaxEnergy + 5__3) * 0.05f), (Repetition)null, (Randomization)null, (Distortion)null, false); 5__2.energyRenderers[5__3].sprite = GetEmptyBatterySprite.emptyBatterySprite; ? val = 5__2; ResourcesManager obj2 = instance; ((PixelResourcesManager)val).BounceRenderer(((Component)((PixelResourcesManager)((obj2 is PixelResourcesManager) ? obj2 : null)).energyRenderers[5__3]).transform); } else if ((Object)(object)Singleton.m_Instance != (Object)null) { AudioController.Instance.PlaySound3D("crushBlip3", (MixerGroup)4, ((Component)instance).transform.position, 0.4f, 0f, new Pitch(0.9f + (float)(instance.PlayerMaxEnergy + 5__3) * 0.05f), (Repetition)null, (Randomization)null, (Distortion)null, false); Singleton.Instance.cellRenderers[5__3].material.DisableKeyword("_EMISSION"); Singleton.Instance.CloseCell(5__3, false); } <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerator RemoveMaxEnergy(this ResourcesManager instance, int amount) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { instance = instance, amount = amount }; } [IteratorStateMachine(typeof(d__1))] public static IEnumerator RemoveMaxEnergy(this ResourcesManager instance, int amount, bool preventable) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { instance = instance, amount = amount, preventable = preventable }; } [IteratorStateMachine(typeof(d__2))] public static IEnumerator ShowRemoveMaxEnergy(this ResourcesManager instance, int amount) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { instance = instance, amount = amount }; } public static int GemsOfType(this ResourcesManager instance, GemType gem) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return instance.gems.Count((GemType x) => x == gem); } public static int GemCount(bool playerGems, GemType gemToCheck) { //IL_0014: 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) if (playerGems) { return Singleton.Instance.GemsOfType(gemToCheck); } return Singleton.Instance.GemsOfType(gemToCheck); } public static bool OwnerHasGems(bool playerGems, params GemType[] gems) { if (playerGems) { return PlayerHasGems(gems); } return OpponentHasGems(gems); } public static bool OpponentHasGems(params GemType[] gems) { //IL_0018: 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) if ((Object)(object)Singleton.Instance == (Object)null) { return false; } foreach (GemType gem in gems) { if (!Singleton.Instance.HasGem(gem)) { return false; } } return true; } public static bool PlayerHasGems(params GemType[] gems) { //IL_0009: 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) foreach (GemType val in gems) { if (!Singleton.Instance.HasGem(val)) { return false; } } return true; } } [HarmonyPatch(typeof(PixelResourcesManager), "Start")] public static class GetEmptyBatterySprite { public static Sprite emptyBatterySprite; [HarmonyPostfix] private static void GetSprite(PixelResourcesManager __instance) { if ((Object)(object)emptyBatterySprite == (Object)null) { emptyBatterySprite = __instance.energyRenderers[0].sprite; } } } [HarmonyPatch] public static class TextureHelper { public enum SpriteType { CardPortrait, PixelPortrait, PixelAbilityIcon, PixelStatIcon, ChallengeIcon, CostDecal, OversizedCostDecal, Act2CostDecalLeft, Act2CostDecalRight, StarterDeckIcon, PixelDecal, PixelActivatedAbilityIcon, PixelStandardButton, Act2CostVanillaLeft, Act2CostVanillaRight } private static Vector2 DEFAULT_PIVOT = new Vector2(0.5f, 0.5f); private static readonly Dictionary emissionMap = new Dictionary(); private static readonly Dictionary SPRITE_RECTS = new Dictionary { { SpriteType.CardPortrait, new Rect(0f, 0f, 114f, 94f) }, { SpriteType.PixelPortrait, new Rect(0f, 0f, 41f, 28f) }, { SpriteType.PixelAbilityIcon, new Rect(0f, 0f, 17f, 17f) }, { SpriteType.PixelStatIcon, new Rect(0f, 0f, 16f, 8f) }, { SpriteType.ChallengeIcon, new Rect(0f, 0f, 49f, 49f) }, { SpriteType.CostDecal, new Rect(0f, 0f, 64f, 28f) }, { SpriteType.OversizedCostDecal, new Rect(0f, 0f, 64f, 112f) }, { SpriteType.Act2CostDecalLeft, new Rect(0f, 0f, 32f, 32f) }, { SpriteType.Act2CostDecalRight, new Rect(0f, 0f, 32f, 32f) }, { SpriteType.StarterDeckIcon, new Rect(0f, 0f, 35f, 44f) }, { SpriteType.PixelDecal, new Rect(0f, 0f, 42f, 56f) }, { SpriteType.PixelActivatedAbilityIcon, new Rect(0f, 0f, 22f, 10f) }, { SpriteType.PixelStandardButton, new Rect(0f, 0f, 26f, 17f) }, { SpriteType.Act2CostVanillaLeft, new Rect(0f, 0f, 48f, 28f) }, { SpriteType.Act2CostVanillaRight, new Rect(0f, 0f, 48f, 28f) } }; private static readonly Dictionary SPRITE_PIVOTS = new Dictionary { { SpriteType.CardPortrait, DEFAULT_PIVOT }, { SpriteType.PixelPortrait, DEFAULT_PIVOT }, { SpriteType.PixelAbilityIcon, DEFAULT_PIVOT }, { SpriteType.PixelStatIcon, DEFAULT_PIVOT }, { SpriteType.ChallengeIcon, DEFAULT_PIVOT }, { SpriteType.CostDecal, DEFAULT_PIVOT }, { SpriteType.OversizedCostDecal, new Vector2(0.5f, 0.875f) }, { SpriteType.Act2CostDecalLeft, new Vector2(0.88f, 0.8f) }, { SpriteType.Act2CostDecalRight, new Vector2(0.55f, 0.8f) }, { SpriteType.StarterDeckIcon, DEFAULT_PIVOT }, { SpriteType.PixelDecal, DEFAULT_PIVOT }, { SpriteType.PixelActivatedAbilityIcon, DEFAULT_PIVOT }, { SpriteType.PixelStandardButton, new Vector2(0.5f, 0f) }, { SpriteType.Act2CostVanillaLeft, new Vector2(0.58f, 0.77f) }, { SpriteType.Act2CostVanillaRight, new Vector2(0.75f, 0.77f) } }; public static byte[] ReadArtworkFileAsBytes(string pathCardArt) { if (!Path.IsPathRooted(pathCardArt)) { string[] files = Directory.GetFiles(Paths.PluginPath, pathCardArt, SearchOption.AllDirectories); if (files.Length < 1) { throw new FileNotFoundException("Could not find relative artwork file!\nFile name: " + pathCardArt, pathCardArt); } pathCardArt = files[0]; } if (!File.Exists(pathCardArt)) { throw new FileNotFoundException("Absolute path to artwork file does not exist!\nFile name: " + pathCardArt, pathCardArt); } return File.ReadAllBytes(pathCardArt); } public static Texture2D GetImageAsTexture(string pathCardArt, FilterMode filterMode = 0) { //IL_0004: 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_0017: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_002c: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); byte[] array = ReadArtworkFileAsBytes(pathCardArt); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = filterMode; ((Object)val).name = Path.GetFileNameWithoutExtension(pathCardArt); return val; } public static Texture2D GetImageAsTexture(string pathCardArt, Assembly target, FilterMode filterMode = 0) { //IL_0004: 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_0018: Expected O, but got Unknown //IL_0019: 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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); byte[] resourceBytes = GetResourceBytes(pathCardArt, target); ImageConversion.LoadImage(val, resourceBytes); ((Texture)val).filterMode = filterMode; ((Object)val).name = Path.GetFileNameWithoutExtension(pathCardArt); return val; } public static Sprite ConvertTexture(this Texture2D texture, SpriteType spriteType, FilterMode filterMode = 0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; Sprite obj = Sprite.Create(texture, SPRITE_RECTS[spriteType], SPRITE_PIVOTS[spriteType]); ((Object)obj).name = ((Object)texture).name; return obj; } public static Sprite ConvertTexture(this Texture2D texture, Vector2? pivot = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) Vector2 valueOrDefault = pivot.GetValueOrDefault(); if (!pivot.HasValue) { ((Vector2)(ref valueOrDefault))..ctor(0.5f, 0.5f); pivot = valueOrDefault; } Sprite obj = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), pivot.Value); ((Object)obj).name = ((Object)texture).name; return obj; } public static Sprite GetImageAsSprite(string pathCardArt, SpriteType spriteType, FilterMode filterMode = 0) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return GetImageAsTexture(pathCardArt, (FilterMode)0).ConvertTexture(spriteType, filterMode); } public static Sprite GetImageAsSprite(string pathCardArt, Assembly target, SpriteType spriteType, FilterMode filterMode = 0) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) return GetImageAsTexture(pathCardArt, target, (FilterMode)0).ConvertTexture(spriteType, filterMode); } public static void RegisterEmissionForSprite(this Sprite regularSprite, Sprite emissionSprite) { ((Object)emissionSprite).name = ((Object)regularSprite).name + "_emission"; emissionMap[regularSprite] = emissionSprite; } public static Sprite GetEmissionSprite(this Sprite sprite) { if ((Object)(object)sprite == (Object)null) { return null; } if (emissionMap.TryGetValue(sprite, out var value)) { return value; } string text = ((Object)sprite).name + "_emission"; value = ResourceBank.Get("Art/Cards/Portraits/" + text); if ((Object)(object)value != (Object)null) { return value; } value = ResourceBank.Get("Art/Cards/GrimoraPortraits/" + text); if ((Object)(object)value != (Object)null) { return value; } return null; } public static void RegisterEmissionForSprite(this Sprite regularSprite, Texture2D emissiveTexture, SpriteType spriteType, FilterMode filterMode = 0) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Sprite emissionSprite = emissiveTexture.ConvertTexture(spriteType, filterMode); regularSprite.RegisterEmissionForSprite(emissionSprite); } public static void RegisterEmissionForSprite(this Sprite regularSprite, string pathToArt, SpriteType spriteType, FilterMode filterMode = 0) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Sprite imageAsSprite = GetImageAsSprite(pathToArt, spriteType, filterMode); regularSprite.RegisterEmissionForSprite(imageAsSprite); } public static void TryReuseEmission(CardInfo info, Sprite alternatePortrait) { if ((Object)(object)info.portraitTex != (Object)null && emissionMap.ContainsKey(info.portraitTex) && !emissionMap.ContainsKey(alternatePortrait)) { emissionMap[alternatePortrait] = emissionMap[info.portraitTex]; } } [HarmonyPatch(typeof(CardDisplayer3D), "GetEmissivePortrait")] [HarmonyPrefix] private static bool GetCustomEmission(Sprite mainPortrait, ref Sprite __result) { if (emissionMap.ContainsKey(mainPortrait)) { __result = emissionMap[mainPortrait]; return false; } return true; } public static byte[] GetResourceBytes(string filename, Assembly target) { string lowerKey = "." + filename.ToLowerInvariant(); string text = target.GetManifestResourceNames().FirstOrDefault((string r) => r.ToLowerInvariant().EndsWith(lowerKey)); if (string.IsNullOrEmpty(text)) { throw new KeyNotFoundException($"Could not find resource matching {filename} in assembly {target}."); } using Stream stream = target.GetManifestResourceStream(text); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } public static Texture2D CombineTextures(List pieces, Texture2D baseTexture, int xStep = 0, int yStep = 0, int xOffset = 0, int yOffset = 0) { if (pieces != null) { for (int i = 0; i < pieces.Count; i++) { if ((Object)(object)pieces[i] != (Object)null) { baseTexture.SetPixels(xOffset + xStep * i, yOffset + yStep * (pieces.Count - i - 1), ((Texture)pieces[i]).width, ((Texture)pieces[i]).height, pieces[i].GetPixels(), 0); } } baseTexture.Apply(); } return baseTexture; } public static Texture2D DuplicateTexture(Texture2D texture) { //IL_0034: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1); Graphics.Blit((Texture)(object)texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } } public static class TranspilerHelpers { public static void LogCodeInscryptions(this List codes, string prefix = null) { string text = prefix ?? ""; for (int i = 0; i < codes.Count; i++) { CodeInstruction val = codes[i]; string text2 = ((val.operand == null) ? "" : val.operand.ToString()); InscryptionAPIPlugin.Logger.LogInfo((object)$"{text}{i}: {val.opcode} {text2}"); } } } } namespace InscryptionAPI.Helpers.Extensions { public static class BoardManagerExtensions { public static List GetPlayerCards(this BoardManager manager, Predicate filterOnPredicate = null) { return manager.PlayerSlotsCopy.SelectCards(filterOnPredicate).ToList(); } public static List GetOpponentCards(this BoardManager manager, Predicate filterOnPredicate = null) { return manager.OpponentSlotsCopy.SelectCards(filterOnPredicate).ToList(); } public static List GetCards(this BoardManager manager, bool getPlayerCards, Predicate filterOnPredicate = null) { return manager.GetSlotsCopy(getPlayerCards).SelectCards(filterOnPredicate).ToList(); } public static List GetCards(this BoardManager manager, Predicate filterOnPredicate = null) { return manager.AllSlotsCopy.SelectCards(filterOnPredicate).ToList(); } public static List GetPlayerOpenSlots(this BoardManager manager, Predicate filterOnPredicate = null) { return manager.PlayerSlotsCopy.SelectOpenSlots(filterOnPredicate).ToList(); } public static List GetOpponentOpenSlots(this BoardManager manager, Predicate filterOnPredicate = null) { return manager.OpponentSlotsCopy.SelectOpenSlots(filterOnPredicate).ToList(); } public static List GetOpenSlots(this BoardManager manager, bool getPlayerSlots, Predicate filterOnPredicate = null) { return manager.GetSlotsCopy(getPlayerSlots).SelectOpenSlots(filterOnPredicate).ToList(); } public static List GetOpenSlots(this BoardManager manager, Predicate filterOnPredicate = null) { return manager.AllSlotsCopy.SelectOpenSlots(filterOnPredicate).ToList(); } public static List GetSlotsCopy(this BoardManager manager, bool getPlayerSlotsCopy) { if (!getPlayerSlotsCopy) { return manager.OpponentSlotsCopy; } return manager.PlayerSlotsCopy; } public static List GetCardSlots(this BoardManager manager, bool getPlayerCards, Predicate filterOnPredicate = null) { return manager.GetSlotsCopy(getPlayerCards).FindAll(filterOnPredicate); } } public static class CardSlotExtensions { [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard playableCard; public CardSlot slotToSpawnIn; public float transitionDuration; public Action tweenCompleteCallback; public bool resolveTriggers; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Singleton.Instance.AssignCardToSlot(playableCard, slotToSpawnIn, transitionDuration, tweenCompleteCallback, resolveTriggers); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardInfo cardInfo; public CardSlot slotToSpawnIn; public float transitionLength; public bool resolveTriggers; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Singleton.Instance.CreateCardInSlot(cardInfo, slotToSpawnIn, transitionLength, resolveTriggers); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard playableCard; public CardSlot slotToSpawnIn; public float tweenLength; public Action landOnBoardCallback; public bool resolveTriggers; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Singleton.Instance.ResolveCardOnBoard(playableCard, slotToSpawnIn, tweenLength, landOnBoardCallback, resolveTriggers); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool IsOpponentSlot(this CardSlot cardSlot) { return !cardSlot.IsPlayerSlot; } public static bool HasCard(this CardSlot cardSlot, string cardName) { if (Object.op_Implicit((Object)(object)cardSlot.Card)) { return ((Object)((Card)cardSlot.Card).Info).name == cardName; } return false; } [IteratorStateMachine(typeof(d__2))] public static IEnumerator CreateCardInSlot(this CardSlot slotToSpawnIn, CardInfo cardInfo, float transitionLength = 0.1f, bool resolveTriggers = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { slotToSpawnIn = slotToSpawnIn, cardInfo = cardInfo, transitionLength = transitionLength, resolveTriggers = resolveTriggers }; } [IteratorStateMachine(typeof(d__3))] public static IEnumerator AssignCardToSlot(this CardSlot slotToSpawnIn, PlayableCard playableCard, float transitionDuration = 0.1f, Action tweenCompleteCallback = null, bool resolveTriggers = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { slotToSpawnIn = slotToSpawnIn, playableCard = playableCard, transitionDuration = transitionDuration, tweenCompleteCallback = tweenCompleteCallback, resolveTriggers = resolveTriggers }; } [IteratorStateMachine(typeof(d__4))] public static IEnumerator ResolveCardOnBoard(this CardSlot slotToSpawnIn, PlayableCard playableCard, float tweenLength = 0.1f, Action landOnBoardCallback = null, bool resolveTriggers = true) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { slotToSpawnIn = slotToSpawnIn, playableCard = playableCard, tweenLength = tweenLength, landOnBoardCallback = landOnBoardCallback, resolveTriggers = resolveTriggers }; } public static List GetAdjacentSlots(this CardSlot cardSlot, bool removeNulls = false) { return (from slot in Singleton.Instance.GetAdjacentSlots(cardSlot) where !removeNulls || Object.op_Implicit((Object)(object)slot) select slot).ToList(); } public static List GetAdjacentCards(this CardSlot cardSlot) { return (from slot in Singleton.Instance.GetAdjacentSlots(cardSlot) where Object.op_Implicit((Object)(object)slot) select slot).SelectCards().ToList(); } public static CardSlot GetAdjacent(this CardSlot cardSlot, bool adjacentOnLeft) { return Singleton.Instance.GetAdjacent(cardSlot, adjacentOnLeft); } public static IEnumerable SelectCards(this IEnumerable slots, Predicate filterOnPredicate = null) { return from slot in slots where Object.op_Implicit((Object)(object)slot.Card) && (filterOnPredicate == null || filterOnPredicate(slot.Card)) select slot.Card; } public static IEnumerable SelectOpenSlots(this IEnumerable slots, Predicate filterOnPredicate = null) { return slots.Where((CardSlot slot) => !Object.op_Implicit((Object)(object)slot.Card) && (filterOnPredicate == null || filterOnPredicate(slot))); } } public static class GameObjectExtensions { public static GameObject FindChild(this GameObject parent, string name) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (((Object)parent).name == name) { return parent; } foreach (Transform item in parent.transform) { GameObject val = ((Component)item).gameObject.FindChild(name); if ((Object)(object)val != (Object)null) { return val; } } return null; } } public static class ListExtensions { public static T PopFirst(this List list) { T result = list[0]; list.RemoveAt(0); return result; } public static T PopLast(this List list) { T result = list[list.Count - 1]; list.RemoveAt(list.Count - 1); return result; } public static List Repeat(this T toRepeat, int times) { List list = new List(); if (toRepeat != null) { for (int i = 0; i < times; i++) { list.Add(toRepeat); } } return list; } public static T GetRandom(this List list) { int index = Random.Range(0, list.Count); return list[index]; } public static T GetSeededRandom(this List list, int seed) { int index = SeededRandom.Range(0, list.Count, seed); return list[index]; } } } namespace InscryptionAPI.Card { public static class AbilityExtensions { public static AbilityInfo AbilityByID(this IEnumerable abilities, Ability id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return abilities.FirstOrDefault((Func)((AbilityInfo x) => x.ability == id)); } public static AbilityManager.FullAbility AbilityByID(this IEnumerable abilities, Ability id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return abilities.FirstOrDefault((AbilityManager.FullAbility x) => x.Id == id); } internal static AbilityManager.FullAbility GetFullAbility(this AbilityInfo info) { if ((Object)(object)info == (Object)null) { return null; } AbilityManager.FullAbility.ReverseMapper.TryGetValue(info, out var value); return value; } public static string GetBaseRulebookDescription(this AbilityInfo info) { return AbilityManager.AllAbilities.Find((AbilityManager.FullAbility x) => (Object)(object)x.Info == (Object)(object)info)?.BaseRulebookDescription; } public static AbilityInfo SetIcon(this AbilityInfo info, Texture2D icon) { (info.GetFullAbility() ?? throw new InvalidOperationException("Cannot set custom texture directly on AbilityInfo unless it has been added via Add().")).SetIcon(icon); return info; } public static void SetIcon(this AbilityManager.FullAbility info, Texture2D icon) { info.Texture = (Texture)(object)icon; } public static AbilityInfo SetCustomFlippedTexture(this AbilityInfo info, Texture2D icon) { (info.GetFullAbility() ?? throw new InvalidOperationException("Cannot set custom texture directly on AbilityInfo unless it has been added via Add().")).SetCustomFlippedTexture(icon); return info; } public static void SetCustomFlippedTexture(this AbilityManager.FullAbility info, Texture2D icon) { info.CustomFlippedTexture = (Texture)(object)icon; info.Info.customFlippedIcon = true; } public static AbilityInfo SetPixelAbilityIcon(this AbilityInfo info, Texture2D icon, FilterMode? filterMode = null) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) TextureHelper.SpriteType spriteType = ((((Texture)icon).width == 22) ? TextureHelper.SpriteType.PixelActivatedAbilityIcon : TextureHelper.SpriteType.PixelAbilityIcon); info.pixelIcon = icon.ConvertTexture(spriteType, filterMode.GetValueOrDefault()); return info; } public static AbilityInfo AddMetaCategories(this AbilityInfo info, params AbilityMetaCategory[] categories) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (info.metaCategories == null) { info.metaCategories = new List(); } foreach (AbilityMetaCategory item in categories) { if (!info.metaCategories.Contains(item)) { info.metaCategories.Add(item); } } return info; } public static AbilityInfo SetDefaultPart1Ability(this AbilityInfo info) { return info.AddMetaCategories((AbilityMetaCategory)1, default(AbilityMetaCategory)); } public static AbilityInfo SetDefaultPart2Ability(this AbilityInfo info) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected I4, but got Unknown return info.AddMetaCategories((AbilityMetaCategory)(int)AbilityManager.Part2Modular); } public static AbilityInfo SetDefaultPart3Ability(this AbilityInfo info) { AbilityMetaCategory[] array = new AbilityMetaCategory[3]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); return info.AddMetaCategories((AbilityMetaCategory[])(object)array); } public static AbilityInfo SetAbilityLearnedDialogue(this AbilityInfo abilityInfo, params string[] lines) { //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) //IL_0026: Expected O, but got Unknown //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_0042: Expected O, but got Unknown if (lines.Length != 0) { List list = new List(); foreach (string text in lines) { list.Add(new Line { text = text }); } abilityInfo.abilityLearnedDialogue = new LineSet { lines = list }; } return abilityInfo; } public static AbilityInfo SetAbilityLearnedDialogue(this AbilityInfo abilityInfo, params Line[] lines) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown if (lines.Length != 0) { abilityInfo.abilityLearnedDialogue = new LineSet { lines = lines.ToList() }; } return abilityInfo; } public static AbilityInfo SetGBCTriggerText(this AbilityInfo abilityInfo, string triggerText) { abilityInfo.triggerText = triggerText; return abilityInfo; } public static AbilityManager.FullAbility SetGBCTriggerText(this AbilityManager.FullAbility fullAbility, string triggerText) { fullAbility.Info.triggerText = triggerText; return fullAbility; } public static AbilityInfo SetPowerlevel(this AbilityInfo abilityInfo, int powerLevel) { abilityInfo.powerLevel = powerLevel; return abilityInfo; } public static AbilityManager.FullAbility SetPowerlevel(this AbilityManager.FullAbility fullAbility, int powerLevel) { fullAbility.Info.powerLevel = powerLevel; return fullAbility; } public static AbilityInfo SetRulebookDescription(this AbilityInfo abilityInfo, string description) { abilityInfo.rulebookDescription = description; return abilityInfo; } public static AbilityManager.FullAbility SetRulebookDescription(this AbilityManager.FullAbility fullAbility, string description) { fullAbility.Info.rulebookDescription = description; return fullAbility; } public static AbilityInfo SetRulebookName(this AbilityInfo abilityInfo, string name) { abilityInfo.rulebookName = name; return abilityInfo; } public static AbilityManager.FullAbility SetRulebookName(this AbilityManager.FullAbility fullAbility, string name) { fullAbility.Info.rulebookName = name; return fullAbility; } public static AbilityInfo SetActivated(this AbilityInfo abilityInfo, bool activated = true) { abilityInfo.activated = activated; return abilityInfo; } public static AbilityManager.FullAbility SetActivated(this AbilityManager.FullAbility fullAbility, bool activated = true) { fullAbility.Info.activated = activated; return fullAbility; } public static AbilityInfo SetPassive(this AbilityInfo abilityInfo, bool passive = true) { abilityInfo.passive = passive; return abilityInfo; } public static AbilityManager.FullAbility SetPassive(this AbilityManager.FullAbility fullAbility, bool passive = true) { fullAbility.Info.passive = passive; return fullAbility; } public static AbilityInfo SetOpponentUsable(this AbilityInfo abilityInfo, bool opponentUsable = true) { abilityInfo.opponentUsable = opponentUsable; return abilityInfo; } public static AbilityManager.FullAbility SetOpponentUsable(this AbilityManager.FullAbility fullAbility, bool opponentUsable = true) { fullAbility.Info.opponentUsable = opponentUsable; return fullAbility; } public static AbilityInfo SetConduit(this AbilityInfo abilityInfo, bool conduit = true) { abilityInfo.conduit = conduit; return abilityInfo; } public static AbilityManager.FullAbility SetConduit(this AbilityManager.FullAbility fullAbility, bool conduit = true) { fullAbility.Info.conduit = conduit; return fullAbility; } public static AbilityInfo SetConduitCell(this AbilityInfo abilityInfo, bool conduitCell = true) { abilityInfo.conduitCell = conduitCell; return abilityInfo; } public static AbilityManager.FullAbility SetConduitCell(this AbilityManager.FullAbility fullAbility, bool conduitCell = true) { fullAbility.Info.conduitCell = conduitCell; return fullAbility; } public static AbilityInfo SetCanStack(this AbilityInfo abilityInfo, bool canStack = true, bool triggersOncePerStack = false) { abilityInfo.canStack = canStack; abilityInfo.SetTriggersOncePerStack(triggersOncePerStack); return abilityInfo; } public static AbilityManager.FullAbility SetCanStack(this AbilityManager.FullAbility fullAbility, bool canStack = true, bool triggersOncePerStack = false) { fullAbility.Info.SetCanStack(canStack, triggersOncePerStack); return fullAbility; } public static AbilityInfo SetFlipYIfOpponent(this AbilityInfo abilityInfo, bool flipY = true) { abilityInfo.flipYIfOpponent = flipY; return abilityInfo; } public static AbilityManager.FullAbility SetFlipYIfOpponent(this AbilityManager.FullAbility fullAbility, bool flipY = true) { fullAbility.Info.SetFlipYIfOpponent(flipY); return fullAbility; } public static AbilityInfo SetHasColorOverride(this AbilityInfo abilityInfo, bool hasOverride, Color colorOverride = default(Color)) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) abilityInfo.hasColorOverride = hasOverride; if (hasOverride) { abilityInfo.colorOverride = colorOverride; } return abilityInfo; } public static AbilityManager.FullAbility SetHasColorOverride(this AbilityManager.FullAbility fullAbility, bool hasOverride, Color colorOverride = default(Color)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) fullAbility.Info.SetHasColorOverride(hasOverride, colorOverride); return fullAbility; } public static AbilityInfo SetKeywordAbility(this AbilityInfo abilityInfo, bool keyword = true) { abilityInfo.keywordAbility = keyword; return abilityInfo; } public static AbilityManager.FullAbility SetKeywordAbility(this AbilityManager.FullAbility fullAbility, bool keyword = true) { fullAbility.Info.keywordAbility = keyword; return fullAbility; } public static AbilityInfo ResetDescription(this AbilityInfo abilityInfo) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) abilityInfo.rulebookDescription = AbilityManager.AllAbilities.AbilityByID(abilityInfo.ability).BaseRulebookDescription; return abilityInfo; } public static AbilityManager.FullAbility SetPart1Rulebook(this AbilityManager.FullAbility full) { full.Info.AddMetaCategories(default(AbilityMetaCategory)); return full; } public static AbilityManager.FullAbility SetPart3Rulebook(this AbilityManager.FullAbility full) { full.Info.AddMetaCategories((AbilityMetaCategory)2); return full; } public static AbilityManager.FullAbility SetGrimoraRulebook(this AbilityManager.FullAbility full) { full.Info.AddMetaCategories((AbilityMetaCategory)5); return full; } public static AbilityManager.FullAbility SetMagnificusRulebook(this AbilityManager.FullAbility full) { full.Info.AddMetaCategories((AbilityMetaCategory)6); return full; } public static bool HasMetaCategories(this AbilityInfo info, params AbilityMetaCategory[] categories) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (AbilityMetaCategory category in categories) { if (!info.HasMetaCategory(category)) { return false; } } return true; } public static bool HasMetaCategory(this AbilityInfo info, AbilityMetaCategory category) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return info.metaCategories.Contains(category); } public static StatIconInfo SetIcon(this StatIconInfo info, Texture2D icon, FilterMode? filterMode = null) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) info.iconGraphic = (Texture)(object)icon; if (filterMode.HasValue) { info.iconGraphic.filterMode = filterMode.Value; } return info; } public static StatIconInfo SetIcon(this StatIconInfo info, string pathToArt, FilterMode? filterMode = null) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) info.iconGraphic = (Texture)(object)TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0); if (filterMode.HasValue) { info.iconGraphic.filterMode = filterMode.Value; } return info; } public static StatIconInfo SetRulebookInfo(this StatIconInfo info, string rulebookName, string rulebookDescription = null) { info.rulebookName = rulebookName; info.rulebookDescription = rulebookDescription; return info; } public static StatIconInfo SetAppliesToStats(this StatIconInfo info, bool appliesToAttack, bool appliesToHealth) { info.appliesToAttack = appliesToAttack; info.appliesToHealth = appliesToHealth; return info; } public static StatIconInfo SetPixelIcon(this StatIconInfo info, Texture2D icon, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) info.pixelIconGraphic = icon.ConvertTexture(TextureHelper.SpriteType.PixelStatIcon, filterMode.GetValueOrDefault()); return info; } public static StatIconInfo SetPixelIcon(this StatIconInfo info, string pathToArt, FilterMode? filterMode = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) Texture2D imageAsTexture = TextureHelper.GetImageAsTexture(pathToArt, filterMode.GetValueOrDefault()); info.pixelIconGraphic = imageAsTexture.ConvertTexture(TextureHelper.SpriteType.PixelStatIcon, (FilterMode)0); return info; } public static StatIconInfo AddMetaCategories(this StatIconInfo info, params AbilityMetaCategory[] categories) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (info.metaCategories == null) { info.metaCategories = new List(); } foreach (AbilityMetaCategory item in categories) { if (!info.metaCategories.Contains(item)) { info.metaCategories.Add(item); } } return info; } public static StatIconInfo SetDefaultPart1Ability(this StatIconInfo info) { return info.AddMetaCategories(default(AbilityMetaCategory)); } public static StatIconInfo SetDefaultPart3Ability(this StatIconInfo info) { return info.AddMetaCategories((AbilityMetaCategory)2); } public static AbilityInfo SetTriggersOncePerStack(this AbilityInfo abilityInfo, bool triggersOncePerStack = true) { abilityInfo.SetExtendedProperty("TriggersOncePerStack", triggersOncePerStack); return abilityInfo; } public static bool GetTriggersOncePerStack(this Ability ability) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return AbilityManager.AllAbilityInfos.AbilityByID(ability).GetTriggersOncePerStack(); } public static bool GetTriggersOncePerStack(this AbilityInfo abilityInfo) { return abilityInfo.GetExtendedPropertyAsBool("TriggersOncePerStack").GetValueOrDefault(); } public static AbilityInfo SetHideSingleStacks(this AbilityInfo abilityInfo, bool hideSingleStacks = true) { abilityInfo.SetExtendedProperty("HideSingleStacks", hideSingleStacks); return abilityInfo; } public static bool GetHideSingleStacks(this Ability ability) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return AbilityManager.AllAbilityInfos.AbilityByID(ability).GetHideSingleStacks(); } public static bool GetHideSingleStacks(this AbilityInfo abilityInfo) { return abilityInfo.GetExtendedPropertyAsBool("HideSingleStacks").GetValueOrDefault(); } public static AbilityInfo SetExtendedProperty(this AbilityInfo info, string propertyName, object value) { info.GetAbilityExtensionTable()[propertyName] = value?.ToString(); return info; } public static AbilityManager.FullAbility SetExtendedProperty(this AbilityManager.FullAbility fullAbility, string propertyName, object value) { fullAbility.Info.GetAbilityExtensionTable()[propertyName] = value?.ToString(); return fullAbility; } public static string GetExtendedProperty(this Ability ability, string propertyName) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return AbilityManager.AllAbilityInfos.AbilityByID(ability).GetExtendedProperty(propertyName); } public static string GetExtendedProperty(this AbilityInfo info, string propertyName) { info.GetAbilityExtensionTable().TryGetValue(propertyName, out var value); return value; } public static int? GetExtendedPropertyAsInt(this Ability ability, string propertyName) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return AbilityManager.AllAbilityInfos.AbilityByID(ability).GetExtendedPropertyAsInt(propertyName); } public static int? GetExtendedPropertyAsInt(this AbilityInfo info, string propertyName) { info.GetAbilityExtensionTable().TryGetValue(propertyName, out var value); if (!int.TryParse(value, out var result)) { return null; } return result; } public static float? GetExtendedPropertyAsFloat(this Ability ability, string propertyName) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return AbilityManager.AllAbilityInfos.AbilityByID(ability).GetExtendedPropertyAsFloat(propertyName); } public static float? GetExtendedPropertyAsFloat(this AbilityInfo info, string propertyName) { info.GetAbilityExtensionTable().TryGetValue(propertyName, out var value); if (!float.TryParse(value, out var result)) { return null; } return result; } public static bool? GetExtendedPropertyAsBool(this Ability ability, string propertyName) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return AbilityManager.AllAbilityInfos.AbilityByID(ability).GetExtendedPropertyAsBool(propertyName); } public static bool? GetExtendedPropertyAsBool(this AbilityInfo info, string propertyName) { info.GetAbilityExtensionTable().TryGetValue(propertyName, out var value); if (!bool.TryParse(value, out var result)) { return null; } return result; } } [HarmonyPatch] public static class AbilityManager { private class AbilityExt { public readonly Dictionary TypeMap = new Dictionary(); public readonly Dictionary StringMap = new Dictionary(); } public class FullAbility { public readonly Ability Id; public readonly string ModGUID; public readonly AbilityInfo Info; public readonly Type AbilityBehavior; public Dictionary RulebookDescriptionRedirects = new Dictionary(); internal static ConditionalWeakTable ReverseMapper = new ConditionalWeakTable(); public Texture Texture { get; internal set; } public Texture CustomFlippedTexture { get; internal set; } public string BaseRulebookDescription { get; internal set; } [Obsolete("Use the constructor that takes a modGUID parameter instead")] public FullAbility(Ability id, AbilityInfo info, Type behaviour, Texture texture) : this("", id, info, behaviour, texture) { }//IL_0006: Unknown result type (might be due to invalid IL or missing references) public FullAbility(string modGUID, Ability id, AbilityInfo info, Type behaviour, Texture texture) { //IL_0019: 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) ModGUID = modGUID; Id = id; Info = info; AbilityBehavior = behaviour; Texture = texture; BaseRulebookDescription = info.rulebookDescription; ReverseMapper.Add(info, this); TypeManager.Add(((object)(Ability)(ref id)).ToString(), behaviour); } public FullAbility Clone() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_01a3: Unknown result type (might be due to invalid IL or missing references) AbilityInfo val = ScriptableObject.CreateInstance(); val.ability = Info.ability; val.abilityLearnedDialogue = Info.abilityLearnedDialogue; val.activated = Info.activated; val.canStack = Info.canStack; val.colorOverride = Info.colorOverride; val.conduit = Info.conduit; val.conduitCell = Info.conduitCell; val.customFlippedIcon = Info.customFlippedIcon; val.customFlippedPixelIcon = Info.customFlippedPixelIcon; val.flipYIfOpponent = Info.flipYIfOpponent; val.hasColorOverride = Info.hasColorOverride; val.keywordAbility = Info.keywordAbility; val.mesh3D = Info.mesh3D; val.metaCategories = new List(Info.metaCategories); ((Object)val).name = ((Object)Info).name; val.opponentUsable = Info.opponentUsable; val.passive = Info.passive; val.pixelIcon = Info.pixelIcon; val.powerLevel = Info.powerLevel; val.rulebookDescription = Info.rulebookDescription; val.rulebookName = Info.rulebookName; val.triggerText = Info.triggerText; AbilityExtensionProperties.Add(val, AbilityExtensionProperties.GetOrCreateValue(Info)); return new FullAbility(ModGUID, Id, val, AbilityBehavior, Texture) { CustomFlippedTexture = CustomFlippedTexture, RulebookDescriptionRedirects = new Dictionary(RulebookDescriptionRedirects) }; } } [CompilerGenerated] private sealed class <g__OnTrigger|38_1>d : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardTriggerHandler r; public Trigger trigger; public object[] otherArgs; private List.Enumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <g__OnTrigger|38_1>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = r.GetAllReceivers().GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { TriggerReceiver current = <>7__wrap1.Current; if (GlobalTriggerHandler.ReceiverRespondsToTrigger(trigger, current, otherArgs) && current is IActivateWhenFacedown && (current as IActivateWhenFacedown).ShouldTriggerWhenFaceDown(trigger, otherArgs)) { <>2__current = Singleton.Instance.TriggerSequence(trigger, current, otherArgs); <>1__state = 1; return true; } } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__53 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SquirrelOrbit instance; private List 5__2; private List.Enumerator <>7__wrap2; private PlayableCard 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__53(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 2) <= 6u) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = new List(); if (((AbilityBehaviour)instance).Card.HasTrait((Trait)16)) { 5__2 = Singleton.Instance.GetSlotsCopy(((AbilityBehaviour)instance).Card.OpponentCard); } else { 5__2 = Singleton.Instance.AllSlotsCopy; } 5__2.RemoveAll((CardSlot x) => !Object.op_Implicit((Object)(object)x.Card) || !x.Card.IsAffectedByTidalLock()); if (5__2.Count == 0) { return false; } ((Card)((AbilityBehaviour)instance).Card).Anim.LightNegationEffect(); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 1; return true; case 1: <>1__state = -1; <>7__wrap2 = 5__2.GetEnumerator(); <>1__state = -3; break; case 2: <>1__state = -3; <>2__current = 5__4.Die(false, (PlayableCard)null, true); <>1__state = 3; return true; case 3: <>1__state = -3; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 4; return true; case 4: <>1__state = -3; if (((AbilityBehaviour)instance).Card.HasTrait((Trait)16)) { Singleton.Instance.SwitchToView((View)6, false, false); } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 5; return true; case 5: <>1__state = -3; if (((AbilityBehaviour)instance).Card.HasSpecialAbility((SpecialTriggeredAbility)16)) { instance.FindMoonPortrait(); instance.moonPortrait.InstantiateOrbitingObject(((Card)5__4).Info); } if (((AbilityBehaviour)instance).HasLearned) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 6; return true; } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 7; return true; case 6: <>1__state = -3; goto IL_02c1; case 7: <>1__state = -3; <>2__current = ((AbilityBehaviour)instance).LearnAbility(0f); <>1__state = 8; return true; case 8: { <>1__state = -3; goto IL_02c1; } IL_02c1: 5__4 = null; break; } if (<>7__wrap2.MoveNext()) { CardSlot current = <>7__wrap2.Current; 5__4 = current.Card; Singleton.Instance.SwitchToView((View)4, false, false); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 2; return true; } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__36 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public PlayableCard __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__36(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; FixStackTriggers(__instance); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__38 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; public bool triggerFacedown; public Trigger trigger; public object[] otherArgs; private List.Enumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__38(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = result; <>1__state = 1; return true; case 1: { <>1__state = -1; if (triggerFacedown) { return false; } List list = new List(Singleton.Instance.CardsOnBoard); <>7__wrap1 = list.GetEnumerator(); <>1__state = -3; break; } case 2: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { PlayableCard current = <>7__wrap1.Current; if ((Object)(object)current != (Object)null && ((Card)current).FaceDown && g__RespondsToTrigger|38_0(current.TriggerHandler, trigger, otherArgs)) { <>2__current = g__OnTrigger|38_1(current.TriggerHandler, trigger, otherArgs); <>1__state = 2; return true; } } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly ConditionalWeakTable AbilityExtensionProperties; public static readonly ReadOnlyCollection BaseGameAbilities; internal static readonly ObservableCollection NewAbilities; public const string SIGILCOST = "[sigilcost:"; public static List AllAbilities { get; private set; } public static List AllAbilityInfos { get; private set; } public static AbilityMetaCategory Part2Modular => GuidManager.GetEnumValue("cyantist.inscryption.api", "Part2Modular"); public static event Func, List> ModifyAbilityList; public static void SyncAbilityList() { AllAbilities = (from a in BaseGameAbilities.Concat(NewAbilities) select a.Clone()).ToList(); AllAbilities = AbilityManager.ModifyAbilityList?.Invoke(AllAbilities) ?? AllAbilities; AllAbilityInfos = AllAbilities.Select((FullAbility x) => x.Info).ToList(); ShieldManager.AllShieldAbilities = AllAbilities.Where((FullAbility x) => x.AbilityBehavior != null && x.AbilityBehavior.IsSubclassOf(typeof(DamageShieldBehaviour))).ToList(); ShieldManager.AllShieldInfos = ShieldManager.AllShieldAbilities.Select((FullAbility x) => x.Info).ToList(); } static AbilityManager() { AbilityExtensionProperties = new ConditionalWeakTable(); BaseGameAbilities = new ReadOnlyCollection(GenBaseGameAbilityList()); NewAbilities = new ObservableCollection(); AllAbilities = BaseGameAbilities.ToList(); AllAbilityInfos = BaseGameAbilities.Select((FullAbility x) => x.Info).ToList(); InscryptionAPIPlugin.ScriptableObjectLoaderLoad += delegate(Type type) { if (type == typeof(AbilityInfo)) { ScriptableObjectLoader.allData = AllAbilityInfos; } }; NewAbilities.CollectionChanged += delegate { SyncAbilityList(); }; } private static List GenBaseGameAbilityList() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) bool flag = true; try { Ability val = (Ability)33; OriginalLoadAbilityIcon(((object)(Ability)(ref val)).ToString()); } catch (NotImplementedException) { flag = false; } List list = new List(); Assembly assembly = typeof(AbilityInfo).Assembly; AbilityInfo[] array = Resources.LoadAll("Data/Abilities"); foreach (AbilityInfo val2 in array) { string text = ((object)(Ability)(ref val2.ability)).ToString(); if (Part2ModularAbilities.BasePart2Modular.Contains(val2.ability)) { val2.SetDefaultPart2Ability(); } if (text == "DeathShield") { val2.SetPassive(passive: false).SetCanStack().SetHideSingleStacks(); FullAbility item = new FullAbility(null, val2.ability, val2, typeof(APIDeathShield), flag ? OriginalLoadAbilityIcon(text) : AbilitiesUtil.LoadAbilityIcon(text, false, false)); list.Add(item); } else { list.Add(new FullAbility(null, val2.ability, val2, assembly.GetType("DiskCardGame." + text), flag ? OriginalLoadAbilityIcon(text) : AbilitiesUtil.LoadAbilityIcon(text, false, false))); } } return list; } public static FullAbility Add(string guid, AbilityInfo info, Type behavior, Texture tex) { //IL_0008: 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_0022: Unknown result type (might be due to invalid IL or missing references) FullAbility fullAbility = new FullAbility(guid, GuidManager.GetEnumValue(guid, info.rulebookName), info, behavior, tex); fullAbility.Info.ability = fullAbility.Id; ((Object)info).name = guid + "_" + info.rulebookName; NewAbilities.Add(fullAbility); return fullAbility; } public static AbilityInfo New(string guid, string rulebookName, string rulebookDescription, Type behavior, string pathToArt) { return New(guid, rulebookName, rulebookDescription, behavior, (Texture)(object)TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static AbilityInfo New(string guid, string rulebookName, string rulebookDescription, Type behavior, Texture tex) { AbilityInfo val = ScriptableObject.CreateInstance(); val.rulebookName = rulebookName; val.rulebookDescription = rulebookDescription; Add(guid, val, behavior, tex); return val; } public static void Remove(Ability id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) NewAbilities.Remove(NewAbilities.FirstOrDefault((FullAbility x) => x.Id == id)); } public static void Remove(FullAbility ability) { NewAbilities.Remove(ability); } internal static Dictionary GetAbilityExtensionTable(this AbilityInfo info) { return AbilityExtensionProperties.GetOrCreateValue(info).StringMap; } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(AbilitiesUtil), "LoadAbilityIcon")] public static Texture OriginalLoadAbilityIcon(string abilityName, bool fillerAbility = false, bool something = false) { throw new NotImplementedException(); } [HarmonyPrefix] [HarmonyPatch(typeof(AbilitiesUtil), "LoadAbilityIcon")] private static bool LoadAbilityIconReplacement(string abilityName, ref Texture __result) { if (string.IsNullOrEmpty(abilityName)) { return true; } bool flag = true; if (abilityName.EndsWith("_opponent")) { flag = false; abilityName = abilityName.Replace("_opponent", ""); } if (int.TryParse(abilityName, out var abilityId)) { FullAbility fullAbility = AllAbilities.FirstOrDefault((FullAbility x) => (int)x.Id == abilityId); __result = ((flag || (Object)(object)fullAbility.CustomFlippedTexture == (Object)null) ? fullAbility.Texture : fullAbility.CustomFlippedTexture); return false; } if (Enum.TryParse(abilityName, out Ability abilityEnum)) { FullAbility fullAbility2 = AllAbilities.FirstOrDefault((FullAbility x) => x.Id == abilityEnum); __result = ((flag || (Object)(object)fullAbility2.CustomFlippedTexture == (Object)null) ? fullAbility2.Texture : fullAbility2.CustomFlippedTexture); return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(AbilitiesUtil), "GetLearnedAbilities")] private static bool GetLearnedAbilitesReplacement(bool opponentUsable, int minPower, int maxPower, AbilityMetaCategory categoryCriteria, ref List __result) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) __result = new List(); foreach (AbilityInfo allAbilityInfo in AllAbilityInfos) { if (true & (!opponentUsable || allAbilityInfo.opponentUsable) & (minPower <= allAbilityInfo.powerLevel && maxPower >= allAbilityInfo.powerLevel) & allAbilityInfo.metaCategories.Contains(categoryCriteria) & ProgressionData.LearnedAbility(allAbilityInfo.ability)) { __result.Add(allAbilityInfo.ability); } } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(AbilityInfo), "ParseAndTranslateDescription")] private static void CleanUpParsedDescription(ref string __result) { while (__result.Contains("[sigilcost:")) { string text = __result.Substring(__result.IndexOf("[sigilcost:")); if (text.Contains("]")) { text = text.Substring(0, text.IndexOf("]") + 1); __result = __result.Replace(text, text.Replace("[sigilcost:", "").Replace("]", "")); continue; } break; } } [HarmonyPrefix] [HarmonyPatch(typeof(RuleBookController), "OpenToAbilityPage")] private static bool UpdateRulebookDescription(PlayableCard card) { PlayableCard obj = card; ExtendedActivatedAbilityBehaviour extendedActivatedAbilityBehaviour = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)extendedActivatedAbilityBehaviour != (Object)null) { foreach (FullAbility item in AllAbilities.Where((FullAbility ai) => ai.Info.activated && card.HasAbility(ai.Id))) { if (item.AbilityBehavior.IsAssignableFrom(((object)extendedActivatedAbilityBehaviour).GetType())) { item.Info.rulebookDescription = ParseAndUpdateDescription(item.Info.rulebookDescription, extendedActivatedAbilityBehaviour); } } } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(RuleBookController), "SetShown")] private static bool ResetAlteredDescriptions(bool shown) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (shown) { return true; } foreach (FullAbility item in AllAbilities.Where((FullAbility a) => !BaseGameAbilities.Contains(a) && a.Info.activated)) { AbilityInfo info = AbilitiesUtil.GetInfo(item.Id); if (info.rulebookDescription != item.BaseRulebookDescription) { info.ResetDescription(); } } return true; } internal static string ParseAndUpdateDescription(string description, ExtendedActivatedAbilityBehaviour ability) { if (description.Contains("[sigilcost:")) { int startIndex = description.IndexOf("[sigilcost:"); string text = description.Substring(startIndex); if (text.Contains("]")) { int num = text.IndexOf("]"); text = text.Substring(0, num + 1); StringBuilder stringBuilder = new StringBuilder(); if (ability.BonesCost > 0) { stringBuilder.Append(ability.BonesCost + " bone"); if (ability.BonesCost != 1) { stringBuilder.Append("s"); } } if (ability.EnergyCost > 0) { if (stringBuilder.ToString() != "") { stringBuilder.Append(", "); } stringBuilder.Append(ability.EnergyCost + " energy"); } if (ability.HealthCost > 0) { if (stringBuilder.ToString() != "") { stringBuilder.Append(", "); } stringBuilder.Append(ability.HealthCost + " health"); } return description.Replace(text, (stringBuilder.ToString() == "") ? "nothing" : stringBuilder.ToString()); } } string[] array = description.Split(new char[1] { ' ' }); bool flag = ability.energyCostMod == 0; bool flag2 = ability.bonesCostMod == 0; bool flag3 = ability.healthCostMod == 0; for (int i = 0; i < array.Length; i++) { if (flag && flag2 && flag3) { break; } if (!array[i].Any((char c) => char.IsDigit(c))) { continue; } string text2 = array[i + 1].ToLowerInvariant(); if (!text2.Contains("energy") && !text2.Contains("bone") && !text2.Contains("health")) { continue; } string text3 = ""; string text4 = array[i]; for (int j = 0; j < text4.Length; j++) { char c2 = text4[j]; if (char.IsDigit(c2)) { text3 += c2; } } if (!flag && text2.Contains("energy")) { flag = true; array[i] = array[i].Replace(text3, ability.EnergyCost.ToString()); } else if (!flag2 && text2.Contains("bone")) { flag2 = true; array[i] = array[i].Replace(text3, ability.BonesCost.ToString()); if (text2.Contains("bones")) { if (ability.BonesCost == 1) { array[i + 1] = text2.Replace("bones", "bone"); } } else if (ability.BonesCost != 1) { array[i + 1] = text2.Replace("bone", "bones"); } } else if (!flag3 && text2.Contains("health") && array[i - 1].ToLowerInvariant() != "power") { flag3 = true; array[i] = array[i].Replace(text3, ability.HealthCost.ToString()); } } return GeneralExtensions.Join((IEnumerable)array, (Func)null, " "); } [HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })] [HarmonyPostfix] private static void FixRulebook(AbilityMetaCategory metaCategory, RuleBookInfo __instance, ref List __result) { //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) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected I4, but got Unknown if (NewAbilities.Count <= 0) { return; } foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges) { if ((int)pageRangeInfo.type != 0) { continue; } int num = 107; int num2 = __result.FindLastIndex((RuleBookPageInfo rbi) => (Object)(object)rbi.pagePrefab == (Object)(object)pageRangeInfo.rangePrefab) + 1; foreach (FullAbility item in NewAbilities.Where((FullAbility x) => __instance.AbilityShouldBeAdded((int)x.Id, metaCategory)).ToList()) { RuleBookPageInfo val = new RuleBookPageInfo(); val.pagePrefab = pageRangeInfo.rangePrefab; val.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION I - MOD ABILITIES {0}"), num); __instance.FillAbilityPage(val, pageRangeInfo, (int)item.Id); __result.Insert(num2, val); num++; num2++; } } } [IteratorStateMachine(typeof(d__36))] [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "TransformIntoCard")] private static IEnumerator TriggerStacksOnceAfterEvolve(IEnumerator enumerator, PlayableCard __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__36(0) { enumerator = enumerator, __instance = __instance }; } internal static void FixStackTriggers(PlayableCard __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) List source = __instance.TriggerHandler.triggeredAbilities.ConvertAll((Tuple x) => x.Item1); foreach (Ability ab in source.Distinct()) { AbilityInfo val = AllAbilityInfos.AbilityByID(ab); if (val.passive || !val.canStack || !val.GetTriggersOncePerStack()) { continue; } for (int i = 0; i < source.Count((Ability x) => x == ab) / 2; i++) { Tuple item = __instance.TriggerHandler.triggeredAbilities.Find((Tuple x) => x.Item1 == ab); __instance.TriggerHandler.triggeredAbilities.Remove(item); } } } [IteratorStateMachine(typeof(d__38))] [HarmonyPatch(typeof(GlobalTriggerHandler), "TriggerCardsOnBoard")] [HarmonyPostfix] private static IEnumerator WaterborneFix(IEnumerator result, Trigger trigger, bool triggerFacedown, params object[] otherArgs) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__38(0) { result = result, trigger = trigger, triggerFacedown = triggerFacedown, otherArgs = otherArgs }; } [HarmonyTranspiler] [HarmonyPatch(typeof(AbilityIconInteractable), "AssignAbility")] public static IEnumerable AbilityIconInteractable_AssignAbility(IEnumerable instructions) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown List list = new List(instructions); MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => LogAbilityInfo((Ability)93, null, null))); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Stloc_1) { list.Insert(++i, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); list.Insert(++i, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(++i, new CodeInstruction(OpCodes.Ldarg_2, (object)null)); list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); break; } } return list; } private static void LogAbilityInfo(Ability ability, AbilityInfo abilityInfo, CardInfo info) { if ((Object)(object)abilityInfo == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("Cannot find ability " + ((object)(Ability)(ref ability)).ToString() + " for " + info.displayedName)); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable AddInherentModsToIceCube(IEnumerable instructions) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldloc_2) { MethodInfo methodInfo = AccessTools.Method(typeof(AbilityManager), "GetIceCubeInfoWithMods", new Type[2] { typeof(IceCube), typeof(string) }, (Type[])null); list[i + 1] = new CodeInstruction(OpCodes.Call, (object)methodInfo); list.Insert(i, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); break; } } return list; } private static CardInfo GetIceCubeInfoWithMods(IceCube instance, string cardName) { CardInfo cardByName = CardLoader.GetCardByName(cardName); if (((Card)((AbilityBehaviour)instance).Card).Info.iceCubeParams != null && (Object)(object)((Card)((AbilityBehaviour)instance).Card).Info.iceCubeParams.creatureWithin != (Object)null && ((Card)((AbilityBehaviour)instance).Card).Info.iceCubeParams.creatureWithin.mods != null && ((Card)((AbilityBehaviour)instance).Card).Info.iceCubeParams.creatureWithin.mods.Count > 0) { cardByName.Mods.AddRange(((Card)((AbilityBehaviour)instance).Card).Info.iceCubeParams.creatureWithin.mods); } return cardByName; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable EvolveOnUpkeepPatches(IEnumerable instructions) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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 List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_5) { MethodInfo methodInfo = AccessTools.Method(typeof(AbilityManager), "OverrideEvolveDerivedIcon", new Type[2] { typeof(Evolve), typeof(int) }, (Type[])null); i -= 2; int num = list.FindIndex(i, (CodeInstruction x) => x.opcode == OpCodes.Ldloc_1); list.RemoveRange(i, num - i); list.Insert(i++, new CodeInstruction(OpCodes.Ldloc_3, (object)null)); list.Insert(i++, new CodeInstruction(OpCodes.Call, (object)methodInfo)); } else if (list[i].opcode == OpCodes.Stfld && list[i].operand.ToString() == "DiskCardGame.CardInfo 5__2") { object operand = list[i].operand; MethodInfo methodInfo2 = AccessTools.Method(typeof(AbilityManager), "RemoveDuplicateMods", new Type[2] { typeof(Evolve), typeof(CardInfo) }, (Type[])null); i += 2; list.Insert(i++, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(i++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i++, new CodeInstruction(OpCodes.Ldfld, operand)); list.Insert(i++, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); break; } } return list; } [HarmonyPrefix] [HarmonyPatch(typeof(AbilityIconInteractable), "LoadIcon")] private static bool OverrideTransformIcon(ref Texture __result, AbilityIconInteractable __instance, CardInfo info, AbilityInfo ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 if ((int)ability.ability == 61 && info != null && info.evolveParams?.turnsToEvolve > 1) { __result = (Texture)(object)TextureHelper.GetImageAsTexture($"ability_transformer_{Mathf.Min(info.evolveParams.turnsToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly, (FilterMode)0); return false; } if ((int)ability.ability == 5 && info != null && info.evolveParams?.turnsToEvolve > 3) { __result = (Texture)(object)TextureHelper.GetImageAsTexture($"ability_evolve_{Mathf.Min(info.evolveParams.turnsToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly, (FilterMode)0); return false; } return true; } private static void OverrideEvolveDerivedIcon(Evolve evolve, int turnsLeftToEvolve) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 if ((int)((AbilityBehaviour)evolve).Ability == 5) { if (turnsLeftToEvolve > 3) { ((Card)((AbilityBehaviour)evolve).Card).RenderInfo.OverrideAbilityIcon((Ability)5, (Texture)(object)TextureHelper.GetImageAsTexture($"ability_evolve_{Mathf.Min(turnsLeftToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly, (FilterMode)0)); } else { ((Card)((AbilityBehaviour)evolve).Card).RenderInfo.OverrideAbilityIcon((Ability)5, ResourceBank.Get("Art/Cards/AbilityIcons/ability_evolve_" + turnsLeftToEvolve)); } } else if ((int)((AbilityBehaviour)evolve).Ability == 61 && (((Card)((AbilityBehaviour)evolve).Card).Info.evolveParams?.turnsToEvolve ?? 1) != 1) { ((Card)((AbilityBehaviour)evolve).Card).RenderInfo.OverrideAbilityIcon((Ability)61, (Texture)(object)TextureHelper.GetImageAsTexture($"ability_transformer_{Mathf.Min(turnsLeftToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly, (FilterMode)0)); } } private static void RemoveDuplicateMods(Evolve instance, CardInfo evolution) { evolution.Mods.RemoveAll(((Card)((AbilityBehaviour)instance).Card).Info.Mods.Contains); } [HarmonyPostfix] [HarmonyPatch(typeof(Evolve), "RemoveTemporaryModsWithEvolve")] private static void ResetOverrideAndTurnsInPlay(Evolve __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) __instance.numTurnsInPlay = 0; if (((Card)((AbilityBehaviour)__instance).Card).RenderInfo.overriddenAbilityIcons.ContainsKey(((AbilityBehaviour)__instance).Ability)) { ((Card)((AbilityBehaviour)__instance).Card).RenderInfo.overriddenAbilityIcons.Remove(((AbilityBehaviour)__instance).Ability); ((Card)((AbilityBehaviour)__instance).Card).StatsLayer.RenderCard(((Card)((AbilityBehaviour)__instance).Card).RenderInfo); } } [HarmonyPostfix] [HarmonyPatch(typeof(Transformer), "GetBeastModeStatsMod")] private static void ModifyOtherTransformerCosts(ref CardModificationInfo __result, CardInfo beastModeCard, CardInfo botModeCard) { __result.SetBloodCost(botModeCard.BloodCost - beastModeCard.BloodCost).SetBonesCost(botModeCard.BonesCost - beastModeCard.BonesCost); } [HarmonyPostfix] [HarmonyPatch(typeof(Transformer), "GetTransformCardInfo")] private static void ChangeTransformerInfoMethod(Transformer __instance, ref CardInfo __result) { __result = NewGetTransformCardInfo(((AbilityBehaviour)__instance).Card); } private static CardInfo NewGetTransformCardInfo(PlayableCard card) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown string text = ((Card)card).Info.Mods.Find((CardModificationInfo x) => !string.IsNullOrEmpty(x.transformerBeastCardId) && x.transformerBeastCardId != ((Object)((Card)card).Info).name)?.transformerBeastCardId; if (text == null) { object obj = ((Card)card).Info.GetTransformerCardId(); if (obj == null) { EvolveParams evolveParams = ((Card)card).Info.evolveParams; if (evolveParams == null) { obj = null; } else { CardInfo evolution = evolveParams.evolution; obj = ((evolution != null) ? ((Object)evolution).name : null); } } if (obj == null) { obj = "CXformerAdder"; } text = (string)obj; } CardInfo cardByName = CardLoader.GetCardByName(text); CardModificationInfo beastModeStatsMod = Transformer.GetBeastModeStatsMod(cardByName, ((Card)card).Info); beastModeStatsMod.nameReplacement = ((Card)card).Info.DisplayedNameEnglish; beastModeStatsMod.nonCopyable = true; cardByName.Mods.Add(beastModeStatsMod); if (cardByName.LacksAbility((Ability)61)) { cardByName.Mods.Add(new CardModificationInfo((Ability)61) { nonCopyable = true }); cardByName.SetEvolve(((Card)card).Info, 1); } if (((Card)card).Info.HasSpecialAbility((SpecialTriggeredAbility)9)) { ((Card)card).RenderInfo.prefabPortrait = null; ((Card)card).RenderInfo.hidePortrait = false; ((Card)card).ClearAppearanceBehaviours(); Singleton.Instance.StopLiveRenderCard(((Card)card).StatsLayer); } return cardByName; } [HarmonyPostfix] [HarmonyPatch(typeof(AbilityIconInteractable), "LoadIcon")] private static void LoadTransformerIcon(ref Texture __result, CardInfo info, AbilityInfo ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)ability.ability == 61) { int valueOrDefault = (info?.evolveParams?.turnsToEvolve).GetValueOrDefault(1); if (valueOrDefault > 1) { __result = (Texture)(object)TextureHelper.GetImageAsTexture($"ability_transformer_{valueOrDefault}.png", InscryptionAPIPlugin.APIAssembly, (FilterMode)0); } } } [HarmonyPatch(typeof(SquirrelOrbit), "OnUpkeep")] [HarmonyPrefix] private static bool FixSquirrelOrbit(SquirrelOrbit __instance, ref IEnumerator __result) { __result = BetterSquirrelOrbit(__instance); return false; } [IteratorStateMachine(typeof(d__53))] private static IEnumerator BetterSquirrelOrbit(SquirrelOrbit instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__53(0) { instance = instance }; } [CompilerGenerated] internal static bool g__RespondsToTrigger|38_0(CardTriggerHandler r, Trigger trigger, object[] otherArgs) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) foreach (TriggerReceiver allReceiver in r.GetAllReceivers()) { if (GlobalTriggerHandler.ReceiverRespondsToTrigger(trigger, allReceiver, otherArgs) && allReceiver is IActivateWhenFacedown && (allReceiver as IActivateWhenFacedown).ShouldTriggerWhenFaceDown(trigger, otherArgs)) { return true; } } return false; } [IteratorStateMachine(typeof(<g__OnTrigger|38_1>d))] [CompilerGenerated] internal static IEnumerator g__OnTrigger|38_1(CardTriggerHandler r, Trigger trigger, object[] otherArgs) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <g__OnTrigger|38_1>d(0) { r = r, trigger = trigger, otherArgs = otherArgs }; } } internal class Part2ModularAbilities { internal static readonly List BasePart2Modular = new List { (Ability)1, (Ability)2, (Ability)3, (Ability)4, (Ability)5, (Ability)6, (Ability)7, (Ability)8, (Ability)9, (Ability)10, (Ability)11, (Ability)12, (Ability)13, (Ability)14, (Ability)15, (Ability)16, (Ability)17, (Ability)18, (Ability)19, (Ability)20, (Ability)22, (Ability)23, (Ability)24, (Ability)26, (Ability)30, (Ability)34, (Ability)83, (Ability)99, (Ability)102, (Ability)105, (Ability)100, (Ability)104, (Ability)103, (Ability)54, (Ability)28, (Ability)101, (Ability)51, (Ability)63, (Ability)52, (Ability)53, (Ability)57, (Ability)58, (Ability)56, (Ability)62, (Ability)64, (Ability)65, (Ability)72, (Ability)84, (Ability)86, (Ability)88, (Ability)36, (Ability)40, (Ability)41, (Ability)42, (Ability)45, (Ability)46, (Ability)68, (Ability)79 }; } public static class CardAppearanceBehaviourManager { public class FullCardAppearanceBehaviour { public readonly Appearance Id; public readonly Type AppearanceBehaviour; public FullCardAppearanceBehaviour(Appearance id, Type appearanceBehaviour) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Id = id; AppearanceBehaviour = appearanceBehaviour; TypeManager.Add(((object)(Appearance)(ref id)).ToString(), appearanceBehaviour); } } public static readonly ReadOnlyCollection BaseGameAppearances; private static readonly ObservableCollection NewAppearances; public static List AllAppearances { get; private set; } static CardAppearanceBehaviourManager() { BaseGameAppearances = new ReadOnlyCollection(GenBaseGameAppearanceList()); NewAppearances = new ObservableCollection(); AllAppearances = BaseGameAppearances.ToList(); NewAppearances.CollectionChanged += delegate { AllAppearances = BaseGameAppearances.Concat(NewAppearances).ToList(); }; } private static List GenBaseGameAppearanceList() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Assembly assembly = typeof(CardAppearanceBehaviour).Assembly; foreach (Appearance value in Enum.GetValues(typeof(Appearance))) { Appearance id = value; string text = ((object)(Appearance)(ref id)).ToString(); list.Add(new FullCardAppearanceBehaviour(id, assembly.GetType("DiskCardGame." + text))); } return list; } public static FullCardAppearanceBehaviour Add(string guid, string abilityName, Type behavior) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) FullCardAppearanceBehaviour fullCardAppearanceBehaviour = new FullCardAppearanceBehaviour(GuidManager.GetEnumValue(guid, abilityName), behavior); NewAppearances.Add(fullCardAppearanceBehaviour); return fullCardAppearanceBehaviour; } public static void Remove(Appearance id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) NewAppearances.Remove(NewAppearances.FirstOrDefault((FullCardAppearanceBehaviour x) => x.Id == id)); } public static void Remove(FullCardAppearanceBehaviour ability) { NewAppearances.Remove(ability); } } public static class CardExtensions { [CompilerGenerated] private sealed class d__111 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Vector3 spawnOffset; public CardInfo cardInfo; public List temporaryMods; public float onDrawnTriggerDelay; public Action cardSpawnedCallback; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__111(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0018: 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_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (spawnOffset == default(Vector3)) { spawnOffset = Singleton.Instance.spawnedPositionOffset; } <>2__current = Singleton.Instance.SpawnCardToHand(cardInfo, temporaryMods, spawnOffset, onDrawnTriggerDelay, cardSpawnedCallback); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__96 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; public Action preTransformCallback; public CardInfo evolvedInfo; public Action onTransformedCallback; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__96(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; Singleton.Instance.SwitchToView((View)1, false, false); PlayerHand instance = Singleton.Instance; PlayerHand obj = ((instance is PlayerHand3D) ? instance : null); if (obj != null) { ((PlayerHand3D)obj).MoveCardAboveHand(card); } <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 1; return true; } case 1: <>1__state = -1; <>2__current = ((Card)card).Anim.FlipInAir(); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 3; return true; case 3: <>1__state = -1; preTransformCallback?.Invoke(); ((Card)card).SetInfo(evolvedInfo); onTransformedCallback?.Invoke(); AbilityManager.FixStackTriggers(card); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__95 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard card; public Action preTransformCallback; public CardInfo evolvedInfo; public Action onTransformedCallback; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__95(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; Singleton.Instance.SwitchToView((View)0, false, false); <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = ((Card)card).Anim.FlipInAir(); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 3; return true; case 3: <>1__state = -1; preTransformCallback?.Invoke(); ((Card)card).SetInfo(evolvedInfo); onTransformedCallback?.Invoke(); AbilityManager.FixStackTriggers(card); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static CardInfo CardByName(this IEnumerable cards, string name) { return cards.FirstOrDefault((Func)((CardInfo c) => ((Object)c).name.Equals(name))); } private static Sprite GetPortrait(Texture2D portrait, TextureHelper.SpriteType spriteType, FilterMode? filterMode = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return portrait.ConvertTexture(spriteType, filterMode.GetValueOrDefault()); } public static CardInfo AddAbilities(this CardInfo info, params Ability[] abilities) { if (info.abilities == null) { info.abilities = new List(); } info.abilities.AddRange(abilities); return info; } public static CardInfo AddAppearances(this CardInfo info, params Appearance[] appearances) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (info.appearanceBehaviour == null) { info.appearanceBehaviour = new List(); } foreach (Appearance item in appearances) { if (!info.appearanceBehaviour.Contains(item)) { info.appearanceBehaviour.Add(item); } } return info; } public static CardInfo AddDecal(this CardInfo info, params Texture[] decals) { if (info.decals == null) { info.decals = new List(); } foreach (Texture item in decals) { if (!info.decals.Contains(item)) { info.decals.Add(item); } } return info; } public static CardInfo AddDecal(this CardInfo info, params string[] decals) { if (decals != null) { Texture[] decals2 = (Texture[])(object)decals.Select((string d) => TextureHelper.GetImageAsTexture(d, (FilterMode)0)).ToArray(); return info.AddDecal(decals2); } return info; } public static CardInfo AddMetaCategories(this CardInfo info, params CardMetaCategory[] categories) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (info.metaCategories == null) { info.metaCategories = new List(); } foreach (CardMetaCategory item in categories) { if (!info.metaCategories.Contains(item)) { info.metaCategories.Add(item); } } return info; } public static CardInfo AddSpecialAbilities(this CardInfo info, params SpecialTriggeredAbility[] abilities) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (info.specialAbilities == null) { info.specialAbilities = new List(); } foreach (SpecialTriggeredAbility item in abilities) { if (!info.specialAbilities.Contains(item)) { info.specialAbilities.Add(item); } } return info; } public static CardInfo AddTraits(this CardInfo info, params Trait[] traits) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (info.traits == null) { info.traits = new List(); } foreach (Trait item in traits) { if (!info.traits.Contains(item)) { info.traits.Add(item); } } return info; } public static CardInfo AddTribes(this CardInfo info, params Tribe[] tribes) { //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (info.tribes == null) { info.tribes = new List(); } foreach (Tribe item in tribes) { if (!info.tribes.Contains(item)) { info.tribes.Add(item); } } return info; } public static CardInfo RemoveAbilities(this CardInfo info, params Ability[] abilities) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) List abilities2 = info.abilities; if (abilities2 != null && abilities2.Count > 0) { foreach (Ability ab in abilities) { info.abilities.RemoveAll((Ability a) => a == ab); } } return info; } public static CardInfo RemoveAbilitiesSingle(this CardInfo info, params Ability[] abilities) { //IL_0020: 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) List abilities2 = info.abilities; if (abilities2 != null && abilities2.Count > 0) { foreach (Ability item in abilities) { info.abilities.Remove(item); } } return info; } public static CardInfo RemoveSpecialAbilities(this CardInfo info, params SpecialTriggeredAbility[] abilities) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) List specialAbilities = info.specialAbilities; if (specialAbilities != null && specialAbilities.Count > 0) { foreach (SpecialTriggeredAbility ab in abilities) { info.specialAbilities.RemoveAll((SpecialTriggeredAbility a) => a == ab); } } return info; } public static CardInfo RemoveSpecialAbilitiesSingle(this CardInfo info, params SpecialTriggeredAbility[] abilities) { //IL_0020: 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) List specialAbilities = info.specialAbilities; if (specialAbilities != null && specialAbilities.Count > 0) { foreach (SpecialTriggeredAbility item in abilities) { info.specialAbilities.Remove(item); } } return info; } public static CardInfo RemoveAppearances(this CardInfo info, params Appearance[] appearances) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) List appearanceBehaviour = info.appearanceBehaviour; if (appearanceBehaviour != null && appearanceBehaviour.Count > 0) { foreach (Appearance app in appearances) { info.appearanceBehaviour.RemoveAll((Appearance a) => a == app); } } return info; } public static CardInfo RemoveAppearancesSingle(this CardInfo info, params Appearance[] appearances) { //IL_0020: 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) List appearanceBehaviour = info.appearanceBehaviour; if (appearanceBehaviour != null && appearanceBehaviour.Count > 0) { foreach (Appearance item in appearances) { info.appearanceBehaviour.Remove(item); } } return info; } public static CardInfo RemoveDecals(this CardInfo info, params Texture[] decals) { List decals2 = info.decals; if (decals2 != null && decals2.Count > 0) { foreach (Texture dec in decals) { info.decals.RemoveAll((Texture d) => (Object)(object)d == (Object)(object)dec); } } return info; } public static CardInfo RemoveDecalsSingle(this CardInfo info, params Texture[] decals) { List decals2 = info.decals; if (decals2 != null && decals2.Count > 0) { foreach (Texture item in decals) { info.decals.Remove(item); } } return info; } public static CardInfo RemoveMetaCategories(this CardInfo info, params CardMetaCategory[] categories) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) List metaCategories = info.metaCategories; if (metaCategories != null && metaCategories.Count > 0) { foreach (CardMetaCategory cat in categories) { info.metaCategories.RemoveAll((CardMetaCategory c) => c == cat); } } return info; } public static CardInfo RemoveMetaCategoriesSingle(this CardInfo info, params CardMetaCategory[] categories) { //IL_0020: 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) List metaCategories = info.metaCategories; if (metaCategories != null && metaCategories.Count > 0) { foreach (CardMetaCategory item in categories) { info.metaCategories.Remove(item); } } return info; } public static CardInfo RemoveTraits(this CardInfo info, params Trait[] traits) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) List traits2 = info.traits; if (traits2 != null && traits2.Count > 0) { foreach (Trait val in traits) { if (info.HasTrait(val)) { info.traits.Remove(val); } } } return info; } public static CardInfo RemoveTribes(this CardInfo info, params Tribe[] tribes) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) List traits = info.traits; if (traits != null && traits.Count > 0) { foreach (Tribe val in tribes) { if (info.IsOfTribe(val)) { info.tribes.Remove(val); } } } return info; } public static CardInfo RemoveCardMetaCategories(this CardInfo info, params CardMetaCategory[] cardMetaCategories) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) List metaCategories = info.metaCategories; if (metaCategories != null && metaCategories.Count > 0) { foreach (CardMetaCategory val in cardMetaCategories) { if (info.HasCardMetaCategory(val)) { info.metaCategories.Remove(val); } } } return info; } internal static CardInfo SetModTag(this CardInfo info, string modGuid) { return info.SetExtendedProperty("CallStackModGUID", modGuid); } public static string GetModTag(this CardInfo info) { return info.GetExtendedProperty("CallStackModGUID"); } internal static CardInfo SetModPrefix(this CardInfo info, string modPrefix) { return info.SetExtendedProperty("ModPrefix", modPrefix); } public static string GetModPrefix(this CardInfo info) { return info.GetExtendedProperty("ModPrefix"); } public static bool ModPrefixIs(this CardInfo info, string prefixToMatch) { return info.GetExtendedProperty("ModPrefix") == prefixToMatch; } public static PlayableCard GetPlayableCard(this CardInfo cardInfo) { if (InscryptionAPI.Card.CostProperties.CostProperties.CardInfoToCard.TryGetValue(cardInfo, out var value)) { for (int num = value.Count - 1; num >= 0; num--) { if (value[num].TryGetTarget(out var target) && (Object)(object)target != (Object)null) { return target; } value.RemoveAt(num); } } return null; } public static int BloodCost(this PlayableCard card) { if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Info != (Object)null) { int num = InscryptionAPI.Card.CostProperties.CostProperties.OriginalBloodCost(((Card)card).Info); if (card.IsUsingBlueGem() && InscryptionAPI.Card.CostProperties.CostProperties.ReduceGemifiedBlood(card, num)) { num--; } { foreach (CardModificationInfo temporaryMod in card.TemporaryMods) { num += temporaryMod.bloodCostAdjustment; } return num; } } InscryptionAPIPlugin.Logger.LogWarning((object)"[BloodCost] Couldn't find PlayableCard or CardInfo, returning 0"); return 0; } public static int BonesCost(this PlayableCard card) { if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Info != (Object)null) { int num = InscryptionAPI.Card.CostProperties.CostProperties.OriginalBonesCost(((Card)card).Info); if (card.IsUsingBlueGem() && InscryptionAPI.Card.CostProperties.CostProperties.ReduceGemifiedBones(card, num)) { num--; } { foreach (CardModificationInfo temporaryMod in card.TemporaryMods) { num += temporaryMod.bonesCostAdjustment; } return num; } } InscryptionAPIPlugin.Logger.LogWarning((object)"[BonesCost] Couldn't find PlayableCard or CardInfo, returning 0"); return 0; } public static List GemsCost(this PlayableCard card) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)card == (Object)null || (Object)(object)((Card)card).Info == (Object)null) { InscryptionAPIPlugin.Logger.LogWarning((object)"[GemsCost] Couldn't find PlayableCard or CardInfo, returning empty list"); return new List(); } List list = card.TemporaryMods.Concat(((Card)card).Info.Mods).ToList(); if (list.Exists((CardModificationInfo x) => x.nullifyGemsCost)) { return new List(); } List list2 = new List(((Card)card).Info.gemsCost); foreach (CardModificationInfo item in list) { if (item.addGemCost != null) { list2.AddRange(item.addGemCost); } foreach (GemType item2 in item.RemovedGemsCosts()) { list2.Remove(item2); } } if (card.IsUsingBlueGem() && InscryptionAPI.Card.CostProperties.CostProperties.ReduceGemifiedMox(card, list2)) { list2.RemoveAt(0); } return list2; } public static bool IsGemified(this PlayableCard card) { if (!((Card)card).Info.Gemified) { return card.TemporaryMods.Exists((CardModificationInfo x) => x.gemify); } return true; } public static bool OwnerHasBlueGem(this PlayableCard card) { if (!card.OpponentCard) { return Singleton.Instance.HasGem((GemType)2); } return Singleton.Instance.HasGem((GemType)2); } public static bool IsUsingBlueGem(this PlayableCard card) { if (card.IsGemified()) { return card.OwnerHasBlueGem(); } return false; } public static bool ProvidesBlueGem(this PlayableCard card) { if (!card.HasAbility((Ability)44)) { return card.HasAbility((Ability)39); } return true; } public static bool ProvidesGreenGem(this PlayableCard card) { if (!card.HasAbility((Ability)44)) { return card.HasAbility((Ability)37); } return true; } public static bool ProvidesOrangeGem(this PlayableCard card) { if (!card.HasAbility((Ability)44)) { return card.HasAbility((Ability)38); } return true; } public static bool ProvidesBlueGem(this CardInfo card) { if (!card.HasAbility((Ability)44)) { return card.HasAbility((Ability)39); } return true; } public static bool ProvidesGreenGem(this CardInfo card) { if (!card.HasAbility((Ability)44)) { return card.HasAbility((Ability)37); } return true; } public static bool ProvidesOrangeGem(this CardInfo card) { if (!card.HasAbility((Ability)44)) { return card.HasAbility((Ability)38); } return true; } public static bool LacksAbility(this CardModificationInfo mod, Ability ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !mod.HasAbility(ability); } public static bool LacksAbility(this CardInfo cardInfo, Ability ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !cardInfo.HasAbility(ability); } public static bool HasAllAbilities(this CardInfo cardInfo, params Ability[] abilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Ability ability in abilities) { if (cardInfo.LacksAbility(ability)) { return false; } } return true; } public static bool LacksAllAbilities(this CardInfo cardInfo, params Ability[] abilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Ability val in abilities) { if (cardInfo.HasAbility(val)) { return false; } } return true; } public static bool HasAnyOfAbilities(this CardInfo cardInfo, params Ability[] abilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Ability val in abilities) { if (cardInfo.HasAbility(val)) { return true; } } return false; } public static bool HasSpecialAbility(this CardInfo cardInfo, SpecialTriggeredAbility ability) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return cardInfo.SpecialAbilities.Contains(ability); } public static bool LacksSpecialAbility(this CardInfo cardInfo, SpecialTriggeredAbility ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !cardInfo.HasSpecialAbility(ability); } public static bool HasAllSpecialAbilities(this CardInfo cardInfo, params SpecialTriggeredAbility[] specialAbilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (SpecialTriggeredAbility ability in specialAbilities) { if (cardInfo.LacksSpecialAbility(ability)) { return false; } } return true; } public static bool LacksAllSpecialAbilities(this CardInfo cardInfo, params SpecialTriggeredAbility[] specialAbilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (SpecialTriggeredAbility ability in specialAbilities) { if (cardInfo.HasSpecialAbility(ability)) { return false; } } return true; } public static bool HasAnyOfSpecialAbilities(this CardInfo cardInfo, params SpecialTriggeredAbility[] specialAbilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (SpecialTriggeredAbility ability in specialAbilities) { if (cardInfo.HasSpecialAbility(ability)) { return true; } } return false; } public static bool IsNotOfTribe(this CardInfo cardInfo, Tribe tribe) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !cardInfo.IsOfTribe(tribe); } public static bool LacksTrait(this CardInfo cardInfo, Trait trait) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !cardInfo.HasTrait(trait); } public static bool HasAllTraits(this CardInfo cardInfo, params Trait[] traits) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Trait trait in traits) { if (cardInfo.LacksTrait(trait)) { return false; } } return true; } public static bool LacksAllTraits(this CardInfo cardInfo, params Trait[] traits) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Trait val in traits) { if (cardInfo.HasTrait(val)) { return false; } } return true; } public static bool HasAnyOfTraits(this CardInfo cardInfo, params Trait[] traits) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Trait val in traits) { if (cardInfo.HasTrait(val)) { return true; } } return false; } public static bool IsPelt(this CardInfo cardInfo) { return cardInfo.HasTrait((Trait)13); } public static bool IsTerrain(this CardInfo cardInfo) { return cardInfo.HasTrait((Trait)12); } public static bool HasCardMetaCategory(this CardInfo cardInfo, CardMetaCategory metaCategory) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return cardInfo.metaCategories.Contains(metaCategory); } public static bool LacksCardMetaCategory(this CardInfo cardInfo, CardMetaCategory metaCategory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !cardInfo.HasCardMetaCategory(metaCategory); } public static bool HasAnyOfCardMetaCategories(this CardInfo cardInfo, params CardMetaCategory[] metaCategories) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (CardMetaCategory metaCategory in metaCategories) { if (cardInfo.HasCardMetaCategory(metaCategory)) { return true; } } return false; } public static bool LacksAllCardMetaCategories(this CardInfo cardInfo, params CardMetaCategory[] metaCategories) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (CardMetaCategory metaCategory in metaCategories) { if (cardInfo.HasCardMetaCategory(metaCategory)) { return false; } } return true; } public static int GetStatIconHealthBuffs(this PlayableCard card) { int num = 0; foreach (CardModificationInfo temporaryMod in card.TemporaryMods) { if (temporaryMod.singletonId == "VARIABLE_STAT") { num += temporaryMod.healthAdjustment; } } return num; } public static int GetAbilityStacks(this PlayableCard card, Ability ability) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) int num = 0; num += ((Card)card).Info.Abilities.Count((Ability a) => a == ability); num += AbilitiesUtil.GetAbilitiesFromMods(card.TemporaryMods).Count((Ability a) => a == ability); num -= card.TemporaryMods.SelectMany((CardModificationInfo m) => m.negateAbilities).Count((Ability a) => a == ability); if (num <= 0) { return 0; } if (!AbilitiesUtil.GetInfo(ability).canStack) { return 1; } return num; } public static int GetAbilityStacks(this CardInfo info, Ability ability) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) int num = info.Abilities.Count((Ability a) => a == ability); if (num == 0) { return 0; } if (!AbilitiesUtil.GetInfo(ability).canStack) { return 1; } return num; } public static bool OtherCardIsOnSameSide(this PlayableCard playableCard, PlayableCard otherCard) { if (playableCard.OnBoard && otherCard.OnBoard) { return playableCard.OpponentCard == otherCard.OpponentCard; } return false; } public static List AllAbilities(this PlayableCard playableCard) { return playableCard.GetAbilitiesFromAllMods().Concat(((Card)playableCard).Info.Abilities).ToList(); } public static List AllAbilities(this PlayableCard playableCard, bool accountForNegation) { List retval = playableCard.AllAbilities(); if (!accountForNegation) { return retval; } playableCard.TemporaryMods.ForEach(delegate(CardModificationInfo m) { m.negateAbilities?.ForEach(delegate(Ability a) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) retval.Remove(a); }); }); return retval; } public static List AllCardModificationInfos(this PlayableCard playableCard) { return playableCard.TemporaryMods.Concat(((Card)playableCard).Info.Mods).ToList(); } public static bool RemoveCardModificationInfo(this PlayableCard playableCard, CardModificationInfo modToRemove, bool updateDisplay = true) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (modToRemove == null) { return false; } if (playableCard.TemporaryMods.Contains(modToRemove)) { playableCard.RemoveTemporaryMod(modToRemove, updateDisplay); return true; } if (((Card)playableCard).Info.Mods.Contains(modToRemove)) { ((Card)playableCard).Info.Mods.Remove(modToRemove); foreach (Ability ability in modToRemove.abilities) { playableCard.TriggerHandler.RemoveAbility(ability); } if (updateDisplay) { playableCard.OnStatsChanged(); } return true; } return false; } public static List AllSpecialAbilities(this PlayableCard playableCard) { return new List(playableCard.TemporaryMods.Concat(((Card)playableCard).Info.Mods).SelectMany((CardModificationInfo mod) => mod.specialAbilities)); } public static List GetAbilitiesFromAllMods(this PlayableCard playableCard) { return AbilitiesUtil.GetAbilitiesFromMods(playableCard.TemporaryMods.Concat(((Card)playableCard).Info.Mods).ToList()); } public static bool HasTrait(this PlayableCard playableCard, Trait trait) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Card)playableCard).Info.HasTrait(trait); } public static bool LacksTrait(this PlayableCard playableCard, Trait trait) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Card)playableCard).Info.LacksTrait(trait); } public static bool HasAllTraits(this PlayableCard playableCard, params Trait[] traits) { return ((Card)playableCard).Info.HasAllTraits(traits); } public static bool LacksAllTraits(this PlayableCard playableCard, params Trait[] traits) { return ((Card)playableCard).Info.LacksAllTraits(traits); } public static bool HasAnyOfTraits(this PlayableCard playableCard, params Trait[] traits) { return ((Card)playableCard).Info.HasAnyOfTraits(traits); } public static bool IsOfTribe(this PlayableCard playableCard, Tribe tribe) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Card)playableCard).Info.IsOfTribe(tribe); } public static bool IsNotOfTribe(this PlayableCard playableCard, Tribe tribe) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Card)playableCard).Info.IsNotOfTribe(tribe); } public static bool NotDead(this PlayableCard playableCard) { if (Object.op_Implicit((Object)(object)playableCard)) { return !playableCard.Dead; } return false; } public static bool IsPlayerCard(this PlayableCard playableCard) { return !playableCard.OpponentCard; } public static bool LacksAbility(this PlayableCard playableCard, Ability ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !playableCard.HasAbility(ability); } public static bool HasAllAbilities(this PlayableCard playableCard, params Ability[] abilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Ability ability in abilities) { if (playableCard.LacksAbility(ability)) { return false; } } return true; } public static bool LacksAllAbilities(this PlayableCard playableCard, params Ability[] abilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Ability val in abilities) { if (playableCard.HasAbility(val)) { return false; } } return true; } public static bool HasAnyOfAbilities(this PlayableCard playableCard, params Ability[] abilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (Ability val in abilities) { if (playableCard.HasAbility(val)) { return true; } } return false; } public static bool LacksSpecialAbility(this PlayableCard playableCard, SpecialTriggeredAbility ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !playableCard.HasSpecialAbility(ability); } public static bool HasSpecialAbility(this PlayableCard playableCard, SpecialTriggeredAbility ability) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!playableCard.TemporaryMods.Exists((CardModificationInfo mod) => mod.specialAbilities.Contains(ability))) { return ((Card)playableCard).Info.HasSpecialAbility(ability); } return true; } public static bool HasAllSpecialAbilities(this PlayableCard playableCard, params SpecialTriggeredAbility[] specialAbilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (SpecialTriggeredAbility ability in specialAbilities) { if (playableCard.LacksSpecialAbility(ability)) { return false; } } return true; } public static bool LacksAllSpecialAbilities(this PlayableCard playableCard, params SpecialTriggeredAbility[] specialAbilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (SpecialTriggeredAbility ability in specialAbilities) { if (playableCard.HasSpecialAbility(ability)) { return false; } } return true; } public static bool HasAnyOfSpecialAbilities(this PlayableCard playableCard, params SpecialTriggeredAbility[] specialAbilities) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) foreach (SpecialTriggeredAbility ability in specialAbilities) { if (playableCard.HasSpecialAbility(ability)) { return true; } } return false; } public static bool HasOpposingCard(this PlayableCard playableCard) { if (Object.op_Implicit((Object)(object)playableCard.Slot)) { return Object.op_Implicit((Object)(object)playableCard.Slot.opposingSlot.Card); } return false; } public static CardSlot OpposingSlot(this PlayableCard playableCard) { if (!Object.op_Implicit((Object)(object)playableCard.Slot)) { return null; } return playableCard.Slot.opposingSlot; } public static PlayableCard OpposingCard(this PlayableCard playableCard) { CardSlot obj = playableCard.OpposingSlot(); if (obj == null) { return null; } return obj.Card; } public static void AddTemporaryMods(this PlayableCard card, params CardModificationInfo[] mods) { foreach (CardModificationInfo val in mods) { card.AddTemporaryMod(val); } } public static void RemoveTemporaryMods(this PlayableCard card, params CardModificationInfo[] mods) { foreach (CardModificationInfo val in mods) { card.RemoveTemporaryMod(val, true); } } [IteratorStateMachine(typeof(d__95))] public static IEnumerator TransformIntoCardInHand(this PlayableCard card, CardInfo evolvedInfo, Action onTransformedCallback = null, Action preTransformCallback = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__95(0) { card = card, evolvedInfo = evolvedInfo, onTransformedCallback = onTransformedCallback, preTransformCallback = preTransformCallback }; } [IteratorStateMachine(typeof(d__96))] public static IEnumerator TransformIntoCardAboveHand(this PlayableCard card, CardInfo evolvedInfo, Action onTransformedCallback = null, Action preTransformCallback = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__96(0) { card = card, evolvedInfo = evolvedInfo, onTransformedCallback = onTransformedCallback, preTransformCallback = preTransformCallback }; } public static void AddShieldCount(this PlayableCard card, int amount, bool updateDisplay = true) { card.AddShieldCount(amount, updateDisplay); } public static void AddShieldCount(this PlayableCard card, int amount, Ability ability, bool updateDisplay = true) { //IL_0001: 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) DamageShieldBehaviour shieldBehaviour = card.GetShieldBehaviour(ability); if ((Object)(object)shieldBehaviour == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)$"[AddShieldCount] DamageShieldBehaviour of Ability [{ability}] not found!"); } else { shieldBehaviour.AddShields(amount, updateDisplay); } } public static void AddShieldCount(this PlayableCard card, int amount, bool updateDisplay = true) where T : DamageShieldBehaviour { ((Component)card).GetComponent()?.AddShields(amount, updateDisplay); } public static void RemoveShieldCount(this PlayableCard card, int amount, bool updateDisplay = true) { card.RemoveShieldCount(amount, updateDisplay); } public static void RemoveShieldCount(this PlayableCard card, int amount, Ability ability, bool updateDisplay = true) { //IL_0001: 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) DamageShieldBehaviour shieldBehaviour = card.GetShieldBehaviour(ability); if ((Object)(object)shieldBehaviour == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)$"[RemoveShieldCount] DamageShieldBehaviour of Ability [{ability}] not found!"); } else { shieldBehaviour.RemoveShields(amount, updateDisplay); } } public static void RemoveShieldCount(this PlayableCard card, int amount, bool updateDisplay = true) where T : DamageShieldBehaviour { ((Component)card).GetComponent()?.RemoveShields(amount, updateDisplay); } public static int GetTotalShields(this PlayableCard card) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)card == (Object)null) { InscryptionAPIPlugin.Logger.LogDebug((object)"[GetTotalShields] Card is null, returning 0."); return 0; } int num = 0; List list = new List(); DamageShieldBehaviour[] components = ((Component)card).GetComponents(); foreach (DamageShieldBehaviour damageShieldBehaviour in components) { if (AbilitiesUtil.GetInfo(((AbilityBehaviour)damageShieldBehaviour).Ability).canStack) { num += damageShieldBehaviour.NumShields; } else if (!list.Contains(((AbilityBehaviour)damageShieldBehaviour).Ability)) { num += damageShieldBehaviour.NumShields; list.Add(((AbilityBehaviour)damageShieldBehaviour).Ability); } } return num; } public static int GetShieldCount(this PlayableCard card) where T : DamageShieldBehaviour { return ((Component)card).GetComponent()?.NumShields ?? 0; } public static DamageShieldBehaviour GetShieldBehaviour(this PlayableCard card, Ability ability) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Type type = ShieldManager.AllShieldAbilities.AbilityByID(ability)?.AbilityBehavior; if (type == null) { return null; } return ((Component)card).GetComponent(type) as DamageShieldBehaviour; } public static void ResetShield(this PlayableCard card, Ability ability) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) DamageShieldBehaviour[] components = ((Component)card).GetComponents(); foreach (DamageShieldBehaviour damageShieldBehaviour in components) { if (((AbilityBehaviour)damageShieldBehaviour).Ability == ability) { damageShieldBehaviour.ResetShields(updateDisplay: false); } } card.Status.lostShield = false; } public static bool IsShieldAbility(this Ability ability) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)ShieldManager.AllShieldInfos.AbilityByID(ability) != (Object)null; } public static bool IsShieldAbility(this AbilityInfo abilityInfo) { return ShieldManager.AllShieldInfos.Contains(abilityInfo); } public static bool HasShieldAbility(this PlayableCard card) { return card.AllAbilities().Exists((Ability x) => x.IsShieldAbility()); } public static bool HasShieldAbility(this CardInfo cardInfo) { return cardInfo.Abilities.Exists((Ability x) => x.IsShieldAbility()); } [IteratorStateMachine(typeof(d__111))] public static IEnumerator SpawnInHand(this CardInfo cardInfo, List temporaryMods = null, Vector3 spawnOffset = default(Vector3), float onDrawnTriggerDelay = 0f, Action cardSpawnedCallback = null) { //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 decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__111(0) { cardInfo = cardInfo, temporaryMods = temporaryMods, spawnOffset = spawnOffset, onDrawnTriggerDelay = onDrawnTriggerDelay, cardSpawnedCallback = cardSpawnedCallback }; } public static CardBlueprint CreateBlueprint(this CardInfo cardInfo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new CardBlueprint { card = cardInfo }; } public static CardInfo SetPortrait(this CardInfo info, string pathToArt) { try { return info.SetPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } catch (FileNotFoundException innerException) { throw new ArgumentException("Image file not found for card \"" + ((Object)info).name + "\"!", innerException); } } public static CardInfo SetPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { return info.SetPortrait(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); } public static CardInfo SetPortrait(this CardInfo info, Texture2D portrait, Texture2D emission, FilterMode? filterMode = null) { info.SetPortrait(portrait, filterMode); info.SetEmissivePortrait(emission, filterMode); return info; } public static CardInfo SetPortrait(this CardInfo info, Sprite sprite) { info.portraitTex = sprite; if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)info.portraitTex).name = ((Object)info).name + "_portrait"; } return info; } public static CardInfo SetPortraitAndEmission(this CardInfo info, string pathToArt, string pathToEmission) { info.SetPortrait(pathToArt); info.SetEmissivePortrait(pathToEmission); return info; } public static CardInfo SetPortraitAndEmission(this CardInfo info, Texture2D portrait, Texture2D emission, FilterMode? filterMode = null) { info.SetPortrait(portrait, filterMode); info.SetEmissivePortrait(emission, filterMode); return info; } public static CardInfo SetPortraitAndEmission(this CardInfo info, Sprite portrait, Sprite emission) { info.SetPortrait(portrait); info.SetEmissivePortrait(emission); return info; } public static CardInfo SetAltPortrait(this CardInfo info, string pathToArt) { return info.SetAltPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetAltPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { return info.SetAltPortrait(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); } public static CardInfo SetAltPortrait(this CardInfo info, Sprite portrait) { info.alternatePortrait = portrait; if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)info.alternatePortrait).name = ((Object)info).name + "_altportrait"; } TextureHelper.TryReuseEmission(info, info.alternatePortrait); return info; } public static CardInfo SetEmissivePortrait(this CardInfo info, string pathToArt) { try { return info.SetEmissivePortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } catch (FileNotFoundException innerException) { throw new ArgumentException("Image file not found for card \"" + ((Object)info).name + "\"!", innerException); } } public static CardInfo SetEmissivePortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { return info.SetEmissivePortrait(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); } public static CardInfo SetEmissivePortrait(this CardInfo info, Sprite sprite) { if ((Object)(object)info.portraitTex == (Object)null) { throw new InvalidOperationException("Cannot set emissive portrait before setting normal portrait!"); } info.portraitTex.RegisterEmissionForSprite(sprite); return info; } public static Sprite GetEmissivePortrait(this CardInfo info) { return info.portraitTex.GetEmissionSprite(); } public static CardInfo SetEmissiveAltPortrait(this CardInfo info, string pathToArt) { return info.SetEmissiveAltPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetEmissiveAltPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { return info.SetEmissiveAltPortrait(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); } public static CardInfo SetEmissiveAltPortrait(this CardInfo info, Sprite portrait) { if ((Object)(object)info.alternatePortrait == (Object)null) { throw new InvalidOperationException("Cannot set emissive portrait before setting the alternate portrait!"); } info.alternatePortrait.RegisterEmissionForSprite(portrait); return info; } public static Sprite GetEmissiveAltPortrait(this CardInfo info) { return info.alternatePortrait.GetEmissionSprite(); } public static CardInfo SetPixelPortrait(this CardInfo info, string pathToArt) { return info.SetPixelPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetPixelPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetPixelPortrait(portrait.ConvertTexture(TextureHelper.SpriteType.PixelPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetPixelPortrait(this CardInfo info, Sprite portrait) { info.pixelPortrait = portrait; if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)info.pixelPortrait).name = ((Object)info).name + "_pixelportrait"; } return info; } public static Sprite GetPixelPortrait(this CardInfo info) { return info.pixelPortrait; } public static CardInfo SetLostTailPortrait(this CardInfo info, string pathToArt) { if (info.tailParams == null) { throw new InvalidOperationException("Cannot set lost tail portrait without tail params being set first"); } info.tailParams.SetLostTailPortrait(pathToArt, info); return info; } public static CardInfo SetLostTailPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { if (info.tailParams == null) { throw new InvalidOperationException("Cannot set lost tail portrait without tail params being set first"); } info.tailParams.SetLostTailPortrait(portrait, info, filterMode); return info; } public static TailParams SetLostTailPortrait(this TailParams info, string pathToArt, CardInfo owner) { owner.tailParams = info; return info.SetLostTailPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0), owner); } public static TailParams SetLostTailPortrait(this TailParams info, Texture2D portrait, CardInfo owner, FilterMode? filterMode = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Sprite portrait2 = ((!filterMode.HasValue) ? portrait.ConvertTexture(TextureHelper.SpriteType.CardPortrait, (FilterMode)0) : portrait.ConvertTexture(TextureHelper.SpriteType.CardPortrait, filterMode.Value)); return info.SetLostTailPortrait(portrait2, owner); } public static TailParams SetLostTailPortrait(this TailParams info, Sprite portrait, CardInfo owner) { info.tailLostPortrait = portrait; if (!string.IsNullOrEmpty(((Object)owner).name)) { ((Object)info.tailLostPortrait).name = ((Object)owner).name + "_tailportrait"; } TextureHelper.TryReuseEmission(owner, info.tailLostPortrait); return info; } public static CardInfo SetPixelAlternatePortrait(this CardInfo info, string pathToArt) { return info.SetPixelAlternatePortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetPixelAlternatePortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetPixelAlternatePortrait(portrait.ConvertTexture(TextureHelper.SpriteType.PixelPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetPixelAlternatePortrait(this CardInfo info, Sprite portrait) { if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)portrait).name = ((Object)info).name + "_pixelalternateportrait"; } info.GetAltPortraits().PixelAlternatePortrait = portrait; return info; } public static Sprite GetPixelAlternatePortrait(this CardInfo info) { return info.PixelAlternatePortrait(); } public static CardInfo SetSteelTrapPortrait(this CardInfo info, string pathToArt) { return info.SetSteelTrapPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetSteelTrapPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetSteelTrapPortrait(portrait.ConvertTexture(TextureHelper.SpriteType.CardPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetSteelTrapPortrait(this CardInfo info, Sprite portrait) { if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)portrait).name = ((Object)info).name + "_steeltrapportrait"; } info.GetAltPortraits().SteelTrapPortrait = portrait; return info; } public static CardInfo SetPixelSteelTrapPortrait(this CardInfo info, string pathToArt) { return info.SetPixelSteelTrapPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetPixelSteelTrapPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetPixelSteelTrapPortrait(portrait.ConvertTexture(TextureHelper.SpriteType.PixelPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetPixelSteelTrapPortrait(this CardInfo info, Sprite portrait) { if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)portrait).name = ((Object)info).name + "_pixelsteeltrapportrait"; } info.GetAltPortraits().PixelSteelTrapPortrait = portrait; return info; } public static CardInfo SetEmissiveSteelTrapPortrait(this CardInfo info, string pathToArt) { return info.SetEmissiveSteelTrapPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetEmissiveSteelTrapPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { return info.SetEmissiveSteelTrapPortrait(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); } public static CardInfo SetEmissiveSteelTrapPortrait(this CardInfo info, Sprite portrait) { if ((Object)(object)info.SteelTrapPortrait() == (Object)null) { throw new InvalidOperationException("Cannot set emissive portrait before setting the default steel trap portrait!"); } info.SteelTrapPortrait().RegisterEmissionForSprite(portrait); return info; } public static Sprite GetEmissiveSteelTrapPortrait(this CardInfo info) { return info.SteelTrapPortrait()?.GetEmissionSprite(); } public static CardInfo SetBrokenShieldPortrait(this CardInfo info, string pathToArt) { return info.SetBrokenShieldPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetBrokenShieldPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetBrokenShieldPortrait(portrait.ConvertTexture(TextureHelper.SpriteType.CardPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetBrokenShieldPortrait(this CardInfo info, Sprite portrait) { if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)portrait).name = ((Object)info).name + "_brokenshieldportrait"; } info.GetAltPortraits().BrokenShieldPortrait = portrait; return info; } public static CardInfo SetPixelBrokenShieldPortrait(this CardInfo info, string pathToArt) { return info.SetPixelBrokenShieldPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetPixelBrokenShieldPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetPixelBrokenShieldPortrait(portrait.ConvertTexture(TextureHelper.SpriteType.PixelPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetPixelBrokenShieldPortrait(this CardInfo info, Sprite portrait) { if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)portrait).name = ((Object)info).name + "_pixelbrokenshieldportrait"; } info.GetAltPortraits().BrokenShieldPortrait = portrait; return info; } public static CardInfo SetEmissiveBrokenShieldPortrait(this CardInfo info, string pathToArt) { return info.SetEmissiveBrokenShieldPortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetEmissiveBrokenShieldPortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { return info.SetEmissiveBrokenShieldPortrait(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); } public static CardInfo SetEmissiveBrokenShieldPortrait(this CardInfo info, Sprite portrait) { if ((Object)(object)info.BrokenShieldPortrait() == (Object)null) { throw new InvalidOperationException("Cannot set the emissive portrait before setting the default broken shield portrait!"); } info.BrokenShieldPortrait().RegisterEmissionForSprite(portrait); return info; } public static Sprite GetEmissiveBrokenShieldPortrait(this CardInfo info) { return info.BrokenShieldPortrait()?.GetEmissionSprite(); } public static CardInfo SetSacrificablePortrait(this CardInfo info, string pathToArt) { return info.SetSacrificablePortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetSacrificablePortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetSacrificablePortrait(portrait.ConvertTexture(TextureHelper.SpriteType.CardPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetSacrificablePortrait(this CardInfo info, Sprite portrait) { if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)portrait).name = ((Object)info).name + "_sacrificableportrait"; } info.GetAltPortraits().SacrificablePortrait = portrait; return info; } public static CardInfo SetPixelSacrificablePortrait(this CardInfo info, string pathToArt) { return info.SetPixelSacrificablePortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetPixelSacrificablePortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return info.SetPixelSacrificablePortrait(portrait.ConvertTexture(TextureHelper.SpriteType.PixelPortrait, filterMode.GetValueOrDefault())); } public static CardInfo SetPixelSacrificablePortrait(this CardInfo info, Sprite portrait) { if (!string.IsNullOrEmpty(((Object)info).name)) { ((Object)portrait).name = ((Object)info).name + "_pixelsacrificableportrait"; } info.GetAltPortraits().PixelSacrificablePortrait = portrait; return info; } public static CardInfo SetEmissiveSacrificablePortrait(this CardInfo info, string pathToArt) { return info.SetEmissiveSacrificablePortrait(TextureHelper.GetImageAsTexture(pathToArt, (FilterMode)0)); } public static CardInfo SetEmissiveSacrificablePortrait(this CardInfo info, Texture2D portrait, FilterMode? filterMode = null) { return info.SetEmissiveSacrificablePortrait(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); } public static CardInfo SetEmissiveSacrificablePortrait(this CardInfo info, Sprite portrait) { if ((Object)(object)info.SteelTrapPortrait() == (Object)null) { throw new InvalidOperationException("Cannot set emissive portrait before setting the default sacrifice portrait!"); } info.SteelTrapPortrait().RegisterEmissionForSprite(portrait); return info; } public static Sprite GetEmissiveSacrificablePortrait(this CardInfo info) { return info.SteelTrapPortrait().GetEmissionSprite(); } public static CardInfo SetAnimatedPortrait(this CardInfo info, GameObject portrait) { info.animatedPortrait = portrait; return info; } public static bool HasAlternatePortrait(this PlayableCard card) { return ((Card)card).Info.HasAlternatePortrait(); } public static bool HasAlternatePortrait(this CardInfo info) { return (Object)(object)info.alternatePortrait != (Object)null; } public static bool HasPixelAlternatePortrait(this CardInfo info) { return (Object)(object)info.PixelAlternatePortrait() != (Object)null; } public static bool HasSteelTrapPortrait(this CardInfo info) { return (Object)(object)info.SteelTrapPortrait() != (Object)null; } public static bool HasPixelSteelTrapPortrait(this CardInfo info) { return (Object)(object)info.PixelSteelTrapPortrait() != (Object)null; } public static bool HasBrokenShieldPortrait(this CardInfo info) { return (Object)(object)info.BrokenShieldPortrait() != (Object)null; } public static bool HasPixelBrokenShieldPortrait(this CardInfo info) { return (Object)(object)info.PixelBrokenShieldPortrait() != (Object)null; } public static bool HasSacrificablePortrait(this CardInfo info) { return (Object)(object)info.SacrificablePortrait() != (Object)null; } public static bool HasPixelSacrificablePortrait(this CardInfo info) { return (Object)(object)info.PixelSacrificablePortrait() != (Object)null; } public static CardInfo SetExtendedProperty(this CardInfo info, string propertyName, object value) { info.GetCardExtensionTable()[propertyName] = value?.ToString(); return info; } public static string GetExtendedProperty(this CardInfo info, string propertyName) { info.GetCardExtensionTable().TryGetValue(propertyName, out var value); return value; } public static int? GetExtendedPropertyAsInt(this CardInfo info, string propertyName) { info.GetCardExtensionTable().TryGetValue(propertyName, out var value); if (!int.TryParse(value, out var result)) { return null; } return result; } public static float? GetExtendedPropertyAsFloat(this CardInfo info, string propertyName) { info.GetCardExtensionTable().TryGetValue(propertyName, out var value); if (!float.TryParse(value, out var result)) { return null; } return result; } public static bool? GetExtendedPropertyAsBool(this CardInfo info, string propertyName) { info.GetCardExtensionTable().TryGetValue(propertyName, out var value); if (!bool.TryParse(value, out var result)) { return null; } return result; } public static bool IsAffectedByTidalLock(this PlayableCard item) { return ((Card)item).Info.IsAffectedByTidalLock(); } public static bool IsAffectedByTidalLock(this CardInfo info) { return info.GetExtendedPropertyAsBool("AffectedByTidalLock").GetValueOrDefault(); } public static CardInfo SetAffectedByTidalLock(this CardInfo info, bool affectedByTidalLock = true) { info.SetExtendedProperty("AffectedByTidalLock", affectedByTidalLock); return info; } public static string GetTransformerCardId(this PlayableCard item) { return ((Card)item).Info.GetTransformerCardId(); } public static string GetTransformerCardId(this CardInfo info) { return info.GetExtendedProperty("TransformerCardId"); } public static CardInfo SetTransformerCardId(this CardInfo info, string transformerCardId) { info.SetExtendedProperty("TransformerCardId", transformerCardId); return info; } public static bool HasCustomCost(this CardInfo info, CardCostManager.FullCardCost customCost) { return info.GetCustomCost(customCost) != 0; } public static CardInfo SetCustomCost(this CardInfo info, CardCostManager.FullCardCost customCost, int amount) { return info.SetCustomCost(customCost.CostName, amount); } public static CardInfo SetCustomCost(this CardInfo info, string costName, int amount) { return info.SetExtendedProperty(costName, amount); } public static CardInfo SetCustomCost(this CardInfo info, int amount) where T : CustomCardCost { CardCostManager.FullCardCost fullCardCost = CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostBehaviour == typeof(T)); return info.SetCustomCost(fullCardCost.CostName, amount); } public static int GetCustomCostAmount(this PlayableCard card, string costName) { return ((Card)card).Info.GetCustomCostAmount(costName); } public static int GetCustomCostAmount(this CardInfo cardInfo, string costName) { return cardInfo.GetCustomCost(costName, CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostName == costName).CanBeNegative); } public static int GetCustomCost(this PlayableCard card, string costName, bool canBeNegative = false) { return ((Card)card).Info.GetCustomCost(costName, canBeNegative); } public static int GetCustomCost(this CardInfo cardInfo, string costName, bool canBeNegative = false) { int num = cardInfo.GetExtendedPropertyAsInt(costName).GetValueOrDefault(); foreach (CardModificationInfo mod in cardInfo.Mods) { num += mod.GetExtendedPropertyAsInt(costName).GetValueOrDefault() + mod.GetCustomCostIdValue(costName); } if (!canBeNegative && num < 0) { num = 0; } return num; } public static int GetCustomCost(this PlayableCard card, bool canBeNegative = false) where T : CustomCardCost { CardCostManager.FullCardCost fullCardCost = CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostBehaviour == typeof(T)); return ((Card)card).Info.GetCustomCost(fullCardCost.CostName, canBeNegative); } public static int GetCustomCost(this CardInfo cardInfo, bool canBeNegative = false) where T : CustomCardCost { CardCostManager.FullCardCost fullCardCost = CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostBehaviour == typeof(T)); return cardInfo.GetCustomCost(fullCardCost.CostName, canBeNegative); } public static int GetCustomCostAmount(this PlayableCard card) where T : CustomCardCost { CardCostManager.FullCardCost fullCardCost = CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostBehaviour == typeof(T)); return card.GetCustomCost(fullCardCost); } public static int GetCustomCostAmount(this CardInfo cardInfo) where T : CustomCardCost { CardCostManager.FullCardCost fullCardCost = CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostBehaviour == typeof(T)); return cardInfo.GetCustomCost(fullCardCost); } public static int GetCustomCost(this PlayableCard card, CardCostManager.FullCardCost fullCardCost) { return card.GetCustomCostAmount(fullCardCost.CostName); } public static int GetCustomCost(this CardInfo cardInfo, CardCostManager.FullCardCost fullCardCost) { return cardInfo.GetCustomCostAmount(fullCardCost.CostName); } public static List GetCustomCardCosts(this Card card) { try { if (!UnityExtensions.SafeIsUnityNull((Object)(object)card)) { CustomCardCost[] array = ((card != null) ? ((Component)card).GetComponents() : null); if (array != null) { return array.ToList(); } } InscryptionAPIPlugin.Logger.LogWarning((object)"[GetCustomCardCosts] Card is null, returning empty List."); } catch { InscryptionAPIPlugin.Logger.LogError((object)"[GetCustomCardCosts] Failed to get CustomCardCosts from Card object, returning empty List."); } return new List(); } public static List GetCustomCosts(this CardInfo info) { List list = new List(); foreach (string key in info.GetCardExtensionTable().Keys) { if (CardCostManager.AllCustomCosts.Exists((CardCostManager.FullCardCost x) => x.CostName == key)) { list.Add(CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostName == key)); } } foreach (CardModificationInfo mod in info.Mods) { list.AddRange(mod.GetCustomCostsFromMod()); } return list; } public static CardInfo SetBasic(this CardInfo info, string displayedName, int attack, int health, string description = null) { info.displayedName = displayedName; info.baseAttack = attack; info.baseHealth = health; info.description = description; return info; } public static CardInfo SetBaseAttackAndHealth(this CardInfo info, int? baseAttack = 0, int? baseHealth = 0) { if (baseAttack.HasValue) { info.baseAttack = baseAttack.Value; } if (baseHealth.HasValue) { info.baseHealth = baseHealth.Value; } return info; } public static CardInfo SetCardTemple(this CardInfo info, CardTemple temple) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) info.temple = temple; return info; } public static CardInfo SetCardComplexity(this CardInfo info, CardComplexity complexity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) info.cardComplexity = complexity; return info; } public static CardInfo SetDisplayedName(this CardInfo info, string displayedName) { info.displayedName = (StringExtensions.IsNullOrWhitespace(displayedName) ? "" : displayedName); return info; } public static CardInfo SetName(this CardInfo info, string name, string modPrefix = null) { ((Object)info).name = ((!string.IsNullOrEmpty(modPrefix) && !name.StartsWith(modPrefix)) ? (modPrefix + "_" + name) : name); return info; } public static CardInfo SetNames(this CardInfo info, string name, string displayedName, string modPrefix = null) { info.SetDisplayedName(displayedName); return info.SetName(name, modPrefix); } public static CardInfo SetSpecialAbilities(this CardInfo info, params SpecialTriggeredAbility[] abilities) { info.specialAbilities = abilities?.ToList(); return info; } public static CardInfo SetStatIcon(this CardInfo info, SpecialStatIcon statIcon) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown info.specialStatIcon = statIcon; info.AddSpecialAbilities((SpecialTriggeredAbility)(int)StatIconManager.AllStatIcons.FirstOrDefault((StatIconManager.FullStatIcon sii) => sii.Id == statIcon).AbilityId); return info; } public static CardInfo SetTraits(this CardInfo info, params Trait[] traits) { info.traits = traits?.ToList(); return info; } public static CardInfo SetTribes(this CardInfo info, params Tribe[] tribes) { info.tribes = tribes?.ToList(); return info; } public static CardInfo SetGemify(this CardInfo info, bool gemify = true) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if (gemify && !info.Mods.Exists((CardModificationInfo x) => x.gemify)) { info.Mods.Add(new CardModificationInfo { gemify = true }); } else if (!gemify) { info.Mods.FindAll((CardModificationInfo x) => x.gemify).ForEach(delegate(CardModificationInfo y) { y.gemify = false; }); } return info; } public static CardInfo SetDefaultPart1Card(this CardInfo info) { //IL_0028: 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 (!info.metaCategories.Contains((CardMetaCategory)3)) { info.AddMetaCategories(default(CardMetaCategory), (CardMetaCategory)1); info.cardComplexity = (CardComplexity)1; } info.temple = (CardTemple)0; return info; } public static CardInfo SetDefaultPart3Card(this CardInfo info) { //IL_0028: 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 (!info.metaCategories.Contains((CardMetaCategory)3)) { info.AddMetaCategories(default(CardMetaCategory), (CardMetaCategory)2); info.cardComplexity = (CardComplexity)1; } info.temple = (CardTemple)2; return info; } public static CardInfo SetGBCPlayable(this CardInfo info, CardTemple temple) { //IL_0016: 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) info.AddMetaCategories((CardMetaCategory)4, (CardMetaCategory)5); info.temple = temple; return info; } public static CardInfo SetRare(this CardInfo info) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) info.AddMetaCategories((CardMetaCategory)3); info.AddAppearances((Appearance)7); info.metaCategories.Remove((CardMetaCategory)0); info.metaCategories.Remove((CardMetaCategory)1); info.metaCategories.Remove((CardMetaCategory)2); info.cardComplexity = (CardComplexity)2; return info; } public static CardInfo SetTerrain(this CardInfo info) { info.AddTraits((Trait)12); info.AddAppearances((Appearance)2, (Appearance)9); return info; } public static CardInfo SetTerrain(this CardInfo info, bool useTerrainLayout) { info.AddTraits((Trait)12); info.AddAppearances((Appearance)2); if (useTerrainLayout) { info.AddAppearances((Appearance)9); } return info; } public static CardInfo SetPelt(this CardInfo info, bool spawnLice = true) { info.AddTraits((Trait)13); info.AddAppearances((Appearance)2, (Appearance)9); if (spawnLice) { info.AddSpecialAbilities((SpecialTriggeredAbility)27); } return info; } public static CardInfo SetEvolve(this CardInfo info, CardInfo evolveCard, int numberOfTurns, IEnumerable mods = null) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown info.evolveParams = new EvolveParams { evolution = evolveCard, turnsToEvolve = numberOfTurns }; if (mods != null && mods.Any()) { info.evolveParams.evolution = CardLoader.Clone(info.evolveParams.evolution); CardInfo evolution = info.evolveParams.evolution; (evolution.mods ?? (evolution.mods = new List())).AddRange(mods); } return info; } public static CardInfo SetEvolve(this CardInfo info, string evolveInto, int numberOfTurns, IEnumerable mods = null) { CardInfo val = CardManager.AllCardsCopy.CardByName(evolveInto); if ((Object)(object)val == (Object)null) { CardManager.ModifyCardList += delegate(List cards) { CardInfo val2 = cards.CardByName(((Object)info).name); CardInfo val3 = cards.CardByName(evolveInto); if ((Object)(object)val2 != (Object)null && (Object)(object)val3 == (Object)null && val2.IsOldApiCard()) { val3 = cards.CardByName(val2.GetModPrefix() + "_" + evolveInto); } if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null) { val2.SetEvolve(val3, numberOfTurns, mods); } return cards; }; } else { info.SetEvolve(val, numberOfTurns, mods); } return info; } public static CardInfo SetDefaultEvolutionName(this CardInfo info, string defaultName) { info.defaultEvolutionName = defaultName; return info; } public static CardInfo SetIceCube(this CardInfo info, CardInfo iceCube, IEnumerable mods = null) { //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_0012: Expected O, but got Unknown info.iceCubeParams = new IceCubeParams { creatureWithin = iceCube }; if (mods != null && mods.Any()) { info.iceCubeParams.creatureWithin = CardLoader.Clone(info.iceCubeParams.creatureWithin); CardInfo creatureWithin = info.iceCubeParams.creatureWithin; (creatureWithin.mods ?? (creatureWithin.mods = new List())).AddRange(mods); } return info; } public static CardInfo SetIceCube(this CardInfo info, string iceCubeName, IEnumerable mods = null) { CardInfo val = CardManager.AllCardsCopy.CardByName(iceCubeName); if ((Object)(object)val == (Object)null) { CardManager.ModifyCardList += delegate(List cards) { CardInfo val2 = cards.CardByName(((Object)info).name); CardInfo val3 = cards.CardByName(iceCubeName); if ((Object)(object)val2 != (Object)null && (Object)(object)val3 == (Object)null && val2.IsOldApiCard()) { val3 = cards.CardByName(val2.GetModPrefix() + "_" + iceCubeName); } if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null) { val2.SetIceCube(val3, mods); } return cards; }; } else { info.SetIceCube(val, mods); } return info; } public static CardInfo SetTail(this CardInfo info, string tailName, string pathToLostTailArt = null, IEnumerable mods = null) { Texture2D tailLostPortrait = ((pathToLostTailArt == null) ? null : TextureHelper.GetImageAsTexture(pathToLostTailArt, (FilterMode)0)); return info.SetTail(tailName, tailLostPortrait, null, mods); } public static CardInfo SetTail(this CardInfo info, string tailName, IEnumerable mods = null) { return info.SetTail(tailName, (Sprite)null, mods); } public static CardInfo SetTail(this CardInfo info, CardInfo tail, IEnumerable mods = null) { return info.SetTail(tail, null, mods); } public static CardInfo SetTail(this CardInfo info, CardInfo tail, Texture2D tailLostPortrait, FilterMode? filterMode = null, IEnumerable mods = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) Sprite tailLostPortrait2 = (filterMode.HasValue ? tailLostPortrait?.ConvertTexture(TextureHelper.SpriteType.CardPortrait, filterMode.Value) : tailLostPortrait?.ConvertTexture(TextureHelper.SpriteType.CardPortrait, (FilterMode)0)); return info.SetTail(tail, tailLostPortrait2, mods); } public static CardInfo SetTail(this CardInfo info, CardInfo tail, Sprite tailLostPortrait, IEnumerable mods = null) { //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_0012: Expected O, but got Unknown info.tailParams = new TailParams { tail = tail }; if (mods != null && mods.Any()) { info.tailParams.tail = CardLoader.Clone(info.tailParams.tail); CardInfo tail2 = info.tailParams.tail; (tail2.mods ?? (tail2.mods = new List())).AddRange(mods); } if ((Object)(object)tailLostPortrait != (Object)null) { info.tailParams.SetLostTailPortrait(tailLostPortrait, info); } return info; } public static CardInfo SetTail(this CardInfo info, string tailName, Texture2D tailLostPortrait, FilterMode? filterMode = null, IEnumerable mods = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) Sprite tailLostPortrait2 = (filterMode.HasValue ? tailLostPortrait?.ConvertTexture(TextureHelper.SpriteType.CardPortrait, filterMode.Value) : tailLostPortrait?.ConvertTexture(TextureHelper.SpriteType.CardPortrait, (FilterMode)0)); return info.SetTail(tailName, tailLostPortrait2, mods); } public static CardInfo SetTail(this CardInfo info, string tailName, Sprite tailLostPortrait, IEnumerable mods = null) { CardInfo val = CardManager.AllCardsCopy.CardByName(tailName); if ((Object)(object)val == (Object)null) { CardManager.ModifyCardList += delegate(List cards) { CardInfo val2 = cards.CardByName(((Object)info).name); CardInfo val3 = cards.CardByName(tailName); if ((Object)(object)val2 != (Object)null && (Object)(object)val3 == (Object)null && val2.IsOldApiCard()) { val3 = cards.CardByName(val2.GetModPrefix() + "_" + tailName); } if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null) { val2.SetTail(val3, tailLostPortrait, mods); } return cards; }; } else { info.SetTail(val, tailLostPortrait, mods); } return info; } public static CardInfo SetCost(this CardInfo info, int? bloodCost = 0, int? bonesCost = 0, int? energyCost = 0, List gemsCost = null) { info.SetBloodCost(bloodCost); info.SetBonesCost(bonesCost); info.SetEnergyCost(energyCost); return info.SetGemsCost(gemsCost); } public static CardInfo SetBloodCost(this CardInfo info, int? bloodCost = 0) { if (bloodCost.HasValue) { info.cost = bloodCost.Value; } return info; } public static CardInfo SetBonesCost(this CardInfo info, int? bonesCost = 0) { if (bonesCost.HasValue) { info.bonesCost = bonesCost.Value; } return info; } public static CardInfo SetEnergyCost(this CardInfo info, int? energyCost = 0) { if (energyCost.HasValue) { info.energyCost = energyCost.Value; } return info; } public static CardInfo SetGemsCost(this CardInfo info, List gemsCost = null) { info.gemsCost = gemsCost ?? new List(); return info; } public static CardInfo SetGemsCost(this CardInfo info, params GemType[] gemsCost) { info.gemsCost = gemsCost.ToList(); return info; } public static CardInfo SetOnePerDeck(this CardInfo info, bool onePerDeck = true) { info.onePerDeck = onePerDeck; return info; } public static CardInfo SetHideStats(this CardInfo info, bool hideStats = true) { info.hideAttackAndHealth = hideStats; return info; } public static CardInfo SetStrafeFlipsPortrait(this CardInfo info, bool flipPortrait = true) { info.flipPortraitForStrafe = flipPortrait; return info; } public static bool IsBaseGameCard(this CardInfo info) { return info.GetExtendedPropertyAsBool("BaseGameCard").GetValueOrDefault(); } internal static CardInfo SetBaseGameCard(this CardInfo info, bool isBaseGameCard = true) { return info.SetExtendedProperty("BaseGameCard", isBaseGameCard); } internal static CardInfo SetOldApiCard(this CardInfo info, bool isOldApiCard = true) { return info.SetExtendedProperty("AddedByOldApi", isOldApiCard); } internal static bool IsOldApiCard(this CardInfo info) { return info.GetExtendedPropertyAsBool("AddedByOldApi").GetValueOrDefault(); } public static CardInfo SetCustomUnlockCheck(this CardInfo c, Func check) { if (check == null && CardManager.CustomCardUnlocks.ContainsKey(((Object)c).name)) { CardManager.CustomCardUnlocks.Remove(((Object)c).name); } else if (CardManager.CustomCardUnlocks.ContainsKey(((Object)c).name)) { CardManager.CustomCardUnlocks[((Object)c).name] = check; } else { CardManager.CustomCardUnlocks.Add(((Object)c).name, check); } return c; } } [HarmonyPatch] public static class CardManager { private class CardExt { public readonly Dictionary TypeMap = new Dictionary(); public readonly Dictionary StringMap = new Dictionary(); } public class CardAltPortraits { public Sprite PixelAlternatePortrait; public Sprite SteelTrapPortrait; public Sprite PixelSteelTrapPortrait; public Sprite BrokenShieldPortrait; public Sprite PixelBrokenShieldPortrait; public Sprite SacrificablePortrait; public Sprite PixelSacrificablePortrait; } [CompilerGenerated] private sealed class d__11 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private CardInfo <>2__current; private int <>l__initialThreadId; private CardInfo[] <>7__wrap1; private int <>7__wrap2; CardInfo IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = Resources.LoadAll("Data/Cards"); <>7__wrap2 = 0; break; case 1: <>1__state = -1; <>7__wrap2++; break; } if (<>7__wrap2 < <>7__wrap1.Length) { CardInfo val = <>7__wrap1[<>7__wrap2]; val.SetBaseGameCard(); if (((Object)val).name == "Squirrel" || ((Object)val).name == "AquaSquirrel" || ((Object)val).name == "Rabbit") { val.SetAffectedByTidalLock(); } else if (((Object)val).name == "SkeletonParrot") { val.AddTribes((Tribe)2); } else if (((Object)val).name == "MudTurtle") { val.SetBrokenShieldPortrait(val.alternatePortrait); } <>2__current = val; <>1__state = 1; return true; } <>7__wrap1 = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__11(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly ConditionalWeakTable CardExtensionProperties; private static readonly ConditionalWeakTable CardAlternatePortraits; internal static readonly Dictionary> CustomCardUnlocks; public static readonly ReadOnlyCollection BaseGameCards; private static readonly ObservableCollection NewCards; private static bool EventActive; private const string ERROR = "ERROR"; public static List AllCardsCopy { get; private set; } public static event Func, List> ModifyCardList; [IteratorStateMachine(typeof(d__11))] private static IEnumerable GetBaseGameCards() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(-2); } internal static void ActivateEvents() { EventActive = true; } public static void SyncCardList() { List list = BaseGameCards.Concat(NewCards).Select((Func)CardLoader.Clone).ToList(); foreach (CardInfo item in list) { if (item.evolveParams != null && (Object)(object)item.evolveParams.evolution != (Object)null) { List mods = item.evolveParams.evolution.Mods; ref CardInfo evolution = ref item.evolveParams.evolution; object obj = list.CardByName(((Object)item.evolveParams.evolution).name).Clone(); evolution = (CardInfo)((obj is CardInfo) ? obj : null); item.evolveParams.evolution.Mods = mods; } if (item.iceCubeParams != null && (Object)(object)item.iceCubeParams.creatureWithin != (Object)null) { List mods2 = item.iceCubeParams.creatureWithin.Mods; ref CardInfo creatureWithin = ref item.iceCubeParams.creatureWithin; object obj2 = list.CardByName(((Object)item.iceCubeParams.creatureWithin).name).Clone(); creatureWithin = (CardInfo)((obj2 is CardInfo) ? obj2 : null); item.iceCubeParams.creatureWithin.Mods = mods2; } if (item.tailParams != null && (Object)(object)item.tailParams.tail != (Object)null) { List mods3 = item.tailParams.tail.Mods; ref CardInfo tail = ref item.tailParams.tail; object obj3 = list.CardByName(((Object)item.tailParams.tail).name).Clone(); tail = (CardInfo)((obj3 is CardInfo) ? obj3 : null); item.tailParams.tail.Mods = mods3; } } AllCardsCopy = ((!EventActive) ? list : (CardManager.ModifyCardList?.Invoke(list) ?? list)); } private static string GetCardPrefixFromName(this CardInfo info) { string[] array = ((Object)info).name.Split(new char[1] { '_' }); if (array.Length <= 1) { return string.Empty; } return array[0]; } private static void AddPrefixesToCards(IEnumerable cards, string prefix) { foreach (CardInfo card in cards) { if (string.IsNullOrEmpty(card.GetModPrefix())) { card.SetModPrefix(prefix); if (!((Object)card).name.StartsWith(prefix + "_")) { ((Object)card).name = prefix + "_" + ((Object)card).name; } } } } internal static void ResolveMissingModPrefixes() { foreach (var item in NewCards.Where((CardInfo ci) => !ci.IsBaseGameCard() && ci.IsOldApiCard()).GroupBy((CardInfo ci) => ci.GetModTag(), (CardInfo ci) => ci, (string key, IEnumerable g) => new { ModId = key, Cards = g.ToList() })) { if (string.IsNullOrEmpty(item.ModId) || item.ModId.Equals("MADH.inscryption.JSONLoader", StringComparison.OrdinalIgnoreCase)) { continue; } List list = (from ci in item.Cards select ci.GetModPrefix() into s where !string.IsNullOrEmpty(s) select s).Distinct().ToList(); if (list.Count == 1) { AddPrefixesToCards(item.Cards, list[0]); } else { if (item.Cards.Count < 6) { continue; } bool flag = false; foreach (var item2 in (from ci in item.Cards select ci.GetCardPrefixFromName() into s group s by s into g select new { Prefix = g.Key, Count = g.Count() }).ToList()) { if (item2.Count >= item.Cards.Count / 2) { AddPrefixesToCards(item.Cards, item2.Prefix); flag = true; } if (flag) { break; } } if (!flag) { string prefix = item.ModId.Split(new char[1] { '.' })[^1]; AddPrefixesToCards(item.Cards, prefix); } } } } static CardManager() { CardExtensionProperties = new ConditionalWeakTable(); CardAlternatePortraits = new ConditionalWeakTable(); CustomCardUnlocks = new Dictionary>(); BaseGameCards = new ReadOnlyCollection(GetBaseGameCards().ToList()); NewCards = new ObservableCollection(); EventActive = false; AllCardsCopy = BaseGameCards.ToList(); InscryptionAPIPlugin.ScriptableObjectLoaderLoad += delegate(Type type) { if (type == typeof(CardInfo)) { ScriptableObjectLoader.allData = AllCardsCopy; } }; NewCards.CollectionChanged += delegate { SyncCardList(); }; } internal static void Add(CardInfo newCard) { if (string.IsNullOrEmpty(newCard.GetModTag())) { Assembly callingAssembly = Assembly.GetCallingAssembly(); newCard.SetModTag(TypeManager.GetModIdFromCallstack(callingAssembly)); } if (!NewCards.Contains(newCard)) { NewCards.Add(newCard); } } public static void Add(string modPrefix, CardInfo newCard) { if (!((Object)newCard).name.StartsWith(modPrefix)) { ((Object)newCard).name = modPrefix + "_" + ((Object)newCard).name; } newCard.SetModPrefix(modPrefix); Add(newCard); } public static void Remove(CardInfo card) { if ((Object)(object)card != (Object)null) { CardInfo item; while ((Object)(object)(item = ((IEnumerable)NewCards).SingleOrDefault((Func)((CardInfo c) => ((Object)c).name == ((Object)card).name))) != (Object)null) { NewCards.Remove(item); } } } public static CardInfo New(string modPrefix, string name, string displayName, int attack, int health, string description = null) { CardInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = ((!name.StartsWith(modPrefix)) ? (modPrefix + "_" + name) : name); val.SetBasic(displayName, attack, health, description); Assembly callingAssembly = Assembly.GetCallingAssembly(); val.SetModTag(TypeManager.GetModIdFromCallstack(callingAssembly)); Add(modPrefix, val); return val; } public static T GetExtendedClass(this CardInfo card) where T : class, new() { Dictionary typeMap = CardExtensionProperties.GetOrCreateValue(card).TypeMap; if (typeMap.TryGetValue(typeof(T), out var value)) { return (T)value; } T val = new T(); typeMap[typeof(T)] = val; return val; } public static Dictionary GetCardExtensionTable(this CardInfo card) { return CardExtensionProperties.GetOrCreateValue(card).StringMap; } internal static CardAltPortraits GetAltPortraits(this CardInfo card) { return CardAlternatePortraits.GetOrCreateValue(card); } public static Sprite PixelAlternatePortrait(this CardInfo card) { return card.GetAltPortraits().PixelAlternatePortrait; } public static Sprite SteelTrapPortrait(this CardInfo card) { return card.GetAltPortraits().SteelTrapPortrait; } public static Sprite EmissiveSteelTrapPortrait(this CardInfo card) { return card.GetAltPortraits().SteelTrapPortrait.GetEmissionSprite(); } public static Sprite PixelSteelTrapPortrait(this CardInfo card) { return card.GetAltPortraits().PixelSteelTrapPortrait; } public static Sprite BrokenShieldPortrait(this CardInfo card) { return card.GetAltPortraits().BrokenShieldPortrait; } public static Sprite EmissiveBrokenShieldPortrait(this CardInfo card) { return card.GetAltPortraits().BrokenShieldPortrait.GetEmissionSprite(); } public static Sprite PixelBrokenShieldPortrait(this CardInfo card) { return card.GetAltPortraits().PixelBrokenShieldPortrait; } public static Sprite SacrificablePortrait(this CardInfo card) { return card.GetAltPortraits().SacrificablePortrait; } public static Sprite EmissiveSacrificablePortrait(this CardInfo card) { return card.GetAltPortraits().SacrificablePortrait.GetEmissionSprite(); } public static Sprite PixelSacrificablePortrait(this CardInfo card) { return card.GetAltPortraits().PixelSacrificablePortrait; } private static string ReverseKey(string key) { foreach (KeyValuePair item in ModdedSaveManager.SaveData.SaveData["cyantist.inscryption.api"]) { if (item.Value.Equals(key)) { return item.Key; } } return "ERROR"; } internal static void AuditCardList() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_003e: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Invalid comparison between Unknown and I4 //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_023b: 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) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Invalid comparison between Unknown and I4 //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) foreach (CardInfo item in AllCardsCopy) { foreach (Ability ability in item.Abilities) { Ability current2 = ability; string text = (((int)current2 >= 1000) ? ReverseKey(((object)(Ability)(ref current2)).ToString()).Replace("Ability_", "") : $"Inscryption_{current2}"); if (text.Equals("ERROR")) { InscryptionAPIPlugin.Logger.LogWarning((object)$"Card {((Object)item).name} has an ability {current2} that is not a part of the base game and was not assigned by the API!"); } else if ((Object)(object)AbilitiesUtil.GetInfo(current2) == (Object)null) { InscryptionAPIPlugin.Logger.LogWarning((object)("Card " + ((Object)item).name + " has an ability " + text + " that has not been properly registered!")); } } foreach (SpecialTriggeredAbility specialAbility2 in item.SpecialAbilities) { SpecialTriggeredAbility specialAbility = specialAbility2; string text2 = (((int)specialAbility >= 1000) ? ReverseKey(((object)(SpecialTriggeredAbility)(ref specialAbility)).ToString()).Replace("SpecialTriggeredAbility_", "") : $"Inscryption_{specialAbility}"); if (text2.Equals("ERROR")) { InscryptionAPIPlugin.Logger.LogWarning((object)$"Card {((Object)item).name} has a special ability {specialAbility} that is not a part of the base game and was not assigned by the API!"); } else if (SpecialTriggeredAbilityManager.AllSpecialTriggers.FirstOrDefault((SpecialTriggeredAbilityManager.FullSpecialTriggeredAbility st) => st.Id == specialAbility) == null) { InscryptionAPIPlugin.Logger.LogWarning((object)("Card " + ((Object)item).name + " has a special ability " + text2 + " that has not been properly registered!")); } } foreach (Appearance item2 in item.appearanceBehaviour) { Appearance appearance = item2; string text3 = (((int)appearance >= 1000) ? ReverseKey(((object)(Appearance)(ref appearance)).ToString()).Replace("CardAppearanceBehaviour.Appearance_", "") : $"Inscryption_{appearance}"); if (text3.Equals("ERROR")) { InscryptionAPIPlugin.Logger.LogWarning((object)$"Card {((Object)item).name} has an appearance behavior {appearance} that is not a part of the base game and was not assigned by the API!"); } else if (CardAppearanceBehaviourManager.AllAppearances.FirstOrDefault((CardAppearanceBehaviourManager.FullCardAppearanceBehaviour f) => f.Id == appearance) == null) { InscryptionAPIPlugin.Logger.LogWarning((object)("Card " + ((Object)item).name + " has an appearance behavior " + text3 + " that has not been properly registered!")); } } } } [HarmonyPatch(typeof(CardInfo), "Clone")] [HarmonyPostfix] private static void ClonePostfix(CardInfo __instance, ref object __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) CardExtensionProperties.Add((CardInfo)__result, CardExtensionProperties.GetOrCreateValue(__instance)); CardAlternatePortraits.Add((CardInfo)__result, CardAlternatePortraits.GetOrCreateValue(__instance)); ((CardInfo)__result).Mods = new List(__instance.Mods); } [HarmonyPrefix] [HarmonyPatch(typeof(DeckInfo), "ModifyCard")] private static bool ModifyCardDontAddDupes(CardInfo card, CardModificationInfo mod) { return !card.Mods.Contains(mod); } [HarmonyILManipulator] [HarmonyPatch(typeof(ConceptProgressionTree), "CardUnlocked")] private static void FixCardUnlocked(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.GotoNext((MoveType)0, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.Method(typeof(Object), "op_Equality", new Type[2] { typeof(Object), typeof(Object) }, (Type[])null)) }); val.Remove(); val.EmitDelegate>((Func)((CardInfo c1, CardInfo c2) => ((Object)c1).name == ((Object)c2).name)); } [HarmonyPostfix] [HarmonyPatch(typeof(ConceptProgressionTree), "CardUnlocked")] private static void AddCustomCardUnlock(ref bool __result, CardInfo card) { __result &= !CustomCardUnlocks.ContainsKey(((Object)card).name) || CustomCardUnlocks[((Object)card).name](SaveFile.IsAscension, (AscensionSaveData.Data?.challengeLevel).GetValueOrDefault()); } [HarmonyPatch(typeof(CardLoader), "GetCardByName", new Type[] { typeof(string) })] [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown List list = new List(instructions); MethodInfo methodInfo = SymbolExtensions.GetMethodInfo((Expression)(() => CardLoader.Clone((CardInfo)null))); MethodInfo methodInfo2 = SymbolExtensions.GetMethodInfo((Expression)(() => LogCardInfo(null, null))); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Call && list[i].operand == methodInfo) { list.Insert(i++, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i++, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); break; } } return list; } public static CardInfo LogCardInfo(CardInfo info, string cardInfoName) { if ((Object)(object)info == (Object)null) { InscryptionAPIPlugin.Logger.LogError((object)("[CardLoader] Could not find CardInfo with name '" + cardInfoName + "'")); } return info; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "SwitchToAlternatePortrait")] private static void SwitchToAlternatePortraitPixel(PlayableCard __instance) { if (SaveManager.SaveFile.IsPart2 && ((Card)__instance).Info.HasPixelAlternatePortrait()) { ((CardDisplayer)((Component)__instance).GetComponentInChildren()).portraitRenderer.sprite = ((Card)__instance).Info.PixelAlternatePortrait(); ((Renderer)((CardDisplayer)((Component)__instance).GetComponentInChildren()).portraitRenderer).enabled = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "SwitchToDefaultPortrait")] private static void SwitchToDefaultPortraitPixel(PlayableCard __instance) { if (SaveManager.SaveFile.IsPart2) { ((CardDisplayer)((Component)__instance).GetComponentInChildren()).portraitRenderer.sprite = ((Card)__instance).Info.pixelPortrait; ((Renderer)((CardDisplayer)((Component)__instance).GetComponentInChildren()).portraitRenderer).enabled = (Object)(object)((Card)__instance).Info.pixelPortrait != (Object)null; } } [HarmonyPostfix] [HarmonyPatch(typeof(PaperCardAnimationController), "SetShaking")] [HarmonyPatch(typeof(CardAnimationController), "SetShaking")] private static void SwitchToSacrificablePortrait(CardAnimationController __instance) { if ((Object)(object)__instance.PlayableCard == (Object)null) { return; } if (SaveManager.SaveFile.IsPart2) { if (((Card)__instance.PlayableCard).Info.HasPixelSacrificablePortrait()) { ((CardDisplayer)((Component)__instance.PlayableCard).GetComponentInChildren()).portraitRenderer.sprite = ((Card)__instance.PlayableCard).Info.PixelSacrificablePortrait(); ((Renderer)((CardDisplayer)((Component)__instance.PlayableCard).GetComponentInChildren()).portraitRenderer).enabled = true; } } else if (((Card)__instance.PlayableCard).Info.HasSacrificablePortrait()) { __instance.PlayableCard.SwitchToPortrait(((Card)__instance.PlayableCard).Info.SacrificablePortrait()); } } } public static class CardModificationInfoExtensions { public static bool HasDeathCardInfo(this CardModificationInfo mod) { return mod.deathCardInfo != null; } public static CardModificationInfo AddDecalIds(this CardModificationInfo mod, params string[] decalIds) { foreach (string item in decalIds) { if (!mod.DecalIds.Contains(item)) { mod.DecalIds.Add(item); } } return mod; } public static CardModificationInfo AddNegateAbilities(this CardModificationInfo mod, params Ability[] negateAbilities) { if (mod.negateAbilities == null) { mod.negateAbilities = new List(); } mod.negateAbilities.AddRange(negateAbilities); return mod; } public static CardModificationInfo SetNameReplacement(this CardModificationInfo mod, string name = null) { mod.nameReplacement = name; return mod; } public static CardModificationInfo SetSingletonId(this CardModificationInfo mod, string id = null) { if (id != null) { mod.singletonId = id; } return mod; } public static CardModificationInfo SetAttackAndHealth(this CardModificationInfo mod, int attack = 0, int health = 0) { mod.attackAdjustment = attack; mod.healthAdjustment = health; return mod; } public static CardModificationInfo SetCosts(this CardModificationInfo mod, int blood = 0, int bones = 0, int energy = 0, List gems = null) { return mod.SetBloodCost(blood).SetBonesCost(bones).SetEnergyCost(energy) .SetGemsCost(gems); } public static CardModificationInfo SetBloodCost(this CardModificationInfo mod, int cost = 0) { mod.bloodCostAdjustment = cost; return mod; } public static CardModificationInfo SetBonesCost(this CardModificationInfo mod, int cost = 0) { mod.bonesCostAdjustment = cost; return mod; } public static CardModificationInfo SetEnergyCost(this CardModificationInfo mod, int cost = 0) { mod.energyCostAdjustment = cost; return mod; } public static CardModificationInfo SetGemsCost(this CardModificationInfo mod, List cost = null) { if (cost != null) { mod.addGemCost = cost; } return mod; } public static CardModificationInfo SetGemsCost(this CardModificationInfo mod, params GemType[] cost) { if (cost.Length != 0) { mod.addGemCost = cost.ToList(); } return mod; } public static CardModificationInfo AddAbilities(this CardModificationInfo mod, params Ability[] abilities) { mod.abilities.AddRange(abilities); return mod; } public static CardModificationInfo SetDeathCardPortrait(this CardModificationInfo mod, FigurineType headType = 0, int mouthIndex = 0, int eyesIndex = 0, bool lostEye = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown mod.deathCardInfo = new DeathCardInfo(headType, mouthIndex, eyesIndex) { lostEye = lostEye }; return mod; } public static void SetTemporaryDecal(this CardModificationInfo mod) { mod.SetExtendedProperty("API:TemporaryDecal", true); } public static bool IsTemporaryDecal(this CardModificationInfo mod) { return mod.GetExtendedPropertyAsBool("API:TemporaryDecal").GetValueOrDefault(); } public static CardModificationInfo ClearCustomPropertiesId(this CardModificationInfo mod) { string customPropertiesIdString = CardModificationInfoManager.GetCustomPropertiesIdString(mod); if (customPropertiesIdString != null) { mod.singletonId = mod.singletonId.Replace(customPropertiesIdString, ""); } return mod; } public static CardModificationInfo ClearCustomCostsId(this CardModificationInfo mod) { string customCostsIdString = CardModificationInfoManager.GetCustomCostsIdString(mod); if (customCostsIdString != null) { mod.singletonId = mod.singletonId.Replace(customCostsIdString, ""); } return mod; } public static bool HasCustomPropertyId(this CardModificationInfo mod, string propertyName) { if (mod.singletonId.HasCustomPropertiesId()) { return mod.singletonId.Contains(propertyName); } return false; } public static bool HasCustomPropertyId(this string singletonId, string propertyName) { if (singletonId.HasCustomPropertiesId()) { return singletonId.Contains(propertyName); } return false; } public static bool HasCustomPropertiesId(this CardModificationInfo mod) { if (!StringExtensions.IsNullOrWhitespace(mod.singletonId)) { return mod.singletonId.Contains("[Properties:"); } return false; } public static bool HasCustomPropertiesId(this string singletonId) { if (!StringExtensions.IsNullOrWhitespace(singletonId)) { return singletonId.Contains("[Properties:"); } return false; } public static CardModificationInfo SetPropertiesId(this CardModificationInfo mod, string propertyName, object value) { string text = $"{propertyName},{value}"; if (mod.HasCustomPropertiesId()) { string customPropertiesIdString = CardModificationInfoManager.GetCustomPropertiesIdString(mod); string newValue; if (customPropertiesIdString.Contains(propertyName)) { string customPropertyId = mod.GetCustomPropertyId(propertyName); string idKeyPair = CardModificationInfoManager.GetIdKeyPair(customPropertiesIdString, propertyName); newValue = customPropertiesIdString.Replace(idKeyPair, idKeyPair.Replace(customPropertyId, value.ToString())); } else { newValue = customPropertiesIdString.Remove(customPropertiesIdString.Length - 1) + ";" + text + "]"; } mod.singletonId = mod.singletonId.Replace(customPropertiesIdString, newValue); } else if (StringExtensions.IsNullOrWhitespace(mod.singletonId)) { mod.singletonId = "[Properties:" + text + "]"; } else { mod.singletonId = mod.singletonId + "[Properties:" + text + "]"; } return mod; } public static bool HasCustomProperty(this CardModificationInfo mod, string propertyName) { return mod.GetCustomProperty(propertyName) != null; } public static string GetCustomProperty(this CardModificationInfo mod, string propertyName) { return mod.GetExtendedProperty(propertyName) ?? mod.GetCustomPropertyId(propertyName); } public static string GetCustomPropertyId(this CardModificationInfo mod, string propertyName) { if (!mod.HasCustomPropertyId(propertyName)) { return null; } string customPropertiesIdString = CardModificationInfoManager.GetCustomPropertiesIdString(mod); int num = customPropertiesIdString.IndexOf(propertyName + ","); if (num == -1) { return null; } string text = customPropertiesIdString.Substring(num); int num2 = text.IndexOf(';'); if (num2 == -1) { num2 = text.IndexOf(']'); } return text.Substring(num2).Replace(propertyName + ",", ""); } public static bool HasCustomCostId(this CardModificationInfo mod, string costName) { if (mod.singletonId.HasCustomCostsId()) { return mod.singletonId.Contains(costName); } return false; } public static bool HasCustomCostId(this string singletonId, string costName) { if (singletonId.HasCustomCostsId()) { return singletonId.Contains(costName); } return false; } public static bool HasCustomCostsId(this CardModificationInfo mod) { if (!StringExtensions.IsNullOrWhitespace(mod.singletonId)) { return mod.singletonId.Contains("[CustomCosts:"); } return false; } public static bool HasCustomCostsId(this string singletonId) { if (!StringExtensions.IsNullOrWhitespace(singletonId)) { return singletonId.Contains("[CustomCosts:"); } return false; } public static CardModificationInfo SetCustomCostId(this CardModificationInfo mod, string costName, object value) { string text = $"{costName},{value}"; if (mod.HasCustomCostsId()) { string customCostsIdString = CardModificationInfoManager.GetCustomCostsIdString(mod); string newValue; if (customCostsIdString.Contains(costName)) { string customCostId = mod.GetCustomCostId(costName); string idKeyPair = CardModificationInfoManager.GetIdKeyPair(customCostsIdString, costName); newValue = customCostsIdString.Replace(idKeyPair, idKeyPair.Replace(customCostId, value.ToString())); } else { newValue = customCostsIdString.Remove(customCostsIdString.Length - 1) + ";" + text + "]"; } mod.singletonId = mod.singletonId.Replace(customCostsIdString, newValue); } else if (StringExtensions.IsNullOrWhitespace(mod.singletonId)) { mod.singletonId = "[CustomCosts:" + text + "]"; } else { mod.singletonId = mod.singletonId + "[CustomCosts:" + text + "]"; } return mod; } public static bool HasCustomCost(this CardModificationInfo mod, string costName) { return (mod.GetExtendedProperty(costName) ?? mod.GetCustomCostId(costName)) != null; } public static int GetCustomCost(this CardModificationInfo mod, string costName) { return mod.GetExtendedPropertyAsInt(costName) ?? mod.GetCustomCostIdValue(costName); } public static string GetCustomCostId(this CardModificationInfo mod, string costName) { if (!mod.HasCustomCostId(costName)) { return null; } string customCostsIdString = CardModificationInfoManager.GetCustomCostsIdString(mod); int num = customCostsIdString.IndexOf(costName + ","); if (num == -1) { return null; } string text = customCostsIdString.Substring(num); int num2 = text.IndexOf(';'); if (num2 == -1) { num2 = text.IndexOf(']'); } return text.Substring(0, num2).Replace(costName + ",", ""); } public static int GetCustomCostIdValue(this CardModificationInfo mod, string costName) { string customCostId = mod.GetCustomCostId(costName); if (customCostId == null) { return 0; } if (!int.TryParse(customCostId, out var result)) { return 0; } return result; } public static List GetCustomCostsFromMod(this CardModificationInfo mod) { List costs = new List(); foreach (string key in mod.GetCardModExtensionTable().Keys) { if (CardCostManager.AllCustomCosts.Exists((CardCostManager.FullCardCost x) => x.CostName == key)) { costs.Add(CardCostManager.AllCustomCosts.Find((CardCostManager.FullCardCost x) => x.CostName == key)); } } if (mod.HasCustomPropertiesId()) { List modCosts = new List(); CardModificationInfoManager.GetCustomCostsFromId(mod.singletonId).ForEach(delegate(string x) { modCosts.Add(x.Split(new char[1] { ',' })[0]); }); costs.AddRange(CardCostManager.AllCustomCosts.Where((CardCostManager.FullCardCost x) => !costs.Contains(x) && modCosts.Contains(x.CostName))); } return costs; } public static string CleanId(this CardModificationInfo mod) { return mod.IdWithoutCosts().IdWithoutProperties(); } public static string IdWithoutProperties(this CardModificationInfo mod) { return mod.singletonId.IdWithoutProperties(); } public static string IdWithoutProperties(this string singletonId) { if (!singletonId.HasCustomPropertiesId()) { return singletonId; } string customPropertiesIdString = CardModificationInfoManager.GetCustomPropertiesIdString(singletonId); return singletonId.Replace(customPropertiesIdString, ""); } public static string IdWithoutCosts(this CardModificationInfo mod) { return mod.singletonId.IdWithoutCosts(); } public static string IdWithoutCosts(this string singletonId) { if (!singletonId.HasCustomCostsId()) { return singletonId; } string customCostsIdString = CardModificationInfoManager.GetCustomCostsIdString(singletonId); return singletonId.Replace(customCostsIdString, ""); } public static CardModificationInfo SetExtendedProperty(this CardModificationInfo mod, string propertyName, object value, bool addToSingletonId = false) { mod.GetCardModExtensionTable()[propertyName] = value?.ToString(); if (addToSingletonId) { mod.SetPropertiesId(propertyName, value); } return mod; } public static string GetExtendedProperty(this CardModificationInfo mod, string propertyName) { mod.GetCardModExtensionTable().TryGetValue(propertyName, out var value); return value; } public static int? GetExtendedPropertyAsInt(this CardModificationInfo mod, string propertyName) { mod.GetCardModExtensionTable().TryGetValue(propertyName, out var value); if (!int.TryParse(value, out var result)) { return null; } return result; } public static float? GetExtendedPropertyAsFloat(this CardModificationInfo mod, string propertyName) { mod.GetCardModExtensionTable().TryGetValue(propertyName, out var value); if (!float.TryParse(value, out var result)) { return null; } return result; } public static bool? GetExtendedPropertyAsBool(this CardModificationInfo mod, string propertyName) { mod.GetCardModExtensionTable().TryGetValue(propertyName, out var value); if (!bool.TryParse(value, out var result)) { return null; } return result; } public static void ClearAllRemovedGemsCosts(this CardModificationInfo mod) { if (mod.HasRemovedGreenGemCost()) { mod.RemoveGreenGemCost(remove: false); } if (mod.HasRemovedOrangeGemCost()) { mod.RemoveOrangeGemCost(remove: false); } if (mod.HasRemoveBlueGemCost()) { mod.RemoveBlueGemCost(remove: false); } } public static List RemovedGemsCosts(this CardModificationInfo mod) { List list = new List(); if (mod.HasRemovedGreenGemCost()) { list.Add((GemType)0); } if (mod.HasRemovedOrangeGemCost()) { list.Add((GemType)1); } if (mod.HasRemoveBlueGemCost()) { list.Add((GemType)2); } return list; } public static CardModificationInfo RemoveGemsCost(this CardModificationInfo mod, params GemType[] gemTypes) { if (gemTypes.Contains((GemType)0)) { mod.RemoveGreenGemCost(remove: true); } if (gemTypes.Contains((GemType)1)) { mod.RemoveOrangeGemCost(remove: true); } if (gemTypes.Contains((GemType)2)) { mod.RemoveBlueGemCost(remove: true); } return mod; } public static CardModificationInfo ClearRemovedGemsCost(this CardModificationInfo mod, params GemType[] gemTypes) { if (gemTypes.Contains((GemType)0)) { mod.RemoveGreenGemCost(remove: false); } if (gemTypes.Contains((GemType)1)) { mod.RemoveOrangeGemCost(remove: false); } if (gemTypes.Contains((GemType)2)) { mod.RemoveBlueGemCost(remove: false); } return mod; } public static CardModificationInfo RemoveGreenGemCost(this CardModificationInfo mod, bool remove) { return mod.SetExtendedProperty("RemoveGreenGem", remove, addToSingletonId: true); } public static CardModificationInfo RemoveOrangeGemCost(this CardModificationInfo mod, bool remove) { return mod.SetExtendedProperty("RemoveOrangeGem", remove, addToSingletonId: true); } public static CardModificationInfo RemoveBlueGemCost(this CardModificationInfo mod, bool remove) { return mod.SetExtendedProperty("RemoveBlueGem", remove, addToSingletonId: true); } public static bool HasRemovedGreenGemCost(this CardModificationInfo mod) { return mod.GetExtendedPropertyAsBool("RemoveGreenGem").GetValueOrDefault(); } public static bool HasRemovedOrangeGemCost(this CardModificationInfo mod) { return mod.GetExtendedPropertyAsBool("RemoveOrangeGem").GetValueOrDefault(); } public static bool HasRemoveBlueGemCost(this CardModificationInfo mod) { return mod.GetExtendedPropertyAsBool("RemoveBlueGem").GetValueOrDefault(); } public static bool HasRemovedAnyGemCost(this CardModificationInfo mod) { if (!mod.HasRemovedGreenGemCost() && !mod.HasRemovedOrangeGemCost()) { return mod.HasRemoveBlueGemCost(); } return true; } public static bool HasRemovedGemCost(this CardModificationInfo mod, GemType gemType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown return (int)gemType switch { 0 => mod.HasRemovedGreenGemCost(), 1 => mod.HasRemovedOrangeGemCost(), 2 => mod.HasRemoveBlueGemCost(), _ => false, }; } } [HarmonyPatch] public static class CardModificationInfoManager { private class CardModExt { public readonly Dictionary TypeMap = new Dictionary(); public readonly Dictionary StringMap = new Dictionary(); } internal const string PROPERTIES = "[Properties:"; internal const string CUSTOM_COSTS = "[CustomCosts:"; private static readonly ConditionalWeakTable CardModExtensionProperties = new ConditionalWeakTable(); public static T GetExtendedClass(this CardModificationInfo card) where T : class, new() { Dictionary typeMap = CardModExtensionProperties.GetOrCreateValue(card).TypeMap; if (typeMap.TryGetValue(typeof(T), out var value)) { return (T)value; } T val = new T(); typeMap[typeof(T)] = val; return val; } internal static Dictionary GetCardModExtensionTable(this CardModificationInfo mod) { if (CardModExtensionProperties.TryGetValue(mod, out var value)) { return value.StringMap; } CardModExt cardModExt = new CardModExt(); CardModExtensionProperties.Add(mod, cardModExt); if (mod.HasCustomPropertiesId()) { foreach (string item in GetCustomPropertiesFromId(mod.singletonId)) { string[] array = item.Split(new char[1] { ',' }); cardModExt.StringMap[array[0]] = array[1]; } } if (mod.HasCustomCostsId()) { foreach (string item2 in GetCustomCostsFromId(mod.singletonId)) { string[] array2 = item2.Split(new char[1] { ',' }); cardModExt.StringMap[array2[0]] = array2[1]; } } return cardModExt.StringMap; } public static void SyncCardMods() { foreach (CardInfo item in CardManager.AllCardsCopy) { foreach (CardModificationInfo item2 in item.Mods.Where((CardModificationInfo x) => x.HasCustomPropertiesId())) { foreach (string item3 in GetCustomPropertiesFromId(item2.singletonId)) { string[] array = item3.Split(new char[1] { ',' }); item2.SetExtendedProperty(array[0], array[1]); } } foreach (CardModificationInfo item4 in item.Mods.Where((CardModificationInfo x) => x.HasCustomCostsId())) { foreach (string item5 in GetCustomCostsFromId(item4.singletonId)) { string[] array2 = item5.Split(new char[1] { ',' }); item4.SetExtendedProperty(array2[0], array2[1]); } } } } public static List GetCustomPropertiesFromId(string singletonId) { List list = new List(); string customPropertiesIdString = GetCustomPropertiesIdString(singletonId); if (customPropertiesIdString != null) { customPropertiesIdString = customPropertiesIdString.Replace("[Properties:", ""); if (customPropertiesIdString.EndsWith("]")) { customPropertiesIdString = customPropertiesIdString.Remove(customPropertiesIdString.Length - 1); LinqExtensions.ForEach((IEnumerable)customPropertiesIdString.Split(new char[1] { ';' }), (Action)list.Add); } } return list; } public static List GetCustomCostsFromId(string singletonId) { List list = new List(); string customCostsIdString = GetCustomCostsIdString(singletonId); if (customCostsIdString != null) { customCostsIdString = customCostsIdString.Replace("[CustomCosts:", ""); if (customCostsIdString.EndsWith("]")) { customCostsIdString = customCostsIdString.Remove(customCostsIdString.Length - 1); LinqExtensions.ForEach((IEnumerable)customCostsIdString.Split(new char[1] { ';' }), (Action)list.Add); } } return list; } public static string GetCustomPropertiesIdString(CardModificationInfo mod) { if (!mod.HasCustomPropertiesId()) { return null; } return GetCustomPropertiesIdString(mod.singletonId); } public static string GetCustomPropertiesIdString(string singletonId) { if (!singletonId.HasCustomPropertiesId()) { return null; } int startIndex = singletonId.IndexOf("[Properties:"); string text = singletonId.Substring(startIndex); int num = text.IndexOf("]"); return text.Substring(0, num + 1); } public static string GetCustomCostsIdString(CardModificationInfo mod) { if (!mod.HasCustomCostsId()) { return null; } return GetCustomCostsIdString(mod.singletonId); } public static string GetCustomCostsIdString(string singletonId) { if (!singletonId.HasCustomCostsId()) { return null; } int startIndex = singletonId.IndexOf("[CustomCosts:"); string text = singletonId.Substring(startIndex); int num = text.IndexOf("]"); return text.Substring(0, num + 1); } public static string GetIdKeyPair(string properties, string key) { string text = properties.Substring(properties.IndexOf(key + ",")); int num = text.IndexOf(";"); if (num == -1) { num = text.IndexOf(']'); } return text.Substring(0, num); } [HarmonyPatch(typeof(CardModificationInfo), "Clone")] [HarmonyPostfix] private static void ClonePostfix(CardModificationInfo __instance, ref object __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown CardModExtensionProperties.Add((CardModificationInfo)__result, CardModExtensionProperties.GetOrCreateValue(__instance)); } [HarmonyPatch(typeof(Card), "SetInfo")] [HarmonyPrefix] private static void AddCustomCostsFromMods(CardInfo info) { CardCostManager.AllCustomCosts.Select((CardCostManager.FullCardCost x) => x.CostName).ToList(); foreach (CardModificationInfo mod in info.Mods) { foreach (string item in GetCustomPropertiesFromId(mod.singletonId)) { item.Split(new char[1] { ',' }); } foreach (string item2 in GetCustomCostsFromId(mod.singletonId)) { item2.Split(new char[1] { ',' }); } } } [HarmonyPatch(typeof(CardTriggerHandler), "RemoveAbility")] [HarmonyPrefix] private static bool FixedRemoveTemporaryMod(CardTriggerHandler __instance, Ability ability) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Tuple tuple = __instance.triggeredAbilities.Find((Tuple x) => x.Item1 == ability); if (tuple != null) { __instance.triggeredAbilities.Remove(tuple); if (!__instance.triggeredAbilities.Exists((Tuple x) => x.Item1 == ability)) { Object.Destroy((Object)(object)tuple.Item2); } } return false; } } public abstract class DamageShieldBehaviour : AbilityBehaviour { public int numShields; public bool initialised; public int NumShields => Mathf.Max(0, numShields); public abstract int StartingNumShields { get; } public bool HasShields() { return NumShields > 0; } public virtual void Awake() { if ((Object)(object)((AbilityBehaviour)this).Card != (Object)null) { numShields = StartingNumShields; } initialised = true; } public virtual void Start() { } public virtual void AddShields(int amount, bool updateDisplay = true) { numShields += amount; if (HasShields()) { ((AbilityBehaviour)this).Card.Status.lostShield = false; } if (updateDisplay) { ((AbilityBehaviour)this).Card.OnStatsChanged(); } } public virtual void RemoveShields(int amount, bool updateDisplay = true) { //IL_0017: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) numShields -= amount; if (!HasShields()) { if (((AbilityBehaviour)this).Ability.GetHideSingleStacks()) { for (int i = 0; i < amount; i++) { ((AbilityBehaviour)this).Card.Status.hiddenAbilities.Add(((AbilityBehaviour)this).Ability); } } else if (!((AbilityBehaviour)this).Card.Status.hiddenAbilities.Contains(((AbilityBehaviour)this).Ability)) { ((AbilityBehaviour)this).Card.Status.hiddenAbilities.Add(((AbilityBehaviour)this).Ability); } } if (updateDisplay) { ((AbilityBehaviour)this).Card.OnStatsChanged(); } } public virtual void ResetShields(bool updateDisplay) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) int num = NumShields; numShields = StartingNumShields; ((AbilityBehaviour)this).Card.Status.lostShield = false; for (int i = 0; i < numShields - num; i++) { ((AbilityBehaviour)this).Card.Status.hiddenAbilities.Remove(((AbilityBehaviour)this).Ability); } if (updateDisplay) { ((AbilityBehaviour)this).Card.OnStatsChanged(); } } } public abstract class ActivatedDamageShieldBehaviour : DamageShieldBehaviour { [CompilerGenerated] private sealed class d__64 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ActivatedDamageShieldBehaviour <>4__this; private BoardManager 5__2; private List.Enumerator <>7__wrap2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__64(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 4) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; ActivatedDamageShieldBehaviour CS$<>8__locals0 = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; 5__2 = Singleton.Instance; List cardSlots = 5__2.GetCardSlots(!((AbilityBehaviour)CS$<>8__locals0).Card.OpponentCard, (CardSlot x) => ((Object)(object)x.Card != (Object)null) & ((Object)(object)x.Card != (Object)(object)((AbilityBehaviour)CS$<>8__locals0).Card)); Singleton.Instance.Controller.LockState = (ViewLockState)0; Singleton.Instance.SwitchToView(5__2.BoardView, false, false); Singleton.Instance.ForceCursorType((CursorType)1); 5__2.cancelledPlacementWithInput = false; 5__2.currentValidSlots = cardSlots; 5__2.currentSacrificeDemandingCard = ((AbilityBehaviour)CS$<>8__locals0).Card; 5__2.CancelledSacrifice = false; 5__2.LastSacrificesInfo.Clear(); 5__2.SetQueueSlotsEnabled(false); foreach (CardSlot item in 5__2.AllSlots.Where((CardSlot x) => (Object)(object)x.Card != (Object)(object)((AbilityBehaviour)CS$<>8__locals0).Card)) { if (!item.IsPlayerSlot || (Object)(object)item.Card == (Object)null) { ((InteractableBase)item).SetEnabled(false); ((HighlightedInteractable)item).ShowState((State)1, false, 0.15f); } if (item.IsPlayerSlot && (Object)(object)item.Card != (Object)null && item.Card.CanBeSacrificed) { ((Card)item.Card).Anim.SetShaking(true); } } <>2__current = 5__2.SetSacrificeMarkersShown(CS$<>8__locals0.BloodCost); <>1__state = 1; return true; } case 1: <>1__state = -1; goto IL_01fe; case 2: <>1__state = -1; goto IL_01fe; case 3: <>1__state = -1; 5__2.HideSacrificeMarkers(); <>7__wrap2 = 5__2.currentSacrifices.GetEnumerator(); <>1__state = -3; goto IL_04bb; case 4: { <>1__state = -3; Singleton.Instance.SwitchToView(5__2.BoardView, false, false); goto IL_04bb; } IL_04bb: while (<>7__wrap2.MoveNext()) { CardSlot current = <>7__wrap2.Current; if ((Object)(object)current.Card != (Object)null && !current.Card.Dead) { BoardManager obj = 5__2; int sacrificesMadeThisTurn = obj.SacrificesMadeThisTurn; obj.SacrificesMadeThisTurn = sacrificesMadeThisTurn + 1; CS$<>8__locals0.currentSacrificedCardInfos.Add(((Card)current.Card).Info, current); <>2__current = current.Card.Sacrifice(); <>1__state = 4; return true; } } <>m__Finally1(); break; IL_01fe: if (5__2.GetValueOfSacrifices(5__2.currentSacrifices) < CS$<>8__locals0.BloodCost && !5__2.cancelledPlacementWithInput) { 5__2.SetSacrificeMarkersValue(5__2.currentSacrifices.Count); <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 2; return true; } foreach (CardSlot allSlot in 5__2.AllSlots) { ((InteractableBase)allSlot).SetEnabled(false); if (allSlot.IsPlayerSlot && (Object)(object)allSlot.Card != (Object)null) { ((Card)allSlot.Card).Anim.SetShaking(false); } } foreach (CardSlot currentSacrifice in 5__2.currentSacrifices) { 5__2.LastSacrificesInfo.Add(((Card)currentSacrifice.Card).Info); } if (5__2.cancelledPlacementWithInput) { 5__2.HideSacrificeMarkers(); foreach (CardSlot slot in 5__2.GetSlots(true)) { if ((Object)(object)slot.Card != (Object)null) { ((Card)slot.Card).Anim.SetSacrificeHoverMarkerShown(false); if (5__2.currentSacrifices.Contains(slot)) { ((Card)slot.Card).Anim.SetMarkedForSacrifice(false); } } } Singleton.Instance.SwitchToView(5__2.defaultView, false, false); Singleton.Instance.ClearForcedCursorType(); 5__2.CancelledSacrifice = true; break; } 5__2.SetSacrificeMarkersValue(5__2.GetValueOfSacrifices(5__2.currentSacrifices)); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 3; return true; } 5__2.SetQueueSlotsEnabled(true); foreach (CardSlot allSlot2 in 5__2.AllSlots) { ((InteractableBase)allSlot2).SetEnabled(true); ((HighlightedInteractable)allSlot2).ShowState((State)2, false, 0.15f); } 5__2.currentSacrificeDemandingCard = null; 5__2.currentSacrifices.Clear(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__60 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ActivatedDamageShieldBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown int num = <>1__state; ActivatedDamageShieldBehaviour CS$<>8__locals0 = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (CS$<>8__locals0.CanAfford() && CS$<>8__locals0.CanActivate()) { if (CS$<>8__locals0.BloodCost > 0) { <>2__current = CS$<>8__locals0.ChooseSacrifices(); <>1__state = 1; return true; } goto IL_0096; } ((Card)((AbilityBehaviour)CS$<>8__locals0).Card).Anim.LightNegationEffect(); AudioController.Instance.PlaySound2D("toneless_negate", (MixerGroup)10, 0.2f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 11; return true; case 1: <>1__state = -1; if (Singleton.Instance.CancelledSacrifice) { return false; } goto IL_0096; case 2: <>1__state = -1; if ((Object)(object)Singleton.Instance != (Object)null) { CardSlot val = Singleton.Instance.GetSlots(true).Find((CardSlot x) => (Object)(object)x.Card != (Object)null && x.Card.HasAbility((Ability)66)); if ((Object)(object)val != (Object)null) { ConduitEnergy component = ((Component)val.Card).GetComponent(); if ((Object)(object)component != (Object)null && component.CompletesCircuit()) { <>2__current = Singleton.Instance.AddEnergy(CS$<>8__locals0.EnergyCost); <>1__state = 3; return true; } } } goto IL_0190; case 3: <>1__state = -1; goto IL_0190; case 4: <>1__state = -1; goto IL_01bf; case 5: <>1__state = -1; <>2__current = ((AbilityBehaviour)CS$<>8__locals0).PreSuccessfulTriggerSequence(); <>1__state = 6; return true; case 6: <>1__state = -1; <>2__current = CS$<>8__locals0.Activate(); <>1__state = 7; return true; case 7: { <>1__state = -1; ProgressionData.SetMechanicLearned((MechanicsConcept)61); if (CS$<>8__locals0.HealthCost > 0 && Object.op_Implicit((Object)(object)((AbilityBehaviour)CS$<>8__locals0).Card) && ((AbilityBehaviour)CS$<>8__locals0).Card.Health <= 0 && !((AbilityBehaviour)CS$<>8__locals0).Card.Dead) { <>2__current = ((AbilityBehaviour)CS$<>8__locals0).Card.Die(true, (PlayableCard)null, true); <>1__state = 8; return true; } int onActivateEnergyCostMod = CS$<>8__locals0.OnActivateEnergyCostMod; int onActivateBonesCostMod = CS$<>8__locals0.OnActivateBonesCostMod; List onActivateGemsCostMod = CS$<>8__locals0.OnActivateGemsCostMod; int onActivateHealthCostMod = CS$<>8__locals0.OnActivateHealthCostMod; if (onActivateEnergyCostMod != 0) { CS$<>8__locals0.energyCostMod += onActivateEnergyCostMod; } if (onActivateBonesCostMod != 0) { CS$<>8__locals0.bonesCostMod += onActivateBonesCostMod; } if (onActivateGemsCostMod != null && onActivateGemsCostMod.Count > 0) { if (CS$<>8__locals0.OnActivateGemsCostModRemovesGems) { onActivateGemsCostMod.ForEach(delegate(GemType x) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) CS$<>8__locals0.gemsCostMod.Remove(x); }); } else { CS$<>8__locals0.gemsCostMod.AddRange(onActivateGemsCostMod); } } if (onActivateHealthCostMod != 0) { CS$<>8__locals0.healthCostMod += onActivateHealthCostMod; } <>2__current = CS$<>8__locals0.PostActivate(); <>1__state = 10; return true; } case 8: <>1__state = -1; <>2__current = CS$<>8__locals0.PostActivate(); <>1__state = 9; return true; case 9: <>1__state = -1; CS$<>8__locals0.currentSacrificedCardInfos.Clear(); return false; case 10: <>1__state = -1; CS$<>8__locals0.currentSacrificedCardInfos.Clear(); break; case 11: { <>1__state = -1; break; } IL_0190: if (CS$<>8__locals0.BonesCost > 0) { <>2__current = Singleton.Instance.SpendBones(CS$<>8__locals0.BonesCost); <>1__state = 4; return true; } goto IL_01bf; IL_01bf: <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 5; return true; IL_0096: if (CS$<>8__locals0.HealthCost > 0) { ((Card)((AbilityBehaviour)CS$<>8__locals0).Card).Anim.LightNegationEffect(); PlayableCardStatus status = ((AbilityBehaviour)CS$<>8__locals0).Card.Status; status.damageTaken += CS$<>8__locals0.HealthCost; } if (CS$<>8__locals0.EnergyCost > 0) { <>2__current = Singleton.Instance.SpendEnergy(CS$<>8__locals0.EnergyCost); <>1__state = 2; return true; } goto IL_0190; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__56 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__56(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__58 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ActivatedDamageShieldBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__58(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown int num = <>1__state; ActivatedDamageShieldBehaviour activatedDamageShieldBehaviour = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (activatedDamageShieldBehaviour.LearnMechanic()) { <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 1; return true; } goto IL_0159; case 1: <>1__state = -1; if (StoryEventsData.EventCompleted((StoryEvent)39)) { <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)1, Singleton.Instance.GetSpeaker((Character)0), (string[])null, (ScreenPosition)0, true); <>1__state = 2; return true; } if (StoryEventsData.EventCompleted((StoryEvent)40)) { <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)0, Singleton.Instance.GetSpeaker((Character)1), (string[])null, (ScreenPosition)0, true); <>1__state = 3; return true; } if (StoryEventsData.EventCompleted((StoryEvent)41)) { <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)2, Singleton.Instance.GetSpeaker((Character)2), (string[])null, (ScreenPosition)0, true); <>1__state = 4; return true; } <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)3, Singleton.Instance.GetSpeaker((Character)9), (string[])null, (ScreenPosition)0, true); <>1__state = 5; return true; case 2: <>1__state = -1; goto IL_0159; case 3: <>1__state = -1; goto IL_0159; case 4: <>1__state = -1; goto IL_0159; case 5: <>1__state = -1; goto IL_0159; case 6: { <>1__state = -1; break; } IL_0159: if (activatedDamageShieldBehaviour.RespondsToPostResolveOnBoard()) { <>2__current = activatedDamageShieldBehaviour.OnPostResolveOnBoard(); <>1__state = 6; return true; } break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__61 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__61(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public int bloodCostMod; public int bonesCostMod; public int energyCostMod; public List gemsCostMod; public int healthCostMod; public Dictionary currentSacrificedCardInfos = new Dictionary(); public virtual int StartingBloodCost { get; } public virtual int StartingBonesCost { get; } public virtual int StartingEnergyCost { get; } public virtual List StartingGemsCost { get; } public virtual int StartingHealthCost { get; } public virtual int OnActivateBloodCostMod { get; set; } public virtual int OnActivateBonesCostMod { get; set; } public virtual int OnActivateEnergyCostMod { get; set; } public virtual List OnActivateGemsCostMod { get; set; } public virtual bool OnActivateGemsCostModRemovesGems { get; set; } public virtual int OnActivateHealthCostMod { get; set; } public int BloodCost => Mathf.Max(0, StartingBloodCost + bloodCostMod); public int BonesCost => Mathf.Max(0, StartingBonesCost + bonesCostMod); public int EnergyCost => Mathf.Max(0, StartingEnergyCost + energyCostMod); public List GemsCost { get { List list = new List(); if (StartingGemsCost != null && StartingGemsCost.Count > 0) { list.AddRange(StartingGemsCost); } list.AddRange(gemsCostMod); return list; } } public int HealthCost => Mathf.Max(0, StartingHealthCost + healthCostMod); public virtual bool RespondsToPostResolveOnBoard() { return false; } [IteratorStateMachine(typeof(d__56))] public virtual IEnumerator OnPostResolveOnBoard() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__56(0); } public sealed override bool RespondsToResolveOnBoard() { if (!RespondsToPostResolveOnBoard()) { return LearnMechanic(); } return true; } [IteratorStateMachine(typeof(d__58))] public sealed override IEnumerator OnResolveOnBoard() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__58(0) { <>4__this = this }; } public sealed override bool RespondsToActivatedAbility(Ability ability) { //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) return ((AbilityBehaviour)this).Ability == ability; } [IteratorStateMachine(typeof(d__60))] public sealed override IEnumerator OnActivatedAbility() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__60(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__61))] public virtual IEnumerator PostActivate() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__61(0); } public virtual bool CanActivate() { return true; } public abstract IEnumerator Activate(); [IteratorStateMachine(typeof(d__64))] private IEnumerator ChooseSacrifices() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__64(0) { <>4__this = this }; } private bool CanAfford() { if ((BloodCost < 1 || SacrificeValue() >= BloodCost) && ((AbilityBehaviour)this).Card.Health >= HealthCost && Singleton.Instance.PlayerEnergy >= EnergyCost && Singleton.Instance.PlayerBones >= BonesCost) { bool num = ResourcesManagerHelpers.GemCount(!((AbilityBehaviour)this).Card.OpponentCard, (GemType)1) >= GemsCost.Count((GemType x) => (int)x == 1); bool flag = ResourcesManagerHelpers.GemCount(!((AbilityBehaviour)this).Card.OpponentCard, (GemType)0) >= GemsCost.Count((GemType x) => (int)x == 0); bool flag2 = ResourcesManagerHelpers.GemCount(!((AbilityBehaviour)this).Card.OpponentCard, (GemType)2) >= GemsCost.Count((GemType x) => (int)x == 2); return num && flag && flag2; } return false; } private bool LearnMechanic() { if (SaveManager.SaveFile.IsPart2) { return !ProgressionData.LearnedMechanic((MechanicsConcept)61); } return false; } private int SacrificeValue() { return Singleton.Instance.GetValueOfSacrifices(Singleton.Instance.GetCardSlots(!((AbilityBehaviour)this).Card.OpponentCard, (CardSlot x) => (Object)(object)x.Card != (Object)null && (Object)(object)x.Card != (Object)(object)((AbilityBehaviour)this).Card)); } } public class APIDeathShield : DamageShieldBehaviour { public override Ability Ability => (Ability)54; public override int StartingNumShields => ((AbilityBehaviour)this).Card.GetAbilityStacks(((AbilityBehaviour)this).Ability); } [HarmonyPatch] public static class DeathCardManager { public const string CardPrefix = "apiDeathCard"; private static readonly List NewDefaultDeathCards = new List(); private static readonly List NewAscensionDeathMods = new List(); public static List APIDeathCards => CardManager.AllCardsCopy.FindAll((CardInfo x) => x.ModPrefixIs("apiDeathCard")); public static void AddDefaultDeathCard(CardModificationInfo deathCardMod, bool addToAscension = false) { if (addToAscension) { NewAscensionDeathMods.Add(deathCardMod); } else { NewDefaultDeathCards.Add(deathCardMod); } } private static bool MatchingDeathCardInfo(DeathCardInfo info, DeathCardInfo compareAgainst) { //IL_0015: 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 (info != null && compareAgainst != null && info.eyesIndex == compareAgainst.eyesIndex && info.headType == compareAgainst.headType && info.lostEye == compareAgainst.lostEye) { return info.mouthIndex == compareAgainst.mouthIndex; } return false; } public static string GetAPIDeathCardName(CardModificationInfo mod, bool createNewCard = false) { string text = mod.CleanId(); string name = "apiDeathCard_" + (string.IsNullOrWhiteSpace(text) ? "" : (text + "_")) + mod.nameReplacement; if (createNewCard) { int num = APIDeathCards.Count((CardInfo x) => ((Object)x).name == name); if (num > 0) { name = name + "#" + (1 + num); } } else if (APIDeathCards.Count((CardInfo x) => x.displayedName == mod.nameReplacement) > 1) { List list = APIDeathCards.FindAll((CardInfo x) => x.displayedName == mod.nameReplacement && x.Mods.Exists((CardModificationInfo y) => MatchingDeathCardInfo(y.deathCardInfo, mod.deathCardInfo))); if (list.Count == 0) { InscryptionAPIPlugin.Logger.LogError((object)("Could not find card [" + mod.nameReplacement + "] with matching deathCardInfo!")); } else { name = ((Object)list[0]).name; } } return name; } internal static CardInfo CreateCustomDeathCard(CardModificationInfo mod) { //IL_00a8: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown CardInfo val = ScriptableObject.CreateInstance().SetName(GetAPIDeathCardName(mod, createNewCard: true)).SetBasic(mod.nameReplacement, mod.attackAdjustment, mod.healthAdjustment) .SetCost(mod.bloodCostAdjustment, mod.bonesCostAdjustment, mod.energyCostAdjustment, mod.addGemCost) .AddAbilities(mod.abilities.ToArray()) .AddAppearances((Appearance)10) .AddTraits((Trait)21) .SetOnePerDeck(); val.animatedPortrait = CardLoader.GetCardByName("!DEATHCARD_BASE").animatedPortrait; val.Mods.Add(new CardModificationInfo { singletonId = mod.CleanId(), deathCardInfo = mod.deathCardInfo }); foreach (string item in CardModificationInfoManager.GetCustomCostsFromId(mod.singletonId)) { string[] array = item.Split(new char[1] { ',' }); val.SetExtendedProperty(array[0], array[1]); } CardManager.Add("apiDeathCard", val); return val; } internal static void AddCustomDeathCards() { foreach (CardModificationInfo item in NewDefaultDeathCards.Concat(SaveManager.SaveFile.deathCardMods).ToList().FindAll((CardModificationInfo x) => x.HasCustomCostsId())) { CreateCustomDeathCard(item); } } [HarmonyPatch(typeof(SaveFile), "GetChoosableDeathcardMods")] [HarmonyPostfix] private static void AddDuplicateNameCards(SaveFile __instance, List __result) { if (SaveFile.IsAscension) { return; } List list = new List(__instance.deathCardMods); list.RemoveAll((CardModificationInfo x) => __result.Contains(x) || ((CardCollectionInfo)RunState.Run.playerDeck).Cards.Exists((CardInfo y) => y.displayedName == x.nameReplacement && y.Mods.Exists((CardModificationInfo z) => MatchingDeathCardInfo(z.deathCardInfo, x.deathCardInfo)))); __result.AddRange(list); } [HarmonyPatch(typeof(CardLoader), "CreateDeathCard")] [HarmonyPostfix] private static void ReplaceWithAPIDeathCard(ref CardInfo __result, CardModificationInfo deathCardMod) { if (deathCardMod.HasCustomCostsId()) { CardInfo cardByName = CardLoader.GetCardByName(GetAPIDeathCardName(deathCardMod)); if ((Object)(object)cardByName != (Object)null) { __result = cardByName; } } } [HarmonyPatch(typeof(DefaultDeathCards), "CreateDefaultCardMods")] [HarmonyPostfix] private static void AddNewDefaultDeathCards(ref List __result) { foreach (CardModificationInfo newDefaultDeathCard in NewDefaultDeathCards) { __result.Add(newDefaultDeathCard); } } [HarmonyPatch(typeof(DefaultDeathCards), "CreateAscensionCardMods")] [HarmonyPostfix] private static void AddNewAscensionDeathMods(ref List __result) { foreach (CardModificationInfo newAscensionDeathMod in NewAscensionDeathMods) { __result.Add(newAscensionDeathMod); } __result.RemoveAll((CardModificationInfo x) => x.abilities.Exists((Ability a) => !ProgressionData.LearnedAbility(a))); } } [HarmonyPatch] internal static class AddCostsToDeathCards { [CompilerGenerated] private sealed class <>c__DisplayClass4_0 { public CardModificationInfo generatedDeathCardMod; internal void b__0(CardInfo c) { generatedDeathCardMod.bloodCostAdjustment = c.BloodCost; generatedDeathCardMod.bonesCostAdjustment = c.BonesCost; generatedDeathCardMod.energyCostAdjustment = c.EnergyCost; generatedDeathCardMod.addGemCost = c.GemsCost; string text = ""; foreach (KeyValuePair item in c.GetCardExtensionTable()) { if (item.Key.ToLowerInvariant().Contains("cost") && !StringExtensions.IsNullOrWhitespace(item.Value)) { if (text != "") { text += "_"; } text = text + item.Key + "," + item.Value; } } if (text != "") { generatedDeathCardMod.singletonId = "[CustomCosts:" + text + "]"; } } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CardModificationInfo generatedDeathCardMod; public DeathCardCreationSequencer instance; public List costChoices; public bool doTutorialDialogue; public ChoiceType choiceType; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>c__DisplayClass4_0 CS$<>8__locals0 = new <>c__DisplayClass4_0 { generatedDeathCardMod = generatedDeathCardMod }; <>2__current = instance.SelectCardFromChoices(costChoices, doTutorialDialogue, choiceType, (Action)delegate(CardInfo c) { CS$<>8__locals0.generatedDeathCardMod.bloodCostAdjustment = c.BloodCost; CS$<>8__locals0.generatedDeathCardMod.bonesCostAdjustment = c.BonesCost; CS$<>8__locals0.generatedDeathCardMod.energyCostAdjustment = c.EnergyCost; CS$<>8__locals0.generatedDeathCardMod.addGemCost = c.GemsCost; string text = ""; foreach (KeyValuePair item in c.GetCardExtensionTable()) { if (item.Key.ToLowerInvariant().Contains("cost") && !StringExtensions.IsNullOrWhitespace(item.Value)) { if (text != "") { text += "_"; } text = text + item.Key + "," + item.Value; } } if (text != "") { CS$<>8__locals0.generatedDeathCardMod.singletonId = "[CustomCosts:" + text + "]"; } }); <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static MethodBase TargetMethod() { return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(DeathCardCreationSequencer), "CreateCardSequence", (Type[])null, (Type[])null)); } [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown List list = new List(instructions); int num = -1; int num2 = -1; object obj = null; object obj2 = null; for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Stloc_S && list[i].operand.ToString() == "System.Collections.Generic.List`1[DiskCardGame.CardInfo] (5)") { MethodInfo methodInfo = AccessTools.Method(typeof(AddCostsToDeathCards), "AllowOverTwoSigils", new Type[1] { typeof(List) }, (Type[])null); list.RemoveRange(i - 10, 10); list.Insert(i - 10, new CodeInstruction(OpCodes.Call, (object)methodInfo)); break; } } for (int j = 0; j < list.Count; j++) { if (list[j].opcode == OpCodes.Ldfld && list[j].operand.ToString() == "DiskCardGame.DeathCardCreationSequencer+<>c__DisplayClass18_0 <>8__1") { obj = list[j].operand; } else if (list[j].opcode == OpCodes.Ldfld && list[j].operand.ToString() == "DiskCardGame.CardModificationInfo generatedDeathCardMod") { obj2 = list[j].operand; } else if (list[j].opcode == OpCodes.Ldc_I4_5) { num = j - 5; num2 = j - 2; break; } } if (num > -1 && num2 > -1 && obj2 != null) { MethodInfo methodInfo2 = AccessTools.Method(typeof(AddCostsToDeathCards), "AddAllCosts", new Type[5] { typeof(DeathCardCreationSequencer), typeof(List), typeof(bool), typeof(ChoiceType), typeof(CardModificationInfo) }, (Type[])null); list.RemoveRange(num, num2 - num); list.Insert(num, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(num + 1, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo2)); } num = -1; for (int num3 = list.Count - 1; num3 > 0; num3--) { if (list[num3].opcode == OpCodes.Callvirt) { num = num3 + 1; break; } } if (num > -1 && obj != null && obj2 != null) { MethodInfo methodInfo3 = AccessTools.Method(typeof(AddCostsToDeathCards), "CreateCustomCard", new Type[1] { typeof(CardModificationInfo) }, (Type[])null); list.Insert(num, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Ldfld, obj)); list.Insert(num + 2, new CodeInstruction(OpCodes.Ldfld, obj2)); list.Insert(num + 3, new CodeInstruction(OpCodes.Call, (object)methodInfo3)); } return list; } private static List AllowOverTwoSigils(List list) { return list.FindAll((CardInfo x) => x.Abilities.Count > 0 && x.Abilities.Count <= 8); } private static void CreateCustomCard(CardModificationInfo generatedDeathCardMod) { if (generatedDeathCardMod.HasCustomCostsId()) { DeathCardManager.CreateCustomDeathCard(SaveManager.SaveFile.deathCardMods.Find((CardModificationInfo x) => x == generatedDeathCardMod)); } } [IteratorStateMachine(typeof(d__4))] private static IEnumerator AddAllCosts(DeathCardCreationSequencer instance, List costChoices, bool doTutorialDialogue, ChoiceType choiceType, CardModificationInfo generatedDeathCardMod) { //IL_001c: 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { instance = instance, costChoices = costChoices, doTutorialDialogue = doTutorialDialogue, choiceType = choiceType, generatedDeathCardMod = generatedDeathCardMod }; } } [HarmonyPatch] internal static class ChangeDeathCardExamineDialogue { private static MethodBase TargetMethod() { return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(DeathCardCreationSequencer), "SelectCardFromChoices", (Type[])null, (Type[])null)); } [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown List list = new List(instructions); int num = -1; for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode == OpCodes.Ldstr)) { continue; } string text = list[i].operand.ToString(); if (text == "A cost of [c:bR]{0} blood[c:] from the [c:bR]{1}[c:].") { num = i - 7; } else { if (!(text == "A cost of... [c:bR]free[c:]... from the [c:bR]{0}[c:].")) { continue; } list.RemoveRange(num, i + 2 - num); for (int j = num; j < list.Count; j++) { if (list[j].opcode == OpCodes.Callvirt && list[j].operand.ToString() == "System.String get_DisplayedNameLocalized()") { MethodInfo methodInfo = AccessTools.Method(typeof(ChangeDeathCardExamineDialogue), "NewCostDialogue", new Type[1] { typeof(CardInfo) }, (Type[])null); list.RemoveRange(j, 2); list.Insert(j, new CodeInstruction(OpCodes.Call, (object)methodInfo)); break; } } break; } } for (int k = 0; k < list.Count; k++) { if (list[k].opcode == OpCodes.Stloc_S && list[k].operand.ToString() == "System.String (10)") { list.Insert(k - 9, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); k++; num = k - 6; } else if (list[k].opcode == OpCodes.Ldstr && list[k].operand.ToString() == "A [c:bR]Sigil of {0}[c:] and a [c:bR]Sigil of {1}[c:] from the [c:bR]{2}[c:].") { MethodInfo methodInfo2 = AccessTools.Method(typeof(ChangeDeathCardExamineDialogue), "NewAbilitiesDialogue", new Type[1] { typeof(CardInfo) }, (Type[])null); list.RemoveRange(num, k + 10 - num); list.Insert(num, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); break; } } return list; } private static string NewCostDialogue(CardInfo info) { string text = "A cost of{A} from the [c:bR]{0}[c:]."; string item = ((info.BloodCost <= 0) ? "" : $" [c:bR]{info.BloodCost} blood[c:]"); string item2 = ((info.BonesCost <= 0) ? "" : ((info.BonesCost == 1) ? " [c:bR]1 bone[c:]" : $" [c:bR]{info.BonesCost} bones[c:]")); string item3 = ((info.EnergyCost <= 0) ? "" : $" [c:bR]{info.EnergyCost} energy[c:]"); string text2 = ((info.GemsCost.Count <= 0) ? "" : ((info.GemsCost.Count == 1) ? "{G}" : $" [c:bR]{info.GemsCost.Count} gems[c:]")); if (text2 == "{G}") { string text3 = (info.GemsCost.Contains((GemType)0) ? " green" : (info.GemsCost.Contains((GemType)2) ? " blue" : "n orange")); text2 = string.Format(text2.Replace("{G}", " [c:bR]a" + text3 + " gem[c:]")); } List list = new List(); Dictionary cardExtensionTable = info.GetCardExtensionTable(); if (cardExtensionTable.Count > 0) { foreach (KeyValuePair item4 in cardExtensionTable) { if (item4.Key.ToLowerInvariant().Contains("cost") && !StringExtensions.IsNullOrWhitespace(item4.Value)) { string text4 = Regex.Replace(item4.Key, "(\\B[A-Z])", " $1").ToLowerInvariant(); text4 = " [c:bR]{0} " + text4.Replace(" cost", "") + "[c:]"; list.Add(string.Format(text4, item4.Value)); } } } List costs = new List { item, item2, item3, text2 }; list.ForEach(delegate(string x) { costs.Add(x); }); costs.RemoveAll((string x) => x == ""); if (costs.Count == 0) { return string.Format(Localization.Translate(text.Replace("{A}", "... [c:bR]free[c:]...")), info.DisplayedNameLocalized); } string text5 = costs.PopFirst() ?? ""; if (costs.Count == 0) { return string.Format(Localization.Translate(text.Replace("{A}", text5)), info.DisplayedNameLocalized); } if (costs.Count > 1) { text5 += ","; for (int i = 0; i < costs.Count - 1; i++) { text5 = text5 + costs[i] + ","; } } text5 = text5 + " and" + costs.Last(); return string.Format(Localization.Translate(text.Replace("{A}", text5)), info.DisplayedNameLocalized); } private static string NewAbilitiesDialogue(CardInfo info) { //IL_0007: 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_008c: Unknown result type (might be due to invalid IL or missing references) string text = Localization.Translate(AbilitiesUtil.GetInfo(info.Abilities[0]).rulebookName); if (info.NumAbilities == 1) { return string.Format(Localization.Translate("A [c:bR]Sigil of {0}[c:] from the [c:bR]{1}[c:]."), text, info.DisplayedNameLocalized); } if (info.NumAbilities > 1) { string text2 = Localization.Translate(AbilitiesUtil.GetInfo(info.Abilities[1]).rulebookName); if (info.NumAbilities == 2) { return string.Format(Localization.Translate("A [c:bR]Sigil of {0}[c:] and a [c:bR]Sigil of {1}[c:] from the [c:bR]{2}[c:]."), text, text2, info.DisplayedNameLocalized); } string text3 = Localization.Translate(AbilitiesUtil.GetInfo(info.Abilities[2]).rulebookName); if (info.NumAbilities == 3) { return string.Format(Localization.Translate("A [c:bR]Sigil of {0}[c:], a [c:bR]Sigil of {1}[c:], and a [c:bR]Sigil of {2}[c:] from the [c:bR]{3}[c:]."), text, text2, text3, info.DisplayedNameLocalized); } } return string.Format(Localization.Translate("A [c:bR]multitude of sigils[c:] from the [c:bR]{0}[c:]."), info.DisplayedNameLocalized); } } [HarmonyPatch] public abstract class ExtendedAbilityBehaviour : AbilityBehaviour, IGetOpposingSlots, IActivateWhenFacedown, IPassiveAttackBuff, IPassiveHealthBuff { private static ConditionalWeakTable> AttackBuffAbilities = new ConditionalWeakTable>(); private static ConditionalWeakTable> HealthBuffAbilities = new ConditionalWeakTable>(); public virtual bool TriggerWhenFacedown => false; [Obsolete("Use IPassiveAttackBuff instead")] public virtual bool ProvidesPassiveAttackBuff => false; [Obsolete("Use IPassiveHealthBuff instead")] public virtual bool ProvidesPassiveHealthBuff => false; public virtual bool ShouldTriggerWhenFaceDown(Trigger trigger, object[] otherArgs) { return TriggerWhenFacedown; } public virtual bool ShouldTriggerCustomWhenFaceDown(Type customTrigger) { return TriggerWhenFacedown; } public virtual bool RespondsToGetOpposingSlots() { return false; } public virtual List GetOpposingSlots(List originalSlots, List otherAddedSlots) { return new List(); } public virtual bool RemoveDefaultAttackSlot() { return false; } private static List GetAttackBuffs(PlayableCard card) { if (AttackBuffAbilities.TryGetValue(card, out var value)) { return value; } value = (from x in ((Component)card).GetComponents() where x.ProvidesPassiveAttackBuff select x).ToList(); AttackBuffAbilities.Add(card, value); return value; } private static List GetHealthBuffs(PlayableCard card) { if (HealthBuffAbilities.TryGetValue(card, out var value)) { return value; } value = (from x in ((Component)card).GetComponents() where x.ProvidesPassiveHealthBuff select x).ToList(); HealthBuffAbilities.Add(card, value); return value; } [Obsolete("Use IPassiveAttackBuff instead")] public virtual int[] GetPassiveAttackBuffs() { return null; } [Obsolete("Use IPassiveHealthBuff instead")] public virtual int[] GetPassiveHealthBuffs() { return null; } public virtual int GetPassiveAttackBuff(PlayableCard target) { if (ProvidesPassiveAttackBuff && target.OpponentCard == ((AbilityBehaviour)this).Card.OpponentCard) { int[] passiveAttackBuffs = GetPassiveAttackBuffs(); if (passiveAttackBuffs != null && target.Slot.Index < passiveAttackBuffs.Length) { return passiveAttackBuffs[target.Slot.Index]; } } return 0; } public virtual int GetPassiveHealthBuff(PlayableCard target) { if (ProvidesPassiveHealthBuff && target.OpponentCard == ((AbilityBehaviour)this).Card.OpponentCard) { int[] passiveHealthBuffs = GetPassiveHealthBuffs(); if (passiveHealthBuffs != null && target.Slot.Index < passiveHealthBuffs.Length) { return passiveHealthBuffs[target.Slot.Index]; } } return 0; } } public abstract class ExtendedActivatedAbilityBehaviour : AbilityBehaviour { [CompilerGenerated] private sealed class d__64 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ExtendedActivatedAbilityBehaviour <>4__this; private BoardManager 5__2; private List.Enumerator <>7__wrap2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__64(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 4) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; ExtendedActivatedAbilityBehaviour CS$<>8__locals0 = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; 5__2 = Singleton.Instance; List cardSlots = 5__2.GetCardSlots(!((AbilityBehaviour)CS$<>8__locals0).Card.OpponentCard, (CardSlot x) => ((Object)(object)x.Card != (Object)null) & ((Object)(object)x.Card != (Object)(object)((AbilityBehaviour)CS$<>8__locals0).Card)); Singleton.Instance.Controller.LockState = (ViewLockState)0; Singleton.Instance.SwitchToView(5__2.BoardView, false, false); Singleton.Instance.ForceCursorType((CursorType)1); 5__2.cancelledPlacementWithInput = false; 5__2.currentValidSlots = cardSlots; 5__2.currentSacrificeDemandingCard = ((AbilityBehaviour)CS$<>8__locals0).Card; 5__2.CancelledSacrifice = false; 5__2.LastSacrificesInfo.Clear(); 5__2.SetQueueSlotsEnabled(false); foreach (CardSlot item in 5__2.AllSlots.Where((CardSlot x) => (Object)(object)x.Card != (Object)(object)((AbilityBehaviour)CS$<>8__locals0).Card)) { if (!item.IsPlayerSlot || (Object)(object)item.Card == (Object)null) { ((InteractableBase)item).SetEnabled(false); ((HighlightedInteractable)item).ShowState((State)1, false, 0.15f); } if (item.IsPlayerSlot && (Object)(object)item.Card != (Object)null && item.Card.CanBeSacrificed) { ((Card)item.Card).Anim.SetShaking(true); } } <>2__current = 5__2.SetSacrificeMarkersShown(CS$<>8__locals0.BloodCost); <>1__state = 1; return true; } case 1: <>1__state = -1; goto IL_01fe; case 2: <>1__state = -1; goto IL_01fe; case 3: <>1__state = -1; 5__2.HideSacrificeMarkers(); <>7__wrap2 = 5__2.currentSacrifices.GetEnumerator(); <>1__state = -3; goto IL_04bb; case 4: { <>1__state = -3; Singleton.Instance.SwitchToView(5__2.BoardView, false, false); goto IL_04bb; } IL_04bb: while (<>7__wrap2.MoveNext()) { CardSlot current = <>7__wrap2.Current; if ((Object)(object)current.Card != (Object)null && !current.Card.Dead) { BoardManager obj = 5__2; int sacrificesMadeThisTurn = obj.SacrificesMadeThisTurn; obj.SacrificesMadeThisTurn = sacrificesMadeThisTurn + 1; CS$<>8__locals0.currentSacrificedCardInfos.Add(((Card)current.Card).Info, current); <>2__current = current.Card.Sacrifice(); <>1__state = 4; return true; } } <>m__Finally1(); break; IL_01fe: if (5__2.GetValueOfSacrifices(5__2.currentSacrifices) < CS$<>8__locals0.BloodCost && !5__2.cancelledPlacementWithInput) { 5__2.SetSacrificeMarkersValue(5__2.currentSacrifices.Count); <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 2; return true; } foreach (CardSlot allSlot in 5__2.AllSlots) { ((InteractableBase)allSlot).SetEnabled(false); if (allSlot.IsPlayerSlot && (Object)(object)allSlot.Card != (Object)null) { ((Card)allSlot.Card).Anim.SetShaking(false); } } foreach (CardSlot currentSacrifice in 5__2.currentSacrifices) { 5__2.LastSacrificesInfo.Add(((Card)currentSacrifice.Card).Info); } if (5__2.cancelledPlacementWithInput) { 5__2.HideSacrificeMarkers(); foreach (CardSlot slot in 5__2.GetSlots(true)) { if ((Object)(object)slot.Card != (Object)null) { ((Card)slot.Card).Anim.SetSacrificeHoverMarkerShown(false); if (5__2.currentSacrifices.Contains(slot)) { ((Card)slot.Card).Anim.SetMarkedForSacrifice(false); } } } Singleton.Instance.SwitchToView(5__2.defaultView, false, false); Singleton.Instance.ClearForcedCursorType(); 5__2.CancelledSacrifice = true; break; } 5__2.SetSacrificeMarkersValue(5__2.GetValueOfSacrifices(5__2.currentSacrifices)); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 3; return true; } 5__2.SetQueueSlotsEnabled(true); foreach (CardSlot allSlot2 in 5__2.AllSlots) { ((InteractableBase)allSlot2).SetEnabled(true); ((HighlightedInteractable)allSlot2).ShowState((State)2, false, 0.15f); } 5__2.currentSacrificeDemandingCard = null; 5__2.currentSacrifices.Clear(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__60 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ExtendedActivatedAbilityBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown int num = <>1__state; ExtendedActivatedAbilityBehaviour CS$<>8__locals0 = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (CS$<>8__locals0.CanAfford() && CS$<>8__locals0.CanActivate()) { if (CS$<>8__locals0.BloodCost > 0) { <>2__current = CS$<>8__locals0.ChooseSacrifices(); <>1__state = 1; return true; } goto IL_0096; } ((Card)((AbilityBehaviour)CS$<>8__locals0).Card).Anim.LightNegationEffect(); AudioController.Instance.PlaySound2D("toneless_negate", (MixerGroup)10, 0.2f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 11; return true; case 1: <>1__state = -1; if (Singleton.Instance.CancelledSacrifice) { return false; } goto IL_0096; case 2: <>1__state = -1; if ((Object)(object)Singleton.Instance != (Object)null) { CardSlot val = Singleton.Instance.GetSlots(true).Find((CardSlot x) => (Object)(object)x.Card != (Object)null && x.Card.HasAbility((Ability)66)); if ((Object)(object)val != (Object)null) { ConduitEnergy component = ((Component)val.Card).GetComponent(); if ((Object)(object)component != (Object)null && component.CompletesCircuit()) { <>2__current = Singleton.Instance.AddEnergy(CS$<>8__locals0.EnergyCost); <>1__state = 3; return true; } } } goto IL_0190; case 3: <>1__state = -1; goto IL_0190; case 4: <>1__state = -1; goto IL_01bf; case 5: <>1__state = -1; <>2__current = ((AbilityBehaviour)CS$<>8__locals0).PreSuccessfulTriggerSequence(); <>1__state = 6; return true; case 6: <>1__state = -1; <>2__current = CS$<>8__locals0.Activate(); <>1__state = 7; return true; case 7: { <>1__state = -1; ProgressionData.SetMechanicLearned((MechanicsConcept)61); if (CS$<>8__locals0.HealthCost > 0 && Object.op_Implicit((Object)(object)((AbilityBehaviour)CS$<>8__locals0).Card) && ((AbilityBehaviour)CS$<>8__locals0).Card.Health <= 0 && !((AbilityBehaviour)CS$<>8__locals0).Card.Dead) { <>2__current = ((AbilityBehaviour)CS$<>8__locals0).Card.Die(true, (PlayableCard)null, true); <>1__state = 8; return true; } int onActivateEnergyCostMod = CS$<>8__locals0.OnActivateEnergyCostMod; int onActivateBonesCostMod = CS$<>8__locals0.OnActivateBonesCostMod; List onActivateGemsCostMod = CS$<>8__locals0.OnActivateGemsCostMod; int onActivateHealthCostMod = CS$<>8__locals0.OnActivateHealthCostMod; if (onActivateEnergyCostMod != 0) { CS$<>8__locals0.energyCostMod += onActivateEnergyCostMod; } if (onActivateBonesCostMod != 0) { CS$<>8__locals0.bonesCostMod += onActivateBonesCostMod; } if (onActivateGemsCostMod != null && onActivateGemsCostMod.Count > 0) { if (CS$<>8__locals0.OnActivateGemsCostModRemovesGems) { onActivateGemsCostMod.ForEach(delegate(GemType x) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) CS$<>8__locals0.gemsCostMod.Remove(x); }); } else { CS$<>8__locals0.gemsCostMod.AddRange(onActivateGemsCostMod); } } if (onActivateHealthCostMod != 0) { CS$<>8__locals0.healthCostMod += onActivateHealthCostMod; } <>2__current = CS$<>8__locals0.PostActivate(); <>1__state = 10; return true; } case 8: <>1__state = -1; <>2__current = CS$<>8__locals0.PostActivate(); <>1__state = 9; return true; case 9: <>1__state = -1; CS$<>8__locals0.currentSacrificedCardInfos.Clear(); return false; case 10: <>1__state = -1; CS$<>8__locals0.currentSacrificedCardInfos.Clear(); break; case 11: { <>1__state = -1; break; } IL_0190: if (CS$<>8__locals0.BonesCost > 0) { <>2__current = Singleton.Instance.SpendBones(CS$<>8__locals0.BonesCost); <>1__state = 4; return true; } goto IL_01bf; IL_01bf: <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 5; return true; IL_0096: if (CS$<>8__locals0.HealthCost > 0) { ((Card)((AbilityBehaviour)CS$<>8__locals0).Card).Anim.LightNegationEffect(); PlayableCardStatus status = ((AbilityBehaviour)CS$<>8__locals0).Card.Status; status.damageTaken += CS$<>8__locals0.HealthCost; } if (CS$<>8__locals0.EnergyCost > 0) { <>2__current = Singleton.Instance.SpendEnergy(CS$<>8__locals0.EnergyCost); <>1__state = 2; return true; } goto IL_0190; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__56 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__56(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__58 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ExtendedActivatedAbilityBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__58(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown int num = <>1__state; ExtendedActivatedAbilityBehaviour extendedActivatedAbilityBehaviour = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (extendedActivatedAbilityBehaviour.LearnMechanic()) { <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 1; return true; } goto IL_0159; case 1: <>1__state = -1; if (StoryEventsData.EventCompleted((StoryEvent)39)) { <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)1, Singleton.Instance.GetSpeaker((Character)0), (string[])null, (ScreenPosition)0, true); <>1__state = 2; return true; } if (StoryEventsData.EventCompleted((StoryEvent)40)) { <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)0, Singleton.Instance.GetSpeaker((Character)1), (string[])null, (ScreenPosition)0, true); <>1__state = 3; return true; } if (StoryEventsData.EventCompleted((StoryEvent)41)) { <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)2, Singleton.Instance.GetSpeaker((Character)2), (string[])null, (ScreenPosition)0, true); <>1__state = 4; return true; } <>2__current = Singleton.Instance.PlayDialogueEvent("ActivatedAbilityTutorial", (Style)3, Singleton.Instance.GetSpeaker((Character)9), (string[])null, (ScreenPosition)0, true); <>1__state = 5; return true; case 2: <>1__state = -1; goto IL_0159; case 3: <>1__state = -1; goto IL_0159; case 4: <>1__state = -1; goto IL_0159; case 5: <>1__state = -1; goto IL_0159; case 6: { <>1__state = -1; break; } IL_0159: if (extendedActivatedAbilityBehaviour.RespondsToPostResolveOnBoard()) { <>2__current = extendedActivatedAbilityBehaviour.OnPostResolveOnBoard(); <>1__state = 6; return true; } break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__61 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__61(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public int bloodCostMod; public int bonesCostMod; public int energyCostMod; public List gemsCostMod = new List(); public int healthCostMod; public Dictionary currentSacrificedCardInfos = new Dictionary(); public virtual int StartingBloodCost { get; } public virtual int StartingBonesCost { get; } public virtual int StartingEnergyCost { get; } public virtual List StartingGemsCost { get; } public virtual int StartingHealthCost { get; } public virtual int OnActivateBloodCostMod { get; set; } public virtual int OnActivateBonesCostMod { get; set; } public virtual int OnActivateEnergyCostMod { get; set; } public virtual List OnActivateGemsCostMod { get; set; } public virtual bool OnActivateGemsCostModRemovesGems { get; set; } public virtual int OnActivateHealthCostMod { get; set; } public int BloodCost => Mathf.Max(0, StartingBloodCost + bloodCostMod); public int BonesCost => Mathf.Max(0, StartingBonesCost + bonesCostMod); public int EnergyCost => Mathf.Max(0, StartingEnergyCost + energyCostMod); public List GemsCost { get { List list = new List(); if (StartingGemsCost != null && StartingGemsCost.Count > 0) { list.AddRange(StartingGemsCost); } list.AddRange(gemsCostMod); return list; } } public int HealthCost => Mathf.Max(0, StartingHealthCost + healthCostMod); public virtual bool RespondsToPostResolveOnBoard() { return false; } [IteratorStateMachine(typeof(d__56))] public virtual IEnumerator OnPostResolveOnBoard() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__56(0); } public sealed override bool RespondsToResolveOnBoard() { if (!RespondsToPostResolveOnBoard()) { return LearnMechanic(); } return true; } [IteratorStateMachine(typeof(d__58))] public sealed override IEnumerator OnResolveOnBoard() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__58(0) { <>4__this = this }; } public sealed override bool RespondsToActivatedAbility(Ability ability) { //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) return ((AbilityBehaviour)this).Ability == ability; } [IteratorStateMachine(typeof(d__60))] public sealed override IEnumerator OnActivatedAbility() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__60(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__61))] public virtual IEnumerator PostActivate() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__61(0); } public virtual bool CanActivate() { return true; } public abstract IEnumerator Activate(); [IteratorStateMachine(typeof(d__64))] private IEnumerator ChooseSacrifices() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__64(0) { <>4__this = this }; } private bool CanAfford() { if ((BloodCost < 1 || SacrificeValue() >= BloodCost) && ((AbilityBehaviour)this).Card.Health >= HealthCost && Singleton.Instance.PlayerEnergy >= EnergyCost && Singleton.Instance.PlayerBones >= BonesCost) { bool num = ResourcesManagerHelpers.GemCount(!((AbilityBehaviour)this).Card.OpponentCard, (GemType)1) >= GemsCost.Count((GemType x) => (int)x == 1); bool flag = ResourcesManagerHelpers.GemCount(!((AbilityBehaviour)this).Card.OpponentCard, (GemType)0) >= GemsCost.Count((GemType x) => (int)x == 0); bool flag2 = ResourcesManagerHelpers.GemCount(!((AbilityBehaviour)this).Card.OpponentCard, (GemType)2) >= GemsCost.Count((GemType x) => (int)x == 2); return num && flag && flag2; } return false; } private bool LearnMechanic() { if (SaveManager.SaveFile.IsPart2) { return !ProgressionData.LearnedMechanic((MechanicsConcept)61); } return false; } private int SacrificeValue() { return Singleton.Instance.GetValueOfSacrifices(Singleton.Instance.GetCardSlots(!((AbilityBehaviour)this).Card.OpponentCard, (CardSlot x) => (Object)(object)x.Card != (Object)null && (Object)(object)x.Card != (Object)(object)((AbilityBehaviour)this).Card)); } } [HarmonyPatch(typeof(CardSlot))] internal class CardSlotPatch { [HarmonyPostfix] [HarmonyPatch("OnCursorEnter")] private static void DisableSacrificeMarker(CardSlot __instance) { if ((Object)(object)__instance.Card != (Object)null && Singleton.Instance.ChoosingSacrifices && (Object)(object)__instance.Card == (Object)(object)Singleton.Instance.CurrentSacrificeDemandingCard) { ((Card)__instance.Card).Anim.SetSacrificeHoverMarkerShown(false); } } } public interface IActivateWhenFacedown { bool ShouldTriggerWhenFaceDown(Trigger trigger, object[] otherArgs); bool ShouldTriggerCustomWhenFaceDown(Type customTrigger); } public class OpponentGemsManager : Singleton { public List opponentGems = new List(); public int GemsOfType(GemType gem) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return opponentGems.Count((GemType x) => x == gem); } public bool HasGem(GemType gem) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return opponentGems.Contains(gem); } public void AddGem(GemType gem) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) opponentGems.Add(gem); } public void LoseGem(GemType gem) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) opponentGems.Remove(gem); } public void AddGems(params GemType[] gems) { //IL_0009: 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) foreach (GemType item in gems) { opponentGems.Add(item); } } public void LoseGems(params GemType[] gems) { //IL_0009: 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) foreach (GemType item in gems) { opponentGems.Remove(item); } } public void ForceGemsUpdate() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) opponentGems.Clear(); foreach (CardSlot slot in Singleton.Instance.GetSlots(false)) { if ((Object)(object)slot.Card != (Object)null && !slot.Card.Dead) { GainGem[] components = ((Component)slot.Card).GetComponents(); foreach (GainGem val in components) { opponentGems.Add(val.Gem); } GainGemTriple[] components2 = ((Component)slot.Card).GetComponents(); for (int j = 0; j < components2.Length; j++) { _ = components2[j]; opponentGems.Add((GemType)0); opponentGems.Add((GemType)1); opponentGems.Add((GemType)2); } } } } } [HarmonyPatch] internal class OpponentGemsPatches { [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public GainGem __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if (((AbilityBehaviour)__instance).Card.OpponentCard && (Object)(object)Singleton.Instance != (Object)null) { Singleton.Instance.AddGem(__instance.Gem); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public GainGemTriple __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if (((AbilityBehaviour)__instance).Card.OpponentCard && Object.op_Implicit((Object)(object)Singleton.Instance)) { Singleton.Instance.AddGems(default(GemType), (GemType)1, (GemType)2); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public GainGem __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if (((AbilityBehaviour)__instance).Card.OpponentCard && (Object)(object)Singleton.Instance != (Object)null) { Singleton.Instance.LoseGem(__instance.Gem); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; public GainGemTriple __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; if (((AbilityBehaviour)__instance).Card.OpponentCard && (Object)(object)Singleton.Instance != (Object)null) { Singleton.Instance.LoseGems(default(GemType), (GemType)1, (GemType)2); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator enumerator; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = enumerator; <>1__state = 1; return true; case 1: <>1__state = -1; Singleton.Instance.ForceGemsUpdate(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] [HarmonyPatch(typeof(ResourcesManager), "Setup")] [HarmonyPatch(typeof(PixelResourcesManager), "Setup")] [HarmonyPatch(typeof(Part3ResourcesManager), "Setup")] private static void SetUpOpponentGems(ResourcesManager __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } [HarmonyPostfix] [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] private static void CleanUpOpponentGems() { Singleton.Instance?.opponentGems.Clear(); } [HarmonyPostfix] [HarmonyPatch(typeof(ResourcesManager), "ForceGemsUpdate")] private static void ForceOpponentGemsUpdate() { Singleton.Instance?.ForceGemsUpdate(); } [IteratorStateMachine(typeof(d__3))] [HarmonyPostfix] [HarmonyPatch(typeof(FishHookGrab), "PullHook")] [HarmonyPatch(typeof(FishHookItem), "OnValidTargetSelected")] private static IEnumerator UpdateGemsOnHookGrab(IEnumerator enumerator) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { enumerator = enumerator }; } [IteratorStateMachine(typeof(d__4))] [HarmonyPostfix] [HarmonyPatch(typeof(GainGem), "OnResolveOnBoard")] private static IEnumerator GainGemsForOpponents(IEnumerator enumerator, GainGem __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { enumerator = enumerator, __instance = __instance }; } [IteratorStateMachine(typeof(d__5))] [HarmonyPostfix] [HarmonyPatch(typeof(GainGem), "OnDie")] private static IEnumerator LoseGemsForOpponents(IEnumerator enumerator, GainGem __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { enumerator = enumerator, __instance = __instance }; } [IteratorStateMachine(typeof(d__6))] [HarmonyPostfix] [HarmonyPatch(typeof(GainGemTriple), "OnResolveOnBoard")] private static IEnumerator GainTripleGemsForOpponents(IEnumerator enumerator, GainGemTriple __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { enumerator = enumerator, __instance = __instance }; } [IteratorStateMachine(typeof(d__7))] [HarmonyPostfix] [HarmonyPatch(typeof(GainGemTriple), "OnDie")] private static IEnumerator LoseTripleGemsForOpponents(IEnumerator enumerator, GainGemTriple __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { enumerator = enumerator, __instance = __instance }; } [HarmonyTranspiler] [HarmonyPatch(typeof(DiskRenderStatsLayer), "RenderCard")] private static IEnumerable CorrectGemifiedColours(IEnumerable instructions) { //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown string text = "DiskCardGame.ResourcesManager get_Instance()"; string text2 = "UnityEngine.Color healthTextColor"; int num = -1; int num2 = -1; List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode == OpCodes.Call) || !(list[i].operand.ToString() == text)) { continue; } num = i; for (int j = i + 1; j < list.Count; j++) { if (list[j].opcode == OpCodes.Stfld && list[j].operand.ToString() == text2) { num2 = j + 1; break; } } break; } if (num > -1 && num2 > -1) { MethodInfo methodInfo = AccessTools.Method(typeof(OpponentGemsPatches), "FixAct3Render", new Type[2] { typeof(DiskRenderStatsLayer), typeof(CardRenderInfo) }, (Type[])null); list.RemoveRange(num, num2 - num); list.Insert(num, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); list.Insert(num + 2, new CodeInstruction(OpCodes.Call, (object)methodInfo)); } return list; } private static void FixAct3Render(DiskRenderStatsLayer __instance, CardRenderInfo info) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_005e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)((RenderStatsLayer)__instance).PlayableCard)) { return; } if (((RenderStatsLayer)__instance).PlayableCard.OpponentCard && Object.op_Implicit((Object)(object)Singleton.Instance)) { if (Singleton.Instance.HasGem((GemType)1)) { info.attackTextColor = GameColors.Instance.gold; } if (Singleton.Instance.HasGem((GemType)0)) { info.healthTextColor = GameColors.Instance.brightLimeGreen; } } else if (!((RenderStatsLayer)__instance).PlayableCard.OpponentCard) { if (Singleton.Instance.HasGem((GemType)1)) { info.attackTextColor = GameColors.Instance.gold; } if (Singleton.Instance.HasGem((GemType)0)) { info.healthTextColor = GameColors.Instance.brightLimeGreen; } } } } [HarmonyPatch] public static class ShieldManager { [CompilerGenerated] private sealed class <>c__DisplayClass8_0 { public PlayableCard target; public int damage; public PlayableCard attacker; internal int b__0(IShieldPreventedDamage a, IShieldPreventedDamage b) { return b.ShieldPreventedDamagePriority(target, damage, attacker) - a.ShieldPreventedDamagePriority(target, damage, attacker); } internal int b__1(IShieldPreventedDamageInHand a, IShieldPreventedDamageInHand b) { return b.ShieldPreventedDamageInHandPriority(target, damage, attacker) - a.ShieldPreventedDamageInHandPriority(target, damage, attacker); } } [CompilerGenerated] private sealed class d__23 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; public DiskCardAnimationController __instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = result; <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)__instance.latchModule != (Object)null) { ((Component)__instance.latchModule).gameObject.SetActive(false); GameObject val = ((Component)__instance.latchModule).gameObject.FindChild("Base"); if ((Object)(object)val != (Object)null) { val.SetActive(true); val.transform.localRotation = Quaternion.Euler(0f, 0f, 90f); } } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayableCard target; public int damage; public PlayableCard attacker; private <>c__DisplayClass8_0 <>8__1; private List.Enumerator <>7__wrap1; private List.Enumerator <>7__wrap2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { switch (<>1__state) { case -3: case 1: try { } finally { <>m__Finally1(); } break; case -4: case 2: try { } finally { <>m__Finally2(); } break; } <>8__1 = null; <>1__state = -2; } private bool MoveNext() { try { List list2; switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>8__1 = new <>c__DisplayClass8_0(); <>8__1.target = target; <>8__1.damage = damage; <>8__1.attacker = attacker; BreakShield(<>8__1.target, <>8__1.damage, <>8__1.attacker); List list = CustomTriggerFinder.FindTriggersOnBoard(findFacedown: false).ToList(); list.Sort((IShieldPreventedDamage a, IShieldPreventedDamage b) => b.ShieldPreventedDamagePriority(<>8__1.target, <>8__1.damage, <>8__1.attacker) - a.ShieldPreventedDamagePriority(<>8__1.target, <>8__1.damage, <>8__1.attacker)); <>7__wrap1 = list.GetEnumerator(); <>1__state = -3; goto IL_0151; } case 1: <>1__state = -3; goto IL_0151; case 2: { <>1__state = -4; break; } IL_0151: while (<>7__wrap1.MoveNext()) { IShieldPreventedDamage current = <>7__wrap1.Current; if ((Object)((current is TriggerReceiver) ? current : null) != (Object)null && current.RespondsToShieldPreventedDamage(<>8__1.target, <>8__1.damage, <>8__1.attacker)) { <>2__current = current.OnShieldPreventedDamage(<>8__1.target, <>8__1.damage, <>8__1.attacker); <>1__state = 1; return true; } } <>m__Finally1(); list2 = CustomTriggerFinder.FindTriggersInHand().ToList(); list2.Sort((IShieldPreventedDamageInHand a, IShieldPreventedDamageInHand b) => b.ShieldPreventedDamageInHandPriority(<>8__1.target, <>8__1.damage, <>8__1.attacker) - a.ShieldPreventedDamageInHandPriority(<>8__1.target, <>8__1.damage, <>8__1.attacker)); <>7__wrap2 = list2.GetEnumerator(); <>1__state = -4; break; } while (<>7__wrap2.MoveNext()) { IShieldPreventedDamageInHand current2 = <>7__wrap2.Current; if ((Object)((current2 is TriggerReceiver) ? current2 : null) != (Object)null && current2.RespondsToShieldPreventedDamageInHand(<>8__1.target, <>8__1.damage, <>8__1.attacker)) { <>2__current = current2.OnShieldPreventedDamageInHand(<>8__1.target, <>8__1.damage, <>8__1.attacker); <>1__state = 2; return true; } } <>m__Finally2(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } private void <>m__Finally2() { <>1__state = -1; ((IDisposable)<>7__wrap2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static List AllShieldAbilities { get; internal set; } = new List(AbilityManager.AllAbilities); public static List AllShieldInfos { get; internal set; } = AllShieldAbilities.Select((AbilityManager.FullAbility x) => x.Info).ToList(); [IteratorStateMachine(typeof(d__8))] public static IEnumerator TriggerBreakShield(PlayableCard target, int damage, PlayableCard attacker) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { target = target, damage = damage, attacker = attacker }; } public static void BreakShield(PlayableCard target, int damage, PlayableCard attacker) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) DamageShieldBehaviour shield = Array.Find(((Component)target).GetComponents(), (DamageShieldBehaviour x) => x.HasShields()); if ((Object)(object)shield != (Object)null) { CardModificationInfo val = target.TemporaryMods.Find((CardModificationInfo x) => x.abilities != null && x.abilities.Contains(((AbilityBehaviour)shield).Ability)); if (val != null) { target.RemoveTemporaryMod(val, false); val.abilities.Remove(((AbilityBehaviour)shield).Ability); target.AddTemporaryMod(val); } else { shield.RemoveShields(1, updateDisplay: false); } } ((Card)target).Anim.StrongNegationEffect(); if (target.GetTotalShields() == 0) { target.Status.lostShield = true; if (((Card)target).Info.HasBrokenShieldPortrait()) { target.SwitchToPortrait(((Card)target).Info.BrokenShieldPortrait()); } } target.OnStatsChanged(); } [HarmonyPostfix] [HarmonyPatch(typeof(Latch), "CardHasLatchMod")] private static void PreventShieldReset(Latch __instance, ref bool __result, PlayableCard card) { if (__instance is LatchDeathShield && card.HasShield()) { __result = true; } } [HarmonyPrefix] [HarmonyPatch(typeof(LatchDeathShield), "OnSuccessfullyLatched")] private static bool PreventShieldReset(PlayableCard target) { target.UpdateFaceUpOnBoardEffects(); return false; } public static bool NewHasShield(PlayableCard instance) { if (instance.GetTotalShields() > 0) { return !instance.Status.lostShield; } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "HasShield")] private static void ReplaceHasShieldBool(PlayableCard __instance, ref bool __result) { __result = NewHasShield(__instance); } [HarmonyPrefix] [HarmonyPatch(typeof(PlayableCard), "ResetShield", new Type[] { })] private static void ResetModShields(PlayableCard __instance) { DamageShieldBehaviour[] components = ((Component)__instance).GetComponents(); for (int i = 0; i < components.Length; i++) { components[i].ResetShields(updateDisplay: false); } if (((Object)((Card)__instance).Info).name == "MudTurtle" || ((Object)(object)((Card)__instance).Info.BrokenShieldPortrait() != (Object)null && (Object)(object)((Card)__instance).RenderInfo.portraitOverride == (Object)(object)((Card)__instance).Info.BrokenShieldPortrait())) { __instance.SwitchToDefaultPortrait(); } } [HarmonyTranspiler] [HarmonyPatch(typeof(PlayableCard), "UpdateFaceUpOnBoardEffects")] private static IEnumerable BetterHideShieldLogic(IEnumerable instructions) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown List list = new List(instructions); int num = list.IndexOf(list.Find((CodeInstruction x) => x.operand?.ToString() == "DiskCardGame.PlayableCardStatus get_Status()")); int num2 = list.IndexOf(list.Find((CodeInstruction x) => x.operand?.ToString() == "Void RenderCard()")) + 1; if (num > 0 && num2 > 0) { MethodBase methodBase = AccessTools.Method(typeof(ShieldManager), "CorrectHiddenAbilityRender", new Type[1] { typeof(PlayableCard) }, (Type[])null); list.RemoveRange(num, num2 - num); list.Insert(num, new CodeInstruction(OpCodes.Call, (object)methodBase)); } return list; } [HarmonyTranspiler] [HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")] private static IEnumerable RemoveSingleHiddenStacks(IEnumerable instructions) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown List list = new List(instructions); int num = -1; int num2 = -1; object obj = null; for (int num3 = list.Count - 1; num3 >= 0; num3--) { if (num2 == -1 && list[num3].opcode == OpCodes.Pop) { num2 = num3 + 1; } else if (num == -1 && list[num3].opcode == OpCodes.Ldftn) { num = num3; } else if (obj == null && list[num3].opcode == OpCodes.Ldfld) { obj = list[num3].operand; break; } } if (num > 0 && num2 > 0) { MethodBase methodBase = AccessTools.Method(typeof(ShieldManager), "HiddensOnlyRemoveStacks", new Type[2] { typeof(List), typeof(List) }, (Type[])null); list.RemoveRange(num, num2 - num); list.Insert(num++, new CodeInstruction(OpCodes.Ldfld, obj)); list.Insert(num++, new CodeInstruction(OpCodes.Callvirt, (object)methodBase)); list.Insert(num++, new CodeInstruction(OpCodes.Stloc_1, (object)null)); } return list; } private static List EmptyList() { return new List(); } private static List HiddensOnlyRemoveStacks(List abilities, List hiddenAbilities) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) abilities.RemoveAll((Ability x) => hiddenAbilities.Contains(x) && !x.GetHideSingleStacks()); foreach (Ability item in hiddenAbilities.Where((Ability x) => x.GetHideSingleStacks())) { abilities.Remove(item); } return abilities; } private static void CorrectHiddenAbilityRender(PlayableCard card) { if (((Card)card).Info.HasBrokenShieldPortrait() && (Object)(object)((Card)card).RenderInfo.portraitOverride == (Object)(object)((Card)card).Info.BrokenShieldPortrait() && card.HasShield()) { ((Card)card).Anim.StrongNegationEffect(); card.SwitchToDefaultPortrait(); } ((Card)card).RenderCard(); } [HarmonyPrefix] [HarmonyPatch(typeof(PlayableCard), "AddTemporaryMod")] private static void AddTemporaryShieldCount(PlayableCard __instance, CardModificationInfo mod) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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 ((Object)(object)__instance == (Object)null || mod == null) { return; } foreach (Ability ability in mod.abilities) { Type abilityBehavior = AbilityManager.AllAbilities.AbilityByID(ability).AbilityBehavior; if ((object)abilityBehavior != null && abilityBehavior.IsSubclassOf(typeof(DamageShieldBehaviour)) && __instance.TriggerHandler.triggeredAbilities.Exists((Tuple x) => x.Item1 == ability)) { (__instance.TriggerHandler.triggeredAbilities.Find((Tuple x) => x.Item1 == ability).Item2 as DamageShieldBehaviour).AddShields(1); } } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayableCard), "RemoveTemporaryMod")] private static void RemoveTemporaryShieldCount(PlayableCard __instance, CardModificationInfo mod) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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 ((Object)(object)__instance == (Object)null || mod == null) { return; } foreach (Ability ability in mod.abilities) { Type abilityBehavior = AbilityManager.AllAbilities.AbilityByID(ability).AbilityBehavior; if ((object)abilityBehavior != null && abilityBehavior.IsSubclassOf(typeof(DamageShieldBehaviour)) && __instance.TriggerHandler.triggeredAbilities.Exists((Tuple x) => x.Item1 == ability)) { (__instance.TriggerHandler.triggeredAbilities.Find((Tuple x) => x.Item1 == ability).Item2 as DamageShieldBehaviour).RemoveShields(1); } } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayableCard), "RemoveTemporaryMod")] private static void ClearTemporaryLatchSigils(PlayableCard __instance, CardModificationInfo mod) { if (!((Object)(object)__instance == (Object)null) && mod != null && mod.fromLatch && !__instance.AllCardModificationInfos().Exists((CardModificationInfo x) => x.fromLatch)) { ((MonoBehaviour)__instance).StartCoroutine(((Card)__instance).Anim.ClearLatchAbility()); } } [IteratorStateMachine(typeof(d__23))] [HarmonyPostfix] [HarmonyPatch(typeof(DiskCardAnimationController), "ClearLatchAbility")] private static IEnumerator DisableLatchModule(IEnumerator result, DiskCardAnimationController __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__23(0) { result = result, __instance = __instance }; } } [HarmonyPatch] public static class StatIconManager { public class FullStatIcon { public readonly SpecialStatIcon Id; public readonly SpecialTriggeredAbility AbilityId; public readonly StatIconInfo Info; public readonly Type VariableStatBehavior; public Dictionary RulebookDescriptionRedirects = new Dictionary(); public FullStatIcon(SpecialStatIcon id, SpecialTriggeredAbility abilityId, StatIconInfo info, Type variableStatBehavior) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) Id = id; AbilityId = abilityId; Info = info; VariableStatBehavior = variableStatBehavior; TypeManager.Add(((object)(SpecialStatIcon)(ref id)).ToString(), variableStatBehavior); } } private static readonly Dictionary BASE_GAME_ABILITIES; public static readonly ReadOnlyCollection BaseGameStatIcons; private static readonly ObservableCollection NewStatIcons; public static List AllStatIcons { get; private set; } public static List AllStatIconInfos { get; private set; } static StatIconManager() { BASE_GAME_ABILITIES = new Dictionary { { (SpecialStatIcon)1, (SpecialTriggeredAbility)6 }, { (SpecialStatIcon)4, (SpecialTriggeredAbility)12 }, { (SpecialStatIcon)2, (SpecialTriggeredAbility)8 }, { (SpecialStatIcon)6, (SpecialTriggeredAbility)23 }, { (SpecialStatIcon)5, (SpecialTriggeredAbility)17 }, { (SpecialStatIcon)3, (SpecialTriggeredAbility)11 }, { (SpecialStatIcon)7, (SpecialTriggeredAbility)26 } }; BaseGameStatIcons = new ReadOnlyCollection(GenBaseGameStatIconList()); NewStatIcons = new ObservableCollection(); AllStatIcons = BaseGameStatIcons.ToList(); AllStatIconInfos = BaseGameStatIcons.Select((FullStatIcon x) => x.Info).ToList(); NewStatIcons.CollectionChanged += delegate { AllStatIcons = BaseGameStatIcons.Concat(NewStatIcons).ToList(); AllStatIconInfos = AllStatIcons.Select((FullStatIcon x) => x.Info).ToList(); }; CardManager.ModifyCardList += delegate(List cards) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected I4, but got Unknown foreach (CardInfo card in cards) { if ((int)card.specialStatIcon != 0) { FullStatIcon fullStatIcon = AllStatIcons.FirstOrDefault((FullStatIcon i) => i.Id == card.specialStatIcon); if (fullStatIcon != null && (int)fullStatIcon.AbilityId != 0) { card.specialAbilities = new List(card.specialAbilities); card.AddSpecialAbilities((SpecialTriggeredAbility)(int)fullStatIcon.AbilityId); } } } return cards; }; } private static List GenBaseGameStatIconList() { //IL_0048: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Assembly assembly = typeof(AbilityInfo).Assembly; StatIconInfo[] array = Resources.LoadAll("Data/staticons"); foreach (StatIconInfo val in array) { string text = ((object)(SpecialStatIcon)(ref val.iconType)).ToString(); SpecialTriggeredAbility abilityId = (SpecialTriggeredAbility)(BASE_GAME_ABILITIES.ContainsKey(val.iconType) ? BASE_GAME_ABILITIES[val.iconType] : ((SpecialTriggeredAbility)Enum.Parse(typeof(SpecialTriggeredAbility), ((object)(SpecialStatIcon)(ref val.iconType)).ToString()))); list.Add(new FullStatIcon(val.iconType, abilityId, val, assembly.GetType("DiskCardGame." + text))); } return list; } public static FullStatIcon Add(string guid, StatIconInfo info, Type behavior) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) SpecialTriggeredAbility id = SpecialTriggeredAbilityManager.Add(guid, info.rulebookName, behavior).Id; FullStatIcon fullStatIcon = new FullStatIcon(GuidManager.GetEnumValue(guid, info.rulebookName), id, info, behavior); fullStatIcon.Info.iconType = fullStatIcon.Id; ((Object)info).name = guid + "_" + info.rulebookName; NewStatIcons.Add(fullStatIcon); return fullStatIcon; } public static StatIconInfo New(string guid, string rulebookName, string rulebookDescription, Type behavior) { StatIconInfo val = ScriptableObject.CreateInstance(); val.rulebookDescription = rulebookDescription; val.rulebookName = rulebookName; return Add(guid, val, behavior).Info; } public static void Remove(SpecialStatIcon id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) NewStatIcons.Remove(NewStatIcons.FirstOrDefault((FullStatIcon x) => x.Id == id)); } public static void Remove(FullStatIcon ability) { NewStatIcons.Remove(ability); } [HarmonyPrefix] [HarmonyPatch(typeof(StatIconInfo), "LoadAbilityData")] private static void AbilityLoadPrefix() { StatIconInfo.allIconInfo = AllStatIconInfos; } [HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })] [HarmonyPostfix] private static void AddNewStatIconsToRuleBook(AbilityMetaCategory metaCategory, RuleBookInfo __instance, ref List __result) { //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) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected I4, but got Unknown if (NewStatIcons.Count <= 0) { return; } foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges) { if ((int)pageRangeInfo.type != 3) { continue; } int num = __result.FindLastIndex((RuleBookPageInfo rbi) => (Object)(object)rbi.pagePrefab == (Object)(object)pageRangeInfo.rangePrefab) + 1; int num2 = 8; foreach (FullStatIcon item in NewStatIcons.Where((FullStatIcon x) => __instance.StatIconShouldBeAdded((int)x.Id, metaCategory))) { RuleBookPageInfo val = new RuleBookPageInfo(); val.pagePrefab = pageRangeInfo.rangePrefab; val.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION VII - VARIABLE STATS {0}"), num2); __instance.FillStatIconPage(val, pageRangeInfo, (int)item.Id); __result.Insert(num, val); num2++; num++; } } } } public static class SpecialTriggeredAbilityManager { public class FullSpecialTriggeredAbility { public readonly SpecialTriggeredAbility Id; public readonly string ModGUID; public readonly string AbilityName; public readonly Type AbilityBehaviour; public FullSpecialTriggeredAbility(SpecialTriggeredAbility id, Type abilityBehaviour) : this(null, abilityBehaviour.ToString(), id, abilityBehaviour) { }//IL_0008: Unknown result type (might be due to invalid IL or missing references) public FullSpecialTriggeredAbility(string guid, string name, SpecialTriggeredAbility id, Type abilityBehaviour) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Id = id; ModGUID = guid; AbilityName = name; AbilityBehaviour = abilityBehaviour; TypeManager.Add(((object)(SpecialTriggeredAbility)(ref id)).ToString(), abilityBehaviour); } } public static readonly ReadOnlyCollection BaseGameSpecialTriggers; private static readonly ObservableCollection NewSpecialTriggers; public static List AllSpecialTriggers { get; private set; } static SpecialTriggeredAbilityManager() { BaseGameSpecialTriggers = new ReadOnlyCollection(GenBaseGameSpecialTriggersList()); NewSpecialTriggers = new ObservableCollection(); AllSpecialTriggers = BaseGameSpecialTriggers.ToList(); NewSpecialTriggers.CollectionChanged += delegate { AllSpecialTriggers = BaseGameSpecialTriggers.Concat(NewSpecialTriggers).ToList(); }; } private static List GenBaseGameSpecialTriggersList() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Assembly assembly = typeof(AbilityInfo).Assembly; foreach (SpecialTriggeredAbility value in Enum.GetValues(typeof(SpecialTriggeredAbility))) { SpecialTriggeredAbility id = value; string text = ((object)(SpecialTriggeredAbility)(ref id)).ToString(); list.Add(new FullSpecialTriggeredAbility(null, text, id, assembly.GetType("DiskCardGame." + text))); } return list; } public static FullSpecialTriggeredAbility Add(string guid, string abilityName, Type behavior) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) FullSpecialTriggeredAbility fullSpecialTriggeredAbility = new FullSpecialTriggeredAbility(guid, abilityName, GuidManager.GetEnumValue(guid, abilityName), behavior); NewSpecialTriggers.Add(fullSpecialTriggeredAbility); return fullSpecialTriggeredAbility; } public static void Remove(SpecialTriggeredAbility id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) NewSpecialTriggers.Remove(NewSpecialTriggers.FirstOrDefault((FullSpecialTriggeredAbility x) => x.Id == id)); } public static void Remove(FullSpecialTriggeredAbility ability) { NewSpecialTriggers.Remove(ability); } } [HarmonyPatch] public static class TribeManager { public class TribeInfo { public string guid; public string name; public Tribe tribe; public Sprite icon; public bool tribeChoice; public Texture2D cardback; } private static readonly List tribes = new List(); private static readonly List tribeTypes = new List(); public static readonly ReadOnlyCollection NewTribes = new ReadOnlyCollection(tribes); public static readonly ReadOnlyCollection NewTribesTypes = new ReadOnlyCollection(tribeTypes); private static readonly Texture2D TribeIconMissing = TextureHelper.GetImageAsTexture("tribeicon_none.png", Assembly.GetExecutingAssembly(), (FilterMode)0); public static Tribe Add(string guid, string name, Texture2D tribeIcon = null, bool appearInTribeChoices = false, Texture2D choiceCardbackTexture = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) Tribe enumValue = GuidManager.GetEnumValue(guid, name); Texture2D cardback = choiceCardbackTexture ?? (appearInTribeChoices ? MakePlaceholderCardback(tribeIcon) : null); TribeInfo item = new TribeInfo { guid = guid, name = name, tribe = enumValue, icon = tribeIcon?.ConvertTexture(), cardback = cardback, tribeChoice = appearInTribeChoices }; tribes.Add(item); tribeTypes.Add(enumValue); return enumValue; } public static Tribe Add(string guid, string name, string pathToTribeIcon = null, bool appearInTribeChoices = false, string pathToChoiceCardBackTexture = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) return Add(guid, name, (pathToTribeIcon != null) ? TextureHelper.GetImageAsTexture(pathToTribeIcon, (FilterMode)0) : null, appearInTribeChoices, (pathToChoiceCardBackTexture != null) ? TextureHelper.GetImageAsTexture(pathToChoiceCardBackTexture, (FilterMode)0) : null); } public static bool IsCustomTribe(Tribe tribe) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return tribeTypes.Contains(tribe); } public static TribeInfo GetCustomTribeInfo(Tribe tribe) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return tribes.Find((TribeInfo x) => x.tribe == tribe); } public static Texture2D GetTribeIcon(Tribe tribe, bool useMissingIconIfNull = true) { //IL_0002: 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) Texture2D val = null; if (IsCustomTribe(tribe)) { foreach (TribeInfo newTribe in NewTribes) { if (newTribe.tribe == tribe) { if ((Object)(object)newTribe.icon != (Object)null && (Object)(object)newTribe.icon.texture != (Object)null) { val = newTribe.icon.texture; } break; } } } else { Sprite val2 = ResourceBank.Get("Art/Cards/TribeIcons/tribeicon_" + ((object)(Tribe)(ref tribe)).ToString().ToLowerInvariant()); if ((Object)(object)val2 != (Object)null) { val = val2.texture; } } if ((Object)(object)val == (Object)null && useMissingIconIfNull) { val = TribeIconMissing; } return val; } private static Texture2D MakePlaceholderCardback(Texture2D tribeIcon) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("empty_rewardCardBack.png", InscryptionAPIPlugin.APIAssembly, (FilterMode)0); if ((Object)(object)tribeIcon == (Object)null) { return imageAsTexture; } int num = (((Texture)imageAsTexture).width - ((Texture)tribeIcon).width) / 2; int num2 = (((Texture)imageAsTexture).height - ((Texture)tribeIcon).height) / 2; for (int i = num; i < ((Texture)imageAsTexture).width && i - num <= ((Texture)tribeIcon).width; i++) { for (int j = num2; j < ((Texture)imageAsTexture).height && j - num2 <= ((Texture)tribeIcon).height; j++) { Color pixel = imageAsTexture.GetPixel(i, j); Color pixel2 = tribeIcon.GetPixel(i - num, j - num2); pixel2.a *= 0.9f; Color val = Color.Lerp(pixel, pixel2, pixel2.a); imageAsTexture.SetPixel(i, j, val); } } imageAsTexture.Apply(); return imageAsTexture; } [HarmonyPatch(typeof(CardDisplayer3D), "UpdateTribeIcon")] [HarmonyPostfix] private static void UpdateTribeIcon(CardDisplayer3D __instance, CardInfo info) { //IL_0048: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)info == (Object)null || __instance.tribeIconRenderers.Count == 0) { return; } foreach (TribeInfo tribe in tribes) { if ((Object)(object)tribe?.icon == (Object)null || info.IsNotOfTribe(tribe.tribe)) { continue; } bool flag = false; foreach (SpriteRenderer tribeIconRenderer in __instance.tribeIconRenderers) { if ((Object)(object)tribeIconRenderer.sprite == (Object)null) { tribeIconRenderer.sprite = tribe.icon; flag = true; break; } } if (!flag) { SpriteRenderer val = __instance.tribeIconRenderers.Last(); SpriteRenderer obj = Object.Instantiate(val); ((Component)obj).transform.parent = ((Component)val).transform.parent; ((Component)obj).transform.localPosition = ((Component)val).transform.localPosition + (((Component)__instance.tribeIconRenderers[1]).transform.localPosition - ((Component)__instance.tribeIconRenderers[0]).transform.localPosition); } } } [HarmonyPatch(typeof(CardSingleChoicesSequencer), "GetCardbackTexture")] [HarmonyPostfix] private static void GetCardbackTexture(ref Texture __result, CardChoice choice) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (choice != null && (int)choice.tribe != 0 && (Object)(object)__result == (Object)null) { __result = (Texture)(object)tribes.Find((TribeInfo x) => x?.tribe == (Tribe?)choice.tribe)?.cardback; } } [HarmonyPatch(typeof(Part1CardChoiceGenerator), "GenerateTribeChoices")] [HarmonyPrefix] private static bool GenerateTribeChoices(ref List __result, int randomSeed) { //IL_0115: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown List list = new List { (Tribe)2, (Tribe)3, (Tribe)4, (Tribe)6, (Tribe)5 }; list.AddRange(TribeManager.tribes.FindAll((TribeInfo x) => x?.tribeChoice ?? false).ConvertAll((TribeInfo x) => x.tribe)); List tribes = new List(RunState.CurrentMapRegion.dominantTribes); List obtainableCards = CardManager.AllCardsCopy.FindAll((CardInfo c) => c.HasCardMetaCategory((CardMetaCategory)0)); tribes.RemoveAll((Tribe t) => TribeManager.tribes.Exists((TribeInfo ct) => ct.tribe == t && !ct.tribeChoice) || !obtainableCards.Exists((CardInfo c) => c.IsOfTribe(t))); list.RemoveAll((Tribe t) => tribes.Contains(t) || !obtainableCards.Exists((CardInfo c) => c.IsOfTribe(t))); if (list.Count == 0) { list.Add((Tribe)6); } while (tribes.Count < 3) { Tribe item = list[SeededRandom.Range(0, list.Count, randomSeed++)]; tribes.Add(item); if (list.Count > 1) { list.Remove(item); } } while (tribes.Count > 3) { tribes.RemoveAt(SeededRandom.Range(0, tribes.Count, randomSeed++)); } List list2 = new List(); foreach (Tribe item2 in CustomList.Randomize((IEnumerable)tribes)) { list2.Add(new CardChoice { tribe = item2 }); } __result = list2; return false; } } } namespace InscryptionAPI.Card.CostProperties { [HarmonyPatch] public static class CostProperties { public class RefreshCostMonoBehaviour : MonoBehaviour { public PlayableCard playableCard; private int cachedBloodCost = -1; private int cachedBoneCost = -1; private readonly List cachedGemsCost = new List(); private void LateUpdate() { if (DidCostsChangeThisFrame()) { ((Card)playableCard).RenderCard(); } } private bool DidCostsChangeThisFrame() { bool result = false; int num = playableCard?.BloodCost() ?? 0; if (num != cachedBloodCost) { cachedBloodCost = num; result = true; } int num2 = playableCard.BonesCost(); if (num2 != cachedBoneCost) { cachedBoneCost = num2; result = true; } List list = playableCard.GemsCost(); if (GemsChanged(cachedGemsCost, list)) { cachedGemsCost.Clear(); cachedGemsCost.AddRange(list); result = true; } return result; } public bool GemsChanged(List a, List b) { if (a.Count != b.Count) { return true; } for (int i = 0; i < a.Count; i++) { if (!a[i].Equals(b[i])) { return true; } } return false; } } public static ConditionalWeakTable>> CardInfoToCard = new ConditionalWeakTable>>(); public static ConditionalWeakTable>> CardInfoToPlayableCardReferences = new ConditionalWeakTable>>(); [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static int OriginalBloodCost(CardInfo __instance) { return 0; } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static int OriginalBonesCost(CardInfo __instance) { return 0; } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static List OriginalGemsCost(CardInfo __instance) { return null; } public static List ImprovedGemsCost(CardInfo instance) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (instance.Mods.Exists((CardModificationInfo x) => x.nullifyGemsCost)) { return new List(); } List list = new List(instance.gemsCost); foreach (CardModificationInfo mod in instance.Mods) { if (mod.addGemCost != null) { list.AddRange(mod.addGemCost); } foreach (GemType item in mod.RemovedGemsCosts()) { list.Remove(item); } } return list; } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static int OriginalEnergyCost(CardInfo __instance) { return 0; } public static bool ReduceGemifiedBlood(PlayableCard card, int? bloodCost = null) { if ((bloodCost ?? OriginalBloodCost(((Card)card).Info)) > 0 && !ReduceGemifiedEnergy(card) && !ReduceGemifiedBones(card)) { return !ReduceGemifiedMox(card); } return false; } public static bool ReduceGemifiedMox(PlayableCard card, List gemsCost = null) { if ((gemsCost?.Count ?? ImprovedGemsCost(((Card)card).Info).Count) > 0 && !ReduceGemifiedBones(card)) { return !ReduceGemifiedEnergy(card); } return false; } public static bool ReduceGemifiedBones(PlayableCard card, int? bonesCost = null) { if ((bonesCost ?? OriginalBonesCost(((Card)card).Info)) > 0) { return !ReduceGemifiedEnergy(card); } return false; } public static bool ReduceGemifiedEnergy(PlayableCard card, int? energyCost = null) { return (energyCost ?? OriginalEnergyCost(((Card)card).Info)) > 0; } } [HarmonyPatch] internal static class ChangeCardCostGetter { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool BloodCost(CardInfo __instance, ref int __result) { __result = Mathf.Max(0, __instance.GetPlayableCard()?.BloodCost() ?? CostProperties.OriginalBloodCost(__instance)); return false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool BoneCost(CardInfo __instance, ref int __result) { PlayableCard playableCard = __instance.GetPlayableCard(); if ((Object)(object)playableCard == (Object)null) { return true; } __result = Mathf.Max(0, playableCard.BonesCost()); return false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool GemsCost(CardInfo __instance, ref List __result) { __result = __instance.GetPlayableCard()?.GemsCost() ?? CostProperties.ImprovedGemsCost(__instance); return false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool EnergyCost(CardInfo __instance, ref int __result) { PlayableCard playableCard = __instance.GetPlayableCard(); __result = ((playableCard != null) ? playableCard.EnergyCost : CostProperties.OriginalEnergyCost(__instance)); return false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool DisableVanillaEnergyCost(PlayableCard __instance, ref int __result) { int num = CostProperties.OriginalEnergyCost(((Card)__instance).Info); if (__instance.IsUsingBlueGem() && CostProperties.ReduceGemifiedEnergy(__instance, num)) { num--; } foreach (CardModificationInfo temporaryMod in __instance.TemporaryMods) { num += temporaryMod.energyCostAdjustment; } __result = Mathf.Max(0, num); return false; } } [HarmonyPatch(typeof(PlayableCard), "SetInfo")] internal static class AddRefreshBehaviourToCard { private static void Postfix(PlayableCard __instance) { (((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent()).playableCard = __instance; if (CostProperties.CardInfoToCard.TryGetValue(((Card)__instance).Info, out var value)) { PlayableCard val = null; for (int num = value.Count - 1; num >= 0; num--) { if (!value[num].TryGetTarget(out var target) || (Object)(object)target == (Object)null) { value.RemoveAt(num); } else if ((Object)(object)target == (Object)(object)__instance) { val = target; } } if ((Object)(object)val == (Object)null) { value.Add(new WeakReference(__instance)); if (value.Count > 1) { InscryptionAPIPlugin.Logger.LogWarning((object)("More than 1 card are using the same CardInfo. This can cause unexpected problems with dynamic costs! " + ((Card)__instance).Info.displayedName)); } } } else { CostProperties.CardInfoToCard.Add(((Card)__instance).Info, new List> { new WeakReference(__instance) }); } } } [HarmonyPatch] internal static class TurnManager_CleanupPhase { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = AccessTools.Method(typeof(TurnManager), "CleanupPhase", (Type[])null, (Type[])null); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = AccessTools.Method(typeof(GBCEncounterManager), "LoadOverworldScene", (Type[])null, (Type[])null); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__0(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2); } private static void Postfix() { CostProperties.CardInfoToCard = new ConditionalWeakTable>>(); } } } namespace InscryptionAPI.Boons { public class BoonBehaviour : NonCardTriggerReceiver { [CompilerGenerated] private sealed class d__26 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__22 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__24 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__18 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public BoonBehaviour <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; BoonBehaviour boonBehaviour = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)Singleton.Instance != (Object)null) { <>2__current = Singleton.Instance.PlayBoonAnimation(boonBehaviour.boon.boon.type); <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static List instances; public BoonManager.FullBoon boon { get; internal set; } public int instanceNumber { get; internal set; } internal static List Instances { get { EnsureInstancesLoaded(); return instances; } } public void Start() { if (!Instances.Contains(this)) { Instances.Add(this); } } public void OnDestroy() { Instances.Remove(this); } public static List FindInstancesOfType(Type type) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Instances.FindAll((BoonBehaviour x) => x.boon.boon.type == type); } public static int CountInstancesOfType(Type type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return FindInstancesOfType(type).Count; } public static bool AnyInstancesOfType(Type type) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Instances.Any((BoonBehaviour x) => x.boon.boon.type == type); } internal static void DestroyAllInstances() { foreach (BoonBehaviour instance in Instances) { if ((Object)(object)instance != (Object)null && (Object)(object)((Component)instance).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)instance).gameObject); } } EnsureInstancesLoaded(); Instances.Clear(); } internal static void EnsureInstancesLoaded() { if (instances == null) { instances = new List(); } instances.RemoveAll((BoonBehaviour x) => (Object)(object)x == (Object)null || (Object)(object)((Component)x).gameObject == (Object)null || (Object)(object)((Component)x).GetComponent() != (Object)null); } [IteratorStateMachine(typeof(d__18))] protected IEnumerator PlayBoonAnimation() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0) { <>4__this = this }; } public virtual bool RespondsToPreBoonActivation() { return false; } [IteratorStateMachine(typeof(d__20))] public virtual IEnumerator OnPreBoonActivation() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0); } public virtual bool RespondsToPostBoonActivation() { return false; } [IteratorStateMachine(typeof(d__22))] public virtual IEnumerator OnPostBoonActivation() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__22(0); } public virtual bool RespondsToPreBattleCleanup() { return false; } [IteratorStateMachine(typeof(d__24))] public virtual IEnumerator OnPreBattleCleanup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__24(0); } public virtual bool RespondsToPostBattleCleanup() { return false; } [IteratorStateMachine(typeof(d__26))] public virtual IEnumerator OnPostBattleCleanup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__26(0); } } [HarmonyPatch] public static class BoonManager { public class FullBoon { public BoonData boon; public Type boonHandlerType; public bool appearInRulebook; public bool stacks; public List metaCategories = new List(); public Dictionary RulebookDescriptionRedirects = new Dictionary(); } [CompilerGenerated] private sealed class <>c__DisplayClass20_0 { public BoonData boon; internal bool b__0(FullBoon x) { //IL_0006: 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) return x.boon.type == boon.type; } } [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public BoonsHandler __instance; public IEnumerator result; private List.Enumerator <>7__wrap1; private BoonBehaviour[] <>7__wrap2; private int <>7__wrap3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; BoonBehaviour.DestroyAllInstances(); if (__instance.BoonsEnabled && RunState.Run?.playerDeck != null && RunState.Run.playerDeck.Boons != null && NewBoons != null) { <>7__wrap1 = RunState.Run.playerDeck.Boons.GetEnumerator(); <>1__state = -3; goto IL_01d0; } goto IL_01e6; case 1: <>1__state = -3; goto IL_01d0; case 2: { <>1__state = -1; BoonBehaviour[] array = BoonBehaviour.Instances.ToArray(); <>7__wrap2 = array; <>7__wrap3 = 0; goto IL_0271; } case 3: { <>1__state = -1; goto IL_0263; } IL_0271: if (<>7__wrap3 < <>7__wrap2.Length) { BoonBehaviour boonBehaviour = <>7__wrap2[<>7__wrap3]; if ((Object)(object)boonBehaviour != (Object)null && boonBehaviour.RespondsToPostBoonActivation()) { <>2__current = boonBehaviour.OnPostBoonActivation(); <>1__state = 3; return true; } goto IL_0263; } <>7__wrap2 = null; return false; IL_01d0: while (<>7__wrap1.MoveNext()) { <>c__DisplayClass20_0 CS$<>8__locals0 = new <>c__DisplayClass20_0 { boon = <>7__wrap1.Current }; if ((Object)(object)CS$<>8__locals0.boon == (Object)null) { continue; } FullBoon fullBoon = AllFullBoons.Find((FullBoon x) => x.boon.type == CS$<>8__locals0.boon.type); if (fullBoon == null) { continue; } int num = BoonBehaviour.CountInstancesOfType(fullBoon.boon.type); if (fullBoon == null || !(fullBoon.boonHandlerType != null) || !fullBoon.boonHandlerType.IsSubclassOf(typeof(BoonBehaviour)) || (!fullBoon.stacks && num >= 1)) { continue; } BoonBehaviour boonBehaviour2 = new GameObject(((Object)fullBoon.boon).name + " Boon Handler").AddComponent(fullBoon.boonHandlerType) as BoonBehaviour; if ((Object)(object)boonBehaviour2 != (Object)null) { GlobalTriggerHandler instance = Singleton.Instance; if (instance != null) { instance.RegisterNonCardReceiver((NonCardTriggerReceiver)(object)boonBehaviour2); } boonBehaviour2.boon = fullBoon; boonBehaviour2.instanceNumber = num + 1; BoonBehaviour.Instances.Add(boonBehaviour2); if (boonBehaviour2.RespondsToPreBoonActivation()) { <>2__current = boonBehaviour2.OnPreBoonActivation(); <>1__state = 1; return true; } } } <>m__Finally1(); goto IL_01e6; IL_01e6: <>2__current = result; <>1__state = 2; return true; IL_0263: <>7__wrap3++; goto IL_0271; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__21 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; private BoonBehaviour[] <>7__wrap1; private int <>7__wrap2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; BoonBehaviour[] array = BoonBehaviour.Instances.ToArray(); <>7__wrap1 = array; <>7__wrap2 = 0; goto IL_008a; } case 1: <>1__state = -1; goto IL_007c; case 2: { <>1__state = -1; BoonBehaviour[] array = BoonBehaviour.Instances.ToArray(); <>7__wrap1 = array; <>7__wrap2 = 0; goto IL_0121; } case 3: { <>1__state = -1; goto IL_0113; } IL_0121: if (<>7__wrap2 < <>7__wrap1.Length) { BoonBehaviour boonBehaviour = <>7__wrap1[<>7__wrap2]; if ((Object)(object)boonBehaviour != (Object)null && boonBehaviour.RespondsToPostBattleCleanup()) { <>2__current = boonBehaviour.OnPostBattleCleanup(); <>1__state = 3; return true; } goto IL_0113; } <>7__wrap1 = null; BoonBehaviour.DestroyAllInstances(); return false; IL_008a: if (<>7__wrap2 < <>7__wrap1.Length) { BoonBehaviour boonBehaviour2 = <>7__wrap1[<>7__wrap2]; if ((Object)(object)boonBehaviour2 != (Object)null && boonBehaviour2.RespondsToPreBattleCleanup()) { <>2__current = boonBehaviour2.OnPreBattleCleanup(); <>1__state = 1; return true; } goto IL_007c; } <>7__wrap1 = null; <>2__current = result; <>1__state = 2; return true; IL_007c: <>7__wrap2++; goto IL_008a; IL_0113: <>7__wrap2++; goto IL_0121; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static readonly ReadOnlyCollection BaseGameBoons; public static readonly List FullBaseGameBoons; internal static readonly ObservableCollection NewBoons; public static List AllFullBoons { get; private set; } public static List AllBoonsCopy { get; private set; } public static Type New(string guid, string name, Type boonHandlerType, string rulebookDescription, Texture icon, Texture cardArt, bool stackable = true, bool appearInLeshyTrials = true, bool appearInRulebook = true) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) FullBoon fullBoon = new FullBoon(); BoonData val = ScriptableObject.CreateInstance(); ((Object)val).name = name; val.displayedName = name; val.description = rulebookDescription; val.icon = icon; val.cardArt = cardArt; val.minorEffect = !appearInLeshyTrials; val.type = GuidManager.GetEnumValue(guid, name); fullBoon.appearInRulebook = appearInRulebook; fullBoon.boon = val; fullBoon.boonHandlerType = boonHandlerType; fullBoon.stacks = stackable; NewBoons.Add(fullBoon); return val.type; } public static Type New(string guid, string name, string rulebookDescription, Texture icon, Texture cardArt, bool stackable = true, bool appearInLeshyTrials = true, bool appearInRulebook = true) where T : BoonBehaviour { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return New(guid, name, typeof(T), rulebookDescription, icon, cardArt, stackable, appearInLeshyTrials, appearInRulebook); } public static Type New(string guid, string name, Type boonHandlerType, string rulebookDescription, string pathToIcon, string pathToCardArt, bool stackable = true, bool appearInLeshyTrials = true, bool appearInRulebook = true) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) return New(guid, name, boonHandlerType, rulebookDescription, (Texture)(object)TextureHelper.GetImageAsTexture(pathToIcon, (FilterMode)0), (Texture)(object)TextureHelper.GetImageAsTexture(pathToCardArt, (FilterMode)0), stackable, appearInLeshyTrials, appearInRulebook); } public static Type New(string guid, string name, string rulebookDescription, string pathToIcon, string pathToCardArt, bool stackable = true, bool appearInLeshyTrials = true, bool appearInRulebook = true) where T : BoonBehaviour { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return New(guid, name, rulebookDescription, pathToIcon, pathToCardArt, stackable, appearInLeshyTrials, appearInRulebook); } public static Type AddRuleBookCategories(this Type boonType, params AbilityMetaCategory[] categories) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) FullBoon fullBoon = boonType.GetFullBoon(); if (fullBoon != null) { foreach (AbilityMetaCategory item in categories) { if (!fullBoon.metaCategories.Contains(item)) { fullBoon.metaCategories.Add(item); } } } return boonType; } public static FullBoon GetFullBoon(this Type boonType) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return AllFullBoons.Find((FullBoon x) => x.boon.type == boonType); } internal static void SyncBoonList() { AllBoonsCopy = BaseGameBoons.Concat(NewBoons.Select((FullBoon x) => x.boon)).ToList(); AllFullBoons = FullBaseGameBoons.Concat(NewBoons).ToList(); } static BoonManager() { BaseGameBoons = new ReadOnlyCollection(Resources.LoadAll("Data/Boons")); FullBaseGameBoons = BaseGameBoons.Select((BoonData x) => new FullBoon { appearInRulebook = true, boon = x, stacks = ((int)x.type == 7), boonHandlerType = null, metaCategories = new List { (AbilityMetaCategory)0 } }).ToList(); NewBoons = new ObservableCollection(); AllFullBoons = new List(FullBaseGameBoons); AllBoonsCopy = BaseGameBoons.ToList(); InscryptionAPIPlugin.ScriptableObjectLoaderLoad += delegate(Type type) { if (type == typeof(BoonData)) { ScriptableObjectLoader.allData = AllBoonsCopy; } }; NewBoons.CollectionChanged += delegate { SyncBoonList(); }; } [IteratorStateMachine(typeof(d__20))] [HarmonyPatch(typeof(BoonsHandler), "ActivatePreCombatBoons")] [HarmonyPostfix] private static IEnumerator ActivatePreCombatBoons(IEnumerator result, BoonsHandler __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0) { result = result, __instance = __instance }; } [IteratorStateMachine(typeof(d__21))] [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] [HarmonyPostfix] private static IEnumerator Postfix(IEnumerator result) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__21(0) { result = result }; } [HarmonyPatch(typeof(DeckInfo), "AddBoon")] [HarmonyPostfix] private static void AddBoon(Type boonType) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Singleton.Instance != (Object)null) || Singleton.Instance.GameEnded || Singleton.Instance.GameEnding || Singleton.Instance.IsSetupPhase || !((Object)(object)Singleton.Instance.Opponent != (Object)null)) { return; } FullBoon fullBoon = NewBoons.ToList().Find((FullBoon x) => x.boon.type == boonType); if (fullBoon == null || !(fullBoon.boonHandlerType != null) || (!fullBoon.stacks && BoonBehaviour.CountInstancesOfType(fullBoon.boon.type) >= 1)) { return; } int num = BoonBehaviour.CountInstancesOfType(fullBoon.boon.type); BoonBehaviour boonBehaviour = new GameObject(((Object)fullBoon.boon).name + " Boon Handler").AddComponent(fullBoon.boonHandlerType) as BoonBehaviour; if ((Object)(object)boonBehaviour != (Object)null) { GlobalTriggerHandler instance = Singleton.Instance; if (instance != null) { instance.RegisterNonCardReceiver((NonCardTriggerReceiver)(object)boonBehaviour); } boonBehaviour.boon = fullBoon; boonBehaviour.instanceNumber = num + 1; BoonBehaviour.Instances.Add(boonBehaviour); } } internal static void DestroyWhenStackClear(this GameObject obj) { if ((Object)(object)obj.GetComponent() == (Object)null) { DestroyingFlag destroyingFlag = obj.AddComponent(); ((MonoBehaviour)destroyingFlag).StartCoroutine(destroyingFlag.WaitForStackClearThenDestroy()); } } [HarmonyPatch(typeof(DeckInfo), "ClearBoons")] [HarmonyPostfix] private static void ClearBoons() { BoonBehaviour.DestroyAllInstances(); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static void get_Boons(DeckInfo __instance) { if (__instance.boons != null && __instance.boonIds != null && __instance.boons.Count != __instance.boonIds.Count) { __instance.LoadBoons(); } } [HarmonyPatch(typeof(DeckInfo), "LoadBoons")] [HarmonyPostfix] private static void LoadBoons(DeckInfo __instance) { __instance.boons.RemoveAll((BoonData x) => (Object)(object)x == (Object)null); } [HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData")] [HarmonyPostfix] private static void ConstructPageData(ref List __result, RuleBookInfo __instance, AbilityMetaCategory metaCategory) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected I4, but got Unknown if (NewBoons.Count == 0) { return; } foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges) { if ((int)pageRangeInfo.type != 4) { continue; } int num = __result.FindLastIndex((RuleBookPageInfo rbi) => (Object)(object)rbi.pagePrefab == (Object)(object)pageRangeInfo.rangePrefab) + 1; int num2 = 8; foreach (FullBoon item in NewBoons.Where((FullBoon x) => RuleBookManager.BoonShouldBeAdded(x, metaCategory)).ToList()) { RuleBookPageInfo val = new RuleBookPageInfo(); val.pagePrefab = pageRangeInfo.rangePrefab; val.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION I - MOD BOONS {0}"), num2); __instance.FillBoonPage(val, pageRangeInfo, (int)item.boon.type); __result.Insert(num, val); num2++; num++; } } } } public static class DeckInfoExtensions { public static void RemoveBoon(this DeckInfo self, Type type) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) self.boonIds.Remove(type); bool removedItem = false; self.Boons.RemoveAll(delegate(BoonData d) { //IL_000a: 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) if ((Object)(object)d != (Object)null && d.type == type && !removedItem) { removedItem = true; return true; } return false; }); List list = BoonBehaviour.FindInstancesOfType(type).FindAll((BoonBehaviour x) => (Object)(object)((Component)x).GetComponent() == (Object)null); if (list.Count > 0) { ((Component)list[0]).gameObject.DestroyWhenStackClear(); BoonBehaviour.EnsureInstancesLoaded(); } } public static void RemoveAllBoonsOfType(this DeckInfo self, Type type) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) self.boonIds.RemoveAll((Type x) => x == type); self.Boons.RemoveAll((BoonData x) => (Object)(object)x != (Object)null && x.type == type); List list = new List(BoonBehaviour.FindInstancesOfType(type)); if (list.Count <= 0) { return; } foreach (BoonBehaviour item in list) { if ((Object)(object)item != (Object)null && (Object)(object)((Component)item).gameObject != (Object)null) { ((Component)item).gameObject.DestroyWhenStackClear(); } } BoonBehaviour.EnsureInstancesLoaded(); } } internal class DestroyingFlag : MonoBehaviour { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DestroyingFlag <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown int num = <>1__state; DestroyingFlag destroyingFlag = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil((Func)(() => (Object)(object)Singleton.Instance == (Object)null || Singleton.Instance.StackSize <= 0)); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)((Component)destroyingFlag).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)destroyingFlag).gameObject); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public IEnumerator WaitForStackClearThenDestroy() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { <>4__this = this }; } } } namespace InscryptionAPI.Ascension { public class AscensionChallengePaginator : MonoBehaviour { private class NoneChallengeDisplayer : MonoBehaviour { public void Start() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) AscensionIconInteractable component = ((Component)this).gameObject.GetComponent(); if (missingChallengeSprite == null) { missingChallengeSprite = TextureHelper.GetImageAsTexture("ascensionicon_none.png", Assembly.GetExecutingAssembly(), (FilterMode)0).ConvertTexture(); } component.iconRenderer.sprite = missingChallengeSprite; ((AscensionMenuBlinkEffect)component.blinkEffect).blinkOffColor = component.conqueredColor; ((AscensionMenuBlinkEffect)component.blinkEffect).SetBlinkingEnabled(false); } } public bool initialized; public List> challengeObjectsForPages; public int pageIndex; public int pageLength; public AscensionChallengeScreen screen; public AscensionMenuScreenTransition transition; public AscensionMenuInteractable leftArrow; public AscensionMenuInteractable rightArrow; public static Sprite missingChallengeSprite; public static AscensionChallengeInfo missingChallengeInfo; public void Initialize(AscensionChallengeScreen screen, AscensionMenuScreenTransition transition = null) { if (challengeObjectsForPages == null) { List list; if ((Object)(object)screen != (Object)null) { list = screen.icons; pageLength = screen.icons.Count; } else { list = new List(transition.screenInteractables.ConvertAll((MainInputInteractable x) => ((Component)x).GetComponent())); list.RemoveAll((AscensionIconInteractable x) => (Object)(object)x == (Object)null); pageLength = list.Count; } challengeObjectsForPages = new List> { list.ConvertAll((AscensionIconInteractable x) => ((Component)x).gameObject) }; } if ((Object)(object)screen == (Object)null) { this.transition = transition; } this.screen = screen; } public void InitialiseMissingChallengeInfo() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) missingChallengeInfo = ScriptableObject.CreateInstance(); ((Object)missingChallengeInfo).name = "MISSING"; missingChallengeInfo.activatedSprite = null; missingChallengeInfo.iconSprite = null; missingChallengeInfo.challengeType = (AscensionChallenge)0; missingChallengeInfo.description = ""; missingChallengeInfo.title = ""; missingChallengeInfo.pointValue = 0; } public void AddPage(List challengeInfos) { //IL_01a8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)missingChallengeInfo == (Object)null) { InitialiseMissingChallengeInfo(); } Initialize(((Component)this).GetComponent(), ((Component)this).GetComponent()); List list = new List(); List list2 = challengeInfos.FindAll((AscensionChallengeInfo x) => !x.challengeType.GetFullChallenge().Boss); int count = challengeInfos.FindAll((AscensionChallengeInfo x) => x.challengeType.GetFullChallenge().Boss).Count; Mathf.Min(14, challengeObjectsForPages[0].Count); int num = (1 + list2.Count) / 2; int num2 = 0; for (int i = 0; i < 14; i++) { GameObject val = null; int num3 = i % 7; if (count > 0 && num3 >= num && num3 < num + count) { if (num2 >= count) { i += count - 1; continue; } num2++; val = challengeObjectsForPages[0][14]; } if (val == null) { val = challengeObjectsForPages[0][i]; } if ((Object)(object)val != (Object)null) { GameObject item = CreateIconGameObject(val, i); list.Add(item); } } list.Sort((GameObject x, GameObject x2) => Mathf.RoundToInt(((Mathf.Abs(x.transform.position.x - x2.transform.position.x) < 0.1f) ? (x2.transform.position.y - x.transform.position.y) : (x.transform.position.x - x2.transform.position.x)) * 100f)); int num4 = 0; int num5 = challengeInfos.Count; for (int j = 0; j < list.Count; j++) { AscensionIconInteractable component = list[j].GetComponent(); if (j < num5) { AscensionChallengeInfo val2 = challengeInfos[num4]; if (val2.GetFullChallenge().Boss && ((BoxCollider2D)/*isinst with value type is only supported in some contexts*/).size.y < 1f) { component.challengeInfo = missingChallengeInfo; list[j].AddComponent(); num5++; } else { component.challengeInfo = val2; num4++; } } else { component.challengeInfo = missingChallengeInfo; list[j].AddComponent(); } } challengeObjectsForPages.Add(list); } private GameObject CreateIconGameObject(GameObject objectRef, int index, AscensionChallengeInfo info = null) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate(objectRef, objectRef.transform.parent); obj.SetActive(false); obj.transform.localPosition = Vector2.op_Implicit(new Vector2(-1.65f + (float)(index % 7) * 0.55f, objectRef.transform.localPosition.y)); AscensionIconInteractable component = obj.GetComponent(); ((InteractableBase)component).SetEnabled(true); screen?.icons.Add(component); if ((Object)(object)info != (Object)null) { component.challengeInfo = info; } return obj; } public void OnEnable() { if (AscensionSaveData.Data.activeChallenges.Count > 0) { LoadPage(pageIndex = 0); return; } ChallengeManager.SyncChallengeList(); Initialize(((Component)this).GetComponent(), ((Component)this).GetComponent()); if (Object.op_Implicit((Object)(object)leftArrow)) { Object.Destroy((Object)(object)((Component)leftArrow).gameObject); } if (Object.op_Implicit((Object)(object)rightArrow)) { Object.Destroy((Object)(object)((Component)rightArrow).gameObject); } for (int i = 1; i < challengeObjectsForPages.Count; i++) { challengeObjectsForPages[i].ForEach((Action)Object.DestroyImmediate); } if (AscensionSaveData.Data.activeChallenges.Count == 0) { challengeObjectsForPages.Clear(); } List list = new List(); if ((Object)(object)screen != (Object)null) { screen.icons?.RemoveAll((AscensionIconInteractable x) => (Object)(object)x == (Object)null); list = screen.icons; pageLength = screen.icons.Count; } else { list = new List(transition.screenInteractables.ConvertAll((MainInputInteractable x) => ((Component)x).GetComponent())); list.RemoveAll((AscensionIconInteractable x) => (Object)(object)x == (Object)null); pageLength = list.Count; } list.Sort((AscensionIconInteractable x, AscensionIconInteractable x2) => Mathf.RoundToInt(((Mathf.Abs(((Component)x).transform.position.x - ((Component)x2).transform.position.x) < 0.1f) ? (((Component)x2).transform.position.y - ((Component)x).transform.position.y) : (((Component)x).transform.position.x - ((Component)x2).transform.position.x)) * 100f)); challengeObjectsForPages = new List> { list.ConvertAll((AscensionIconInteractable x) => ((Component)x).gameObject) }; List<(ChallengeManager.FullChallenge, AscensionChallengeInfo)> list2 = new List<(ChallengeManager.FullChallenge, AscensionChallengeInfo)>(new List(ChallengeManager.AllChallenges).ConvertAll((ChallengeManager.FullChallenge x) => (x, x.Challenge).Repeat(x.AppearancesInChallengeScreen)).SelectMany((List<(ChallengeManager.FullChallenge x, AscensionChallengeInfo Challenge)> x) => x)); foreach (AscensionIconInteractable item in new List(list)) { if (list2.Count > 0) { item.AssignInfo(list2[0].Item2); list2.RemoveAt(0); } else { if ((Object)(object)missingChallengeInfo == (Object)null) { InitialiseMissingChallengeInfo(); } item.AssignInfo(missingChallengeInfo); } ((Component)item.conqueredRenderer).gameObject.SetActive(item.Conquered && item.showConquered); } list2.Sort(((ChallengeManager.FullChallenge, AscensionChallengeInfo) x, (ChallengeManager.FullChallenge, AscensionChallengeInfo) x2) => (x.Item1.SortValue != x2.Item1.SortValue) ? (x.Item1.SortValue - x2.Item1.SortValue) : (x2.Item1.UnlockLevel - x.Item1.UnlockLevel)); List> list3 = new List>(); while (list2.Count > 0) { List<(ChallengeManager.FullChallenge, AscensionChallengeInfo)> list4 = new List<(ChallengeManager.FullChallenge, AscensionChallengeInfo)>(); for (int j = 0; j < 14; j++) { if (list2.Count > 0) { list4.Add(list2.Last()); if (list2.Last().Item1.Boss) { j++; } list2.RemoveAt(list2.Count - 1); } } list4.Sort(((ChallengeManager.FullChallenge, AscensionChallengeInfo) x, (ChallengeManager.FullChallenge, AscensionChallengeInfo) x2) => (x.Item1.BossSortValue != x2.Item1.BossSortValue) ? (x2.Item1.BossSortValue - x.Item1.BossSortValue) : (x.Item1.UnlockLevel + (x2.Item1.Boss ? 0 : 0) - (x2.Item1.UnlockLevel + (x.Item1.Boss ? 0 : 0)))); list3.Add(list4.ConvertAll(((ChallengeManager.FullChallenge, AscensionChallengeInfo) x) => x.Item2)); } challengeObjectsForPages.ForEach(delegate(List x) { x.RemoveAll((GameObject x) => (Object)(object)x == (Object)null); }); LoadPage(pageIndex = 0); if (list3.Count != 0) { list3.ForEach(AddPage); InstantiateArrowObjects(list); } } public void InstantiateArrowObjects(List icons) { //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: 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_0239: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(float.MinValue, float.MinValue); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(float.MaxValue, float.MaxValue); foreach (AscensionIconInteractable icon in icons) { if (!((Object)(object)icon?.iconRenderer == (Object)null) && ((Component)icon).gameObject.activeSelf) { if (((Component)icon.iconRenderer).transform.position.x < val2.x) { val2.x = ((Component)icon.iconRenderer).transform.position.x; } if (((Component)icon.iconRenderer).transform.position.x > val.x) { val.x = ((Component)icon.iconRenderer).transform.position.x; } if (((Component)icon.iconRenderer).transform.position.y < val2.y) { val2.y = ((Component)icon.iconRenderer).transform.position.y; } if (((Component)icon.iconRenderer).transform.position.y > val.y) { val.y = ((Component)icon.iconRenderer).transform.position.y; } } } AscensionChallengeScreen obj = screen; Transform val3 = ((obj != null) ? ((Component)obj.continueButton).gameObject.transform : null); Vector3 position = Vector3.Lerp(new Vector3(val2.x, val.y, val.z), new Vector3(val2.x, val2.y, val.z), 0.5f) + Vector3.left / 3f; Vector3 val4 = Vector3.Lerp(new Vector3(val.x, val.y, val.z), new Vector3(val.x, val2.y, val.z), 0.5f) + Vector3.right / 3f; if (InscryptionAPIPlugin.configOverrideArrows.Value || val3.position.x < val4.x) { val4 = val3.position + Vector3.left / 2f; AscensionChallengeScreen obj2 = screen; ((Vector3)(ref position))..ctor((((obj2 != null) ? new float?(((Component)obj2).transform.position.x) : null) - val3.position.x).Value + Vector3.right.x / 2f, val3.position.y, val3.position.z); } AscensionChallengeScreen obj3 = screen; leftArrow = Object.Instantiate(((Component)(((obj3 != null) ? ((Component)obj3).gameObject : null) ?? ((Component)((Component)this).transform).gameObject).GetComponentInParent().cardUnlockSummaryScreen.GetComponent().pageLeftButton).gameObject).GetComponent(); Transform transform = ((Component)leftArrow).transform; AscensionChallengeScreen obj4 = screen; transform.SetParent(((obj4 != null) ? ((Component)obj4).transform : null) ?? ((Component)((Component)this).transform).transform, false); ((Component)leftArrow).transform.position = position; ((InteractableBase)leftArrow).ClearDelegates(); AscensionMenuInteractable obj5 = leftArrow; ((MainInputInteractable)obj5).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)obj5).CursorSelectStarted, (Action)delegate { PreviousPage(); }); AscensionChallengeScreen obj6 = screen; rightArrow = Object.Instantiate(((Component)(((obj6 != null) ? ((Component)obj6).gameObject : null) ?? ((Component)((Component)this).transform).gameObject).GetComponentInParent().cardUnlockSummaryScreen.GetComponent().pageRightButton).gameObject).GetComponent(); Transform transform2 = ((Component)rightArrow).transform; AscensionChallengeScreen obj7 = screen; transform2.SetParent(((obj7 != null) ? ((Component)obj7).transform : null) ?? ((Component)((Component)this).transform).transform, false); ((Component)rightArrow).transform.position = val4; ((InteractableBase)rightArrow).ClearDelegates(); AscensionMenuInteractable obj8 = rightArrow; ((MainInputInteractable)obj8).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)obj8).CursorSelectStarted, (Action)delegate { NextPage(); }); } public void NextPage() { pageIndex++; if (pageIndex >= challengeObjectsForPages.Count) { pageIndex = 0; } LoadPage(pageIndex); } public void PreviousPage() { pageIndex--; if (pageIndex < 0) { pageIndex = challengeObjectsForPages.Count - 1; } LoadPage(pageIndex); } public void LoadPage(int page) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (page >= 0 && page < challengeObjectsForPages.Count) { for (int i = 0; i < challengeObjectsForPages.Count; i++) { List list = challengeObjectsForPages[i]; list.RemoveAll((GameObject x) => (Object)(object)x == (Object)null); if (i != page) { list.ForEach(delegate(GameObject x) { x.SetActive(false); }); continue; } for (int j = 0; j < list.Count; j++) { AscensionIconInteractable component = list[j].GetComponent(); if ((Object)(object)component != (Object)null) { AscensionChallengeInfo info = component.Info; AscensionChallenge val = (AscensionChallenge)((info == null) ? 15 : ((int)info.challengeType)); list[j].SetActive((int)val != 15 || AscensionUnlockSchedule.ChallengeIsUnlockedForLevel(val, AscensionSaveData.Data.challengeLevel)); } else { list[j].SetActive(false); } } } } CommandLineTextDisplayer.PlayCommandLineClickSound(); } private void DebugChallengePageArray(int page, List iconsForPage, List infos = null) { InscryptionAPIPlugin.Logger.LogDebug((object)$"Current Page: {page} | {iconsForPage?.Count ?? infos.Count}"); StringBuilder stringBuilder = new StringBuilder("|"); if (iconsForPage != null) { StringBuilder stringBuilder2 = new StringBuilder("|"); for (int i = 0; i < 14; i++) { if (i % 2 == 0) { if (i < iconsForPage.Count) { stringBuilder.Append($"{DebugArrayCode(iconsForPage[i])}|"); } else { stringBuilder.Append(" |"); } } else if (i < iconsForPage.Count) { stringBuilder2.Append($"{DebugArrayCode(iconsForPage[i])}|"); } else { stringBuilder2.Append(" |"); } } InscryptionAPIPlugin.Logger.LogDebug((object)stringBuilder.ToString()); InscryptionAPIPlugin.Logger.LogDebug((object)stringBuilder2.ToString()); return; } for (int j = 0; j < 14; j++) { if (j < infos.Count) { stringBuilder.Append($"{DebugArrayCode(null, infos[j])}|"); } else { stringBuilder.Append(" |"); } } InscryptionAPIPlugin.Logger.LogDebug((object)stringBuilder.ToString()); } private char DebugArrayCode(GameObject icon, AscensionChallengeInfo info = null) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)info != (Object)null) { if (!info.challengeType.GetFullChallenge().Boss) { return 'O'; } return 'B'; } AscensionIconInteractable component = icon.GetComponent(); if ((Object)(object)component.Info == (Object)(object)missingChallengeInfo) { return '-'; } if ((component.Info?.challengeType.GetFullChallenge()?.Boss).GetValueOrDefault()) { if (!((Renderer)component.activatedRenderer).enabled) { return 'D'; } return 'B'; } if (!((Renderer)component.activatedRenderer).enabled) { return 'O'; } return 'X'; } } public class AscensionChallengePaginatorSetupifier : ManagedBehaviour { public void Start() { AscensionMenuScreenTransition component = ((Component)this).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && new List(component.screenInteractables.FindAll((MainInputInteractable x) => (Object)(object)((Component)x).GetComponent() != (Object)null).ConvertAll((MainInputInteractable x) => ((Component)x).GetComponent())).Count > 0 && (Object)(object)((Component)this).gameObject.GetComponent() == (Object)null) { ChallengeManager.SyncChallengeList(); ((Component)this).gameObject.gameObject.AddComponent().Initialize(null, component); } } } [HarmonyPatch] internal static class AscensionChallengeScreenPatches { [HarmonyPostfix] [HarmonyPatch(typeof(AscensionIconInteractable), "AssignInfo")] private static void ReassignableIconFixes(ref AscensionIconInteractable __instance, AscensionChallengeInfo info) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)info)) { return; } if (info.pointValue > 0 || (int)info.challengeType == 0) { Color darkFuschia = GameColors.Instance.darkFuschia; if (__instance.Conquered && __instance.showConquered) { ((AscensionMenuBlinkEffect)__instance.blinkEffect).blinkOffColor = darkFuschia; __instance.iconRenderer.color = darkFuschia; } else { ((AscensionMenuBlinkEffect)__instance.blinkEffect).blinkOffColor = GameColors.Instance.red; __instance.iconRenderer.color = GameColors.Instance.red; } __instance.conqueredColor = darkFuschia; return; } if (info.pointValue < 0) { Color32 val = default(Color32); ((Color32)(ref val))..ctor((byte)0, (byte)52, (byte)33, byte.MaxValue); if (__instance.Conquered && __instance.showConquered) { ((AscensionMenuBlinkEffect)__instance.blinkEffect).blinkOffColor = Color32.op_Implicit(val); __instance.iconRenderer.color = Color32.op_Implicit(val); } else { ((AscensionMenuBlinkEffect)__instance.blinkEffect).blinkOffColor = GameColors.Instance.darkLimeGreen; __instance.iconRenderer.color = GameColors.Instance.darkLimeGreen; } __instance.conqueredColor = Color32.op_Implicit(val); return; } Color val2 = GameColors.Instance.darkGold / 2f; Color val3 = default(Color); ((Color)(ref val3))..ctor(val2.r, val2.g, val2.b, 1f); if (__instance.Conquered && __instance.showConquered) { ((AscensionMenuBlinkEffect)__instance.blinkEffect).blinkOffColor = val3; __instance.iconRenderer.color = val3; } else { ((AscensionMenuBlinkEffect)__instance.blinkEffect).blinkOffColor = GameColors.Instance.gold; __instance.iconRenderer.color = GameColors.Instance.gold; } __instance.conqueredColor = val3; } [HarmonyPatch(typeof(AscensionChallengeDisplayer), "DisplayChallenge")] [HarmonyPrefix] public static bool DisplayChallenge(AscensionChallengeDisplayer __instance, AscensionChallengeInfo challengeInfo, bool immediate) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)challengeInfo != (Object)null && ((int)challengeInfo.challengeType == 0 || (AscensionUnlockSchedule.ChallengeIsUnlockedForLevel(challengeInfo.challengeType, AscensionSaveData.Data.challengeLevel) && challengeInfo.pointValue < 0))) { string text = ""; string text2 = ""; string text3 = ""; if ((int)challengeInfo.challengeType == 0) { text = " ??? "; text2 = Localization.Translate("CHALLENGE UNAVAILABLE"); text3 = ""; } else if (AscensionUnlockSchedule.ChallengeIsUnlockedForLevel(challengeInfo.challengeType, AscensionSaveData.Data.challengeLevel) && challengeInfo.pointValue < 0) { text = " " + Localization.ToUpper(Localization.Translate(challengeInfo.title)) + " "; text2 = Localization.Translate(challengeInfo.description); text3 = string.Format(Localization.Translate("+{0} CHALLENGE POINTS").Substring(1), challengeInfo.pointValue.ToString()); } ChallengeDisplayerPlus.TryAddChallengeDisplayerPlusToDisplayer(__instance).DisplayChallenge(challengeInfo, immediate); __instance.DisplayText(text, text2, text3, immediate); return false; } ChallengeDisplayerPlus.TryAddChallengeDisplayerPlusToDisplayer(__instance).DisplayChallenge(challengeInfo, immediate); return true; } [HarmonyPatch(typeof(AscensionChallengeScreen), "UpdateFooterText")] [HarmonyPrefix] public static bool UpdateFooterText(AscensionChallengeScreen __instance, AscensionChallengeInfo challengeInfo, bool activated) { if (challengeInfo.pointValue < 0) { string arg = Localization.ToUpper(Localization.Translate(challengeInfo.title)); string text = string.Format(Localization.Translate(activated ? "{0} ENABLED" : "{0} DISABLED"), arg); string text2 = ((!activated) ? string.Format(Localization.Translate("{0} Challenge Points Added"), (-challengeInfo.pointValue).ToString()) : string.Format(Localization.Translate("{0} Challenge Points Subtracted"), (-challengeInfo.pointValue).ToString())); int challengeLevel = AscensionSaveData.Data.challengeLevel; int activeChallengePoints = AscensionSaveData.Data.GetActiveChallengePoints(); string text3 = ((activeChallengePoints > AscensionSaveData.GetChallengePointsForLevel(challengeLevel)) ? string.Format(Localization.Translate("WARNING(!) Lvl Reqs EXCEEDED")) : ((activeChallengePoints != AscensionSaveData.GetChallengePointsForLevel(challengeLevel)) ? string.Format(Localization.Translate("Lvl Reqs NOT MET")) : string.Format(Localization.Translate("Lvl Reqs Met")))); __instance.footerLines.ShowText(0.1f, new string[3] { text, text2, text3 }, false); return false; } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(AscensionMenuScreens), "Start")] private static void AddPaginatorSetupifierToMenuScreens(AscensionMenuScreens __instance) { if ((Object)(object)__instance.challengeUnlockSummaryScreen != (Object)null && (Object)(object)__instance.challengeUnlockSummaryScreen.GetComponent() != (Object)null && (Object)(object)__instance.challengeUnlockSummaryScreen.GetComponent() == (Object)null) { __instance.challengeUnlockSummaryScreen.AddComponent(); } } [HarmonyPostfix] [HarmonyPatch(typeof(AscensionChallengeScreen), "Start")] private static void AddPaginatorToChallengeScreen(AscensionChallengeScreen __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ChallengeManager.SyncChallengeList(); ((Component)__instance).gameObject.AddComponent().Initialize(__instance); } } } public abstract class AscensionRunSetupScreenBase : ManagedBehaviour { public SequentialPixelTextLines cardInfoLines; public SequentialPixelTextLines challengeFooterLines; public ChallengeLevelText challengeHeaderDisplay; public List cards; public GameObject cardPanel; public MainInputInteractable leftButton; public MainInputInteractable rightButton; public AscensionMenuInteractable continueButton; public AscensionMenuBackButton backButton; public PixelText screenTitle; public PixelText secondaryInfoDisplayer; public AscensionMenuScreenTransition transitionController; private static Vector2 FIRST_CARD_OFFSET = new Vector2(-1.5f, 0f); private static Vector2 BETWEEN_CARD_OFFSET = new Vector2(0.5f, 0f); public const string CENTER_DASHES = "-------------------------------------------------------------------------------------------------------------------------------"; public const string FULL_DASHES = "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"; public abstract string headerText { get; } public abstract bool showCardDisplayer { get; } public abstract bool showCardPanel { get; } public virtual void InitializeScreen(GameObject partialScreen) { } private static void CleanupGameObject(GameObject obj, AscensionMenuScreenTransition transition, bool destroy = true) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) MainInputInteractable component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { transition.screenInteractables.Remove(component); } transition.onEnableRevealedObjects.Remove(obj); foreach (Transform item in obj.transform) { CleanupGameObject(((Component)item).gameObject, transition, destroy: false); } if (destroy) { Object.Destroy((Object)(object)obj); } } public static (AscensionMenuInteractable, AscensionMenuInteractable) BuildPaginators(Transform parent, bool upperPosition = false) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0155: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)Singleton.Instance.cardUnlockSummaryScreen.transform.Find("Unlocks/ScreenAnchor/PageLeftButton")).gameObject; GameObject gameObject2 = ((Component)Singleton.Instance.cardUnlockSummaryScreen.transform.Find("Unlocks/ScreenAnchor/PageRightButton")).gameObject; GameObject val = Object.Instantiate(gameObject, parent); GameObject val2 = Object.Instantiate(gameObject2, parent); val.transform.localPosition = Vector3.zero; val2.transform.localPosition = Vector3.zero; ViewportRelativePosition val3 = val.AddComponent(); ViewportRelativePosition val4 = val2.AddComponent(); val3.viewportCam = Camera.main; val4.viewportCam = Camera.main; if (!upperPosition) { float num = 1f; float num2 = 0f; Renderer[] componentsInChildren = ((Component)parent).gameObject.GetComponentsInChildren(); foreach (Renderer val5 in componentsInChildren) { Camera main = Camera.main; Bounds bounds = val5.bounds; Vector3 val6 = main.WorldToViewportPoint(((Bounds)(ref bounds)).min); Camera main2 = Camera.main; bounds = val5.bounds; Vector3 val7 = main2.WorldToViewportPoint(((Bounds)(ref bounds)).max); if (val6.x < num) { num = val6.x; } if (val7.x > num2) { num2 = val7.x; } } num /= 2f; num2 = 1f - (1f - num2) / 2f; val3.viewportAnchor = new Vector2(num, 0.565f); val4.viewportAnchor = new Vector2(num2, 0.565f); } else { val3.viewportAnchor = new Vector2(0.25f, 0.8f); val4.viewportAnchor = new Vector2(0.75f, 0.8f); } val3.offset = new Vector2(0f, 0f); val4.offset = new Vector2(0f, 0f); return (val.GetComponent(), val2.GetComponent()); } public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Screen previousScreen, Screen nextScreen) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Expected O, but got Unknown //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_083d: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_0873: Invalid comparison between Unknown and I4 //IL_066f: Unknown result type (might be due to invalid IL or missing references) GameObject cardUnlockSummaryScreen = Singleton.Instance.cardUnlockSummaryScreen; GameObject val = Object.Instantiate(cardUnlockSummaryScreen, cardUnlockSummaryScreen.transform.parent); ((Object)val).name = screenType.Name; AscensionCardsSummaryScreen component = val.GetComponent(); AscensionRunSetupScreenBase controller = val.AddComponent(screenType) as AscensionRunSetupScreenBase; GameObject gameObject = ((Component)val.transform.Find("Header/Mid")).gameObject; gameObject.transform.localPosition = new Vector3(0f, -0.575f, 0f); controller.screenTitle = gameObject.GetComponent(); controller.screenTitle.SetText(Localization.ToUpper(Localization.Translate(controller.headerText)), false); controller.transitionController = val.GetComponent(); GameObject footer = ((Component)val.transform.Find("Footer")).gameObject; footer.SetActive(true); GameObject gameObject2 = ((Component)val.transform.Find("Footer/CardTextDisplayer")).gameObject; GameObject gameObject3 = ((Component)val.transform.Find("Footer/PixelTextLine_DIV")).gameObject; if (controller.showCardDisplayer) { gameObject2.transform.localPosition = new Vector3(2.38f, 0.27f, 0f); gameObject3.transform.localPosition = new Vector3(0f, 0.33f, 0f); gameObject3.transform.SetParent(gameObject2.transform, true); Object.Destroy((Object)(object)footer.GetComponent()); controller.cardInfoLines = gameObject2.AddComponent(); controller.cardInfoLines.lines = new List { gameObject3.GetComponent(), ((Component)gameObject2.transform.Find("PixelTextLine_DESC1")).gameObject.GetComponent(), ((Component)gameObject2.transform.Find("PixelTextLine_NAME")).gameObject.GetComponent() }; } else { CleanupGameObject(gameObject2, controller.transitionController); CleanupGameObject(gameObject3, controller.transitionController); GameObject val2 = Object.Instantiate(gameObject); controller.secondaryInfoDisplayer = val2.GetComponent(); controller.secondaryInfoDisplayer.SetColor(GameColors.Instance.nearWhite); val2.transform.localPosition = new Vector3(0f, -2.25f, 0f); } if (controller.showCardPanel) { controller.cards = ((AscensionCardsScreen)component).cards; } Object.Destroy((Object)(object)component); controller.cardPanel = ((Component)val.transform.Find("Unlocks")).gameObject; GameObject gameObject4 = ((Component)val.transform.Find("Header")).gameObject; SequentialPixelTextLines val3 = gameObject4.AddComponent(); GameObject selectChallengesScreen = Singleton.Instance.selectChallengesScreen; GameObject gameObject5 = ((Component)selectChallengesScreen.transform.Find("Header/ChallengeLevel")).gameObject; GameObject gameObject6 = ((Component)selectChallengesScreen.transform.Find("Header/ChallengePoints")).gameObject; GameObject val4 = Object.Instantiate(gameObject5, gameObject4.transform); GameObject val5 = Object.Instantiate(gameObject6, gameObject4.transform); val3.lines = new List { val4.GetComponent(), val5.GetComponent() }; ChallengeLevelText val6 = val.AddComponent(); val6.headerPointsLines = val3; controller.challengeHeaderDisplay = val6; List list = new List(); GameObject gameObject7 = ((Component)selectChallengesScreen.transform.Find("Footer")).gameObject; foreach (Transform item in gameObject7.transform) { Transform val7 = item; if (((Object)val7).name.ToLowerInvariant() == "pixeltextline") { list.Add(val7); } } list.Sort((Transform a, Transform b) => (!(a.localPosition.y < b.localPosition.y)) ? 1 : (-1)); List source = list.Select((Transform t) => Object.Instantiate(((Component)t).gameObject, footer.transform)).ToList(); SequentialPixelTextLines val8 = footer.AddComponent(); val8.lines = source.Select((GameObject o) => o.GetComponent()).ToList(); val8.linePrefix = gameObject7.GetComponent().linePrefix; controller.challengeFooterLines = val8; controller.leftButton = ((Component)val.transform.Find("Unlocks/ScreenAnchor/PageLeftButton")).gameObject.GetComponent(); controller.rightButton = ((Component)val.transform.Find("Unlocks/ScreenAnchor/PageRightButton")).gameObject.GetComponent(); if (controller.showCardPanel) { controller.cardPanel.transform.localPosition = new Vector3(0f, 0.2f, 0f); controller.leftButton.CursorSelectStarted = controller.LeftButtonClicked; controller.rightButton.CursorSelectStarted = controller.RightButtonClicked; ((Component)controller.leftButton).gameObject.transform.localPosition = ((Component)controller.leftButton).gameObject.transform.localPosition - Vector2.op_Implicit(BETWEEN_CARD_OFFSET) * 1.5f; ((Component)controller.rightButton).gameObject.transform.localPosition = ((Component)controller.rightButton).gameObject.transform.localPosition + Vector2.op_Implicit(BETWEEN_CARD_OFFSET) * 1.5f; GameObject val9 = Resources.Load("prefabs/gbccardbattle/pixelselectablecard"); Transform val10 = val.transform.Find("Unlocks/ScreenAnchor/Cards"); for (int j = 0; j < 3; j++) { GameObject obj = Object.Instantiate(val9, val10); PixelSelectableCard component2 = obj.GetComponent(); controller.cards.Add(component2); GameObject gameObject8 = ((Component)obj.transform.Find("Base/PixelSnap/CardElements/PixelSelectionBorder")).gameObject; gameObject8.GetComponent().color = new Color(0.619f, 0.149f, 0.188f); Traverse.Create((object)component2).Field("pixelBorder").SetValue((object)gameObject8); } foreach (PixelSelectableCard card in controller.cards) { ((MainInputInteractable)card).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)card).CursorSelectStarted, (Action)delegate { controller.CardClicked(card); }); ((MainInputInteractable)card).CursorEntered = (Action)Delegate.Combine(((MainInputInteractable)card).CursorEntered, (Action)delegate { controller.CardCursorEntered(card); }); Transform val11 = ((Component)card).gameObject.transform.Find("Locked"); if ((Object)(object)val11 != (Object)null) { CleanupGameObject(((Component)val11).gameObject, controller.transitionController); } } } else { CleanupGameObject(controller.cardPanel, controller.transitionController); CleanupGameObject(((Component)controller.leftButton).gameObject, controller.transitionController); CleanupGameObject(((Component)controller.rightButton).gameObject, controller.transitionController); controller.leftButton = null; controller.rightButton = null; } GameObject gameObject9 = ((Component)val.transform.Find("BackButton")).gameObject; controller.backButton = gameObject9.GetComponent(); controller.backButton.screenToReturnTo = previousScreen; GameObject val12 = Object.Instantiate(Resources.Load("prefabs/ui/ascension/ascensionmenucontinuebutton"), val.transform); controller.continueButton = val12.GetComponent(); Action b2 = (((int)nextScreen != 4) ? ((Action)delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Singleton.Instance.SwitchToScreen(nextScreen); }) : ((Action)delegate { TransitionToGame(); })); ((MainInputInteractable)controller.continueButton).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)controller.continueButton).CursorSelectStarted, b2); controller.InitializeScreen(val); return controller; } private static void TransitionToGame() { if (!AscensionSaveData.Data.ChallengeLevelIsMet() && AscensionSaveData.Data.challengeLevel <= 12) { Singleton.Instance.SwitchToScreen((Screen)4); } else { Singleton.Instance.TransitionToGame(true); } } public virtual void ClearMessage() { if (((Component)this).gameObject.activeSelf) { if (showCardDisplayer) { DisplayCardInfo(null, " ", " "); } else { ((Component)secondaryInfoDisplayer).gameObject.SetActive(false); } } } public virtual void DisplayMessage(string message) { if (showCardDisplayer) { DisplayCardInfo(null, message, " "); return; } secondaryInfoDisplayer.SetText(message, false); ((Component)secondaryInfoDisplayer).gameObject.SetActive(true); } public virtual void LeftButtonClicked(MainInputInteractable button) { } public virtual void RightButtonClicked(MainInputInteractable button) { } public virtual void CardCursorEntered(PixelSelectableCard card) { if (showCardDisplayer) { DisplayCardInfo(((Card)card).Info); } } public virtual void CardClicked(PixelSelectableCard card) { } public void ShowCards(List cardsToDisplay) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (!showCardDisplayer) { return; } foreach (PixelSelectableCard card in cards) { ((Component)card).gameObject.SetActive(false); } int num = Math.Min(cards.Count, cardsToDisplay.Count); float num2 = (float)(cards.Count - num) / 2f; Vector2 val = FIRST_CARD_OFFSET + BETWEEN_CARD_OFFSET * num2; for (int i = 0; i < num; i++) { ((Card)cards[i]).SetInfo(cardsToDisplay[i]); ((Component)cards[i]).gameObject.transform.localPosition = Vector2.op_Implicit(val + (float)i * BETWEEN_CARD_OFFSET); ((Component)cards[i]).gameObject.SetActive(true); } } public void DisplayCardInfo(CardInfo info, string nameOverride = null, string descOverride = null, bool immediate = false) { if (showCardDisplayer) { string text = "------------------------------------------------------------------------------------------------------------------------------- " + (nameOverride ?? info.DisplayedNameLocalized) + " -------------------------------------------------------------------------------------------------------------------------------"; string text2 = descOverride ?? info.GetGBCDescriptionLocalized(info.Abilities); string text3 = "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"; cardInfoLines.ShowText(0.1f, new string[3] { text3, text2, text }, immediate); } } public void ClearCardInfo(bool immediate = true) { if (showCardDisplayer) { cardInfoLines.ShowText(0.1f, new string[3] { "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", string.Empty, "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" }, immediate); } } public void DisplayChallengeInfo(string message, int points, bool immediate = false) { string text = Localization.Translate(message); string text2 = ((points == 0) ? string.Format(Localization.Translate("{0} Challenge Points"), 0) : ((points >= 0) ? string.Format(Localization.Translate("{0} Challenge Points Added"), points) : string.Format(Localization.Translate("{0} Challenge Points Subtracted"), -points))); int challengeLevel = AscensionSaveData.Data.challengeLevel; int activeChallengePoints = AscensionSaveData.Data.GetActiveChallengePoints(); string text3 = ((activeChallengePoints > challengeLevel * 10) ? string.Format(Localization.Translate("WARNING(!) Lvl Reqs EXCEEDED")) : ((activeChallengePoints != challengeLevel * 10) ? string.Format(Localization.Translate("Lvl Reqs NOT MET")) : string.Format(Localization.Translate("Lvl Reqs Met")))); challengeFooterLines.ShowText(0.1f, new string[3] { text, text2, text3 }, immediate); challengeHeaderDisplay.UpdateText(); } public override void OnEnable() { ViewportRelativePosition[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].viewportCam = Camera.main; } ((ManagedBehaviour)this).OnEnable(); } public void DisplayChallengeInfo(AscensionChallenge challenge, bool immediate = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) AscensionChallengeInfo info = AscensionChallengesUtil.GetInfo(challenge); int points = info.pointValue * (AscensionSaveData.Data.ChallengeIsActive(challenge) ? 1 : (-1)); DisplayChallengeInfo(info.title, points, immediate); } } [HarmonyPatch] public static class AscensionScreenManager { [CompilerGenerated] private sealed class d__9 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator sequenceEvent; public Screen screen; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_0045; case 1: <>1__state = -1; goto IL_0045; case 2: { <>1__state = -1; if (screens.ContainsKey(screen)) { ((Component)screens[screen]).gameObject.SetActive(true); } return false; } IL_0045: if (sequenceEvent.MoveNext()) { <>2__current = sequenceEvent.Current; <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static List registeredScreens = new List(); internal static Dictionary screens; internal static Screen initialScreen = (Screen)8; internal const int CUSTOM_SCREEN_START = 100; private static string challengeScreenHoverText = "START RUN"; public static void RegisterScreen() where T : AscensionRunSetupScreenBase { registeredScreens.Add(typeof(T)); } private static AscensionScreenSort.Direction GetPreferredDirection(Type t) { if (!(Attribute.GetCustomAttribute(t, typeof(AscensionScreenSort)) is AscensionScreenSort ascensionScreenSort)) { return AscensionScreenSort.Direction.NoPreference; } return ascensionScreenSort.preferredDirection; } public static void InitializeAllScreens() { //IL_0034: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022e: 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_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) registeredScreens.Sort((Type a, Type b) => GetPreferredDirection(a) - GetPreferredDirection(b)); screens = new Dictionary(); Screen previousScreen = (Screen)1; Screen val = (Screen)100; Screen val2 = (Screen)101; initialScreen = val; for (int j = 0; j < registeredScreens.Count; j++) { Type screenType = registeredScreens[j]; if (j == registeredScreens.Count - 1) { val2 = (Screen)4; } try { AscensionRunSetupScreenBase value = AscensionRunSetupScreenBase.BuildScreen(screenType, previousScreen, val2); screens.Add(val, value); previousScreen = val; val = val2; val2 = (Screen)(val2 + 1); } catch (Exception ex) { InscryptionAPIPlugin.Logger.LogError((object)ex); } } if (screens.Count == 0) { return; } previousScreen = (Screen)1; val = (Screen)100; val2 = (Screen)101; challengeScreenHoverText = screens[val].headerText; for (int k = 0; k < screens.Count; k++) { AscensionRunSetupScreenBase cur = screens[val]; string prevText = (screens.ContainsKey(previousScreen) ? screens[previousScreen].headerText : "SELECT CHALLENGES"); string nextText = (screens.ContainsKey(val2) ? screens[val2].headerText : "START RUN"); Action b2 = delegate { cur.DisplayMessage(Localization.ToUpper(Localization.Translate(prevText))); }; Action b3 = delegate { cur.DisplayMessage(Localization.ToUpper(Localization.Translate(nextText))); }; Action b4 = delegate { cur.ClearMessage(); }; ((MainInputInteractable)cur.backButton).CursorEntered = (Action)Delegate.Combine(((MainInputInteractable)cur.backButton).CursorEntered, b2); ((MainInputInteractable)cur.backButton).CursorExited = (Action)Delegate.Combine(((MainInputInteractable)cur.backButton).CursorExited, b4); ((MainInputInteractable)cur.continueButton).CursorEntered = (Action)Delegate.Combine(((MainInputInteractable)cur.continueButton).CursorEntered, b3); ((MainInputInteractable)cur.continueButton).CursorExited = (Action)Delegate.Combine(((MainInputInteractable)cur.continueButton).CursorExited, b4); previousScreen = val; val = val2; val2 = (Screen)(val2 + 1); } } [HarmonyPatch(typeof(AscensionChallengeScreen), "OnContinuePressed")] [HarmonyPrefix] private static bool TransitionToSideDeckScreen(ref AscensionChallengeScreen __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (screens == null || screens.Count == 0) { return true; } Singleton.Instance.SwitchToScreen(initialScreen); return false; } [IteratorStateMachine(typeof(d__9))] [HarmonyPatch(typeof(AscensionMenuScreens), "ScreenSwitchSequence")] [HarmonyPostfix] private static IEnumerator SwitchToScreen(IEnumerator sequenceEvent, Screen screen) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { sequenceEvent = sequenceEvent, screen = screen }; } [HarmonyPatch(typeof(AscensionMenuScreens), "ConfigurePostGameScreens")] [HarmonyPostfix] private static void InitializeScreensOnStart() { InitializeAllScreens(); } [HarmonyPatch(typeof(AscensionMenuScreens), "DeactivateAllScreens")] [HarmonyPostfix] private static void DeactivateAllCustomScreens() { if (screens == null || screens.Count <= 0) { return; } foreach (AscensionRunSetupScreenBase value in screens.Values) { if ((Object)(object)value != (Object)null && (Object)(object)((Component)value).gameObject != (Object)null) { ((Component)value).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(AscensionChallengeScreen), "OnContinueCursorEnter")] [HarmonyPrefix] private static bool HoverTextFirstCustomScreen(ref AscensionChallengeScreen __instance) { string text = Localization.Translate(challengeScreenHoverText); __instance.challengeDisplayer.DisplayText("", text, "", false); return false; } } public class AscensionScreenSort : Attribute { public enum Direction { RequiresStart = 1, PrefersStart, NoPreference, PrefersEnd, RequiresEnd } public Direction preferredDirection; public AscensionScreenSort(Direction preferredDirection = Direction.NoPreference) { this.preferredDirection = preferredDirection; } } public class ChallengeBehaviour : NonCardTriggerReceiver { [CompilerGenerated] private sealed class d__26 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__22 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__24 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static List instances; public ChallengeManager.FullChallenge challenge { get; internal set; } public int instanceNumber { get; internal set; } internal static List Instances { get { EnsureInstancesLoaded(); return instances; } } public void Start() { if (!Instances.Contains(this)) { Instances.Add(this); } } public void OnDestroy() { Instances.Remove(this); } public static List FindInstancesOfType(AscensionChallenge type) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Instances.FindAll((ChallengeBehaviour x) => x.challenge.Challenge.challengeType == type); } public static int CountInstancesOfType(AscensionChallenge type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return FindInstancesOfType(type).Count; } public static bool AnyInstancesOfType(AscensionChallenge type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return CountInstancesOfType(type) > 0; } internal static void DestroyAllInstances() { foreach (ChallengeBehaviour instance in Instances) { if ((Object)(object)instance != (Object)null && (Object)(object)((Component)instance).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)instance).gameObject); } } EnsureInstancesLoaded(); Instances.Clear(); } internal static void EnsureInstancesLoaded() { if (instances == null) { instances = new List(); } instances.RemoveAll((ChallengeBehaviour x) => (Object)(object)x == (Object)null || (Object)(object)((Component)x).gameObject == (Object)null); } protected void ShowActivation() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ChallengeActivationUI.TryShowActivation(challenge.Challenge.challengeType); } public virtual bool RespondsToPreBattleSetup() { return false; } [IteratorStateMachine(typeof(d__20))] public virtual IEnumerator OnPreBattleSetup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0); } public virtual bool RespondsToPostBattleSetup() { return false; } [IteratorStateMachine(typeof(d__22))] public virtual IEnumerator OnPostBattleSetup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__22(0); } public virtual bool RespondsToPreBattleCleanup() { return false; } [IteratorStateMachine(typeof(d__24))] public virtual IEnumerator OnPreBattleCleanup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__24(0); } public virtual bool RespondsToPostBattleCleanup() { return false; } [IteratorStateMachine(typeof(d__26))] public virtual IEnumerator OnPostBattleCleanup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__26(0); } } public class ChallengeDisplayerPlus : ManagedBehaviour { public class PrefixedString { public string prefix; public AscensionChallenge challenge; public int number; public string FullText => prefix + ((number > 1) ? (" (x" + number + ")") : ""); public string RedPrefixText => prefix + ((number > 1) ? (" [c:R](x" + number + ")[c]") : ""); } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ChallengeDisplayerPlus <>4__this; public string dependency; public string incompatibility; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown int num = <>1__state; ChallengeDisplayerPlus challengeDisplayerPlus = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; PixelText dependencyText = challengeDisplayerPlus.dependencyText; if (dependencyText != null) { dependencyText.SetText("", false); } PixelText incompatibilityText = challengeDisplayerPlus.incompatibilityText; if (incompatibilityText != null) { incompatibilityText.SetText("", false); } <>2__current = (object)new WaitForSecondsRealtime(0.125f); <>1__state = 1; return true; } case 1: <>1__state = -1; if ((Object)(object)challengeDisplayerPlus.displayer.descriptionText != (Object)null) { <>2__current = (object)new WaitForSecondsRealtime(0.05f); <>1__state = 2; return true; } goto IL_00b6; case 2: <>1__state = -1; goto IL_00b6; case 3: <>1__state = -1; goto IL_00e9; case 4: <>1__state = -1; challengeDisplayerPlus.dependencyText.SetText(dependency, true); CommandLineTextDisplayer.PlayCommandLineClickSound(); goto IL_013b; case 5: { <>1__state = -1; challengeDisplayerPlus.incompatibilityText.SetText(incompatibility, true); CommandLineTextDisplayer.PlayCommandLineClickSound(); break; } IL_00b6: if ((Object)(object)challengeDisplayerPlus.displayer.pointsText != (Object)null) { <>2__current = (object)new WaitForSecondsRealtime(0.05f); <>1__state = 3; return true; } goto IL_00e9; IL_013b: if ((Object)(object)challengeDisplayerPlus.incompatibilityText != (Object)null && !string.IsNullOrEmpty(incompatibility)) { <>2__current = (object)new WaitForSecondsRealtime(0.05f); <>1__state = 5; return true; } break; IL_00e9: if ((Object)(object)challengeDisplayerPlus.dependencyText != (Object)null && !string.IsNullOrEmpty(dependency)) { <>2__current = (object)new WaitForSecondsRealtime(0.05f); <>1__state = 4; return true; } goto IL_013b; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private PixelText dependencyText; private PixelText incompatibilityText; private float originalTitlePos; private float originalDescriptionPos; private float originalPointsPos; public AscensionChallengeDisplayer displayer => ((Component)this).GetComponent(); public static ChallengeDisplayerPlus TryAddChallengeDisplayerPlusToDisplayer(AscensionChallengeDisplayer displayer) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0290: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) ChallengeDisplayerPlus challengeDisplayerPlus = ((Component)displayer).GetComponent(); if ((Object)(object)challengeDisplayerPlus == (Object)null) { challengeDisplayerPlus = ((Component)displayer).gameObject.AddComponent(); challengeDisplayerPlus.originalTitlePos = ((Component)displayer.titleText).transform.localPosition.y; if ((Object)(object)displayer.descriptionText != (Object)null) { challengeDisplayerPlus.originalDescriptionPos = ((Component)displayer.descriptionText).transform.localPosition.y; } if ((Object)(object)displayer.pointsText != (Object)null) { challengeDisplayerPlus.originalPointsPos = ((Component)displayer.pointsText).transform.localPosition.y; } } if ((Object)(object)challengeDisplayerPlus.incompatibilityText == (Object)null) { GameObject val = Object.Instantiate(((Component)displayer.titleText).gameObject); ((Object)val).name = "PixelTextLine_INCOMPATIBLE"; val.transform.parent = ((Component)displayer.titleText).transform.parent; float num = challengeDisplayerPlus.originalTitlePos; if ((Object)(object)displayer.descriptionText != (Object)null) { num = challengeDisplayerPlus.originalDescriptionPos; } if ((Object)(object)displayer.pointsText != (Object)null) { num = challengeDisplayerPlus.originalPointsPos; } val.transform.localPosition = new Vector3(((Component)displayer.titleText).transform.localPosition.x, num, ((Component)displayer.titleText).transform.localPosition.z); val.SetActive(true); challengeDisplayerPlus.incompatibilityText = val.GetComponent(); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)238, (byte)244, (byte)198, byte.MaxValue); challengeDisplayerPlus.incompatibilityText.DefaultColor = Color32.op_Implicit(val2); challengeDisplayerPlus.incompatibilityText.SetColor(Color32.op_Implicit(val2)); challengeDisplayerPlus.incompatibilityText.SetText("", false); } if ((Object)(object)challengeDisplayerPlus.dependencyText == (Object)null) { GameObject val3 = Object.Instantiate(((Component)displayer.titleText).gameObject); ((Object)val3).name = "PixelTextLine_DEPENDENCY"; val3.transform.parent = ((Component)displayer.titleText).transform.parent; float num2 = challengeDisplayerPlus.originalTitlePos; if ((Object)(object)displayer.descriptionText != (Object)null) { num2 = challengeDisplayerPlus.originalDescriptionPos; } if ((Object)(object)displayer.pointsText != (Object)null) { num2 = challengeDisplayerPlus.originalPointsPos; } val3.transform.localPosition = new Vector3(((Component)displayer.titleText).transform.localPosition.x, num2, ((Component)displayer.titleText).transform.localPosition.z); val3.SetActive(true); challengeDisplayerPlus.dependencyText = val3.GetComponent(); Color32 val4 = default(Color32); ((Color32)(ref val4))..ctor((byte)238, (byte)244, (byte)198, byte.MaxValue); challengeDisplayerPlus.dependencyText.DefaultColor = Color32.op_Implicit(val4); challengeDisplayerPlus.dependencyText.SetColor(Color32.op_Implicit(val4)); challengeDisplayerPlus.dependencyText.SetText("", false); } return challengeDisplayerPlus; } public float GetBestAvailableY() { float result = originalTitlePos; if ((Object)(object)displayer.descriptionText != (Object)null) { result = originalDescriptionPos; } if ((Object)(object)displayer.pointsText != (Object)null) { result = originalPointsPos; } return result; } public void DisplayChallenge(AscensionChallengeInfo challengeInfo, bool immediate = false) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) string dependency = ""; string incompatibility = ""; ChallengeManager.FullChallenge fullChallenge = challengeInfo?.GetFullChallenge(); if (fullChallenge != null) { AscensionMenuScreens instance = Singleton.Instance; if (instance != null && (int)instance.CurrentScreen == 1) { List list = fullChallenge.DependantChallengeGetter?.Invoke(ChallengeManager.GetChallengeIcons())?.ToList(); List list2 = fullChallenge.IncompatibleChallengeGetter?.Invoke(ChallengeManager.GetChallengeIcons())?.ToList(); list?.RemoveAll((AscensionChallenge x) => x == challengeInfo.challengeType); list2?.RemoveAll((AscensionChallenge x) => x == challengeInfo.challengeType); if (list != null && list.Count > 0) { list2?.RemoveAll(list.Contains); List list3 = new List(); foreach (AscensionChallenge d in list) { AscensionChallengeInfo info = d.GetInfo(); if ((Object)(object)info != (Object)null) { PrefixedString prefixedString = list3.Find((PrefixedString x) => x.challenge == d); if (prefixedString != null) { prefixedString.number++; continue; } PrefixedString item = new PrefixedString { prefix = Localization.Translate(info.title), challenge = d, number = 1 }; list3.Add(item); } } if (list3.Count > 0) { List values = list3.ConvertAll((PrefixedString x) => AscensionSaveData.Data.activeChallenges.Contains(x.challenge) ? ((AscensionSaveData.Data.activeChallenges.Count((AscensionChallenge x2) => x2 == x.challenge) >= x.number) ? x.FullText : x.RedPrefixText) : ("[c:R]" + x.FullText + "[c:]")); dependency = "Depends on: " + string.Join(", ", values); } } if (list2 != null && list2.Count > 0) { List list4 = new List(); List list5 = new List(); foreach (AscensionChallenge item3 in list2) { AscensionChallengeInfo info2 = item3.GetInfo(); if ((Object)(object)info2 != (Object)null && !list5.Contains(item3)) { string item2 = (AscensionSaveData.Data.activeChallenges.Contains(item3) ? ("[c:R]" + Localization.Translate(info2.title) + "[c:]") : Localization.Translate(info2.title)); list4.Add(item2); list5.Add(item3); } } if (list4.Count > 0) { incompatibility = "Incompatible with: " + string.Join(", ", list4); } } } } DisplayText(dependency, incompatibility, immediate); } public void DisplayText(string dependency, string incompatibility, bool immediate = false) { //IL_0040: 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_0065: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) float num = ((!string.IsNullOrEmpty(dependency)) ? 0.11f : 0f) + ((!string.IsNullOrEmpty(incompatibility)) ? 0.11f : 0f); ((Component)dependencyText).transform.localPosition = new Vector3(((Component)dependencyText).transform.localPosition.x, GetBestAvailableY(), ((Component)dependencyText).transform.localPosition.z); ((Component)incompatibilityText).transform.localPosition = new Vector3(((Component)incompatibilityText).transform.localPosition.x, GetBestAvailableY(), ((Component)incompatibilityText).transform.localPosition.z); if (!string.IsNullOrEmpty(dependency) && !string.IsNullOrEmpty(incompatibility)) { ((Component)dependencyText).transform.localPosition = new Vector3(((Component)dependencyText).transform.localPosition.x, GetBestAvailableY() + 0.11f, ((Component)dependencyText).transform.localPosition.z); } ((Component)displayer.titleText).transform.localPosition = new Vector3(((Component)displayer.titleText).transform.localPosition.x, originalTitlePos + num, ((Component)displayer.titleText).transform.localPosition.z); if ((Object)(object)displayer.descriptionText != (Object)null) { ((Component)displayer.descriptionText).transform.localPosition = new Vector3(((Component)displayer.descriptionText).transform.localPosition.x, originalDescriptionPos + num, ((Component)displayer.descriptionText).transform.localPosition.z); } if ((Object)(object)displayer.pointsText != (Object)null) { ((Component)displayer.pointsText).transform.localPosition = new Vector3(((Component)displayer.pointsText).transform.localPosition.x, originalPointsPos + num, ((Component)displayer.pointsText).transform.localPosition.z); } if (immediate) { dependencyText.SetText(dependency, true); incompatibilityText.SetText(incompatibility, true); } else { ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)this).StartCoroutine(DisplayTextSequence(dependency, incompatibility)); } } [IteratorStateMachine(typeof(d__6))] private IEnumerator DisplayTextSequence(string dependency, string incompatibility) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { <>4__this = this, dependency = dependency, incompatibility = incompatibility }; } } [HarmonyPatch] public static class ChallengeManager { public class FullChallenge { public AscensionChallengeInfo Challenge { get; set; } public int AppearancesInChallengeScreen { get; set; } public Func CustomUnlockCheck { get; set; } public bool Boss { get; set; } public bool Stackable { get { return AppearancesInChallengeScreen > 1; } set { if (Stackable != value) { AppearancesInChallengeScreen = ((!value) ? 1 : 2); } } } public bool AppearsInChallengeScreen { get { return AppearancesInChallengeScreen > 0; } set { if (AppearsInChallengeScreen != value) { AppearancesInChallengeScreen = (value ? 1 : 0); } } } public int UnlockLevel { get; set; } public Type ChallengeHandler { get; set; } public Func> DependantChallengeGetter { get; set; } public Func> IncompatibleChallengeGetter { get; set; } public List Flags { get; set; } public int SortValue => Math.Sign(Challenge.pointValue); public int BossSortValue { get { if (!Boss) { return SortValue; } return SortValue - 3; } } public static bool ValidHandlerType(Type t) { if (t != null && !t.IsAbstract) { return t.IsSubclassOf(typeof(ChallengeBehaviour)); } return false; } public bool HasValidHandler() { return ValidHandlerType(ChallengeHandler); } public static implicit operator AscensionChallengeInfo(FullChallenge fc) { return fc.Challenge; } public FullChallenge SetChallenge(AscensionChallengeInfo challenge) { Challenge = challenge; return this; } public FullChallenge SetAppearancesInChallengeScreen(int appearancesInChallengeScreen) { AppearancesInChallengeScreen = appearancesInChallengeScreen; return this; } public FullChallenge SetUnlockLevel(int unlockLevel) { UnlockLevel = unlockLevel; return this; } public FullChallenge SetChallengeHandler(Type challengeHandler) { ChallengeHandler = challengeHandler; return this; } public FullChallenge SetDependantChallengeGetter(Func> dependantChallengeGetter) { DependantChallengeGetter = dependantChallengeGetter; return this; } public FullChallenge SetDependantChallengeGetterStatic(params AscensionChallenge[] dependantChallenges) { DependantChallengeGetter = (FullChallenge[] x) => dependantChallenges; return this; } public FullChallenge SetDependantChallengeGetterFlagWhitelist(params string[] whitelistFlags) { DependantChallengeGetter = (FullChallenge[] x) => from x2 in x where x2.Flags != null && x2.Flags.Exists((object x3) => whitelistFlags.Contains(x3)) select x2 into x select x.Challenge.challengeType; return this; } public FullChallenge SetDependantChallengeGetterFlagBlacklist(params string[] blacklistFlags) { DependantChallengeGetter = (FullChallenge[] x) => from x2 in x where x2.Flags == null || !x2.Flags.Exists((object x3) => blacklistFlags.Contains(x3)) select x2 into x select x.Challenge.challengeType; return this; } public FullChallenge SetIncompatibleChallengeGetter(Func> incompatibleChallengeGetter) { IncompatibleChallengeGetter = incompatibleChallengeGetter; return this; } public FullChallenge SetIncompatibleChallengeGetterStatic(params AscensionChallenge[] incompatibleChallenges) { IncompatibleChallengeGetter = (FullChallenge[] x) => incompatibleChallenges; return this; } public FullChallenge SetIncompatibleChallengeGetterFlagWhitelist(params string[] whitelistFlags) { IncompatibleChallengeGetter = (FullChallenge[] x) => from x2 in x where x2.Flags.Exists((object x3) => whitelistFlags.Contains(x3)) select x2 into x select x.Challenge.challengeType; return this; } public FullChallenge SetIncompatibleChallengeGetterFlagBlacklist(params string[] blacklistFlags) { IncompatibleChallengeGetter = (FullChallenge[] x) => from x2 in x where !x2.Flags.Exists((object x3) => blacklistFlags.Contains(x3)) select x2 into x select x.Challenge.challengeType; return this; } public FullChallenge SetFlags(params object[] flags) { Flags = flags.ToList(); return this; } public FullChallenge SetCustomUnlock(Func check) { CustomUnlockCheck = check; return this; } public FullChallenge SetBoss(bool boss) { Boss = boss; return this; } } [CompilerGenerated] private sealed class d__31 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; private AscensionChallenge[] <>7__wrap1; private int <>7__wrap2; private ChallengeBehaviour[] <>7__wrap3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>7__wrap3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; ChallengeBehaviour.DestroyAllInstances(); if (SaveFile.IsAscension) { AscensionChallenge[] array2 = AscensionSaveData.Data.activeChallenges.ToArray(); <>7__wrap1 = array2; <>7__wrap2 = 0; goto IL_0139; } goto IL_0153; case 1: <>1__state = -1; goto IL_012b; case 2: { <>1__state = -1; ChallengeBehaviour[] array = ChallengeBehaviour.Instances.ToArray(); <>7__wrap3 = array; <>7__wrap2 = 0; goto IL_01d7; } case 3: { <>1__state = -1; goto IL_01c9; } IL_01d7: if (<>7__wrap2 < <>7__wrap3.Length) { ChallengeBehaviour challengeBehaviour = <>7__wrap3[<>7__wrap2]; if ((Object)(object)challengeBehaviour != (Object)null && challengeBehaviour.RespondsToPostBattleSetup()) { <>2__current = challengeBehaviour.OnPostBattleSetup(); <>1__state = 3; return true; } goto IL_01c9; } <>7__wrap3 = null; return false; IL_0153: <>2__current = result; <>1__state = 2; return true; IL_0139: if (<>7__wrap2 < <>7__wrap1.Length) { FullChallenge fullChallenge = <>7__wrap1[<>7__wrap2].GetFullChallenge(); if (fullChallenge != null && fullChallenge.HasValidHandler()) { int num = ChallengeBehaviour.CountInstancesOfType(fullChallenge.Challenge.challengeType); if (fullChallenge.Stackable || num < 1) { ChallengeBehaviour challengeBehaviour2 = new GameObject(((Object)fullChallenge.Challenge).name + " Challenge Handler").AddComponent(fullChallenge.ChallengeHandler) as ChallengeBehaviour; if ((Object)(object)challengeBehaviour2 != (Object)null) { GlobalTriggerHandler instance = Singleton.Instance; if (instance != null) { instance.RegisterNonCardReceiver((NonCardTriggerReceiver)(object)challengeBehaviour2); } challengeBehaviour2.challenge = fullChallenge; challengeBehaviour2.instanceNumber = num + 1; ChallengeBehaviour.Instances.Add(challengeBehaviour2); if (challengeBehaviour2.RespondsToPreBattleSetup()) { <>2__current = challengeBehaviour2.OnPreBattleSetup(); <>1__state = 1; return true; } } } } goto IL_012b; } <>7__wrap1 = null; goto IL_0153; IL_012b: <>7__wrap2++; goto IL_0139; IL_01c9: <>7__wrap2++; goto IL_01d7; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__33 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator result; private ChallengeBehaviour[] <>7__wrap1; private int <>7__wrap2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__33(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; ChallengeBehaviour[] array = ChallengeBehaviour.Instances.ToArray(); <>7__wrap1 = array; <>7__wrap2 = 0; goto IL_008a; } case 1: <>1__state = -1; goto IL_007c; case 2: { <>1__state = -1; ChallengeBehaviour[] array = ChallengeBehaviour.Instances.ToArray(); <>7__wrap1 = array; <>7__wrap2 = 0; goto IL_0121; } case 3: { <>1__state = -1; goto IL_0113; } IL_0121: if (<>7__wrap2 < <>7__wrap1.Length) { ChallengeBehaviour challengeBehaviour = <>7__wrap1[<>7__wrap2]; if ((Object)(object)challengeBehaviour != (Object)null && challengeBehaviour.RespondsToPostBattleCleanup()) { <>2__current = challengeBehaviour.OnPostBattleCleanup(); <>1__state = 3; return true; } goto IL_0113; } <>7__wrap1 = null; ChallengeBehaviour.DestroyAllInstances(); return false; IL_008a: if (<>7__wrap2 < <>7__wrap1.Length) { ChallengeBehaviour challengeBehaviour2 = <>7__wrap1[<>7__wrap2]; if ((Object)(object)challengeBehaviour2 != (Object)null && challengeBehaviour2.RespondsToPreBattleCleanup()) { <>2__current = challengeBehaviour2.OnPreBattleCleanup(); <>1__state = 1; return true; } goto IL_007c; } <>7__wrap1 = null; <>2__current = result; <>1__state = 2; return true; IL_007c: <>7__wrap2++; goto IL_008a; IL_0113: <>7__wrap2++; goto IL_0121; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static readonly Texture2D DEFAULT_ACTIVATED_SPRITE; public static readonly Texture2D HAPPY_ACTIVATED_SPRITE; public static readonly ReadOnlyCollection BaseGameChallenges; internal static readonly ObservableCollection NewInfos; public static readonly ReadOnlyCollection NewChallenges; public static List AllChallenges; private static AscensionIconInteractable currentIcon; public static List AllInfo => AllChallenges.ConvertAll((FullChallenge x) => x.Challenge); public static event Func, List> ModifyChallenges; private static List GenBaseGameChallenges() { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Invalid comparison between Unknown and I4 new List(Resources.LoadAll("Data/Ascension/Challenges")); GameObject obj = Resources.Load("prefabs/ui/ascension/AscensionChallengesScreen"); AscensionUnlockSchedule.Initialize(); AscensionUnlockSchedule instance = AscensionUnlockSchedule.instance; List list = new List(); List list2 = new List(obj.GetComponentInChildren().icons); list2.Sort((AscensionIconInteractable x, AscensionIconInteractable x2) => Mathf.RoundToInt(((Mathf.Abs(((Component)x).transform.position.x - ((Component)x2).transform.position.x) < 0.1f) ? (((Component)x2).transform.position.y - ((Component)x).transform.position.y) : (((Component)x).transform.position.x - ((Component)x2).transform.position.x)) * 100f)); foreach (AscensionIconInteractable icon in list2) { FullChallenge fullChallenge = list.Find((FullChallenge x) => x != null && (Object)(object)x.Challenge == (Object)(object)icon.Info); if (fullChallenge != null) { fullChallenge.AppearancesInChallengeScreen++; continue; } list.Add(new FullChallenge { Challenge = icon.Info, AppearancesInChallengeScreen = 1, UnlockLevel = instance.unlockTiers.FindIndex((UnlockTier x) => x.challengesUnlocked.Contains(icon.Info.challengeType)), ChallengeHandler = null, Boss = ((int)icon.Info.challengeType == 15) }); } return list; } internal static FullChallenge[] GetChallengeIcons() { AscensionChallengeScreen instance = Singleton.Instance; if ((Object)(object)instance == (Object)null) { return new FullChallenge[0]; } return instance.icons?.FindAll((AscensionIconInteractable x) => (Object)(object)x != (Object)null && (Object)(object)x.challengeInfo != (Object)null && (int)x.challengeInfo.challengeType != 0 && x.challengeInfo.GetFullChallenge() != null)?.ConvertAll((AscensionIconInteractable x) => x.challengeInfo.challengeType.GetFullChallenge())?.ToArray() ?? new FullChallenge[0]; } private static AscensionChallengeInfo CloneChallengeInfo(AscensionChallengeInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown return new AscensionChallengeInfo { activatedSprite = info.activatedSprite, challengeType = info.challengeType, description = info.description, iconSprite = info.iconSprite, name = ((Object)info).name, pointValue = info.pointValue, title = info.title }; } public static void SyncChallengeList() { List second = new List(NewInfos); List list = BaseGameChallenges.Concat(second).ToList(); AllChallenges = ChallengeManager.ModifyChallenges?.Invoke(list) ?? list; } static ChallengeManager() { DEFAULT_ACTIVATED_SPRITE = Resources.Load("art/ui/ascension/ascensionicon_activated_default"); HAPPY_ACTIVATED_SPRITE = Resources.Load("art/ui/ascension/ascensionicon_activated_difficulty"); BaseGameChallenges = new ReadOnlyCollection(GenBaseGameChallenges()); NewInfos = new ObservableCollection(); NewChallenges = new ReadOnlyCollection(NewInfos); AllChallenges = BaseGameChallenges.ToList(); InscryptionAPIPlugin.ScriptableObjectLoaderLoad += delegate(Type type) { if (type == typeof(AscensionChallengeInfo)) { ScriptableObjectLoader.allData = AllInfo; } }; NewInfos.CollectionChanged += delegate { SyncChallengeList(); }; } public static AscensionChallengeInfo GetInfo(this AscensionChallenge info) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return AllChallenges.Find((FullChallenge x) => x != null && (Object)(object)x.Challenge != (Object)null && x.Challenge.challengeType == info)?.Challenge; } public static FullChallenge GetFullChallenge(this AscensionChallenge info) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return AllChallenges.Find((FullChallenge x) => x != null && (Object)(object)x.Challenge != (Object)null && x.Challenge.challengeType == info); } public static FullChallenge GetFullChallenge(this AscensionChallengeInfo info) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)info == (Object)null) { return null; } return info.challengeType.GetFullChallenge(); } public static bool IsStackable(AscensionChallenge id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return (AllChallenges.Find((FullChallenge x) => x != null && (Object)(object)x.Challenge != (Object)null && x.Challenge.challengeType == id)?.Stackable).GetValueOrDefault(); } public static FullChallenge Add(string pluginGuid, AscensionChallengeInfo info, int unlockLevel = 0, bool stackable = false) { return AddSpecific(pluginGuid, info, unlockLevel, (!stackable) ? 1 : 2); } public static FullChallenge AddSpecific(string pluginGuid, AscensionChallengeInfo info, int unlockLevel = 0, int numAppearancesInChallengeScreen = 1) { return AddSpecific(pluginGuid, info, null, unlockLevel, null, null, null, numAppearancesInChallengeScreen); } public static FullChallenge AddSpecific(string pluginGuid, string title, string description, int pointValue, Texture2D iconTexture, Texture2D activatedTexture, int unlockLevel = 0, List flags = null, Func> dependantChallengeGetter = null, Func> incompatibleChallengeGetter = null, int numAppearancesInChallengeScreen = 1) where T : ChallengeBehaviour { return AddSpecific(pluginGuid, title, description, pointValue, iconTexture, activatedTexture, typeof(T), unlockLevel, flags, dependantChallengeGetter, incompatibleChallengeGetter, numAppearancesInChallengeScreen); } public static FullChallenge AddSpecific(string pluginGuid, string title, string description, int pointValue, Texture2D iconTexture, Texture2D activatedTexture, Type handlerType = null, int unlockLevel = 0, List flags = null, Func> dependantChallengeGetter = null, Func> incompatibleChallengeGetter = null, int numAppearancesInChallengeScreen = 1) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) AscensionChallengeInfo val = ScriptableObject.CreateInstance(); val.title = title; val.challengeType = (AscensionChallenge)0; val.description = description; val.pointValue = pointValue; val.iconSprite = iconTexture.ConvertTexture(TextureHelper.SpriteType.ChallengeIcon, (FilterMode)0); val.activatedSprite = activatedTexture.ConvertTexture(TextureHelper.SpriteType.ChallengeIcon, (FilterMode)0); return AddSpecific(pluginGuid, val, handlerType, unlockLevel, flags, dependantChallengeGetter, incompatibleChallengeGetter, numAppearancesInChallengeScreen); } public static FullChallenge AddSpecific(string pluginGuid, AscensionChallengeInfo info, int unlockLevel = 0, List flags = null, Func> dependantChallengeGetter = null, Func> incompatibleChallengeGetter = null, int numAppearancesInChallengeScreen = 1) where T : ChallengeBehaviour { return AddSpecific(pluginGuid, info, typeof(T), unlockLevel, flags, dependantChallengeGetter, incompatibleChallengeGetter, numAppearancesInChallengeScreen); } public static FullChallenge AddSpecific(string pluginGuid, AscensionChallengeInfo info, Type handlerType = null, int unlockLevel = 0, List flags = null, Func> dependantChallengeGetter = null, Func> incompatibleChallengeGetter = null, int numAppearancesInChallengeScreen = 1) { //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) info.challengeType = GuidManager.GetEnumValue(pluginGuid, info.title); FullChallenge fullChallenge = new FullChallenge { Challenge = info, AppearancesInChallengeScreen = numAppearancesInChallengeScreen, UnlockLevel = unlockLevel, ChallengeHandler = handlerType, DependantChallengeGetter = dependantChallengeGetter, IncompatibleChallengeGetter = incompatibleChallengeGetter, Flags = ((flags != null) ? new List(flags) : new List()) }; NewInfos.Add(fullChallenge); return fullChallenge; } public static FullChallenge AddSpecific(string pluginGuid, string title, string description, int pointValue, Texture2D iconTexture, Texture2D activatedTexture, int unlockLevel = 0, int numAppearancesInChallengeScreen = 1) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) AscensionChallengeInfo val = ScriptableObject.CreateInstance(); val.title = title; val.challengeType = (AscensionChallenge)0; val.description = description; val.pointValue = pointValue; val.iconSprite = iconTexture.ConvertTexture(TextureHelper.SpriteType.ChallengeIcon, (FilterMode)0); val.activatedSprite = activatedTexture.ConvertTexture(TextureHelper.SpriteType.ChallengeIcon, (FilterMode)0); return AddSpecific(pluginGuid, val, unlockLevel, numAppearancesInChallengeScreen); } public static FullChallenge Add(string pluginGuid, string title, string description, int pointValue, Texture2D iconTexture, Texture2D activatedTexture, int unlockLevel = 0, bool stackable = false) { return AddSpecific(pluginGuid, title, description, pointValue, iconTexture, activatedTexture, unlockLevel, (!stackable) ? 1 : 2); } [HarmonyPatch(typeof(AscensionUnlockSchedule), "ChallengeIsUnlockedForLevel")] [HarmonyPostfix] private static void IsCustomChallengeUnlocked(ref bool __result, int level, AscensionChallenge challenge) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!__result) { FullChallenge fullChallenge = NewInfos.ToList().Find((FullChallenge x) => x != null && (Object)(object)x.Challenge != (Object)null && x.Challenge.challengeType == challenge); __result = fullChallenge != null && level >= fullChallenge.UnlockLevel; } __result &= challenge.GetFullChallenge()?.CustomUnlockCheck == null || challenge.GetFullChallenge().CustomUnlockCheck(level); } [HarmonyPatch(typeof(AscensionMenuScreens), "TransitionToGame")] [HarmonyPrefix] private static void ResyncWhenTransitioningToGame() { SyncChallengeList(); } [IteratorStateMachine(typeof(d__31))] [HarmonyPatch(typeof(TurnManager), "SetupPhase")] [HarmonyPostfix] private static IEnumerator ActivateChallenges(IEnumerator result, TurnManager __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__31(0) { result = result }; } [HarmonyPatch(typeof(ChallengeActivationUI), "ShowActivation")] [HarmonyPrefix] private static void FixIconColor(ChallengeActivationUI __instance, AscensionChallenge challenge) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Color val = GameColors.Instance.gold; AscensionChallengeInfo info = AscensionChallengesUtil.GetInfo(challenge); if ((Object)(object)info == (Object)null || info.pointValue > 0 || (int)challenge == 0) { val = GameColors.Instance.red; } else if (info.pointValue < 0) { val = GameColors.Instance.darkLimeGreen; } __instance.icon.color = val; ((AscensionMenuBlinkEffect)__instance.blinkEffect).blinkOffColor = val; } [IteratorStateMachine(typeof(d__33))] [HarmonyPatch(typeof(TurnManager), "CleanupPhase")] [HarmonyPostfix] private static IEnumerator Postfix(IEnumerator result) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__33(0) { result = result }; } [HarmonyPatch(typeof(AscensionIconInteractable), "OnCursorSelectStart")] [HarmonyPostfix] private static void DoDependenciesAndIncompatibilities(AscensionIconInteractable __instance) { //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) if (!__instance.Unlocked || !__instance.clickable) { return; } bool flag = false; if ((Object)(object)currentIcon == (Object)null) { currentIcon = __instance; flag = true; } bool enabled = ((Renderer)__instance.activatedRenderer).enabled; AscensionChallengeScreen instance = Singleton.Instance; AscensionChallengeInfo challengeInfo = __instance.challengeInfo; if (enabled) { bool flag2 = false; List dependencies2 = challengeInfo?.GetFullChallenge()?.DependantChallengeGetter?.Invoke(GetChallengeIcons())?.ToList(); List incompatibilities = challengeInfo?.GetFullChallenge()?.IncompatibleChallengeGetter?.Invoke(GetChallengeIcons())?.ToList(); if (dependencies2 != null && incompatibilities != null) { incompatibilities.RemoveAll((AscensionChallenge x) => dependencies2.Contains(x)); } if (dependencies2 != null) { dependencies2.RemoveAll((AscensionChallenge x) => x == challengeInfo.challengeType); List list = new List(dependencies2); foreach (AscensionIconInteractable item in instance.icons.Where((AscensionIconInteractable x) => (Object)(object)x != (Object)null && x.Unlocked && x.clickable && (Object)(object)x.activatedRenderer != (Object)null && ((Renderer)x.activatedRenderer).enabled && (Object)(object)x.Info != (Object)null && dependencies2.Contains(x.Info.challengeType))) { if (list.Contains(item.Info.challengeType)) { list.Remove(item.Info.challengeType); } } if (list.Count > 0) { List list2 = new List(); foreach (AscensionIconInteractable item2 in instance.icons.Where((AscensionIconInteractable x) => (Object)(object)x != (Object)null && x.Unlocked && x.clickable && (Object)(object)x.activatedRenderer != (Object)null && !((Renderer)x.activatedRenderer).enabled && (Object)(object)x.Info != (Object)null && dependencies2.Contains(x.Info.challengeType))) { if (list.Contains(item2.Info.challengeType)) { list.Remove(item2.Info.challengeType); list2.Add(item2); } } if (list.Count > 0) { flag2 = true; } else { foreach (AscensionIconInteractable item3 in list2) { if (item3 != null) { ((MainInputInteractable)item3).OnCursorSelectStart(); } } AscensionChallengeDisplayer instance2 = Singleton.Instance; if (instance2 != null) { instance2.DisplayChallenge(challengeInfo, false); } } } } if (flag2) { __instance.ShowActivated(false); instance.SetChallengeActivated(__instance.challengeInfo, false); } else { foreach (AscensionIconInteractable icon2 in instance.icons) { if (!((Object)(object)icon2.activatedRenderer != (Object)null) || !((Renderer)icon2.activatedRenderer).enabled || !((Object)(object)icon2 != (Object)(object)currentIcon) || !((Object)(object)icon2.challengeInfo != (Object)null)) { continue; } List list3 = icon2?.challengeInfo?.GetFullChallenge()?.DependantChallengeGetter?.Invoke(GetChallengeIcons())?.ToList(); List incompatibilities2 = icon2?.challengeInfo?.GetFullChallenge()?.IncompatibleChallengeGetter?.Invoke(GetChallengeIcons())?.ToList(); if (incompatibilities2 == null) { continue; } if (list3 != null) { incompatibilities.RemoveAll(list3.Contains); } incompatibilities2.RemoveAll((AscensionChallenge x) => x == icon2.challengeInfo.challengeType); if (instance.icons.Exists((AscensionIconInteractable x) => x.Unlocked && x.clickable && (Object)(object)x.Info != (Object)null && (Object)(object)x.activatedRenderer != (Object)null && ((Renderer)x.activatedRenderer).enabled && incompatibilities2.Contains(x.Info.challengeType))) { AscensionIconInteractable obj = icon2; if (obj != null) { ((MainInputInteractable)obj).OnCursorSelectStart(); } } } if (incompatibilities != null) { incompatibilities.RemoveAll((AscensionChallenge x) => x == challengeInfo.challengeType); instance.icons.FindAll((AscensionIconInteractable x) => x.Unlocked && x.clickable && ((Renderer)x.activatedRenderer).enabled && incompatibilities.Contains(x.Info.challengeType)).ForEach(delegate(AscensionIconInteractable x) { ((MainInputInteractable)x).OnCursorSelectStart(); }); instance.icons.FindAll((AscensionIconInteractable x) => x.Unlocked && x.clickable && ((Renderer)x.activatedRenderer).enabled && incompatibilities.Contains(x.Info.challengeType)).ForEach(delegate(AscensionIconInteractable x) { ((MainInputInteractable)x).OnCursorSelectStart(); }); AscensionSaveData.Data.activeChallenges?.RemoveAll(incompatibilities.Contains); ChallengeLevelText challengeLevelText = instance.challengeLevelText; if (challengeLevelText != null) { challengeLevelText.UpdateText(); } AscensionChallengeDisplayer instance3 = Singleton.Instance; if (instance3 != null) { instance3.DisplayChallenge(challengeInfo, false); } } } } else { foreach (AscensionIconInteractable icon in instance.icons) { if (!((Renderer)icon.activatedRenderer).enabled || !((Object)(object)icon != (Object)(object)currentIcon)) { continue; } List dependencies = icon?.challengeInfo?.GetFullChallenge()?.DependantChallengeGetter?.Invoke(GetChallengeIcons())?.ToList(); List list4 = icon?.challengeInfo?.GetFullChallenge()?.IncompatibleChallengeGetter?.Invoke(GetChallengeIcons())?.ToList(); if (dependencies == null) { continue; } list4?.RemoveAll(dependencies.Contains); dependencies.RemoveAll((AscensionChallenge x) => x == icon.challengeInfo.challengeType); List list5 = new List(dependencies); foreach (AscensionIconInteractable item4 in instance.icons.Where((AscensionIconInteractable x) => x.Unlocked && x.clickable && (Object)(object)x.Info != (Object)null && (Object)(object)x.activatedRenderer != (Object)null && ((Renderer)x.activatedRenderer).enabled && dependencies.Contains(x.Info.challengeType))) { if (list5.Contains(item4.Info.challengeType)) { list5.Remove(item4.Info.challengeType); } } if (list5.Count > 0) { AscensionIconInteractable obj2 = icon; if (obj2 != null) { ((MainInputInteractable)obj2).OnCursorSelectStart(); } } } } if (flag) { currentIcon = null; } } } [HarmonyPatch] public static class StarterDeckManager { public class FullStarterDeck { public StarterDeckInfo Info { get; set; } public int UnlockLevel { get; set; } public Func CustomUnlockCheck { get; set; } public List CardNames { get; set; } } public static readonly ReadOnlyCollection BaseGameDecks; internal static readonly ObservableCollection NewDecks; public static List AllDecks; public static List AllDeckInfos; public static event Func, List> ModifyDeckList; private static List GetBaseGameDecks() { List source = new List(Resources.LoadAll("Data/Ascension/StarterDecks")); Transform val = Resources.Load("prefabs/ui/ascension/AscensionStarterDeckScreen").transform.Find("Icons"); List list = new List(); for (int i = 1; i <= 8; i++) { AscensionStarterDeckIcon icon = ((Component)val.Find($"StarterDeckIcon_{i}")).gameObject.GetComponent(); FullStarterDeck fullStarterDeck = new FullStarterDeck { Info = source.First((StarterDeckInfo d) => ((Object)d).name == ((Object)icon.Info).name), UnlockLevel = -1 }; fullStarterDeck.CardNames = fullStarterDeck.Info.cards.Select((CardInfo ci) => ((Object)ci).name).ToList(); list.Add(fullStarterDeck); } return list; } private static FullStarterDeck CloneStarterDeck(FullStarterDeck info) { FullStarterDeck fullStarterDeck = new FullStarterDeck(); StarterDeckInfo val = ScriptableObject.CreateInstance(); val.cards = ((info.Info.cards == null) ? null : new List(info.Info.cards)); val.iconSprite = info.Info.iconSprite; ((Object)val).name = ((Object)info.Info).name; val.title = info.Info.title; fullStarterDeck.Info = val; fullStarterDeck.CardNames = new List(info.CardNames); fullStarterDeck.CustomUnlockCheck = info.CustomUnlockCheck; fullStarterDeck.UnlockLevel = info.UnlockLevel; return fullStarterDeck; } public static void SyncDeckList() { List list = BaseGameDecks.Concat(NewDecks).Select(CloneStarterDeck).ToList(); foreach (FullStarterDeck item in list) { FullStarterDeck deck = item; UpdateCardsList(ScriptableObjectLoader.AllData); if (deck.Info.cards.Count != deck.CardNames.Count) { CardManager.ModifyCardList += TryAddMissingCards; } List TryAddMissingCards(List x) { UpdateCardsList(x); if (deck.Info.cards.Count == deck.CardNames.Count) { CardManager.ModifyCardList -= TryAddMissingCards; } return x; } void UpdateCardsList(List allcards) { List list2 = new List(); foreach (string c in deck.CardNames) { if (allcards.Exists((CardInfo x) => ((Object)x).name == c)) { list2.Add(CardLoader.Clone(allcards.Find((CardInfo x) => ((Object)x).name == c))); } } deck.Info.cards = list2; } } AllDecks = StarterDeckManager.ModifyDeckList?.Invoke(list) ?? list; AllDeckInfos = AllDecks.Select((FullStarterDeck fsd) => fsd.Info).ToList(); } static StarterDeckManager() { BaseGameDecks = new ReadOnlyCollection(GetBaseGameDecks()); NewDecks = new ObservableCollection(); AllDecks = BaseGameDecks.ToList(); AllDeckInfos = BaseGameDecks.Select((FullStarterDeck fsd) => fsd.Info).ToList(); InscryptionAPIPlugin.ScriptableObjectLoaderLoad += delegate(Type type) { if (type == typeof(StarterDeckInfo)) { ScriptableObjectLoader.allData = AllDecks.Select((FullStarterDeck fsd) => fsd.Info).ToList(); } }; NewDecks.CollectionChanged += delegate { SyncDeckList(); }; } public static FullStarterDeck Add(string pluginGuid, StarterDeckInfo info, int unlockLevel = 0) { ((Object)info).name = pluginGuid + "_" + (info.title ?? ((Object)info).name); FullStarterDeck fullStarterDeck = new FullStarterDeck(); fullStarterDeck.Info = info; fullStarterDeck.UnlockLevel = unlockLevel; fullStarterDeck.CardNames = info.cards.Select((CardInfo ci) => ((Object)ci).name).ToList(); if (NewDecks.FirstOrDefault((FullStarterDeck sdi) => ((Object)sdi.Info).name == ((Object)info).name) == null) { NewDecks.Add(fullStarterDeck); } return fullStarterDeck; } public static FullStarterDeck New(string pluginGuid, string title, Texture2D iconTexture, string[] cardNames, int unlockLevel = 0) { StarterDeckInfo val = ScriptableObject.CreateInstance(); val.title = title; val.iconSprite = iconTexture.ConvertTexture(TextureHelper.SpriteType.StarterDeckIcon, (FilterMode)0); ((Object)val).name = pluginGuid + "_" + title; FullStarterDeck fullStarterDeck = new FullStarterDeck(); fullStarterDeck.Info = val; fullStarterDeck.UnlockLevel = unlockLevel; fullStarterDeck.CardNames = cardNames.ToList(); NewDecks.Add(fullStarterDeck); return fullStarterDeck; } public static FullStarterDeck New(string pluginGuid, string title, string pathToIconTexture, string[] cardNames, int unlockLevel = 0) { Texture2D imageAsTexture = TextureHelper.GetImageAsTexture(pathToIconTexture, (FilterMode)0); return New(pluginGuid, title, imageAsTexture, cardNames, unlockLevel); } [HarmonyPatch(typeof(AscensionUnlockSchedule), "StarterDeckIsUnlockedForLevel")] [HarmonyPrefix] private static bool CustomStarterLevel(ref bool __result, string id, int level) { FullStarterDeck fullStarterDeck = AllDecks.FirstOrDefault((FullStarterDeck d) => ((Object)d.Info).name == id); if (fullStarterDeck == null || (fullStarterDeck.UnlockLevel < 0 && fullStarterDeck.CustomUnlockCheck == null)) { return true; } __result = level >= fullStarterDeck.UnlockLevel && (fullStarterDeck.CustomUnlockCheck == null || fullStarterDeck.CustomUnlockCheck(level)); return false; } } public class StarterDeckPaginator : MonoBehaviour { private static Sprite noneDeckSprite; public GameObject leftArrow; public GameObject rightArrow; public int pageIndex; public List> pages; public int pageLength; public AscensionChooseStarterDeckScreen screen; private void Initialize(AscensionChooseStarterDeckScreen screen) { pages = new List>(); pageLength = screen.deckIcons.Count; this.screen = screen; } public void AddPage(List page) { if (page.Count < pageLength) { while (page.Count < pageLength) { page.Add(null); } } pages.Add(page); } public void NextPage() { pageIndex++; if (pageIndex >= pages.Count) { pageIndex = 0; } LoadPage(pages[pageIndex]); } public void PreviousPage() { pageIndex--; if (pageIndex < 0) { pageIndex = pages.Count - 1; } LoadPage(pages[pageIndex]); } public void LoadPage(List page) { List list = new List(screen.deckIcons); list.Sort((AscensionStarterDeckIcon x, AscensionStarterDeckIcon x2) => Mathf.RoundToInt(((Mathf.Abs(((Component)x).transform.position.y - ((Component)x2).transform.position.y) < 0.1f) ? (((Component)x).transform.position.x - ((Component)x2).transform.position.x) : (((Component)x2).transform.position.y - ((Component)x).transform.position.y)) * 100f)); for (int i = 0; i < pageLength; i++) { if (i >= list.Count) { continue; } if (i < page.Count) { list[i].starterDeckInfo = page[i]; list[i].AssignInfo(page[i]); if (!list[i].Unlocked) { ((Renderer)list[i].conqueredRenderer).enabled = false; } } else { list[i].starterDeckInfo = null; list[i].AssignInfo((StarterDeckInfo)null); ((Renderer)list[i].conqueredRenderer).enabled = false; list[i].iconRenderer.sprite = noneDeckSprite; } } if (noneDeckSprite == null) { noneDeckSprite = TextureHelper.GetImageAsTexture("starterdeck_icon_none.png", Assembly.GetExecutingAssembly(), (FilterMode)0).ConvertTexture(); } foreach (AscensionStarterDeckIcon deckIcon in screen.deckIcons) { if ((Object)(object)deckIcon.Info == (Object)null) { deckIcon.iconRenderer.sprite = noneDeckSprite; } } CommandLineTextDisplayer.PlayCommandLineClickSound(); } public void OnEnable() { //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: 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_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) StarterDeckManager.SyncDeckList(); Initialize(((Component)this).GetComponent()); if (Object.op_Implicit((Object)(object)rightArrow)) { Object.Destroy((Object)(object)rightArrow); } if (Object.op_Implicit((Object)(object)leftArrow)) { Object.Destroy((Object)(object)leftArrow); } List list = new List(StarterDeckManager.AllDecks.ConvertAll((StarterDeckManager.FullStarterDeck x) => x.Info)); List deckIcons = screen.deckIcons; List> list2 = new List>(); while (list.Count > 0) { List list3 = new List(); for (int i = 0; i < deckIcons.Count; i++) { if (list.Count > 0) { list3.Add(list[0]); list.RemoveAt(0); } } list2.Add(list3); } if (list2.Count > 0) { foreach (List item in list2) { AddPage(item); } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(float.MinValue, float.MinValue); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(float.MaxValue, float.MaxValue); foreach (AscensionStarterDeckIcon item2 in deckIcons) { if ((Object)(object)item2 != (Object)null && (Object)(object)item2.iconRenderer != (Object)null) { if (((Component)item2.iconRenderer).transform.position.x < val2.x) { val2.x = ((Component)item2.iconRenderer).transform.position.x; } if (((Component)item2.iconRenderer).transform.position.x > val.x) { val.x = ((Component)item2.iconRenderer).transform.position.x; } if (((Component)item2.iconRenderer).transform.position.y < val2.y) { val2.y = ((Component)item2.iconRenderer).transform.position.y; } if (((Component)item2.iconRenderer).transform.position.y > val.y) { val.y = ((Component)item2.iconRenderer).transform.position.y; } } } leftArrow = Object.Instantiate(((Component)((Component)screen).GetComponentInParent().cardUnlockSummaryScreen.GetComponent().pageLeftButton).gameObject); leftArrow.transform.parent = ((Component)screen).transform; leftArrow.transform.position = Vector3.Lerp(new Vector3(val2.x, val.y, val.z), new Vector3(val2.x, val2.y, val.z), 0.5f) + Vector3.left / 2f; ((InteractableBase)leftArrow.GetComponent()).ClearDelegates(); AscensionMenuInteractable component = leftArrow.GetComponent(); ((MainInputInteractable)component).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)component).CursorSelectStarted, (Action)delegate { PreviousPage(); }); rightArrow = Object.Instantiate(((Component)((Component)screen).GetComponentInParent().cardUnlockSummaryScreen.GetComponent().pageRightButton).gameObject); rightArrow.transform.parent = ((Component)screen).transform; rightArrow.transform.position = Vector3.Lerp(new Vector3(val.x, val.y, val.z), new Vector3(val.x, val2.y, val.z), 0.5f) + Vector3.right / 2f; ((InteractableBase)rightArrow.GetComponent()).ClearDelegates(); AscensionMenuInteractable component2 = rightArrow.GetComponent(); ((MainInputInteractable)component2).CursorSelectStarted = (Action)Delegate.Combine(((MainInputInteractable)component2).CursorSelectStarted, (Action)delegate { NextPage(); }); } pageIndex = 0; LoadPage(pages[0]); } } internal class StarterDeckScreenPlus : ManagedBehaviour { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public StarterDeckScreenPlus <>4__this; private List.Enumerator <>7__wrap1; private GameObject 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown try { int num = <>1__state; StarterDeckScreenPlus starterDeckScreenPlus = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (starterDeckScreenPlus.tempCards == null) { starterDeckScreenPlus.tempCards = new List(); } starterDeckScreenPlus.tempCards.ForEach(delegate(GameObject x) { x.SetActive(false); }); <>7__wrap1 = starterDeckScreenPlus.tempCards.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; 5__3.SetActive(true); CommandLineTextDisplayer.PlayCommandLineClickSound(); 5__3 = null; break; } if (<>7__wrap1.MoveNext()) { 5__3 = <>7__wrap1.Current; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public List tempCards = new List(); public List noneCardObjects = new List(); [IteratorStateMachine(typeof(d__0))] public IEnumerator ShowCardsSequence() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { <>4__this = this }; } } [HarmonyPatch] internal static class StarterDeckSelectscreenPatches { private static Sprite noneCard; [HarmonyPatch(typeof(AscensionChooseStarterDeckScreen), "Start")] [HarmonyPostfix] private static void Postfix(AscensionChooseStarterDeckScreen __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } [HarmonyPatch(typeof(AscensionChooseStarterDeckScreen), "OnCursorEnterDeckIcon")] [HarmonyPrefix] private static bool FixDeckPreview(AscensionChooseStarterDeckScreen __instance, AscensionStarterDeckIcon icon) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) StarterDeckScreenPlus starterDeckScreenPlus = ((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent(); starterDeckScreenPlus.tempCards?.ForEach(delegate(GameObject x) { x.SetActive(false); }); if ((Object)(object)icon.starterDeckInfo == (Object)null) { StarterDeckScreenPlus starterDeckScreenPlus2 = starterDeckScreenPlus; if (starterDeckScreenPlus2.noneCardObjects == null) { starterDeckScreenPlus2.noneCardObjects = new List(); } if (starterDeckScreenPlus.noneCardObjects.Count <= 0) { foreach (SpriteRenderer cardLockedSprite in __instance.cardLockedSprites) { GameObject val = Object.Instantiate(((Component)cardLockedSprite).gameObject); val.transform.parent = ((Component)cardLockedSprite).transform.parent; val.transform.localPosition = ((Component)cardLockedSprite).transform.localPosition; val.GetComponent().sprite = noneCard ?? (noneCard = TextureHelper.GetImageAsTexture("ascension_card_none_darker.png", Assembly.GetExecutingAssembly(), (FilterMode)0).ConvertTexture()); ((Renderer)val.GetComponent()).enabled = true; starterDeckScreenPlus.noneCardObjects.Add(val); } } starterDeckScreenPlus.noneCardObjects.ForEach(delegate(GameObject x) { x.SetActive(true); }); __instance.cardLockedSprites.ForEach(delegate(SpriteRenderer x) { ((Component)x).gameObject.SetActive(false); }); } else { starterDeckScreenPlus?.noneCardObjects.ForEach(delegate(GameObject x) { x.SetActive(false); }); __instance.cardLockedSprites.ForEach(delegate(SpriteRenderer x) { ((Component)x).gameObject.SetActive(true); }); if (icon.Unlocked && icon.starterDeckInfo.cards != null && icon.starterDeckInfo.cards.Count != __instance.cards.Count) { __instance.cardLockedSprites.ForEach(delegate(SpriteRenderer x) { ((Renderer)x).enabled = false; }); __instance.cards.ForEach(delegate(PixelSelectableCard x) { ((Component)x).gameObject.SetActive(false); }); PixelSelectableCard val2 = __instance.cards.FirstOrDefault(); if ((Object)(object)val2 != (Object)null) { StarterDeckScreenPlus starterDeckScreenPlus2 = starterDeckScreenPlus; if (starterDeckScreenPlus2.tempCards == null) { starterDeckScreenPlus2.tempCards = new List(); } List cards = icon.starterDeckInfo.cards; for (int i = 0; i < cards.Count; i++) { CardInfo info = cards[i]; float num = ((cards.Count > 8) ? 0.425f : 0.5f) * ((float)i - (float)(cards.Count - 1) / 2f); if (Math.Abs(num) <= 2.5f) { GameObject? obj = starterDeckScreenPlus.tempCards.Find((GameObject x) => !x.activeSelf); PixelSelectableCard val3 = ((obj != null) ? obj.GetComponentInChildren() : null) ?? Object.Instantiate(val2); ((Component)val3).transform.parent = ((Component)val2).transform.parent; ((Component)val3).transform.localPosition = new Vector3(num, ((Component)val2).transform.localPosition.y, ((Component)val2).transform.localPosition.z); ((Card)val3).SetInfo(info); ((InteractableBase)val3).SetEnabled(false); ((Component)val3).gameObject.SetActive(true); if (!starterDeckScreenPlus.tempCards.Contains(((Component)val3).gameObject)) { starterDeckScreenPlus.tempCards.Add(((Component)val3).gameObject); } } } ((MonoBehaviour)__instance).StopAllCoroutines(); ((MonoBehaviour)__instance).StartCoroutine(__instance.ShowCardsSequence()); return false; } } } __instance.cards.ForEach(delegate(PixelSelectableCard x) { ((Component)x).gameObject.SetActive(true); }); return true; } [HarmonyPatch(typeof(AscensionChooseStarterDeckScreen), "OnRandomSelected")] [HarmonyPrefix] public static bool TrueRandom(AscensionChooseStarterDeckScreen __instance) { StarterDeckPaginator component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { StarterDeckInfo[] array = (from x in component.pages.SelectMany((List x) => x) where (Object)(object)x != (Object)null && AscensionUnlockSchedule.StarterDeckIsUnlockedForLevel(((Object)x).name, AscensionSaveData.Data.challengeLevel) select x).ToArray(); StarterDeckInfo deck = array[Random.Range(0, array.Length)]; int num = component.pages.FindIndex((List x) => x.Contains(deck)); if (num >= 0 && num < component.pages.Count) { component.LoadPage(component.pages[num]); AscensionStarterDeckIcon val = __instance.deckIcons.Find((AscensionStarterDeckIcon x) => ((Object)x.starterDeckInfo).name == ((Object)deck).name); if ((Object)(object)val != (Object)null) { __instance.OnSelectStarterDeck(val, false); ((Component)__instance.randomButton).GetComponent().SetBlinkingEnabled(false); } return false; } } return true; } } }