public static void Load() { SNLogger.Debug("Method call: Main.Load()"); try { SEConfig.Config_Load(); SlotHelper.InitSlotIDs(); SlotHelper.ExpandSlotMapping(); hInstance = new Harmony("Subnautica.SlotExtender.mod"); SNLogger.Debug($"Main.Load(): Harmony Instance created, Name = [{hInstance.Id}]"); hInstance.PatchAll(Assembly.GetExecutingAssembly()); SceneManager.sceneLoaded += new UnityAction <Scene, LoadSceneMode>(OnSceneLoaded); SNLogger.Debug("Main.Load(): Added OnSceneLoaded method to SceneManager.sceneLoaded event."); //add console commad for configuration window commandRoot = new CommandRoot("SEConfigGO"); commandRoot.AddCommand <SECommand>(); IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent); } catch (Exception ex) { Debug.LogException(ex); } // check MoreQuickSlots namespace is exists if (ReflectionHelper.IsNamespaceExists("MoreQuickSlots")) { SNLogger.Log("MoreQuickSlots namespace is exist! Trying to install a Cross-MOD patch..."); // if yes construct a Harmony patch if (MQS_Patches.InitPatch(hInstance)) { SNLogger.Log("MoreQuickSlots Cross-MOD patch installed!"); } else { SNLogger.Error("MoreQuickSlots Cross-MOD patch install failed!"); } } }
public static void Load() { try { SEConfig.LoadConfig(); SlotHelper.InitSlotIDs(); hInstance = HarmonyInstance.Create("Subnautica.SlotExtender.mod"); //Harmony autopatch not working if MoreQuickSlots mod not installed therefore switch to manual patching mode //hInstance.PatchAll(Assembly.GetExecutingAssembly()); //begin manual patch hInstance.Patch(typeof(DevConsole).GetMethod("SetState"), new HarmonyMethod(typeof(DevConsole_SetState_Patch), "Prefix"), null); hInstance.Patch(typeof(Equipment).GetMethod("GetSlotType"), new HarmonyMethod(typeof(Equipment_GetSlotType_Patch), "Prefix"), null); hInstance.Patch(typeof(Equipment).GetMethod("AllowedToAdd"), new HarmonyMethod(typeof(Equipment_AllowedToAdd_Patch), "Prefix"), null); hInstance.Patch(typeof(SeaMoth).GetProperty("slotIDs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty).GetGetMethod(true), new HarmonyMethod(typeof(Seamoth_slotIDs_Patch), "Prefix"), null); hInstance.Patch(typeof(uGUI_QuickSlots).GetMethod("SetBackground", BindingFlags.NonPublic | BindingFlags.Instance), new HarmonyMethod(typeof(uGUI_QuickSlots_SetBackground_Patch), "Prefix"), null); hInstance.Patch(typeof(uGUI_Equipment).GetMethod("Awake", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField), new HarmonyMethod(typeof(uGUI_Equipment_Awake_Patch), "Prefix"), new HarmonyMethod(typeof(uGUI_Equipment_Awake_Patch), "Postfix")); hInstance.Patch(typeof(SeaMoth).GetMethod("Start"), null, new HarmonyMethod(typeof(SeaMoth_Start_Patch), "Postfix")); hInstance.Patch(typeof(Exosuit).GetProperty("slotIDs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty).GetGetMethod(true), new HarmonyMethod(typeof(Exosuit_slotIDs_Patch), "Prefix"), null); hInstance.Patch(typeof(Exosuit).GetMethod("Start"), null, new HarmonyMethod(typeof(Exosuit_Start_Patch), "Postfix")); //end manual patch SceneManager.sceneLoaded += new UnityAction <Scene, LoadSceneMode>(OnSceneLoaded); } catch (Exception ex) { Debug.LogException(ex); } //check MoreQuickSlots namespace is exists if (RefHelp.IsNamespaceExists("MoreQuickSlots")) { SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] -> MoreQuickSlots namespace is exist! Trying to install a Cross-MOD patch..."); //if yes construct a Harmony patch MQS_Patches mqs_patcher = new MQS_Patches(hInstance); if (mqs_patcher.InitPatch()) { SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] -> MoreQuickSlots Cross-MOD patch installed!"); } else { SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] -> MoreQuickSlots Cross-MOD patch install failed!"); } } }