예제 #1
0
 static bool Load(UnityModManager.ModEntry modEntry)
 {
     logger             = modEntry.Logger;
     modEntry.OnToggle  = OnToggle;
     modEntry.OnGUI     = OnGUI;
     modEntry.OnSaveGUI = OnSaveGUI;
     settings           = UnityModManager.ModSettings.Load <Settings>(modEntry);
     harmonyInstance    = Harmony12.HarmonyInstance.Create(modEntry.Info.Id);
     if (!ApplyPatch(typeof(LibraryScriptableObject_LoadDictionary_Patch), "All mod features"))
     {
         // If we can't patch this, nothing will work, so want the mod to turn red in UMM.
         throw Error("Failed to patch LibraryScriptableObject.LoadDictionary(), cannot load mod");
     }
     return(true);
 }
예제 #2
0
 static bool Load(UnityModManager.ModEntry modEntry)
 {
     try
     {
         logger  = modEntry.Logger;
         harmony = Harmony12.HarmonyInstance.Create(modEntry.Info.Id);
         harmony.PatchAll(Assembly.GetExecutingAssembly());
     }
     catch (Exception ex)
     {
         DebugError(ex);
         throw ex;
     }
     return(true);
 }
예제 #3
0
 static bool Load(UnityModManager.ModEntry modEntry)
 {
     Logger             = modEntry.Logger;
     RES.Culture        = CultureInfo.InstalledUICulture;
     modEntry.OnToggle  = OnToggle;
     modEntry.OnGUI     = OnGUI;
     modEntry.OnSaveGUI = OnSaveGUI;
     settings           = UnityModManager.ModSettings.Load <Settings>(modEntry);
     harmonyInstance    = Harmony12.HarmonyInstance.Create(modEntry.Info.Id);
     if (!ApplyPatch(typeof(LibraryScriptableObject_LoadDictionary_Patch), RES.featureNameAll_error))
     {
         // If we can't patch this, nothing will work, so want the mod to turn red in UMM.
         throw Error(RES.cannotLoadMod_error);
     }
     return(true);
 }
예제 #4
0
        // Mod entry point, invoked from UMM
        static bool Load(UnityModManager.ModEntry modEntry)
        {
            logger             = modEntry.Logger;
            modEntry.OnToggle  = OnToggle;
            modEntry.OnGUI     = OnGUI;
            modEntry.OnSaveGUI = OnSaveGUI;
            settings           = UnityModManager.ModSettings.Load <Settings>(modEntry);
            harmonyInstance    = Harmony12.HarmonyInstance.Create(modEntry.Info.Id);
            if (!ApplyPatch(typeof(LibraryScriptableObject_LoadDictionary_Patch), "Load library"))
            {
                throw Error("Failed to patch LibraryScriptableObject.LoadDictionary(), cannot load mod");
            }
            if (!ApplyPatch(typeof(UnityModManager_UI_Update_Patch), "Read keys"))
            {
                throw Error("Failed to patch LibraryScriptableObject.LoadDictionary(), cannot load mod");
            }
            if (!ApplyPatch(typeof(LocalMap_OnPointerClick_Patch), "Local map click"))
            {
                throw Error("Failed to patch LocalMap.OnPointerClick(), cannot load mod");
            }
            if (!ApplyPatch(typeof(LocalMap_OnShow_Patch), "Local map show"))
            {
                throw Error("Failed to patch LocalMap.OnShow(), cannot load mod");
            }
            if (!ApplyPatch(typeof(LocalMap_OnHide_Patch), "Local map hide"))
            {
                throw Error("Failed to patch LocalMap.OnHide(), cannot load mod");
            }
            if (!ApplyPatch(typeof(GlobalMapLocation_HandleClick_Patch), "Global map location click"))
            {
                throw Error("Failed to patch GlobalMapLocation.HandleClick(), cannot load mod");
            }
            if (!ApplyPatch(typeof(GlobalMapLocation_HandleHoverChange_Patch), "Global map hover change"))
            {
                throw Error("Failed to patch GlobalMapLocation.HandleHoverChange(), cannot load mod");
            }
            if (!ApplyPatch(typeof(BlueprintLocation_GetDescription_Patch), "Blueprint location description"))
            {
                throw Error("Failed to patch BlueprintLocation.GetDescription(), cannot load mod");
            }

            StartMod();
            return(true);
        }
예제 #5
0
        static bool Load(UnityModManager.ModEntry modEntry)
        {
            try
            {
                logger  = modEntry.Logger;
                harmony = Harmony12.HarmonyInstance.Create(modEntry.Info.Id);
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                if (settings.swap_weapon_sets_as_move_action)
                {
                    Main.logger.Log("Changing weapons will take move action.");
                    NewMechanics.WeaponSetSwapPatch.Run();
                }
            }
            catch (Exception ex)
            {
                DebugError(ex);
                throw ex;
            }
            return(true);
        }
예제 #6
0
        internal static bool Load(UnityModManager.ModEntry modEntry)
        {
            logger = modEntry.Logger;

            harmony = Harmony12.HarmonyInstance.Create(modEntry.Info.Id);
            harmony.PatchAll(typeof(Main).Assembly);

            try {
                using (StreamReader file = File.OpenText(UnityModManager.modsPath + @"/PenultimateAzlanti/settings.json"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    settings = (Settings)serializer.Deserialize(file, typeof(Settings));
                }
            }
            catch (Exception e)
            {
                logger.Log($"Failed to load custom settings.json due to {e.GetType().ToString()}. Using defaults.");
            }

            return(true);
        }
예제 #7
0
        /// <summary>Loads on game start.</summary>
        /// <param name="modEntry.Info">Contains all fields from the 'Info.json' file.</param>
        /// <param name="modEntry.Path">The path to the mod folder e.g. '\Steam\steamapps\common\YourGame\Mods\TestMod\'.</param>
        /// <param name="modEntry.Active">Active or inactive.</param>
        /// <param name="modEntry.Logger">Writes logs to the 'Log.txt' file.</param>
        /// <param name="modEntry.OnToggle">The presence of this function will let the mod manager know that the mod can be safely disabled during the game.</param>
        /// <param name="modEntry.OnGUI">Called to draw UI.</param>
        /// <param name="modEntry.OnSaveGUI">Called while saving.</param>
        /// <param name="modEntry.OnUpdate">Called by MonoBehaviour.Update.</param>
        /// <param name="modEntry.OnLateUpdate">Called by MonoBehaviour.LateUpdate.</param>
        /// <param name="modEntry.OnFixedUpdate">Called by MonoBehaviour.FixedUpdate.</param>
        /// <returns>Returns true, if no error occurred.</returns>
        internal static bool Load(UnityModManager.ModEntry modEntry)
        {
            ModPath           = modEntry.Path;
            logger            = modEntry.Logger;
            modEntry.OnToggle = OnToggle;
            modEntry.OnGUI    = OnGUI;

            try
            {
                harmony = Harmony12.HarmonyInstance.Create(modEntry.Info.Id);
                harmony.PatchAll(typeof(Main).Assembly);
            }
            catch (Exception ex)
            {
                DebugError(ex);
                throw ex;
            }


            return(true);
        }
예제 #8
0
 internal HarmonyPatcher(Harmony12.HarmonyInstance harmonyInstance)
 {
     m_harmonyInstance = harmonyInstance;
 }