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.Pelt; 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_Incorporal_sigil")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Incorporal_sigil")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("56dcff78-f765-498f-811c-982c4a8a5935")] [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.Incorporal; public static class IncorporalAPI { public static FullAbility ability; public static void Init() { AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "Incorporal"; val.rulebookName = "Incorporal"; val.metaCategories = new List { (AbilityMetaCategory)0, (AbilityMetaCategory)1 }; val.powerLevel = 3; val.opponentUsable = true; val.canStack = false; Texture imageAsTexture = (Texture)(object)TextureHelper.GetImageAsTexture("OldSa_Incorporal.png", (FilterMode)0); FieldInfo field = typeof(AbilityInfo).GetField("rulebookDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, "When [creature] is on the board, it cannot be hit, and it cannot hit enemies."); } ability = AbilityManager.Add("OLD_SA", val, typeof(IncorporalBehaviour), imageAsTexture); } } public class IncorporalBehaviour : AbilityBehaviour { public override Ability Ability => IncorporalAPI.ability.Id; public override bool RespondsToResolveOnBoard() { return true; } public override IEnumerator OnResolveOnBoard() { yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence(); IncorporalState state = IncorporalState.GetOrCreate(((AbilityBehaviour)this).Card); if ((Object)(object)state != (Object)null) { state.Apply((Component)(object)this); } } } [HarmonyPatch(typeof(PlayableCard), "CanAttackDirectly")] public static class IncorporalDirectAttackPatch { [HarmonyPostfix] private static void Postfix(PlayableCard __instance, CardSlot opposingSlot, ref bool __result) { if ((Object)(object)__instance == (Object)null || (Object)(object)opposingSlot == (Object)null) { return; } PlayableCard card = opposingSlot.Card; if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Info != (Object)null && ((Card)card).Info.traits.Contains((Trait)16)) { return; } IncorporalState component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && component.IsIncorporal) { __result = true; } else if ((Object)(object)card != (Object)null) { IncorporalState component2 = ((Component)card).GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsIncorporal) { __result = true; } } } } public class IncorporalState : MonoBehaviour { private PlayableCard card; private readonly HashSet sources = new HashSet(); public bool IsIncorporal => sources.Count > 0; private void Awake() { card = ((Component)this).GetComponent(); } public static IncorporalState GetOrCreate(PlayableCard card) { if ((Object)(object)card == (Object)null) { return null; } IncorporalState incorporalState = ((Component)card).GetComponent(); if ((Object)(object)incorporalState == (Object)null) { incorporalState = ((Component)card).gameObject.AddComponent(); } return incorporalState; } public void Apply(Component source) { if (!((Object)(object)source == (Object)null)) { if ((Object)(object)card == (Object)null) { card = ((Component)this).GetComponent(); } if (!((Object)(object)card == (Object)null) && sources.Add(source) && sources.Count == 1) { EnableGhost(); } } } public void Remove(Component source) { if (!((Object)(object)source == (Object)null) && sources.Remove(source) && sources.Count <= 0) { DisableGhost(); } } private void EnableGhost() { if (!((Object)(object)card == (Object)null)) { GhostCard.Apply(card); } } private void DisableGhost() { if (!((Object)(object)card == (Object)null)) { GhostCard.Remove(card); } } private void OnDestroy() { } } [BepInPlugin("OLD_SA.Incorporal", "OLD SA Incorporal", "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 IncorporalAPI.Init(); Harmony val = new Harmony("OLD_SA.Incorporal"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"OLD SA Incorporal loaded."); } }