using System; 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.Blessing; 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_Wind's Blessing_sigil")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Wind's Blessing_sigil")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3c5c93e4-53b2-4569-b21f-e6bb56856b02")] [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.WindsBlessing; [BepInPlugin("OLD_SA.WindsBlessing", "OLD SA Wind's Blessing", "1.0.0")] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"OLD SA Wind's Blessing Loaded"); WindBlessingAPI.Init(); WindBlessingAudio.Init(); Harmony val = new Harmony("OLD_SA.WindsBlessing"); val.PatchAll(); } } public class WindBlessingAPI { public static FullAbility ability; public static void Init() { AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "WindsBlessing"; val.rulebookName = "Wind's Blessing"; val.powerLevel = 5; Texture2D imageAsTexture = TextureHelper.GetImageAsTexture("OldSa_Winds_Blessing.png", (FilterMode)0); ability = AbilityManager.Add("OLD_SA", val, typeof(WindBlessingBehaviour), (Texture)(object)imageAsTexture); val.metaCategories = new List { (AbilityMetaCategory)0 }; FieldInfo field = typeof(AbilityInfo).GetField("rulebookDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, "At the start of the turn, [creature] grants Wind Blessing to itself and adjacent creatures."); } } } public static class WindBlessingAssets { public static Sprite LoadSprite(string name) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) { Debug.Log((object)("Missing artwork: " + name)); 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 WindBlessingAudio { private static AudioClip windSound; private static AudioClip pterosaurRoar; public static void Init() { Debug.Log((object)"Loading Wind Blessing Audio..."); windSound = LoadAudio("old_sa_wind.wav"); pterosaurRoar = LoadAudio("old_sa_pterosaur_roar.wav"); Debug.Log((object)("Wind sound = " + (object)windSound)); Debug.Log((object)("Pterosaur roar = " + (object)pterosaurRoar)); } public static void PlayWind(Vector3 position) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"Playing wind sound"); if ((Object)(object)windSound == (Object)null) { Debug.Log((object)"Wind sound missing"); } else { PlayClip(windSound, position); } } public static void PlayPterosaurRoar(Vector3 position) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"Playing pterosaur roar"); if ((Object)(object)pterosaurRoar == (Object)null) { Debug.Log((object)"Pterosaur roar missing"); } else { PlayClip(pterosaurRoar, position); } } private static void PlayClip(AudioClip clip, Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("WindBlessingAudio"); val.transform.position = position; AudioSource val2 = val.AddComponent(); val2.clip = clip; val2.volume = 1f; Debug.Log((object)("Audio length:" + clip.length)); val2.spatialBlend = 0f; val2.Play(); Object.Destroy((Object)(object)val, clip.length + 0.2f); } private static AudioClip LoadAudio(string fileName) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown Debug.Log((object)("LoadAudio called: " + fileName)); string text = Path.Combine(Path.GetDirectoryName(typeof(WindBlessingAudio).Assembly.Location), "Audio", fileName); if (!File.Exists(text)) { Debug.Log((object)("Missing audio: " + text)); return null; } WWW val = new WWW("file:///" + text); while (!val.isDone) { } if (!string.IsNullOrEmpty(val.error)) { Debug.Log((object)("Audio load error: " + val.error)); return null; } AudioClip audioClip = val.GetAudioClip(false, false); if ((Object)(object)audioClip == (Object)null) { Debug.Log((object)("AudioClip creation failed: " + fileName)); return null; } Debug.Log((object)("Loaded audio " + fileName + " length=" + audioClip.length)); return audioClip; } } public class WindBlessingBehaviour : AbilityBehaviour { private bool windBlessingTriggered; public override Ability Ability => WindBlessingAPI.ability.Id; public override bool RespondsToUpkeep(bool playerUpkeep) { return playerUpkeep; } public override IEnumerator OnUpkeep(bool playerUpkeep) { windBlessingTriggered = true; yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence(); Singleton.Instance.SwitchToView((View)4, false, false); if (ShouldUseWindPortrait()) { yield return WindBlessingPterosaurPortraitSwitch.SwitchToStage1(((AbilityBehaviour)this).Card); } CardSlot leftSlot = GetAdjacentSlot(-1); if ((Object)(object)leftSlot != (Object)null && (Object)(object)leftSlot.Card != (Object)null) { yield return TriggerWindBlessing(leftSlot.Card); } yield return (object)new WaitForSeconds(0.15f); if (ShouldUseWindPortrait()) { yield return WindBlessingPterosaurPortraitSwitch.SwitchToStage2(((AbilityBehaviour)this).Card); } CardSlot rightSlot = GetAdjacentSlot(1); if ((Object)(object)rightSlot != (Object)null && (Object)(object)rightSlot.Card != (Object)null) { yield return TriggerWindBlessing(rightSlot.Card); } yield return (object)new WaitForSeconds(0.25f); yield return TriggerSelfWindBlessing(); yield return SigilDialogueAPI.ShowFirstTime("WindBlessing", "It spreads its wings, sending creatures soaring into the sky.", ((AbilityBehaviour)this).Card); while (WindBlessingEffect.ActiveWindIcons > 0) { yield return null; } Singleton.Instance.SwitchToView((View)1, false, false); } private IEnumerator TriggerWindBlessing(PlayableCard target) { if (!((Object)(object)target == (Object)null) && !target.HasAbility((Ability)19)) { yield return WindBlessingEffect.Play(target); yield return GiveWindBlessing(target); } } private IEnumerator TriggerSelfWindBlessing() { if (!((Object)(object)((AbilityBehaviour)this).Card == (Object)null) && !((AbilityBehaviour)this).Card.HasAbility((Ability)19)) { if (ShouldUseWindPortrait()) { yield return WindBlessingPterosaurPortraitSwitch.SwitchToStage3(((AbilityBehaviour)this).Card); } yield return WindBlessingEffect.Play(((AbilityBehaviour)this).Card, selfCast: true); yield return GiveWindBlessing(((AbilityBehaviour)this).Card); } } private bool ShouldUseWindPortrait() { return windBlessingTriggered && (Object)(object)((AbilityBehaviour)this).Card != (Object)null && (Object)(object)((Card)((AbilityBehaviour)this).Card).Info != (Object)null && ((Object)((Card)((AbilityBehaviour)this).Card).Info).name == "OLD_SA_WIND_PTEROSAUR"; } private CardSlot GetAdjacentSlot(int offset) { if ((Object)(object)((AbilityBehaviour)this).Card == (Object)null || (Object)(object)((AbilityBehaviour)this).Card.Slot == (Object)null) { return null; } CardSlot slot = ((AbilityBehaviour)this).Card.Slot; int num = slot.Index + offset; List slots = Singleton.Instance.GetSlots(slot.IsPlayerSlot); if (num < 0 || num >= slots.Count) { return null; } return slots[num]; } private IEnumerator GiveWindBlessing(PlayableCard target) { if (!((Object)(object)target == (Object)null) && !target.HasAbility((Ability)19) && !WindBlessingRuntime.HasWind(target)) { WindBlessingRuntime.Add(target); target.UpdateFaceUpOnBoardEffects(); ((Card)target).RenderCard(); } yield break; } } public static class WindBlessingEffect { private const string PTEROSAUR_CARD = "OLD_SA_WIND_PTEROSAUR"; public static int ActiveWindIcons; public static IEnumerator Play(PlayableCard card, bool selfCast = false) { if (!((Object)(object)card == (Object)null)) { Debug.Log((object)("Wind Blessing effect on " + ((Object)((Card)card).Info).name)); ((Card)card).Anim.PlayTransformAnimation(); WindBlessingWindIcon.Spawn(card); if (selfCast && ((Object)((Card)card).Info).name == "OLD_SA_WIND_PTEROSAUR") { WindBlessingAudio.PlayPterosaurRoar(((Component)card).transform.position); } else { WindBlessingAudio.PlayWind(((Component)card).transform.position); } } yield break; } } public static class WindBlessingFlyingManager { public static HashSet AddingWindFlying = new HashSet(); public static bool IsAddingWindFlying(PlayableCard card) { if ((Object)(object)card == (Object)null) { return false; } return AddingWindFlying.Contains(card); } public static void ClearAdding() { AddingWindFlying.Clear(); } } public static class WindBlessingPterosaurPortraitSwitch { private const string PTEROSAUR_CARD = "OLD_SA_WIND_PTEROSAUR"; public static IEnumerator SwitchToStage1(PlayableCard card, bool allowEmission = false) { yield return SwitchPortrait(card, 1, allowEmission); } public static IEnumerator SwitchToStage2(PlayableCard card, bool allowEmission = false) { yield return SwitchPortrait(card, 2, allowEmission); } public static IEnumerator SwitchToStage3(PlayableCard card, bool allowEmission = false) { yield return SwitchPortrait(card, 3, allowEmission); } private static IEnumerator SwitchPortrait(PlayableCard card, int stage, bool allowEmission) { if ((Object)(object)card == (Object)null || (Object)(object)((Card)card).Info == (Object)null || ((Object)((Card)card).Info).name != "OLD_SA_WIND_PTEROSAUR") { yield break; } string portraitName = null; switch (stage) { case 1: portraitName = "OLD_SA_WIND_PTEROSAUR_1"; break; case 2: portraitName = "OLD_SA_WIND_PTEROSAUR_2"; break; case 3: portraitName = "OLD_SA_WIND_PTEROSAUR_3"; break; } if (portraitName != null) { Sprite portrait = LoadPortrait(portraitName); if ((Object)(object)portrait != (Object)null) { card.SwitchToPortrait(portrait); ((Card)card).RenderInfo.forceEmissivePortrait = allowEmission && HasEmission(portraitName); ((Card)card).RenderCard(); } } } public static IEnumerator ResetPortrait(PlayableCard card) { if (!((Object)(object)card == (Object)null) && !((Object)(object)((Card)card).Info == (Object)null) && !(((Object)((Card)card).Info).name != "OLD_SA_WIND_PTEROSAUR")) { Sprite normalPortrait = LoadPortrait("OLD_SA_WIND_PTEROSAUR"); if ((Object)(object)normalPortrait != (Object)null) { ((Card)card).RenderInfo.forceEmissivePortrait = false; ((Card)card).RenderInfo.portraitOverride = null; card.SwitchToPortrait(normalPortrait); ((Card)card).RenderCard(); } } yield break; } private static Sprite LoadPortrait(string name) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) Texture2D imageAsTexture = TextureHelper.GetImageAsTexture(name + ".png", (FilterMode)0); if ((Object)(object)imageAsTexture == (Object)null) { Debug.Log((object)("Missing portrait: " + name)); return null; } Sprite val = Sprite.Create(imageAsTexture, new Rect(0f, 0f, (float)((Texture)imageAsTexture).width, (float)((Texture)imageAsTexture).height), new Vector2(0.5f, 0.5f)); ((Object)val).name = name; Texture2D val2 = null; try { val2 = TextureHelper.GetImageAsTexture(name + "_emission.png", (FilterMode)0); } catch { } if ((Object)(object)val2 != (Object)null) { Sprite val3 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)); ((Object)val3).name = name + "_emission"; TextureHelper.RegisterEmissionForSprite(val, val3); } return val; } private static bool HasEmission(string name) { Texture2D val = null; try { val = TextureHelper.GetImageAsTexture(name + "_emission.png", (FilterMode)0); } catch { } return (Object)(object)val != (Object)null; } } public static class WindBlessingWindIcon { public static void Spawn(PlayableCard card) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)card == (Object)null)) { Sprite val = WindBlessingAssets.LoadSprite("WindIcon.png"); if ((Object)(object)val == (Object)null) { Debug.Log((object)"Missing WindIcon"); return; } GameObject val2 = new GameObject("WindBlessingIcon"); val2.transform.position = ((Component)card).transform.position + new Vector3(0f, 0.8f, 0f); val2.transform.rotation = Quaternion.Euler(90f, 0f, 0f); SpriteRenderer val3 = val2.AddComponent(); val3.sprite = val; ((Renderer)val3).sortingOrder = 999; WindBlessingEffect.ActiveWindIcons++; WindIconRotation windIconRotation = val2.AddComponent(); windIconRotation.StartAnimation(); } } } public class WindIconRotation : MonoBehaviour { private float duration = 1.2f; private float timer = 0f; private float startSpeed = 720f; private SpriteRenderer renderer; private Vector3 startScale = new Vector3(0.2f, 0.2f, 0.2f); private Vector3 normalScale = Vector3.one; public void StartAnimation() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) timer = 0f; renderer = ((Component)this).GetComponent(); ((Component)this).transform.localScale = startScale; } private void Update() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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) timer += Time.deltaTime; float num = Mathf.Clamp01(timer / duration); if (num < 0.15f) { float num2 = num / 0.15f; ((Component)this).transform.localScale = Vector3.Lerp(startScale, normalScale, Mathf.Sin(num2 * (float)Math.PI * 0.5f)); } float num3 = Mathf.Lerp(startSpeed, 0f, Mathf.Pow(num, 2.5f)); ((Component)this).transform.Rotate(Vector3.forward, num3 * Time.deltaTime); if (num > 0.8f) { float num4 = (num - 0.8f) / 0.2f; float num5 = Mathf.Lerp(1f, 0f, num4); ((Component)this).transform.localScale = new Vector3(num5, num5, num5); if ((Object)(object)renderer != (Object)null) { Color color = renderer.color; color.a = Mathf.Lerp(1f, 0f, num4); renderer.color = color; } } if (timer >= duration) { WindBlessingEffect.ActiveWindIcons--; Object.Destroy((Object)(object)((Component)this).gameObject); } } }