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 OLD_SA.Dialogue; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OLD_SA_Evolution")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OLD_SA_Evolution")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5b768fcb-7685-41db-8b51-6ca3e88435e4")] [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.Evolution; public static class EvolutionAPI { public static Dictionary Evolutions = new Dictionary(); public static Dictionary Turns = new Dictionary(); public static Dictionary EvolutionDialogues = new Dictionary(); public static HashSet TriggeredEvolutionDialogues = new HashSet(); public static void AddEvolution(string from, string to, int turns, string dialogue = null) { Evolutions[from] = to; Turns[from] = turns; if (!string.IsNullOrEmpty(dialogue)) { EvolutionDialogues[from] = dialogue; } } public static bool ShouldTriggerEvolutionDialogue(string cardName) { if (TriggeredEvolutionDialogues.Contains(cardName)) { return false; } TriggeredEvolutionDialogues.Add(cardName); OLD_SA_SaveManager.Save(); return true; } public static List GetTriggeredDialogues() { return new List(TriggeredEvolutionDialogues); } public static void LoadTriggeredDialogues(List data) { TriggeredEvolutionDialogues.Clear(); if (data == null) { return; } foreach (string datum in data) { if (!string.IsNullOrEmpty(datum)) { TriggeredEvolutionDialogues.Add(datum); } } } public static void ClearTriggeredDialogues() { TriggeredEvolutionDialogues.Clear(); } } public class EvolutionData { public string target; public int turns; public string dialogue; } [HarmonyPatch(typeof(PlayableCard))] public static class EvolutionDialoguePatch { private static Dictionary BeforeEvolution = new Dictionary(); [HarmonyPatch("TransformIntoCard")] [HarmonyPrefix] public static void Prefix(PlayableCard __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Card)__instance).Info == (Object)null)) { BeforeEvolution[__instance] = ((Object)((Card)__instance).Info).name; } } [HarmonyPatch("TransformIntoCard")] [HarmonyPostfix] public static IEnumerator Postfix(IEnumerator result, PlayableCard __instance, CardInfo evolvedInfo) { while (result.MoveNext()) { yield return result.Current; } if (!((Object)(object)__instance == (Object)null) && !((Object)(object)evolvedInfo == (Object)null) && BeforeEvolution.ContainsKey(__instance)) { string oldName = BeforeEvolution[__instance]; BeforeEvolution.Remove(__instance); if (EvolutionAPI.EvolutionDialogues.ContainsKey(oldName) && EvolutionAPI.ShouldTriggerEvolutionDialogue(oldName)) { string dialogue = EvolutionAPI.EvolutionDialogues[oldName]; yield return ShowEvolutionDialogue(dialogue); } } } private static IEnumerator ShowEvolutionDialogue(string dialogue) { yield return (object)new WaitForEndOfFrame(); if ((Object)(object)Singleton.Instance != (Object)null) { yield return Singleton.Instance.ShowUntilInput(dialogue, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true); } } } public static class EvolutionManager { public static void RegisterAll() { foreach (CardInfo item in CardManager.AllCardsCopy) { string evolveFrom = CardExtensions.GetExtendedProperty(item, "OLD_SA_EvolveFrom"); if (string.IsNullOrEmpty(evolveFrom)) { continue; } CardInfo val = CardManager.AllCardsCopy.Find((CardInfo x) => ((Object)x).name == evolveFrom); if (!((Object)(object)val == (Object)null)) { int num = 1; string extendedProperty = CardExtensions.GetExtendedProperty(item, "OLD_SA_EvolveTurns"); if (int.TryParse(extendedProperty, out var result)) { num = result; } if (val.evolveParams == null || (Object)(object)val.evolveParams.evolution != (Object)(object)item) { CardExtensions.SetEvolve(val, item, num, (IEnumerable)null); } if (val.evolveParams != null) { val.evolveParams.turnsToEvolve = num; } string extendedProperty2 = CardExtensions.GetExtendedProperty(item, "OLD_SA_EvolveDialogue"); EvolutionAPI.AddEvolution(((Object)val).name, ((Object)item).name, num, extendedProperty2); } } } } [BepInPlugin("OLD_SA.Evolution", "OLD SA Evolution", "1.0.0")] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("OLD_SA.Evolution"); val.PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(InitialRegister()); Debug.Log((object)"OLD SA Evolution Loaded"); } private IEnumerator InitialRegister() { yield return (object)new WaitUntil((Func)(() => CardManager.AllCardsCopy != null && CardManager.AllCardsCopy.Count > 0)); yield return (object)new WaitForSeconds(1f); EvolutionManager.RegisterAll(); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ((MonoBehaviour)this).StartCoroutine(DelayedSceneRegister()); } private IEnumerator DelayedSceneRegister() { yield return (object)new WaitForSeconds(1f); EvolutionManager.RegisterAll(); } }