Example #1
0
        private static void PostloadHandler(HarmonyInstance instance)
        {
            if (DebugNotIncludedOptions.Instance?.PowerUserMode ?? false)
            {
                instance.Patch(typeof(ModsScreen), "BuildDisplay",
                               new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(HidePopups)),
                               new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(BuildDisplay)));
            }
            KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(),
                              new UISnapshotHandler(), 1024);
            // New postload architecture requires going back a little ways
            var      st       = new System.Diagnostics.StackTrace(6);
            Assembly assembly = null;

            if (st.FrameCount > 0)
            {
                assembly = st.GetFrame(0).GetMethod()?.DeclaringType?.Assembly;
            }
            PUtil.LogDebug(assembly?.FullName ?? "none");
            RunningPLibAssembly = assembly ?? Assembly.GetCallingAssembly();
            // Log which mod is running PLib
            var latest = ModDebugRegistry.Instance.OwnerOfAssembly(RunningPLibAssembly);

            if (latest != null)
            {
                DebugLogger.LogDebug("Executing version of PLib is from: " + latest.ModName);
            }
            HarmonyPatchInspector.Check();
        }
Example #2
0
 /// <summary>
 /// Runs the required postload patches after all other mods load.
 /// </summary>
 /// <param name="instance">The Harmony instance to execute patches.</param>
 private static void PostloadHandler(HarmonyInstance instance)
 {
     if (DebugNotIncludedOptions.Instance?.PowerUserMode ?? false)
     {
         instance.Patch(typeof(ModsScreen), "BuildDisplay", postfix:
                        new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(BuildDisplay)));
     }
     KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(),
                       new UISnapshotHandler(), 1024);
 }
    private void Awake()
    {
        GameInputManager inputManager = Global.Instance.GetInputManager();

        for (int i = 0; i < inputManager.GetControllerCount(); i++)
        {
            KInputController controller = inputManager.GetController(i);
            if (controller.IsGamepad)
            {
                KInputHandler.Add(controller, base.gameObject);
            }
        }
        KInputHandler.Add(inputManager.GetDefaultController(), KScreenManager.Instance, 10);
        DebugHandler child = new DebugHandler();

        KInputHandler.Add(inputManager.GetDefaultController(), child, -1);
    }
        /// <summary>
        /// Runs the required postload patches after all other mods load.
        /// </summary>
        /// <param name="instance">The Harmony instance to execute patches.</param>
        private static void PostloadHandler(HarmonyInstance instance)
        {
            if (DebugNotIncludedOptions.Instance?.PowerUserMode ?? false)
            {
                instance.Patch(typeof(ModsScreen), "BuildDisplay", postfix:
                               new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(BuildDisplay)));
            }
            KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(),
                              new UISnapshotHandler(), 1024);
            // Log which mod is running PLib
            RunningPLibAssembly = Assembly.GetCallingAssembly();
            var latest = ModDebugRegistry.Instance.OwnerOfAssembly(RunningPLibAssembly);

            if (latest != null)
            {
                DebugLogger.LogDebug("Executing version of PLib is from: " + latest.ModName);
            }
        }
Example #5
0
        private static void PostloadHandler(HarmonyInstance instance)
        {
            if (DebugNotIncludedOptions.Instance?.PowerUserMode ?? false)
            {
                instance.Patch(typeof(ModsScreen), "BuildDisplay",
                               new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(HidePopups)),
                               new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(BuildDisplay)));
            }
            KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(),
                              new UISnapshotHandler(), 1024);
            // New postload architecture requires going back a little ways
            var      st       = new StackTrace(6);
            Assembly assembly = null;

            if (st.FrameCount > 0)
            {
                assembly = st.GetFrame(0).GetMethod()?.DeclaringType?.Assembly;
            }
            RunningPLibAssembly = assembly ?? Assembly.GetCallingAssembly();
            // Log which mod is running PLib
            var latest = ModDebugRegistry.Instance.OwnerOfAssembly(RunningPLibAssembly);

            if (latest != null)
            {
                DebugLogger.LogDebug("Executing version of PLib is from: " + latest.ModName);
            }
            HarmonyPatchInspector.Check();
#if DEBUG
            // SaveManager.Load:: 13831 ms
            instance.ProfileMethod(typeof(SaveLoader).GetMethodSafe("Load", false, typeof(
                                                                        IReader)));
            instance.ProfileMethod(typeof(SaveLoader).GetMethodSafe("Save", false, typeof(
                                                                        BinaryWriter)));
            instance.ProfileMethod(typeof(SaveManager).GetMethodSafe("Load", false,
                                                                     PPatchTools.AnyArguments));
            instance.ProfileMethod(typeof(SaveManager).GetMethodSafe("Save", false,
                                                                     PPatchTools.AnyArguments));
#endif
        }
Example #6
0
 internal static void AddSpamHandler()
 {
     KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(),
                       new SpamObjectsHandler(), 512);
 }
Example #7
0
 internal static void AfterModsLoad()
 {
     // Input manager is not set up until this time
     KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(),
                       new UISnapshotHandler(), 1024);
 }