/// <summary> /// Side agnostic Start method, called after all mods received a call to StartPre(). /// </summary> /// <param name="api">The main API for the game.</param> public override void Start(ICoreAPI api) { Api = api as TApi; Files = api.RegisterFileManager(); ApplyHarmonyPatches(_patchAssembly); api.Logger.Notification($" {_patchAssembly.GetName()} - Patched Methods:"); foreach (var val in ModPatches.GetPatchedMethods()) { api.Logger.Notification(" " + val.FullDescription()); } }
/// <summary> /// Applies the harmony patches for this mod. /// </summary> protected virtual void ApplyHarmonyPatches(Assembly assembly) { try { ModPatches.PatchAll(assembly); } catch (Exception ex) { Api.Logger.Audit($"{ex.Message}"); ModPatches.PatchAll(assembly == Assembly.GetExecutingAssembly() ? Assembly.GetCallingAssembly() : Assembly.GetExecutingAssembly()); if (++_retries == 3) { throw; } } }
/// <summary> /// If this mod allows runtime reloading, you must implement this method to unregister any listeners / handlers. /// </summary> public override void Dispose() { ModPatches.UnpatchAll(_patchAssembly.FullName); base.Dispose(); }