summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Patching/GamePatcher.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-30 00:54:15 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-30 00:54:15 -0400
commit948c800a98f00b1bdcfd05ee6228e3423f9eb465 (patch)
treeb958b3cdb4428fa8788a5698a207a45912923de7 /src/SMAPI/Framework/Patching/GamePatcher.cs
parent4074f697d73f5cac6699836550b144fd0c4e2803 (diff)
downloadSMAPI-948c800a98f00b1bdcfd05ee6228e3423f9eb465.tar.gz
SMAPI-948c800a98f00b1bdcfd05ee6228e3423f9eb465.tar.bz2
SMAPI-948c800a98f00b1bdcfd05ee6228e3423f9eb465.zip
migrate to the new Harmony patch pattern used in my mods
That improves validation and error-handling.
Diffstat (limited to 'src/SMAPI/Framework/Patching/GamePatcher.cs')
-rw-r--r--src/SMAPI/Framework/Patching/GamePatcher.cs45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/SMAPI/Framework/Patching/GamePatcher.cs b/src/SMAPI/Framework/Patching/GamePatcher.cs
deleted file mode 100644
index 3ce22ee9..00000000
--- a/src/SMAPI/Framework/Patching/GamePatcher.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using HarmonyLib;
-
-namespace StardewModdingAPI.Framework.Patching
-{
- /// <summary>Encapsulates applying Harmony patches to the game.</summary>
- internal class GamePatcher
- {
- /*********
- ** Fields
- *********/
- /// <summary>Encapsulates monitoring and logging.</summary>
- private readonly IMonitor Monitor;
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- public GamePatcher(IMonitor monitor)
- {
- this.Monitor = monitor;
- }
-
- /// <summary>Apply all loaded patches to the game.</summary>
- /// <param name="patches">The patches to apply.</param>
- public void Apply(params IHarmonyPatch[] patches)
- {
- Harmony harmony = new Harmony("SMAPI");
- foreach (IHarmonyPatch patch in patches)
- {
- try
- {
- patch.Apply(harmony);
- }
- catch (Exception ex)
- {
- this.Monitor.Log($"Couldn't apply runtime patch '{patch.GetType().Name}' to the game. Some SMAPI features may not work correctly. See log file for details.", LogLevel.Error);
- this.Monitor.Log(ex.GetLogSummary(), LogLevel.Trace);
- }
- }
- }
- }
-}