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 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("OldSa_Ring Fort_sigil")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Ring Fort_sigil")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c7d3d1e4-a719-44a4-9bbf-73e52029f5e9")] [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.RingFort; [BepInPlugin("oldsa.ringfort", "Old SA Ring Fort", "1.0.0")] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown RingFortAPI.Init(); Harmony val = new Harmony("oldsa.ringfort"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Old SA Ring Fort Loaded"); } } public class RingFortBehaviour : AbilityBehaviour { public override Ability Ability => RingFortAPI.ability.Id; public IEnumerator TriggerFirstDialogue() { yield return SigilDialogueAPI.ShowFirstTime("RingFort", "A pitiful creature... yet this time, it managed to protect everything.", ((AbilityBehaviour)this).Card); } } public class RingFortAPI { public static FullAbility ability; public unsafe static void Init() { //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) AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "RingFort"; val.rulebookName = "Ring Fort"; val.powerLevel = 5; val.metaCategories = new List { (AbilityMetaCategory)0 }; FieldInfo field = typeof(AbilityInfo).GetField("rulebookDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, "When [creature] takes damage, it intercepts the attack and reduces that damage by 1."); } Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("OldSa_Ring_Fort.png", (FilterMode)0); ability = AbilityManager.Add("OLD_SA", val, typeof(RingFortBehaviour), (Texture)(object)imageAsTexture); Ability id = ability.Id; Debug.Log((object)("Ring Fort registered ID = " + ((object)(*(Ability*)(&id))/*cast due to .constrained prefix*/).ToString())); } } [HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSlot")] public class RingFortPatch { public static PlayableCard redirectedCard; public static void Prefix(CardSlot attackingSlot, ref CardSlot opposingSlot, float waitAfter) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) redirectedCard = null; if ((Object)(object)attackingSlot == (Object)null || (Object)(object)opposingSlot == (Object)null || (Object)(object)attackingSlot.Card == (Object)null) { return; } List list = ((!attackingSlot.IsPlayerSlot) ? Singleton.Instance.PlayerSlotsCopy : Singleton.Instance.OpponentSlotsCopy); foreach (CardSlot item in list) { if ((Object)(object)item.Card == (Object)null || !item.Card.HasAbility(RingFortAPI.ability.Id)) { continue; } redirectedCard = item.Card; opposingSlot = item; break; } } } [HarmonyPatch(typeof(PlayableCard), "TakeDamage")] public class RingFortDamagePatch { public static void Prefix(PlayableCard __instance, ref int damage) { if ((Object)(object)__instance == (Object)null || !((Object)(object)__instance == (Object)(object)RingFortPatch.redirectedCard)) { return; } int num = damage; damage = Mathf.Max(0, damage - 1); if (num > damage && !SigilDialogueSaveData.HasTriggered("RingFort")) { RingFortBehaviour component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { ((MonoBehaviour)__instance).StartCoroutine(component.TriggerFirstDialogue()); } } } } [HarmonyPatch(typeof(PlayableCard), "CanAttackDirectly")] public class RingFortDirectAttackPatch { public static bool Prefix(PlayableCard __instance, CardSlot opposingSlot, ref bool __result) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return true; } if ((Object)(object)opposingSlot == (Object)null) { return true; } if ((Object)(object)opposingSlot.Card != (Object)null && opposingSlot.Card.HasAbility(RingFortAPI.ability.Id)) { Debug.Log((object)"Ring Fort blocks direct attack"); __result = false; return false; } return true; } }