using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using FMODUnity; using HarmonyLib; using Microsoft.CodeAnalysis; using SuperFantasyKingdom; using SuperFantasyKingdom.TitleScreen; using SuperFantasyKingdom.UI; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("UnlimitedJail")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+14a22b142920a276e529c9edd73b255a4bf0cc56")] [assembly: AssemblyProduct("Unlimited Jail")] [assembly: AssemblyTitle("UnlimitedJail")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UnlimitedJail { [BepInPlugin("ownly.unlimitedjail", "Unlimited Jail", "1.1.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll(); } } internal static class Filter { public static void Apply(UnlockedUnitsManager manager) { List stashed = Stash.Units; Traverse obj = Traverse.Create((object)manager); List value = obj.Field("m_UnlockedUnits").GetValue>(); List value2 = obj.Field("m_Banned").GetValue>(); foreach (string item in stashed) { value.Remove(item); if (!value2.Contains(item)) { value2.Add(item); } } value2.RemoveAll((string id) => id != "empty" && !stashed.Contains(id)); } } [HarmonyPatch(typeof(UnlockedUnitsManager), "Awake")] internal static class Patch_UnlockedUnitsAwake { private static void Postfix(UnlockedUnitsManager __instance) { try { Filter.Apply(__instance); } catch { } } } [HarmonyPatch(typeof(UnlockedUnitsManager), "SetBannedUnits")] internal static class Patch_SetBannedUnits { private static void Postfix(UnlockedUnitsManager __instance) { try { Filter.Apply(__instance); } catch { } } } internal static class Jail { internal const string Empty = "empty"; private static readonly HashSet s_Warned = new HashSet(); public static string Force(string jailed) { if (!string.IsNullOrEmpty(jailed) && jailed != "empty" && s_Warned.Add(jailed)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("jail slot held " + jailed + " - the mod frees it, jail it from the selection screen to keep it held back")); } } return "empty"; } public static void Paint(TitleScreenJail jail, int index) { List units = Stash.Units; Traverse val = Traverse.Create((object)jail); GameObject value = val.Field("jail" + index).GetValue(); GameObject value2 = val.Field("jail" + index + "Rubble").GetValue(); Image value3 = val.Field("jail" + index + "Door").GetValue(); ImageAnimator value4 = val.Field("jail" + index + "Jailed").GetValue(); if (units.Count < index) { return; } Unit unit = AddressablesManager.Instance.GetUnit(units[index - 1]); if ((Object)(object)unit == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("stashed unit has no prefab: " + units[index - 1])); } } else { value.SetActive(true); value2.SetActive(false); value3.sprite = val.Field("spriteDoorClosed").GetValue(); value4.SetSprites(((UnitBase)unit).GetIdleSprites()); ((Component)value4).gameObject.SetActive(true); } } } [HarmonyPatch(typeof(RaceDataManager), "GetJail1")] internal static class Patch_GetJail1 { private static void Postfix(ref string __result) { __result = Jail.Force(__result); } } [HarmonyPatch(typeof(RaceDataManager), "GetJail2")] internal static class Patch_GetJail2 { private static void Postfix(ref string __result) { __result = Jail.Force(__result); } } [HarmonyPatch(typeof(RaceDataManager), "GetJail3")] internal static class Patch_GetJail3 { private static void Postfix(ref string __result) { __result = Jail.Force(__result); } } [HarmonyPatch(typeof(TitleScreenJail), "ShowJail1")] internal static class Patch_ShowJail1 { private static void Postfix(TitleScreenJail __instance) { try { Jail.Paint(__instance, 1); } catch { } } } [HarmonyPatch(typeof(TitleScreenJail), "ShowJail2")] internal static class Patch_ShowJail2 { private static void Postfix(TitleScreenJail __instance) { try { Jail.Paint(__instance, 2); } catch { } } } [HarmonyPatch(typeof(TitleScreenJail), "ShowJail3")] internal static class Patch_ShowJail3 { private static void Postfix(TitleScreenJail __instance) { try { Jail.Paint(__instance, 3); } catch { } } } [HarmonyPatch(typeof(TitleScreenJail), "SetJailed")] internal static class Patch_SetJailed { private static bool Prefix(TitleScreenJail __instance) { try { Traverse val = Traverse.Create((object)__instance); int value = val.Field("m_SelectedCell").GetValue(); if (value >= 1 && value <= 3) { Button value2 = val.Field("jail" + value + "Button").GetValue