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 BepInEx.Logging; using DiskCardGame; using HarmonyLib; using InscryptionAPI.Card; using InscryptionAPI.Helpers; using OLD_SA.Dialogue; 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("Blood Recompense")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Blood Recompense")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("cc6d3245-7eca-4c79-b54b-b4a2e4110b2f")] [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 BloodRecompense; public static class BloodRecompenseAPI { private static bool initialized = false; public const string DefaultSpawnCard = "Squirrel"; private static Dictionary DamageSources = new Dictionary(); public static void RegisterDamageSource(PlayableCard target, PlayableCard attacker) { if (!((Object)(object)target == (Object)null) && !((Object)(object)attacker == (Object)null)) { DamageSources[target] = attacker; } } public static bool WasKilledBy(PlayableCard dead, PlayableCard killer) { if ((Object)(object)dead == (Object)null || (Object)(object)killer == (Object)null) { return false; } if (DamageSources.TryGetValue(dead, out var value)) { return (Object)(object)value == (Object)(object)killer; } return false; } public static void ClearDamageSource(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { DamageSources.Remove(card); } } public static void Init() { if (!initialized) { BloodRecompenseBehaviour.Init(); initialized = true; } } public static bool HasBloodRecompense(CardInfo info) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)info == (Object)null) { return false; } return info.Abilities.Contains(BloodRecompenseBehaviour.ability); } public static BloodRecompenseResult GetResult(PlayableCard card) { if ((Object)(object)card == (Object)null) { return null; } string text = "Squirrel"; BloodRecompenseInfo bloodRecompenseInfo = ((Card)card).Info.GetBloodRecompenseInfo(); if (bloodRecompenseInfo != null && !string.IsNullOrEmpty(bloodRecompenseInfo.SpawnCard)) { text = bloodRecompenseInfo.SpawnCard; } CardInfo cardByName = CardLoader.GetCardByName(text); if ((Object)(object)cardByName == (Object)null) { return null; } return new BloodRecompenseResult(cardByName); } } public static class BloodRecompenseExtensions { private const string InfoKey = "OLD_SA.BloodRecompenseInfo"; public static void AddBloodRecompense(this CardInfo card) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0029: 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: Expected I4, but got Unknown if (!((Object)(object)card == (Object)null)) { if ((int)BloodRecompenseBehaviour.ability == 0) { BloodRecompenseAPI.Init(); } if (!card.Abilities.Contains(BloodRecompenseBehaviour.ability)) { CardExtensions.AddAbilities(card, (Ability[])(object)new Ability[1] { (Ability)(int)BloodRecompenseBehaviour.ability }); } } } public static void AddBloodRecompense(this CardInfo card, string spawnCard) { if (!((Object)(object)card == (Object)null)) { card.AddBloodRecompense(); if (!string.IsNullOrEmpty(spawnCard)) { card.SetBloodRecompenseInfo(new BloodRecompenseInfo(spawnCard)); } } } public static void SetBloodRecompenseInfo(this CardInfo card, BloodRecompenseInfo info) { if (!((Object)(object)card == (Object)null) && info != null && !string.IsNullOrEmpty(info.SpawnCard)) { CardExtensions.SetExtendedProperty(card, "OLD_SA.BloodRecompenseInfo", (object)info.SpawnCard); } } public static BloodRecompenseInfo GetBloodRecompenseInfo(this CardInfo card) { if ((Object)(object)card == (Object)null) { return null; } string extendedProperty = CardExtensions.GetExtendedProperty(card, "OLD_SA.BloodRecompenseInfo"); if (string.IsNullOrEmpty(extendedProperty)) { return null; } return new BloodRecompenseInfo(extendedProperty); } } public class BloodRecompenseInfo { public string SpawnCard { get; set; } public BloodRecompenseInfo(string card) { SpawnCard = card; } } public class BloodRecompenseResult { public CardInfo Card { get; set; } public int Count { get; set; } public BloodRecompenseResult(CardInfo card) { Card = card; Count = 1; } } [HarmonyPatch(typeof(PlayableCard), "TakeDamage")] public static class BloodRecompenseDamagePatch { public static void Prefix(PlayableCard __instance, int damage, PlayableCard attacker) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)attacker == (Object)null)) { BloodRecompenseAPI.RegisterDamageSource(__instance, attacker); } } } public static class BloodRecompenseManager { public static bool Processing; } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.oldsa.BloodRecompense", "OLD_SA_BloodRecompense", "1.0.0")] public class Plugin : BaseUnityPlugin { private static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"OLD_SA_BloodRecompense Mod loaded successfully."); BloodRecompenseBehaviour.Init(); Log.LogInfo((object)"Blood Recompense ability initialized."); } } public static class BloodRecompenseSpawnAPI { public static IEnumerator SpawnToHand(CardInfo card) { if (!((Object)(object)card == (Object)null)) { yield return Singleton.Instance.SpawnCardToHand(card, 0.5f); } } public static IEnumerator SpawnToHand(string cardName) { CardInfo card = CardLoader.GetCardByName(cardName); if (!((Object)(object)card == (Object)null)) { yield return SpawnToHand(card); } } } public class BloodRecompenseBehaviour : AbilityBehaviour { public static Ability ability; public override Ability Ability => ability; public static void Init() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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) AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "BloodRecompense"; val.rulebookName = "Blood Recompense"; Texture imageAsTexture = (Texture)(object)TextureHelper.GetImageAsTexture("OldSa_Blood_Recompense.png", (FilterMode)0); Texture2D imageAsTexture2 = TextureHelper.GetImageAsTexture("OldSa_Blood_Recompense_px.png", (FilterMode)0); val.pixelIcon = Sprite.Create(imageAsTexture2, new Rect(0f, 0f, (float)((Texture)imageAsTexture2).width, (float)((Texture)imageAsTexture2).height), new Vector2(0.5f, 0.5f)); FieldInfo field = typeof(AbilityInfo).GetField("rulebookDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, "When [creature] eliminates another creature, the owner gains a specific card in their hand."); } val.metaCategories = new List { (AbilityMetaCategory)0, (AbilityMetaCategory)2, (AbilityMetaCategory)1, (AbilityMetaCategory)3 }; val.powerLevel = 3; val.opponentUsable = false; FullAbility val2 = AbilityManager.Add("OLD_SA", val, typeof(BloodRecompenseBehaviour), imageAsTexture); ability = val2.Id; Debug.Log((object)("Blood Recompense ability registered ID=" + ((object)Unsafe.As(ref ability)/*cast due to .constrained prefix*/).ToString())); } public override bool RespondsToOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer) { return (Object)(object)killer == (Object)(object)((AbilityBehaviour)this).Card; } public override IEnumerator OnOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer) { yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence(); BloodRecompenseResult result = BloodRecompenseAPI.GetResult(((AbilityBehaviour)this).Card); if (result != null && !((Object)(object)result.Card == (Object)null)) { CardInfo spawn = (CardInfo)result.Card.Clone(); ModifySpawnedCard(spawn); yield return BloodRecompenseSpawnAPI.SpawnToHand(spawn); Singleton.Instance.SwitchToView((View)0, false, false); yield return (object)new WaitForSeconds(0.5f); yield return SigilDialogueAPI.ShowFirstTime("BloodRecompense", "A new cycle begins... Even death can give birth to new life."); if ((Object)(object)card != (Object)null) { BloodRecompenseAPI.ClearDamageSource(card); } Singleton.Instance.SwitchToView((View)4, false, false); } } private void ModifySpawnedCard(CardInfo card) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown List list = new List(((Card)((AbilityBehaviour)this).Card).Info.Abilities); foreach (CardModificationInfo temporaryMod in ((AbilityBehaviour)this).Card.TemporaryMods) { list.AddRange(temporaryMod.abilities); } list.RemoveAll((Ability x) => x == ability); if (list.Count != 0) { CardModificationInfo val = new CardModificationInfo(); val.fromCardMerge = true; val.abilities = list; card.Mods.Add(val); } } }