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 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_Pitfall_Trap_sigil")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Pitfall_Trap_sigil")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b5f5bff9-b1b2-4cb1-9e58-784a743b478b")] [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.PitfallTrap; public static class PitfallTrapAPI { public static FullAbility ability; public static void Init() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "Pitfall Trap"; val.rulebookName = "Pitfall Trap"; val.metaCategories = new List { (AbilityMetaCategory)0, (AbilityMetaCategory)1 }; val.powerLevel = 2; val.opponentUsable = true; val.canStack = false; Texture imageAsTexture = (Texture)(object)TextureHelper.GetImageAsTexture("OldSa_Pitfall_Trap.png", (FilterMode)0); Texture2D imageAsTexture2 = TextureHelper.GetImageAsTexture("OldSa_Pitfall_Trap_px.png", (FilterMode)0); if ((Object)(object)imageAsTexture2 != (Object)null) { 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] is attacked by an Insect, it takes no damage and kills the attacker. It gains 1 Power and 1 Health."); } ability = AbilityManager.Add("OLD_SA", val, typeof(PitfallTrapBehaviour), imageAsTexture); } } public class PitfallTrapBehaviour : AbilityBehaviour { public override Ability Ability => PitfallTrapAPI.ability.Id; public IEnumerator TriggerPitfall(PlayableCard attacker) { if (!((Object)(object)((AbilityBehaviour)this).Card == (Object)null) && !((AbilityBehaviour)this).Card.Dead && !((Object)(object)attacker == (Object)null) && !attacker.Dead) { yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence(); if (!((Object)(object)((AbilityBehaviour)this).Card == (Object)null) && !((AbilityBehaviour)this).Card.Dead && !((Object)(object)attacker == (Object)null) && !attacker.Dead) { yield return attacker.Die(false, ((AbilityBehaviour)this).Card, true); CardModificationInfo bonus = new CardModificationInfo { attackAdjustment = 1, healthAdjustment = 1, singletonId = "OLD_SA_PitfallTrap_Bonus_" + Guid.NewGuid() }; ((AbilityBehaviour)this).Card.AddTemporaryMod(bonus); ((AbilityBehaviour)this).Card.OnStatsChanged(); ((Card)((AbilityBehaviour)this).Card).RenderCard(); ((AbilityBehaviour)this).Card.UpdateFaceUpOnBoardEffects(); } } } } internal static class PitfallTrapAttackContext { internal static PlayableCard AttackingCard; internal static PlayableCard TargetCard; internal static void Set(PlayableCard attackingCard, PlayableCard targetCard) { AttackingCard = attackingCard; TargetCard = targetCard; } internal static void Clear() { AttackingCard = null; TargetCard = null; } } [HarmonyPatch(typeof(CombatPhaseManager), "SlotAttackSlot")] internal static class PitfallTrap_SlotAttackSlot_Patch { [HarmonyPostfix] private static void Postfix(CardSlot attackingSlot, CardSlot opposingSlot, ref IEnumerator __result) { if (__result != null) { PlayableCard attackingCard = (((Object)(object)attackingSlot != (Object)null) ? attackingSlot.Card : null); PlayableCard targetCard = (((Object)(object)opposingSlot != (Object)null) ? opposingSlot.Card : null); __result = WrapAttackCoroutine(__result, attackingCard, targetCard); } } private static IEnumerator WrapAttackCoroutine(IEnumerator original, PlayableCard attackingCard, PlayableCard targetCard) { try { while (true) { PitfallTrapAttackContext.Set(attackingCard, targetCard); bool hasNext; try { hasNext = original.MoveNext(); } finally { PitfallTrapAttackContext.Clear(); } if (!hasNext) { break; } yield return original.Current; } } finally { PitfallTrapAttackContext.Clear(); } } } [HarmonyPatch(typeof(PlayableCard), "TakeDamage")] public static class PitfallTrapPatch { [HarmonyPrefix] public static bool Prefix(PlayableCard __instance, int damage, PlayableCard attacker, ref IEnumerator __result) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return true; } if ((Object)(object)attacker == (Object)null) { return true; } if ((Object)(object)PitfallTrapAttackContext.AttackingCard == (Object)null || (Object)(object)PitfallTrapAttackContext.TargetCard == (Object)null) { return true; } if ((Object)(object)attacker != (Object)(object)PitfallTrapAttackContext.AttackingCard) { return true; } if ((Object)(object)__instance != (Object)(object)PitfallTrapAttackContext.TargetCard) { return true; } if (__instance.Dead) { return true; } if (!__instance.HasAbility(PitfallTrapAPI.ability.Id)) { return true; } if ((Object)(object)((Card)attacker).Info == (Object)null || ((Card)attacker).Info.tribes == null || !((Card)attacker).Info.tribes.Contains((Tribe)6)) { return true; } PitfallTrapBehaviour pitfallBehaviour = GetPitfallBehaviour(__instance); if ((Object)(object)pitfallBehaviour == (Object)null) { return true; } __result = pitfallBehaviour.TriggerPitfall(attacker); return false; } private static PitfallTrapBehaviour GetPitfallBehaviour(PlayableCard card) { if ((Object)(object)card == (Object)null) { return null; } AbilityBehaviour[] components = ((Component)card).GetComponents(); if (components == null) { return null; } AbilityBehaviour[] array = components; foreach (AbilityBehaviour val in array) { PitfallTrapBehaviour pitfallTrapBehaviour = val as PitfallTrapBehaviour; if ((Object)(object)pitfallTrapBehaviour != (Object)null) { return pitfallTrapBehaviour; } } return null; } } [BepInPlugin("OLD_SA.PitfallTrap", "OLD SA Pitfall Trap", "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 PitfallTrapAPI.Init(); Harmony val = new Harmony("OLD_SA.PitfallTrap"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"OLD SA Pitfall Trap loaded."); } }