using HarmonyLib; using System; using System.Reflection; namespace ConsoleUnlocker.Patches { /* * Emit "DevModeActivated" signal to enable the console, and do some other setup. */ [HarmonyPatch(typeof(PlatformSetup), "GetDevIDs")] internal class PlatformSetupPatches { static void Postfix() { if (!PlatformSetup.HasDevAccess(DevUser.IsDev)) { // If someone is already a dev, don't emit this twice just in case GlobalContext.Invoke(Array.Empty()); } if (!PlatformSetup.HasDevAccess(DevUser.CommandlineAccess) || !PlatformSetup.HasDevAccess(DevUser.IsDev)) { // If a dev already has console access... why are they using the mod lol MIU.Console.Instance.gameObject.SetActive(true); } // It seems it doesn't scan on first console open, but waits for you to type something. Just scan now so all // commands are available right away MethodInfo scanMethod = typeof(MIU.Console).GetMethod("CheckInitializeVarsAndCommands", BindingFlags.Instance | BindingFlags.NonPublic); scanMethod.Invoke(MIU.Console.Instance, null); } } }