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 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_Random_sigil")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Random_sigil")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("cf3705a4-140c-4f68-8f0c-b63c824f267b")] [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.Random; [BepInPlugin("OLD_SA.Random", "OLD SA Random", "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 RandomAPI.Init(); Harmony val = new Harmony("OLD_SA.Random"); val.PatchAll(); } } public static class RandomAPI { public static FullAbility ability; public static Ability RandomAbility; public static void Init() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) AbilityInfo val = ScriptableObject.CreateInstance(); ((Object)val).name = "Random"; val.rulebookName = "Random"; val.metaCategories = new List { (AbilityMetaCategory)0 }; val.powerLevel = -1; val.opponentUsable = false; val.canStack = false; Texture imageAsTexture = (Texture)(object)TextureHelper.GetImageAsTexture("OldSa_Random.png", (FilterMode)0); FieldInfo field = typeof(AbilityInfo).GetField("rulebookDescription", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, "When [creature] attacks, its target is random."); } ability = AbilityManager.Add("OLD_SA", val, typeof(RandomBehaviour), imageAsTexture); RandomAbility = val.ability; } } public class RandomBehaviour : AbilityBehaviour { public override Ability Ability => RandomAPI.ability.Id; } [HarmonyPatch(typeof(PlayableCard), "GetOpposingSlots")] public static class RandomPatch { private static int randomCounter; [HarmonyPostfix] public static void Postfix(PlayableCard __instance, ref List __result) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.Slot == (Object)null || __result == null || RandomAPI.ability == null || !__instance.HasAbility(RandomAPI.ability.Id)) { return; } List list = (__instance.OpponentCard ? Singleton.Instance.PlayerSlotsCopy : Singleton.Instance.OpponentSlotsCopy); if (list == null || list.Count == 0) { return; } int count = __result.Count; if (count > 0) { List list2 = new List(); for (int i = 0; i < count; i++) { int randomSeed = GetRandomSeed(__instance, i); float num = SeededRandom.Value(randomSeed); int num2 = Mathf.FloorToInt(num * (float)list.Count); num2 = Mathf.Clamp(num2, 0, list.Count - 1); list2.Add(list[num2]); } __result = list2; } } private static int GetRandomSeed(PlayableCard card, int attackIndex) { int currentRandomSeed = SaveManager.SaveFile.GetCurrentRandomSeed(); int num = (((Object)(object)card != (Object)null && (Object)(object)card.Slot != (Object)null) ? card.Slot.Index : 0); int num2 = randomCounter++; int num3 = currentRandomSeed; num3 = num3 * 31 + num; num3 = num3 * 31 + attackIndex; return num3 * 31 + num2; } }