tweak patch code style

This commit is contained in:
Jesse Plamondon-Willard 2019-04-14 22:14:43 -04:00
parent 36efdcfce2
commit e43f01ffce
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
4 changed files with 14 additions and 15 deletions

View File

@ -42,7 +42,7 @@ namespace StardewModdingAPI.Patches
{
harmony.Patch(
original: AccessTools.Method(typeof(GameLocation), "checkEventPrecondition"),
prefix: new HarmonyMethod(AccessTools.Method(this.GetType(), nameof(CheckEventPreconditionErrorPatch.Prefix)))
prefix: new HarmonyMethod(this.GetType(), nameof(CheckEventPreconditionErrorPatch.Prefix))
);
}

View File

@ -46,10 +46,10 @@ namespace StardewModdingAPI.Patches
/// <param name="harmony">The Harmony instance.</param>
public void Apply(HarmonyInstance harmony)
{
ConstructorInfo constructor = AccessTools.Constructor(typeof(Dialogue), new[] { typeof(string), typeof(NPC) });
MethodInfo prefix = AccessTools.Method(this.GetType(), nameof(DialogueErrorPatch.Prefix));
harmony.Patch(constructor, new HarmonyMethod(prefix), null);
harmony.Patch(
original: AccessTools.Constructor(typeof(Dialogue), new[] { typeof(string), typeof(NPC) }),
prefix: new HarmonyMethod(this.GetType(), nameof(DialogueErrorPatch.Prefix))
);
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Reflection;
using Harmony;
using StardewModdingAPI.Enums;
using StardewModdingAPI.Framework.Patching;
@ -28,7 +27,7 @@ namespace StardewModdingAPI.Patches
private static bool IsCreating;
/// <summary>The number of times that <see cref="Game1.locations"/> has been cleared since <see cref="Game1.loadForNewGame"/> started.</summary>
private static int TimesLocationsCleared = 0;
private static int TimesLocationsCleared;
/*********
@ -54,11 +53,11 @@ namespace StardewModdingAPI.Patches
/// <param name="harmony">The Harmony instance.</param>
public void Apply(HarmonyInstance harmony)
{
MethodInfo method = AccessTools.Method(typeof(Game1), nameof(Game1.loadForNewGame));
MethodInfo prefix = AccessTools.Method(this.GetType(), nameof(LoadForNewGamePatch.Prefix));
MethodInfo postfix = AccessTools.Method(this.GetType(), nameof(LoadForNewGamePatch.Postfix));
harmony.Patch(method, new HarmonyMethod(prefix), new HarmonyMethod(postfix));
harmony.Patch(
original: AccessTools.Method(typeof(Game1), nameof(Game1.loadForNewGame)),
prefix: new HarmonyMethod(this.GetType(), nameof(LoadForNewGamePatch.Prefix)),
postfix: new HarmonyMethod(this.GetType(), nameof(LoadForNewGamePatch.Postfix))
);
}
@ -89,7 +88,7 @@ namespace StardewModdingAPI.Patches
if (LoadForNewGamePatch.IsCreating)
{
// clean up
ObservableCollection<GameLocation> locations = (ObservableCollection<GameLocation>) Game1.locations;
ObservableCollection<GameLocation> locations = (ObservableCollection<GameLocation>)Game1.locations;
locations.CollectionChanged -= LoadForNewGamePatch.OnLocationListChanged;
// raise stage changed

View File

@ -27,13 +27,13 @@ namespace StardewModdingAPI.Patches
// object.getDescription
harmony.Patch(
original: AccessTools.Method(typeof(SObject), nameof(SObject.getDescription)),
prefix: new HarmonyMethod(AccessTools.Method(this.GetType(), nameof(ObjectErrorPatch.Object_GetDescription_Prefix)))
prefix: new HarmonyMethod(this.GetType(), nameof(ObjectErrorPatch.Object_GetDescription_Prefix))
);
// IClickableMenu.drawToolTip
harmony.Patch(
original: AccessTools.Method(typeof(IClickableMenu), nameof(IClickableMenu.drawToolTip)),
prefix: new HarmonyMethod(AccessTools.Method(this.GetType(), nameof(ObjectErrorPatch.IClickableMenu_DrawTooltip_Prefix)))
prefix: new HarmonyMethod(this.GetType(), nameof(ObjectErrorPatch.IClickableMenu_DrawTooltip_Prefix))
);
}