using System; using StardewModdingAPI.Framework.Input; namespace StardewModdingAPI.Framework.ModHelpers { /// Provides an API for checking and changing input state. internal class InputHelper : BaseHelper, IInputHelper { /********* ** Accessors *********/ /// Manages the game's input state for the current player instance. That may not be the main player in split-screen mode. private readonly Func CurrentInputState; /********* ** Public methods *********/ /// Construct an instance. /// The unique ID of the relevant mod. /// Manages the game's input state for the current player instance. That may not be the main player in split-screen mode. public InputHelper(string modID, Func currentInputState) : base(modID) { this.CurrentInputState = currentInputState; } /// public ICursorPosition GetCursorPosition() { return this.CurrentInputState().CursorPosition; } /// public bool IsDown(SButton button) { return this.CurrentInputState().IsDown(button); } /// public bool IsSuppressed(SButton button) { return this.CurrentInputState().IsSuppressed(button); } /// public void Suppress(SButton button) { this.CurrentInputState().OverrideButton(button, setDown: false); } /// public SButtonState GetState(SButton button) { return this.CurrentInputState().GetState(button); } } }