コード例 #1
0
 private static void HoeDirt_plant_Patch()
 {
     HarmonyPatcher.ApplyPatch(
         caller: typeof(HoeDirt_Patch).GetMethod("plant_Postfix"),
         original: typeof(HoeDirt).GetMethod("plant"),
         prefix: new HarmonyMethod(typeof(HoeDirt_Patch).GetMethod("plant_Prefix")),
         postfix: new HarmonyMethod(typeof(HoeDirt_Patch).GetMethod("plant_Postfix"))
         );
 }
コード例 #2
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            Globals.Helper   = this.Helper;      // Helper can be referenced by Globals.Helper
            Globals.Monitor  = this.Monitor;     // Monitor can be referenced by Globals.Logger.Log(...)
            Globals.Manifest = this.ModManifest; // Manifest can be referenced by Globals.Manifest

            // Add event hooks for our own custom methods
            helper.Events.GameLoop.DayStarted += this.OnDayStart;
            helper.Events.Input.ButtonPressed += this.OnButtonPressed;
            // the game clears locations when loading the save, so load the custom map after the save loads
            helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;

            // Uses harmony to patch all OriginalClassName_Patch.cs classes
            HarmonyPatcher.ApplyPatches();
        }