More robust unlocking and scanning
This commit is contained in:
parent
8580189282
commit
f99f2e7a86
2 changed files with 19 additions and 4 deletions
|
@ -1,5 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace ConsoleUnlocker
|
namespace ConsoleUnlocker
|
||||||
|
|
|
@ -1,16 +1,32 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using MIU;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace ConsoleUnlocker.Patches
|
namespace ConsoleUnlocker.Patches
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Emit "DevModeActivated" signal to enable the console, and do some other setup.
|
||||||
|
*/
|
||||||
[HarmonyPatch(typeof(PlatformSetup), "GetDevIDs")]
|
[HarmonyPatch(typeof(PlatformSetup), "GetDevIDs")]
|
||||||
internal class PlatformSetupPatches
|
internal class PlatformSetupPatches
|
||||||
{
|
{
|
||||||
static void Postfix()
|
static void Postfix()
|
||||||
{
|
{
|
||||||
GlobalContext.Invoke<DevModeActivated>(Array.Empty<object>());
|
if (!PlatformSetup.HasDevAccess(DevUser.IsDev))
|
||||||
MIU.Console.Instance.gameObject.SetActive(true);
|
{
|
||||||
|
// If someone is already a dev, don't emit this twice just in case
|
||||||
|
GlobalContext.Invoke<DevModeActivated>(Array.Empty<object>());
|
||||||
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue