using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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_Hive Will_sigil")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Hive Will_sigil")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("014ad8de-ec23-4e3d-82f6-36fbdce503a7")] [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.HiveWill; public static class HiveWillAPI { public static FullAbility ability; public unsafe static void Init() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "HiveWill"; val.rulebookName = "Hive Will"; val.metaCategories = new List { (AbilityMetaCategory)0 }; Texture imageAsTexture = (Texture)(object)TextureHelper.GetImageAsTexture("OldSa_Hive_Will.png", (FilterMode)0); Texture2D imageAsTexture2 = TextureHelper.GetImageAsTexture("OldSa_Hive_Will_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 a specific card is played on [creature], they fuse with each other."); } val.opponentUsable = false; val.powerLevel = 0; ability = AbilityManager.Add("OLD_SA", val, typeof(HiveWillBehaviour), imageAsTexture); Ability id = ability.Id; Debug.Log((object)("HiveWill registered ID=" + ((object)(*(Ability*)(&id))/*cast due to .constrained prefix*/).ToString())); } } public static class HiveWillAssets { public static Sprite LoadSprite(string name) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Texture2D imageAsTexture = TextureHelper.GetImageAsTexture(name, (FilterMode)0); if ((Object)(object)imageAsTexture == (Object)null) { return null; } return Sprite.Create(imageAsTexture, new Rect(0f, 0f, (float)((Texture)imageAsTexture).width, (float)((Texture)imageAsTexture).height), new Vector2(0.5f, 0.5f)); } } public static class HiveWillAudio { public static AudioClip LoadBuzz() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown string text = Path.Combine(Path.GetDirectoryName(typeof(HiveWillAudio).Assembly.Location), "Audio", "hive_buzz.wav"); if (!File.Exists(text)) { return null; } WWW val = new WWW("file:///" + text); while (!val.isDone) { } return val.GetAudioClip(false, false); } } public class HiveWillBehaviour : AbilityBehaviour { public override Ability Ability => HiveWillAPI.ability.Id; } [HarmonyPatch(typeof(TurnManager), "set_GameEnded")] public static class HiveWillCombatEndPatch { public static void Postfix(bool value) { if (value) { Debug.Log((object)"HiveWill Combat End Clear Trigger"); HiveWillTemporaryManager.Clear(); } } } public class HiveWillIconShake : MonoBehaviour { private float angle = 4f; private float speed = 35f; private Quaternion startRotation; public void StartShake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) startRotation = ((Component)this).transform.localRotation; } private void Update() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sin(Time.time * speed) * angle; ((Component)this).transform.localRotation = startRotation * Quaternion.Euler(0f, 0f, num); } } public static class HiveWillManager { public static IEnumerator Merge(PlayableCard host, PlayableCard material) { if ((Object)(object)host == (Object)null || (Object)(object)material == (Object)null) { HiveWillPatch.Merging = false; yield break; } CardModificationInfo statMod = new CardModificationInfo(); statMod.attackAdjustment = material.Attack; statMod.healthAdjustment = material.Health; statMod.fromCardMerge = true; host.AddTemporaryMod(statMod); if (ShouldInherit(host)) { InheritAbilities(host, material); } Singleton.Instance.RemoveCardFromHand(material); ((Component)material).gameObject.SetActive(false); yield return (object)new WaitForSeconds(0.2f); ((Card)host).Anim.PlayTransformAnimation(); yield return (object)new WaitForSeconds(0.8f); ((Card)host).RenderCard(); try { yield return SigilDialogueAPI.ShowFirstTime("HiveWill", "She shall lead her swarm to victory.", host); } finally { HiveWillSelectionPatch.DisableFlying(); ((Card)host).Anim.SetSelectedToPlay(false); HiveWillPatch.Merging = false; Singleton.Instance.SwitchToView((View)0, false, false); } } private static bool ShouldInherit(PlayableCard host) { string extendedProperty = CardExtensions.GetExtendedProperty(((Card)host).Info, "OLD_SA.HiveWillInherit"); if (extendedProperty == "false") { return false; } return true; } private static void InheritAbilities(PlayableCard host, PlayableCard material) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (CardModificationInfo mod in ((Card)material).Info.Mods) { if (mod.abilities == null || !mod.fromCardMerge) { continue; } foreach (Ability ability in mod.abilities) { if (!host.HasAbility(ability) && !list.Contains(ability)) { list.Add(ability); } } } if (list.Count != 0) { CardModificationInfo val = new CardModificationInfo(); val.abilities = new List(list); val.fromCardMerge = true; val.singletonId = "OLD_SA_HIVEWILL"; Debug.Log((object)("HiveWill Add Temporary Mod: " + ((Object)((Card)host).Info).name + " ID=" + val.singletonId + " Abilities=" + string.Join(",", list))); host.AddTemporaryMod(val); CardModificationInfo val2 = new CardModificationInfo(); val2.abilities = new List(list); val2.fromCardMerge = true; val2.singletonId = "OLD_SA_HIVEWILL"; ((Card)host).Info.Mods.Add(val2); Debug.Log((object)("HiveWill Add Display Mod: " + ((Object)((Card)host).Info).name + " ID=" + val2.singletonId)); HiveWillTemporaryManager.Register(host); host.OnStatsChanged(); ((Card)host).RenderCard(); } } } [HarmonyPatch(typeof(BoardManager))] public static class HiveWillPatch { public static bool Merging; [HarmonyPatch("ChooseSlot")] [HarmonyPrefix] public static void ChooseSlotPrefix(List validSlots) { if (validSlots == null) { return; } PlayableCard choosingSlotCard = Singleton.Instance.ChoosingSlotCard; if ((Object)(object)choosingSlotCard == (Object)null) { return; } foreach (CardSlot item in Singleton.Instance.PlayerSlotsCopy) { if (!((Object)(object)item.Card == (Object)null)) { PlayableCard card = item.Card; if (HasHiveWill(card) && IsHiveWillTarget(card, choosingSlotCard) && !validSlots.Contains(item)) { validSlots.Add(item); } } } } [HarmonyPatch("OnSlotSelected")] [HarmonyPrefix] public static bool OnSlotSelectedPrefix(CardSlot slot) { if (Merging) { return false; } if ((Object)(object)slot == (Object)null) { return true; } if ((Object)(object)slot.Card == (Object)null) { return true; } PlayableCard card = slot.Card; if (!HasHiveWill(card)) { return true; } PlayableCard choosingSlotCard = Singleton.Instance.ChoosingSlotCard; if ((Object)(object)choosingSlotCard == (Object)null) { return true; } if (!IsHiveWillTarget(card, choosingSlotCard)) { return true; } Merging = true; HiveWillSelectionPatch.DisableFlying(); Singleton.Instance.SwitchToView((View)4, false, false); ((MonoBehaviour)card).StartCoroutine(HiveWillManager.Merge(card, choosingSlotCard)); return false; } private static bool IsHiveWillTarget(PlayableCard host, PlayableCard card) { string text = CardExtensions.GetExtendedProperty(((Card)host).Info, "OLD_SA.HiveWillTarget"); if (string.IsNullOrEmpty(text)) { text = "Squirrel"; } return ((Object)((Card)card).Info).name == text; } private static bool HasHiveWill(PlayableCard card) { //IL_0011: 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) if (((Card)card).Info.Abilities.Contains(HiveWillAPI.ability.Id)) { return true; } foreach (CardModificationInfo temporaryMod in card.TemporaryMods) { if (temporaryMod.abilities.Contains(HiveWillAPI.ability.Id)) { return true; } } return false; } } public static class HiveWillSelectionEffect { private static GameObject currentIcon; public static void Show(PlayableCard card) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)card == (Object)null) && !((Object)(object)currentIcon != (Object)null)) { Sprite val = HiveWillAssets.LoadSprite("HiveIcon.png"); if ((Object)(object)val == (Object)null) { Debug.Log((object)"Missing HiveIcon"); return; } currentIcon = new GameObject("HiveWillIcon"); currentIcon.transform.position = ((Component)card).transform.position + new Vector3(0f, 0.8f, 0f); currentIcon.transform.rotation = Quaternion.Euler(90f, 0f, 0f); SpriteRenderer val2 = currentIcon.AddComponent(); val2.sprite = val; ((Renderer)val2).sortingOrder = 999; HiveWillIconShake hiveWillIconShake = currentIcon.AddComponent(); hiveWillIconShake.StartShake(); } } public static void Hide() { if ((Object)(object)currentIcon != (Object)null) { Object.Destroy((Object)(object)currentIcon); } currentIcon = null; } public static bool IsShowing() { return (Object)(object)currentIcon != (Object)null; } } public static class HiveWillSelectionManager { public static PlayableCard Material; public static PlayableCard Target; public static bool Choosing; public static void StartSelection(PlayableCard material, PlayableCard target) { Material = material; Target = target; Choosing = true; if ((Object)(object)Target != (Object)null && (Object)(object)((Card)Target).Anim != (Object)null) { ((Card)Target).Anim.SetSelectedToPlay(true); } } public static void Finish() { if (!((Object)(object)Material == (Object)null) && !((Object)(object)Target == (Object)null)) { ((MonoBehaviour)Target).StartCoroutine(HiveWillManager.Merge(Target, Material)); Choosing = false; Material = null; Target = null; } } private static bool IsHiveWillTarget(PlayableCard host, PlayableCard card) { string text = CardExtensions.GetExtendedProperty(((Card)host).Info, "OLD_SA.HiveWillTarget"); if (string.IsNullOrEmpty(text)) { text = "Squirrel"; } return ((Object)((Card)card).Info).name == text; } private static void InheritAbilities(PlayableCard host, PlayableCard material) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"=== HiveWill Ability Inherit ==="); Debug.Log((object)("Material: " + ((Object)((Card)material).Info).name)); Debug.Log((object)("TemporaryMods Count: " + material.TemporaryMods.Count)); HashSet hashSet = new HashSet(); foreach (CardModificationInfo temporaryMod in material.TemporaryMods) { if (temporaryMod.abilities == null) { continue; } Debug.Log((object)("Found Mod Abilities: " + string.Join(", ", temporaryMod.abilities))); foreach (Ability ability in temporaryMod.abilities) { hashSet.Add(ability); } } hashSet.Remove(HiveWillAPI.ability.Id); if (hashSet.Count == 0) { Debug.Log((object)"No extra abilities found."); return; } CardModificationInfo val = new CardModificationInfo(); val.fromCardMerge = true; val.abilities = new List(hashSet); host.AddTemporaryMod(val); } } [HarmonyPatch(typeof(PlayerHand))] public static class HiveWillSelectionPatch { private static HashSet ActiveCards = new HashSet(); [HarmonyPatch("ManagedUpdate")] [HarmonyPostfix] public static void UpdateCheck() { PlayerHand instance = Singleton.Instance; if (!((Object)(object)instance == (Object)null)) { if ((Object)(object)instance.ChoosingSlotCard != (Object)null) { CheckHiveWill(instance.ChoosingSlotCard); } else { DisableFlying(); } } } private static void CheckHiveWill(PlayableCard material) { HashSet hashSet = new HashSet(); foreach (CardSlot item in Singleton.Instance.PlayerSlotsCopy) { if ((Object)(object)item.Card == (Object)null) { continue; } PlayableCard card = item.Card; if (HasHiveWill(card)) { string text = CardExtensions.GetExtendedProperty(((Card)card).Info, "OLD_SA.HiveWillTarget"); if (string.IsNullOrEmpty(text)) { text = "Squirrel"; } if (!(((Object)((Card)material).Info).name != text)) { hashSet.Add(card); EnableFlying(card); } } } foreach (PlayableCard item2 in new List(ActiveCards)) { if (!hashSet.Contains(item2)) { RemoveFlying(item2); } } } private static void EnableFlying(PlayableCard card) { if (!ActiveCards.Contains(card)) { HiveWillSelectionEffect.Show(card); ActiveCards.Add(card); } } private static void RemoveFlying(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { HiveWillSelectionEffect.Hide(); ActiveCards.Remove(card); } } public static void DisableFlying() { foreach (PlayableCard item in new List(ActiveCards)) { RemoveFlying(item); } } private static bool HasHiveWill(PlayableCard card) { //IL_0011: 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) if (((Card)card).Info.Abilities.Contains(HiveWillAPI.ability.Id)) { return true; } foreach (CardModificationInfo temporaryMod in card.TemporaryMods) { if (temporaryMod.abilities.Contains(HiveWillAPI.ability.Id)) { return true; } } return false; } } public static class HiveWillTemporaryManager { private static List Cards = new List(); public static void Register(PlayableCard card) { if (!((Object)(object)card == (Object)null) && !((Object)(object)((Card)card).Info == (Object)null)) { Debug.Log((object)("HiveWill Register CardInfo = " + ((Object)((Card)card).Info).name)); if (!Cards.Contains(((Card)card).Info)) { Cards.Add(((Card)card).Info); } } } public static void Clear() { Debug.Log((object)("HiveWill Clear Start Count = " + Cards.Count)); foreach (CardInfo card in Cards) { if (!((Object)(object)card == (Object)null)) { Debug.Log((object)("HiveWill Clearing CardInfo = " + ((Object)card).name)); int count = card.Mods.Count; card.Mods.RemoveAll((CardModificationInfo x) => x.singletonId == "OLD_SA_HIVEWILL"); int count2 = card.Mods.Count; Debug.Log((object)("HiveWill Remove Display Mods: " + (count - count2))); } } Cards.Clear(); Debug.Log((object)"HiveWill Clear Finished"); } } [BepInPlugin("OLD_SA.HiveWill", "OLD_SA Hive Will", "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 HiveWillAPI.Init(); Harmony val = new Harmony("OLD_SA.HiveWill"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"OLD_SA Hive Will Loaded"); } }