using System; using Microsoft.Xna.Framework.Input; using StardewValley; namespace StardewModdingAPI { /// Intercepts predefined Stardew Valley mod hooks. internal class SModHooks : ModHooks { /********* ** Delegates *********/ /// A delegate invoked by the hook. /// The game's keyboard state for the current tick. /// The game's mouse state for the current tick. /// The game's controller state for the current tick. /// The game's default logic. public delegate void UpdateControlInputDelegate(ref KeyboardState keyboardState, ref MouseState mouseState, ref GamePadState gamePadState, Action action); /********* ** Properties *********/ /// The callback for . private readonly UpdateControlInputDelegate UpdateControlInputHandler; /********* ** Public methods *********/ /// Construct an instance. /// The callback for . public SModHooks(UpdateControlInputDelegate updateControlInputHandler) { this.UpdateControlInputHandler = updateControlInputHandler; } /// A hook invoked before the game processes player input. /// The game's keyboard state for the current tick. /// The game's mouse state for the current tick. /// The game's controller state for the current tick. /// The game's default logic. public override void OnGame1_UpdateControlInput(ref KeyboardState keyboardState, ref MouseState mouseState, ref GamePadState gamePadState, Action action) { this.UpdateControlInputHandler(ref keyboardState, ref mouseState, ref gamePadState, action); } } }