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 Pixelplacement; 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_Bone_Devourer_sigil")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Bone_Devourer_sigil")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("499f2d57-312a-4735-b826-444696765434")] [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.BoneDevourer; public static class BoneDevourerAPI { public static FullAbility ability; public static void Init() { AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "Bone Devourer"; val.rulebookName = "Bone Devourer"; val.metaCategories = new List { (AbilityMetaCategory)0 }; val.powerLevel = 4; val.opponentUsable = false; Texture imageAsTexture = (Texture)(object)TextureHelper.GetImageAsTexture("OldSa_Bone_Devourer.png", (FilterMode)0); FieldInfo field = typeof(AbilityInfo).GetField("rulebookDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, "When a bone appears, [creature] devours one. For every 4 bones devoured, [creature] gains 1 Power and 1 Health."); } ability = AbilityManager.Add("OLD_SA", val, typeof(BoneDevourerBehaviour), imageAsTexture); } } public class BoneDevourerBehaviour : AbilityBehaviour { private int bonesDevoured; public override Ability Ability => BoneDevourerAPI.ability.Id; public PlayableCard GetCard() { return ((AbilityBehaviour)this).Card; } public IEnumerator DevourBone() { bonesDevoured++; if (bonesDevoured % 4 == 0) { yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence(); Singleton.Instance.SwitchToView((View)4, false, false); yield return (object)new WaitForSeconds(0.15f); CardModificationInfo mod = new CardModificationInfo(1, 1); ((AbilityBehaviour)this).Card.AddTemporaryMod(mod); ((Card)((AbilityBehaviour)this).Card).Anim.PlayTransformAnimation(); yield return (object)new WaitForSeconds(0.15f); ((Card)((AbilityBehaviour)this).Card).RenderCard(); } } } [HarmonyPatch(typeof(Part1ResourcesManager), "ShowAddBones")] public static class BoneDevourerBonePatch { [HarmonyPrefix] private static bool Prefix(Part1ResourcesManager __instance, int amount, CardSlot slot, ref IEnumerator __result) { __result = ShowAddBonesWithDevourer(__instance, amount, slot); return false; } private static IEnumerator ShowAddBonesWithDevourer(Part1ResourcesManager instance, int amount, CardSlot slot) { if (!ProgressionData.LearnedMechanic((MechanicsConcept)0)) { yield break; } BoneDevourerBehaviour devourer = FindBoneDevourer(); GetBoneTokens(instance); bool devoured = false; for (int i = 0; i < amount; i++) { GameObject gameObject = Object.Instantiate(GetBoneTokenPrefab(instance)); BoneTokenInteractable component = gameObject.GetComponent(); Component tokenRB = gameObject.GetComponent("Rigidbody"); if ((Object)(object)slot != (Object)null) { InvokeRigidbodyMethod(tokenRB, "Sleep"); gameObject.transform.position = ((Component)slot).transform.position + Vector3.up; InvokePushTokenDown(instance, tokenRB); Vector3 landingPosition = GetRandomLandingPosition(instance) + Vector3.up; Tween.Position(((Component)component).transform, landingPosition, 0.25f, 0.5f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)delegate { InvokeRigidbodyMethod(tokenRB, "WakeUp"); InvokePushTokenDown(instance, tokenRB); }, true); } else { gameObject.transform.position = GetRandomLandingPosition(instance) + Vector3.up * 5f; InvokePushTokenDown(instance, tokenRB); } if (!devoured && (Object)(object)devourer != (Object)null && (Object)(object)component != (Object)null) { devoured = true; GetBoneTokens(instance)?.Remove(component); yield return DevourBoneAnimation(component, devourer); yield return devourer.DevourBone(); } else { GetBoneTokens(instance)?.Add(component); SetOrganizedFalse(instance); } yield return (object)new WaitForSeconds(0.05f); } } private static IEnumerator DevourBoneAnimation(BoneTokenInteractable token, BoneDevourerBehaviour devourer) { if (!((Object)(object)token == (Object)null) && !((Object)(object)devourer == (Object)null)) { ((InteractableBase)token).SetEnabled(false); Component rigidbody = ((Component)token).GetComponent("Rigidbody"); if ((Object)(object)rigidbody != (Object)null) { Object.Destroy((Object)(object)rigidbody); } Vector3 target = ((Component)devourer).transform.position + Vector3.up; Tween.Position(((Component)token).transform, target, 0.3f, 0f, Tween.EaseInOut, (LoopType)0, (Action)null, (Action)null, true); Tween.Rotate(((Component)token).transform, new Vector3(90f, 0f, 90f), (Space)0, 0.3f, 0f, (AnimationCurve)null, (LoopType)0, (Action)null, (Action)null, true); AudioController.Instance.PlaySound3D("token_enter_higher", (MixerGroup)4, ((Component)token).transform.position, 1f, 0f, new Pitch((Variation)0), new Repetition(0.05f, ""), (Randomization)null, (Distortion)null, false); yield return (object)new WaitForSeconds(0.3f); Object.Destroy((Object)(object)((Component)token).gameObject); } } private static BoneDevourerBehaviour FindBoneDevourer() { if ((Object)(object)Singleton.Instance == (Object)null) { return null; } foreach (CardSlot item in Singleton.Instance.OpponentSlotsCopy) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item.Card == (Object)null) && !item.Card.Dead) { BoneDevourerBehaviour component = ((Component)item.Card).GetComponent(); if ((Object)(object)component != (Object)null) { return component; } } } return null; } private static GameObject GetBoneTokenPrefab(Part1ResourcesManager instance) { FieldInfo field = typeof(Part1ResourcesManager).GetField("boneTokenPrefab", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return null; } object? value = field.GetValue(instance); return (GameObject)((value is GameObject) ? value : null); } private static List GetBoneTokens(Part1ResourcesManager instance) { FieldInfo field = typeof(Part1ResourcesManager).GetField("boneTokens", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return null; } return field.GetValue(instance) as List; } private static Vector3 GetRandomLandingPosition(Part1ResourcesManager instance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) FieldInfo field = typeof(Part1ResourcesManager).GetField("boneTokenArea", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return Vector3.zero; } object? value = field.GetValue(instance); Transform val = (Transform)((value is Transform) ? value : null); if ((Object)(object)val == (Object)null) { return Vector3.zero; } return val.position + new Vector3(Random.value * 0.6f, 0f, Random.value * 0.6f); } private static void InvokePushTokenDown(Part1ResourcesManager instance, Component tokenRB) { if (!((Object)(object)instance == (Object)null) && !((Object)(object)tokenRB == (Object)null)) { MethodInfo method = typeof(Part1ResourcesManager).GetMethod("PushTokenDown", BindingFlags.Instance | BindingFlags.NonPublic); if (!(method == null)) { method.Invoke(instance, new object[1] { tokenRB }); } } } private static void InvokeRigidbodyMethod(Component component, string methodName) { if (!((Object)(object)component == (Object)null)) { MethodInfo method = ((object)component).GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public); if (!(method == null)) { method.Invoke(component, null); } } } private static void SetOrganizedFalse(Part1ResourcesManager instance) { FieldInfo field = typeof(Part1ResourcesManager).GetField("isOrganized", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(instance, false); } } } [BepInPlugin("OLD_SA.Bone_Devourer_sigil", "OldSa Bone Devourer Sigil", "1.0.0")] public class BoneDevourerPlugin : BaseUnityPlugin { public const string PluginGuid = "OLD_SA.Bone_Devourer_sigil"; public const string PluginName = "OldSa Bone Devourer Sigil"; public const string PluginVersion = "1.0.0"; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown BoneDevourerAPI.Init(); Harmony val = new Harmony("OLD_SA.Bone_Devourer_sigil"); val.PatchAll(Assembly.GetExecutingAssembly()); } }