예제 #1
0
        internal static void GameInput_OnBindingsChanged()
        {
            SNLogger.Debug("Method call: Main.GameInput_OnBindingsChanged()");

            // SlotExtender Update() method now disabled until all keybinding updates are complete
            isKeyBindigsUpdate = true;

            // updating slot key bindings
            SEConfig.SLOTKEYBINDINGS_Update();

            // synchronizing keybindings to config file
            SEConfig.SLOTKEYBINDINGS_SyncToAll();

            // updating ALLSLOTS dictionary
            SlotHelper.ALLSLOTS_Update();

            // updating SlotTextHandler
            if (uGUI_SlotTextHandler.Instance != null)
            {
                uGUI_SlotTextHandler.Instance.UpdateSlotText();
            }

            // SlotExtender Update() method now enabled
            isKeyBindigsUpdate = false;
        }
예제 #2
0
        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!");
                }
            }
        }
예제 #3
0
        private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            if (scene.name == "StartScreen")
            {
                // enabling game console
                DevConsole.disableConsole = false;

                // init config
                SEConfig.Config_Init();

                // add an action if changed keybindings
                GameInput.OnBindingsChanged += GameInput_OnBindingsChanged;

                SlotHelper.InitSessionAllSlots();
            }
            if (scene.name == "Main")
            {
                // creating a console input field listener to skip SlotExdender Update method key events conflict while console is active in game
                ListenerInstance = InitializeListener();
            }
        }
예제 #4
0
        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!");
                }
            }
        }