public override void Entry(IModHelper helper) { RemovableHorseHatsConfig config = helper.ReadConfig <RemovableHorseHatsConfig>(); this.keysToRemoveHat = config.KeysToRemoveHat.ToLowerInvariant().Split(new char[] { ' ' }).Select(item => item.Trim()).Where(item => !string.IsNullOrEmpty(item)); InputEvents.ButtonPressed += this.InputEvents_ButtonPressed; InputEvents.ButtonReleased += this.InputEvents_ButtonReleased; HarmonyInstance harmony = HarmonyInstance.Create("cat.removablehorsehats"); harmony.Patch(GetSDVType("Characters.Horse").GetMethod("checkAction"), new HarmonyMethod(typeof(HorseCheckActionPatch).GetMethod("Prefix")), null); }
/// <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) { RemovableHorseHatsConfig config = helper.ReadConfig <RemovableHorseHatsConfig>(); this.keysToRemoveHat = new HashSet <SButton>( config.KeysToRemoveHat .Split(' ') .Select(raw => Enum.TryParse(raw, true, out SButton button) ? button : SButton.None) .Where(key => key != SButton.None) ); helper.Events.Input.ButtonPressed += this.OnButtonPressed; helper.Events.Input.ButtonReleased += this.OnButtonReleased; HarmonyInstance harmony = HarmonyInstance.Create("cat.removablehorsehats"); harmony.Patch(typeof(Horse).GetMethod(nameof(Horse.checkAction)), new HarmonyMethod(typeof(HorseCheckActionPatch).GetMethod(nameof(HorseCheckActionPatch.Prefix))), null); }