using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using DiskCardGame; using HarmonyLib; using InscryptionAPI.Card; using InscryptionAPI.Helpers; using InscryptionCommunityPatch.Card; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OldSa_SmallSigils")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_SmallSigils")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1cd49d69-dd3b-4c57-b7ac-6ff7e5278d53")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace OLD_SA.SmallSigils; public class BurningStatusEffect : SmallSigilStatusEffectBehaviour { public override string CardModSingletonName => "OLD_SA_Burning"; } public class GluttonyStatusEffect : SmallSigilStatusEffectBehaviour { public override string CardModSingletonName => "OLD_SA_Gluttony"; } [BepInPlugin("OLD_SA.SmallSigils", "OLD SA Small Sigils", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "OLD_SA.SmallSigils"; private Harmony harmony; public static Plugin Instance { get; private set; } private void Awake() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)"OLD SA Small Sigils Loaded"); SmallSigilStatusEffectManager.Initialize("OLD_SA.SmallSigils"); harmony = new Harmony("OLD_SA.SmallSigils"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"OLD SA Small Sigils patches applied."); } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); harmony = null; } Instance = null; } } public class PoisonStatusEffect : SmallSigilStatusEffectBehaviour { public override string CardModSingletonName => "OLD_SA_Poison"; } public class SmallSigilAbilityIcons : ManagedBehaviour { public List part1AbilityIcons = new List(); public List smallSigilIconGroups = new List(); public List abilityIcons = new List(); public Material smallSigilMat; public Color burningColor = new Color(1f, 0.15f, 0.05f, 1f); public Color poisonColor = new Color(0.15f, 1f, 0.15f, 1f); public Color gluttonyColor = new Color(0.45f, 0.22f, 0.08f, 1f); } [HarmonyPatch] internal static class SmallSigilAbilityIconsPatch { private const int MaxSmallSigilIcons = 5; private const float StartX = 0.4f; private const float XSpacing = 0.14f; private const float IconY = 0.75f; private static readonly Vector3 IconScale = new Vector3(0.1f, 0.075f, 1f); [HarmonyPostfix] [HarmonyPatch(typeof(CardAbilityIcons), "UpdateAbilityIcons")] private static void AddSmallSigilIcons(CardAbilityIcons __instance, PlayableCard playableCard) { //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Invalid comparison between Unknown and I4 //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || !SaveManager.SaveFile.IsPart1 || (Object)(object)playableCard == (Object)null) { return; } SmallSigilAbilityIcons smallSigilAbilityIcons = ((Component)__instance).GetComponent(); if ((Object)(object)smallSigilAbilityIcons == (Object)null) { smallSigilAbilityIcons = ((Component)__instance).gameObject.AddComponent(); } if ((Object)(object)smallSigilAbilityIcons == (Object)null || smallSigilAbilityIcons.part1AbilityIcons == null) { return; } if (smallSigilAbilityIcons.part1AbilityIcons.Count < 5) { CreateSmallSigilSlots(__instance, smallSigilAbilityIcons); } if (smallSigilAbilityIcons.part1AbilityIcons.Count == 0) { return; } for (int i = 0; i < smallSigilAbilityIcons.part1AbilityIcons.Count; i++) { AbilityIconInteractable val = smallSigilAbilityIcons.part1AbilityIcons[i]; if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } List list = new List(); if (SmallSigilManager.GetStacks(playableCard, SmallSigilType.Burning) > 0) { list.Add(SmallSigilType.Burning); } if (SmallSigilManager.GetStacks(playableCard, SmallSigilType.Poison) > 0) { list.Add(SmallSigilType.Poison); } if (SmallSigilManager.GetStacks(playableCard, SmallSigilType.Gluttony) > 0) { list.Add(SmallSigilType.Gluttony); } if (list.Count == 0) { return; } int num = Mathf.Min(new int[3] { list.Count, smallSigilAbilityIcons.part1AbilityIcons.Count, 5 }); for (int j = 0; j < num; j++) { SmallSigilType type = list[j]; Ability ability = GetAbility(type); if ((int)ability == 0) { continue; } AbilityIconInteractable val2 = smallSigilAbilityIcons.part1AbilityIcons[j]; if ((Object)(object)val2 == (Object)null) { continue; } int stacks = SmallSigilManager.GetStacks(playableCard, type); if (stacks <= 0) { continue; } ((Component)val2).transform.localPosition = new Vector3(0.4f - 0.14f * (float)j, 0.75f, 0f); ((Component)val2).transform.localScale = IconScale; Texture texture = GetTexture(type); if ((Object)(object)texture == (Object)null) { continue; } val2.AssignAbility(ability, ((Card)playableCard).Info, playableCard); if (stacks > 1) { Texture val3 = InvokePatchTexture(ability, stacks); if ((Object)(object)val3 != (Object)null) { val2.SetIcon(val3); } else { val2.SetIcon(texture); } } else { val2.SetIcon(texture); } Renderer component = ((Component)val2).GetComponent(); if ((Object)(object)component != (Object)null) { component.material.color = GetColor(smallSigilAbilityIcons, type); } ((Component)val2).gameObject.SetActive(true); if (!smallSigilAbilityIcons.abilityIcons.Contains(val2)) { smallSigilAbilityIcons.abilityIcons.Add(val2); } } } [HarmonyPostfix] [HarmonyPatch(typeof(CardAbilityIcons), "UpdateAbilityIcons")] private static void ResetSmallSigilController(CardAbilityIcons __instance) { if ((Object)(object)__instance == (Object)null) { return; } SmallSigilAbilityIcons component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && component.abilityIcons != null) { component.abilityIcons.RemoveAll((AbilityIconInteractable icon) => (Object)(object)icon == (Object)null || !((Component)icon).gameObject.activeSelf); } } private static Texture InvokePatchTexture(Ability ability, int count) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (count <= 1) { return null; } MethodInfo methodInfo = AccessTools.Method(typeof(StackAbilityIcons), "PatchTexture", (Type[])null, (Type[])null); if (methodInfo == null) { return null; } int num = Mathf.Clamp(count, 2, 99); try { object obj = methodInfo.Invoke(null, new object[2] { ability, num }); return (Texture)((obj is Texture) ? obj : null); } catch { return null; } } private static void CreateSmallSigilSlots(CardAbilityIcons instance, SmallSigilAbilityIcons controller) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)instance == (Object)null || (Object)(object)controller == (Object)null) { return; } AbilityIconInteractable val = null; AbilityIconInteractable[] componentsInChildren = ((Component)instance).GetComponentsInChildren(true); AbilityIconInteractable[] array = componentsInChildren; foreach (AbilityIconInteractable val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)((Component)val2).gameObject).name.StartsWith("SmallSigilIcon_")) { val = val2; break; } } if ((Object)(object)val == (Object)null) { return; } for (int j = controller.part1AbilityIcons.Count; j < 5; j++) { GameObject val3 = Object.Instantiate(((Component)val).gameObject, ((Component)val).transform.parent); if ((Object)(object)val3 == (Object)null) { continue; } ((Object)val3).name = "SmallSigilIcon_" + (j + 1); val3.transform.localPosition = new Vector3(0.4f - 0.14f * (float)j, 0.75f, 0f); val3.transform.localScale = IconScale; AbilityIconInteractable component = val3.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val3); continue; } Renderer component2 = ((Component)val).GetComponent(); Renderer component3 = ((Component)component).GetComponent(); if ((Object)(object)component2 != (Object)null && (Object)(object)component3 != (Object)null) { component3.sharedMaterial = component2.sharedMaterial; } controller.part1AbilityIcons.Add(component); val3.SetActive(false); } } private static Ability GetAbility(SmallSigilType type) { //IL_0023: 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) //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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) return (Ability)(type switch { SmallSigilType.Burning => SmallSigilStatusEffectManager.GetIconAbility(typeof(BurningStatusEffect)), SmallSigilType.Poison => SmallSigilStatusEffectManager.GetIconAbility(typeof(PoisonStatusEffect)), SmallSigilType.Gluttony => SmallSigilStatusEffectManager.GetIconAbility(typeof(GluttonyStatusEffect)), _ => 0, }); } private static Texture GetTexture(SmallSigilType type) { return (Texture)(type switch { SmallSigilType.Burning => SmallSigilStatusEffectManager.GetIconTexture(typeof(BurningStatusEffect)), SmallSigilType.Poison => SmallSigilStatusEffectManager.GetIconTexture(typeof(PoisonStatusEffect)), SmallSigilType.Gluttony => SmallSigilStatusEffectManager.GetIconTexture(typeof(GluttonyStatusEffect)), _ => null, }); } private static Color GetColor(SmallSigilAbilityIcons controller, SmallSigilType type) { //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_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) //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_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_0050: 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) if ((Object)(object)controller == (Object)null) { return Color.white; } return (Color)(type switch { SmallSigilType.Burning => controller.burningColor, SmallSigilType.Poison => controller.poisonColor, SmallSigilType.Gluttony => controller.gluttonyColor, _ => Color.white, }); } [HarmonyPostfix] [HarmonyPatch(typeof(CardAbilityIcons), "GetDistinctShownAbilities")] private static void HideSmallSigilsFromNormalIcons(ref List __result) { if (__result != null && __result.Count != 0) { __result.RemoveAll((Ability ability) => SmallSigilStatusEffectManager.IsSmallSigilAbility(ability)); } } } public class SmallSigilBehaviour : MonoBehaviour { public PlayableCard Card { get; private set; } private void Awake() { Card = ((Component)this).GetComponent(); if (!((Object)(object)Card == (Object)null)) { SmallSigilManager.RegisterCard(Card); EnsureTriggerBehaviour(); } } private void EnsureTriggerBehaviour() { if (!((Object)(object)Card == (Object)null) && (Object)(object)((Component)Card).GetComponent() == (Object)null) { ((Component)Card).gameObject.AddComponent(); } } private void OnDestroy() { if (!((Object)(object)Card == (Object)null)) { SmallSigilRuleManager.ClearCard(Card); SmallSigilManager.ClearCard(Card); Card = null; } } } public class SmallSigilData { private readonly Dictionary stacks = new Dictionary(); public int GetStacks(SmallSigilType type) { if (stacks.TryGetValue(type, out var value)) { return value; } return 0; } public void AddStacks(SmallSigilType type, int amount) { if (amount > 0) { int num = GetStacks(type); stacks[type] = num + amount; } } public bool RemoveStacks(SmallSigilType type, int amount) { if (amount <= 0) { return false; } int num = GetStacks(type); if (num < amount) { return false; } int num2 = num - amount; if (num2 <= 0) { stacks.Remove(type); } else { stacks[type] = num2; } return true; } public void SetStacks(SmallSigilType type, int amount) { if (amount <= 0) { stacks.Remove(type); } else { stacks[type] = amount; } } public void Clear() { stacks.Clear(); } } public static class SmallSigilManager { private static Type GetBehaviourType(SmallSigilType type) { return type switch { SmallSigilType.Burning => typeof(BurningStatusEffect), SmallSigilType.Poison => typeof(PoisonStatusEffect), SmallSigilType.Gluttony => typeof(GluttonyStatusEffect), _ => null, }; } private static SmallSigilStatusEffectBehaviour GetBehaviour(PlayableCard card, SmallSigilType type, bool create) { if ((Object)(object)card == (Object)null) { return null; } Type behaviourType = GetBehaviourType(type); if (behaviourType == null) { return null; } SmallSigilStatusEffectBehaviour smallSigilStatusEffectBehaviour = ((Component)card).GetComponent(behaviourType) as SmallSigilStatusEffectBehaviour; if ((Object)(object)smallSigilStatusEffectBehaviour == (Object)null && create) { smallSigilStatusEffectBehaviour = ((Component)card).gameObject.AddComponent(behaviourType) as SmallSigilStatusEffectBehaviour; } return smallSigilStatusEffectBehaviour; } public static SmallSigilStatusEffectBehaviour GetBehaviourForRule(PlayableCard card, SmallSigilType type) { return GetBehaviour(card, type, create: false); } public static void RegisterCard(PlayableCard card) { } public static int GetStacks(PlayableCard card, SmallSigilType type) { SmallSigilStatusEffectBehaviour behaviour = GetBehaviour(card, type, create: false); if ((Object)(object)behaviour == (Object)null) { return 0; } return behaviour.EffectSeverity; } public static void AddStacks(PlayableCard card, SmallSigilType type, int amount) { if (!((Object)(object)card == (Object)null) && amount > 0) { SmallSigilStatusEffectBehaviour behaviour = GetBehaviour(card, type, create: true); if (!((Object)(object)behaviour == (Object)null)) { behaviour.AddSeverity(amount); SmallSigilRuleManager.RequestProcess(card); } } } public static bool RemoveStacks(PlayableCard card, SmallSigilType type, int amount) { if ((Object)(object)card == (Object)null || amount <= 0) { return false; } SmallSigilStatusEffectBehaviour behaviour = GetBehaviour(card, type, create: false); if ((Object)(object)behaviour == (Object)null) { return false; } if (behaviour.EffectSeverity < amount) { return false; } behaviour.SetSeverity(behaviour.EffectSeverity - amount); return true; } public static void SetStacks(PlayableCard card, SmallSigilType type, int amount) { if ((Object)(object)card == (Object)null) { return; } SmallSigilStatusEffectBehaviour behaviour = GetBehaviour(card, type, create: true); if (!((Object)(object)behaviour == (Object)null)) { behaviour.SetSeverity(amount); if (amount > 0) { SmallSigilRuleManager.RequestProcess(card); } } } public static void ClearStacks(PlayableCard card, SmallSigilType type) { if (!((Object)(object)card == (Object)null)) { SmallSigilStatusEffectBehaviour behaviour = GetBehaviour(card, type, create: false); if (!((Object)(object)behaviour == (Object)null)) { behaviour.SetSeverity(0); } } } public static void ClearCard(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { ClearStacks(card, SmallSigilType.Burning); ClearStacks(card, SmallSigilType.Poison); ClearStacks(card, SmallSigilType.Gluttony); } } public static void ClearAll() { } private static string GetCardName(PlayableCard card) { if ((Object)(object)card == (Object)null || (Object)(object)((Card)card).Info == (Object)null) { return "NULL"; } return ((Object)((Card)card).Info).name; } } public static class SmallSigilRuleManager { private class SmallSigilRule { public int Threshold; public int Consume; public SmallSigilCategory Category; public SmallSigilAttribute Attribute; public Func Effect; } private static readonly Dictionary Rules; private const float TriggerDelay = 0.4f; private static readonly HashSet ProcessingCards; private static readonly Dictionary BattleTriggerCounts; private static IEnumerator RunSmallSigilTriggerSequence(PlayableCard card, Ability ability) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)card == (Object)null)) { if ((Object)(object)Singleton.Instance != (Object)null) { Singleton.Instance.AbilitiesTriggeredThisTurn.Add(ability); } yield return card.OnAbilityTriggered(ability); } } static SmallSigilRuleManager() { Rules = new Dictionary(); ProcessingCards = new HashSet(); BattleTriggerCounts = new Dictionary(); RegisterRules(); } private static void RegisterRules() { Register(SmallSigilType.Burning, 2, 2, SmallSigilCategory.Debuff, SmallSigilAttribute.Fire, BurningEffect); Register(SmallSigilType.Poison, 4, 4, SmallSigilCategory.Debuff, SmallSigilAttribute.Poison, PoisonEffect); Register(SmallSigilType.Gluttony, 3, 3, SmallSigilCategory.Buff, SmallSigilAttribute.None, GluttonyEffect); } private static void Register(SmallSigilType type, int threshold, int consume, SmallSigilCategory category, SmallSigilAttribute attribute, Func effect) { Rules[type] = new SmallSigilRule { Threshold = threshold, Consume = consume, Category = category, Attribute = attribute, Effect = effect }; } public static void RequestProcess(PlayableCard card) { if (!((Object)(object)card == (Object)null) && !ProcessingCards.Contains(card) && HasTriggeredEffect(card)) { ProcessingCards.Add(card); SmallSigilStatusEffectBehaviour component = ((Component)card).GetComponent(); if ((Object)(object)component == (Object)null) { ProcessingCards.Remove(card); } else { ((MonoBehaviour)component).StartCoroutine(Process(card)); } } } public static bool HasTriggeredEffect(PlayableCard card) { if ((Object)(object)card == (Object)null) { return false; } foreach (KeyValuePair rule in Rules) { int stacks = SmallSigilManager.GetStacks(card, rule.Key); if (stacks >= rule.Value.Threshold) { return true; } } return false; } public static IEnumerator Process(PlayableCard card) { if ((Object)(object)card == (Object)null) { yield break; } if (!ProcessingCards.Contains(card)) { ProcessingCards.Add(card); } try { bool needsAnotherCheck = true; while ((Object)(object)card != (Object)null && needsAnotherCheck) { needsAnotherCheck = false; foreach (KeyValuePair pair in Rules) { if ((Object)(object)card == (Object)null) { yield break; } SmallSigilType type = pair.Key; SmallSigilRule rule = pair.Value; int stacks = SmallSigilManager.GetStacks(card, type); if (stacks < rule.Threshold) { continue; } int triggerCount = stacks / rule.Threshold; for (int i = 0; i < triggerCount; i++) { if ((Object)(object)card == (Object)null) { yield break; } int currentStacks = SmallSigilManager.GetStacks(card, type); if (currentStacks < rule.Threshold) { break; } SmallSigilStatusEffectBehaviour behaviour = SmallSigilManager.GetBehaviourForRule(card, type); if ((Object)(object)behaviour == (Object)null) { break; } yield return RunSmallSigilTriggerSequence(card, behaviour.IconAbilityInfo.ability); if ((Object)(object)card == (Object)null) { yield break; } currentStacks = SmallSigilManager.GetStacks(card, type); if (currentStacks < rule.Threshold || !SmallSigilManager.RemoveStacks(card, type, rule.Consume)) { break; } if (rule.Effect != null) { yield return rule.Effect(card); } if ((Object)(object)card == (Object)null) { yield break; } yield return null; } if ((Object)(object)card != (Object)null && SmallSigilManager.GetStacks(card, type) >= rule.Threshold) { needsAnotherCheck = true; } } if ((Object)(object)card != (Object)null && HasTriggeredEffect(card)) { needsAnotherCheck = true; } } } finally { ProcessingCards.Remove(card); } } private static IEnumerator BurningEffect(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { yield return card.TakeDamage(1, (PlayableCard)null); } } private static IEnumerator PoisonEffect(PlayableCard card) { if (!((Object)(object)card == (Object)null) && !card.HasAbility((Ability)105)) { yield return card.Die(false, (PlayableCard)null, true); } } private static IEnumerator GluttonyEffect(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { if (!BattleTriggerCounts.ContainsKey(card)) { BattleTriggerCounts.Add(card, 0); } BattleTriggerCounts[card]++; CardModificationInfo mod = new CardModificationInfo(); mod.attackAdjustment = 1; mod.healthAdjustment = 1; ((Card)card).Info.Mods.Add(mod); ((Card)card).RenderCard(); if (BattleTriggerCounts[card] >= 3) { yield return card.Die(false, (PlayableCard)null, true); } else { yield return null; } } } public static SmallSigilCategory GetCategory(SmallSigilType type) { if (Rules.TryGetValue(type, out var value)) { return value.Category; } return SmallSigilCategory.Debuff; } public static SmallSigilAttribute GetAttribute(SmallSigilType type) { if (Rules.TryGetValue(type, out var value)) { return value.Attribute; } return SmallSigilAttribute.None; } public static void ClearCard(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { BattleTriggerCounts.Remove(card); ProcessingCards.Remove(card); } } public static void ClearAll() { BattleTriggerCounts.Clear(); ProcessingCards.Clear(); } private static string GetCardName(PlayableCard card) { if ((Object)(object)card == (Object)null || (Object)(object)((Card)card).Info == (Object)null) { return "NULL"; } return ((Object)((Card)card).Info).name; } } public abstract class SmallSigilStatusEffectBehaviour : SpecialCardBehaviour { public abstract string CardModSingletonName { get; } protected string DisplayModSingletonName => CardModSingletonName + "_DISPLAY"; public virtual bool EffectCanBeInherited => false; public AbilityInfo IconAbilityInfo => SmallSigilStatusEffectManager.GetIconAbilityInfo(((object)this).GetType()); public int EffectSeverity { get; protected set; } protected virtual void Start() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null)) { AbilityInfo iconAbilityInfo = IconAbilityInfo; if (!((Object)(object)iconAbilityInfo == (Object)null)) { EffectSeverity = GetExistingSeverity(iconAbilityInfo.ability); SyncEffectMods(); } } } private int GetExistingSeverity(Ability ability) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_009a: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_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_0170: 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) if ((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null || (Object)(object)((Card)((SpecialCardBehaviour)this).PlayableCard).Info == (Object)null || (int)ability == 0) { return 0; } int num = 0; foreach (CardModificationInfo temporaryMod in ((SpecialCardBehaviour)this).PlayableCard.TemporaryMods) { if (temporaryMod == null || temporaryMod.singletonId != CardModSingletonName || temporaryMod.abilities == null) { continue; } foreach (Ability ability2 in temporaryMod.abilities) { if (ability2 == ability) { num++; } } } if (num > 0) { return num; } int num2 = 0; foreach (CardModificationInfo mod in ((Card)((SpecialCardBehaviour)this).PlayableCard).Info.Mods) { if (mod == null || mod.singletonId != DisplayModSingletonName || mod.abilities == null) { continue; } foreach (Ability ability3 in mod.abilities) { if (ability3 == ability) { num2++; } } } return num2; } public void AddSeverity(int amount) { if (!((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null) && amount > 0) { EffectSeverity += amount; SyncEffectMods(); } } public void SetSeverity(int amount) { if (!((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null)) { EffectSeverity = ((amount >= 0) ? amount : 0); SyncEffectMods(); } } private void SyncEffectMods() { if ((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null || (Object)(object)((Card)((SpecialCardBehaviour)this).PlayableCard).Info == (Object)null) { return; } RemoveTemporaryEffectMod(); RemoveDisplayEffectMod(); if (EffectSeverity <= 0) { ((SpecialCardBehaviour)this).PlayableCard.OnStatsChanged(); ((Card)((SpecialCardBehaviour)this).PlayableCard).RenderCard(); return; } CardModificationInfo val = CreateEffectMod(); if (val != null && val.abilities != null && val.abilities.Count > 0) { ((SpecialCardBehaviour)this).PlayableCard.AddTemporaryMod(val); } CardModificationInfo val2 = CreateDisplayMod(); if (val2 != null && val2.abilities != null && val2.abilities.Count > 0) { ((Card)((SpecialCardBehaviour)this).PlayableCard).Info.Mods.Add(val2); } ((SpecialCardBehaviour)this).PlayableCard.OnStatsChanged(); ((Card)((SpecialCardBehaviour)this).PlayableCard).RenderCard(); } private void RemoveTemporaryEffectMod() { if (!((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null)) { CardModificationInfo val = ((SpecialCardBehaviour)this).PlayableCard.TemporaryMods.Find((CardModificationInfo x) => x != null && x.singletonId == CardModSingletonName); if (val != null) { ((SpecialCardBehaviour)this).PlayableCard.RemoveTemporaryMod(val, true); } } } private void RemoveDisplayEffectMod() { if ((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null || (Object)(object)((Card)((SpecialCardBehaviour)this).PlayableCard).Info == (Object)null) { return; } List list = ((Card)((SpecialCardBehaviour)this).PlayableCard).Info.Mods.FindAll((CardModificationInfo x) => x != null && x.singletonId == DisplayModSingletonName); if (list.Count == 0) { return; } foreach (CardModificationInfo item in list) { ((Card)((SpecialCardBehaviour)this).PlayableCard).Info.Mods.Remove(item); } } private CardModificationInfo CreateEffectMod() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown CardModificationInfo val = new CardModificationInfo(); val.singletonId = CardModSingletonName; val.nonCopyable = true; AbilityInfo iconAbilityInfo = IconAbilityInfo; if ((Object)(object)iconAbilityInfo == (Object)null) { return val; } for (int i = 0; i < EffectSeverity; i++) { CardModificationInfoExtensions.AddAbilities(val, (Ability[])(object)new Ability[1] { (Ability)(int)iconAbilityInfo.ability }); } return val; } private CardModificationInfo CreateDisplayMod() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown CardModificationInfo val = new CardModificationInfo(); val.singletonId = DisplayModSingletonName; val.nonCopyable = true; AbilityInfo iconAbilityInfo = IconAbilityInfo; if ((Object)(object)iconAbilityInfo == (Object)null) { return val; } for (int i = 0; i < EffectSeverity; i++) { CardModificationInfoExtensions.AddAbilities(val, (Ability[])(object)new Ability[1] { (Ability)(int)iconAbilityInfo.ability }); } return val; } public void ClearDisplayMod() { if (!((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null) && !((Object)(object)((Card)((SpecialCardBehaviour)this).PlayableCard).Info == (Object)null)) { RemoveDisplayEffectMod(); ((SpecialCardBehaviour)this).PlayableCard.OnStatsChanged(); ((Card)((SpecialCardBehaviour)this).PlayableCard).RenderCard(); } } public void ClearAllEffectMods() { if (!((Object)(object)((SpecialCardBehaviour)this).PlayableCard == (Object)null) && !((Object)(object)((Card)((SpecialCardBehaviour)this).PlayableCard).Info == (Object)null)) { RemoveTemporaryEffectMod(); RemoveDisplayEffectMod(); EffectSeverity = 0; ((SpecialCardBehaviour)this).PlayableCard.OnStatsChanged(); ((Card)((SpecialCardBehaviour)this).PlayableCard).RenderCard(); } } } public static class SmallSigilStatusEffectManager { public const string SmallSigilProperty = "OLD_SA_SmallSigil"; private static readonly Dictionary Effects = new Dictionary(); private static readonly Dictionary IconTextures = new Dictionary(); public static void Initialize(string pluginGuid) { if (Effects.Count <= 0) { Register(pluginGuid, "Blaze", "Every 2 Blaze, the bearer takes 1 damage.", "OldSa_Blaze.png"); Register(pluginGuid, "Poison", "Every 4 Poison, the bearer dies.", "OldSa_Poison.png"); Register(pluginGuid, "Gluttony", "Every 3 Gluttony, the bearer gains 1 Power and 1 Health.After triggering 3 times in a battle, the bearer dies.", "OldSa_Gluttony.png"); } } private static void Register(string pluginGuid, string rulebookName, string rulebookDescription, string iconFile) where T : SmallSigilStatusEffectBehaviour { Texture2D imageAsTexture = TextureHelper.GetImageAsTexture(iconFile, (FilterMode)0); if (!((Object)(object)imageAsTexture == (Object)null)) { IconTextures[typeof(T)] = (Texture)(object)imageAsTexture; AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = rulebookName; val.rulebookName = rulebookName; FieldInfo field = typeof(AbilityInfo).GetField("rulebookDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, rulebookDescription); } val.metaCategories = new List { (AbilityMetaCategory)0 }; AbilityExtensions.SetCanStack(val, true, false); AbilityExtensions.SetPassive(val, true); AbilityExtensions.SetExtendedProperty(val, "OLD_SA_SmallSigil", (object)true); FullAbility val2 = AbilityManager.Add(pluginGuid, val, typeof(T), (Texture)(object)imageAsTexture); if (val2 != null) { Effects[typeof(T)] = val2.Info; } } } public static AbilityInfo GetIconAbilityInfo(Type behaviourType) { if (behaviourType == null) { return null; } if (Effects.TryGetValue(behaviourType, out var value)) { return value; } return null; } public static Ability GetIconAbility(Type behaviourType) { //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_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) AbilityInfo iconAbilityInfo = GetIconAbilityInfo(behaviourType); if ((Object)(object)iconAbilityInfo == (Object)null) { return (Ability)0; } return iconAbilityInfo.ability; } public static Texture GetIconTexture(Type behaviourType) { if (behaviourType == null) { return null; } if (IconTextures.TryGetValue(behaviourType, out var value)) { return value; } return null; } public static bool IsSmallSigilAbility(Ability ability) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((int)ability == 0) { return false; } AbilityInfo info = AbilitiesUtil.GetInfo(ability); if ((Object)(object)info == (Object)null) { return false; } return AbilityExtensions.GetExtendedPropertyAsBool(info, "OLD_SA_SmallSigil") == true; } } public enum SmallSigilCategory { Buff, Debuff } public enum SmallSigilAttribute { None, Fire, Poison } public class SmallSigilTriggerBehaviour : TriggerReceiver { private PlayableCard Card => ((Component)this).GetComponent(); public override bool RespondsToTakeDamage(PlayableCard source) { return (Object)(object)Card != (Object)null && SmallSigilRuleManager.HasTriggeredEffect(Card); } public override IEnumerator OnTakeDamage(PlayableCard source) { if (!((Object)(object)Card == (Object)null)) { yield return SmallSigilRuleManager.Process(Card); } } public override bool RespondsToCardGettingAttacked(PlayableCard source) { return false; } public override IEnumerator OnCardGettingAttacked(PlayableCard card) { yield break; } public override bool RespondsToTurnEnd(bool playerTurnEnd) { return false; } public override IEnumerator OnTurnEnd(bool playerTurnEnd) { yield break; } public override bool RespondsToDie(bool wasSacrifice, PlayableCard killer) { return false; } public override IEnumerator OnDie(bool wasSacrifice, PlayableCard killer) { yield break; } } public enum SmallSigilType { Burning, Poison, Gluttony }