Class ActionState<T>
Definition
Namespace: StardewUI.Input
Assembly: StardewUI.dll
Translates raw input to semantic actions.
Type Parameters
T
The semantic action type.
Inheritance
Object ⇦ ActionState<T>
Members
Constructors
Name | Description |
---|---|
ActionState<T>(ActionRepeat, Boolean) | Translates raw input to semantic actions. |
Methods
Name | Description |
---|---|
Bind(SButton, T, ActionRepeat, Boolean?) | Binds an action to a single button. |
Bind(IReadOnlyList<SButton>, T, ActionRepeat, Boolean) | Binds an action to several individual buttons. |
Bind(Keybind, T, ActionRepeat, Boolean?) | Binds an action to a button combination. |
Bind(IReadOnlyList<Keybind>, T, ActionRepeat, Boolean?) | Binds an action to several button combinations. |
Bind(KeybindList, T, ActionRepeat, Boolean?) | Binds an action to all keybinds in a KeybindList. |
GetControllerBindings(T) | Gets all controller bindings associated with a given action. |
GetCurrentActions() | Gets the actions that should be run right now, either because one of the triggering buttons/combinations was just pressed, or because it was held and is due to repeat. |
GetKeyboardBindings(T) | Gets all keyboard bindings associated with a given action. |
Details
Constructors
ActionState<T>(ActionRepeat, bool)
Translates raw input to semantic actions.
Parameters
defaultRepeat
ActionRepeat
Default repetition settings for registered actions that do not specify one.
defaultSuppress
Boolean
Whether registered actions should, by default, suppress the normal game behavior for any buttons in their active keybinds. Individual registrations can override this setting.
Methods
Bind(SButton, T, ActionRepeat, bool?)
Binds an action to a single button.
public StardewUI.Input.ActionState<T> Bind(StardewModdingAPI.SButton button, T action, StardewUI.Input.ActionRepeat repeat, bool? suppress);
Parameters
button
SButton
The bound button.
action
T
The action to activate.
repeat
ActionRepeat
Repeat behavior for this binding, if not using the default setting.
suppress
Nullable<Boolean>
Input suppression behavior for this binding, if not using the default setting.
Returns
The current instance.
Bind(IReadOnlyList<SButton>, T, ActionRepeat, bool)
Binds an action to several individual buttons.
public StardewUI.Input.ActionState<T> Bind(System.Collections.Generic.IReadOnlyList<StardewModdingAPI.SButton> buttons, T action, StardewUI.Input.ActionRepeat repeat, bool suppress);
Parameters
buttons
IReadOnlyList
List of buttons which will each trigger the associated action
.
action
T
The action to activate.
repeat
ActionRepeat
Repeat behavior for this binding, if not using the default setting.
suppress
Boolean
Input suppression behavior for this binding, if not using the default setting.
Returns
The current instance.
Remarks
The buttons
are not treated as a single keybind; each individual SButton will independently trigger the action
.
Bind(Keybind, T, ActionRepeat, bool?)
Binds an action to a button combination.
public StardewUI.Input.ActionState<T> Bind(StardewModdingAPI.Utilities.Keybind keybind, T action, StardewUI.Input.ActionRepeat repeat, bool? suppress);
Parameters
keybind
Keybind
Keybind containing buttons that must be simultaneously pressed.
action
T
The action to activate.
repeat
ActionRepeat
Repeat behavior for this binding, if not using the default setting.
suppress
Nullable<Boolean>
Input suppression behavior for this binding, if not using the default setting.
Returns
The current instance.
Bind(IReadOnlyList<Keybind>, T, ActionRepeat, bool?)
Binds an action to several button combinations.
public StardewUI.Input.ActionState<T> Bind(System.Collections.Generic.IReadOnlyList<StardewModdingAPI.Utilities.Keybind> keybinds, T action, StardewUI.Input.ActionRepeat repeat, bool? suppress);
Parameters
keybinds
IReadOnlyList
List of keybinds each of whose button combinations will trigger the associated action
.
action
T
The action to activate.
repeat
ActionRepeat
Repeat behavior for this binding, if not using the default setting.
suppress
Nullable<Boolean>
Input suppression behavior for this binding, if not using the default setting.
Returns
The current instance.
Bind(KeybindList, T, ActionRepeat, bool?)
Binds an action to all keybinds in a KeybindList.
public StardewUI.Input.ActionState<T> Bind(StardewModdingAPI.Utilities.KeybindList keybindList, T action, StardewUI.Input.ActionRepeat repeat, bool? suppress);
Parameters
keybindList
KeybindList
List of all keybinds that should trigger the action
.
action
T
The action to activate.
repeat
ActionRepeat
Repeat behavior for this binding, if not using the default setting.
suppress
Nullable<Boolean>
Input suppression behavior for this binding, if not using the default setting.
Returns
The current instance.
GetControllerBindings(T)
Gets all controller bindings associated with a given action.
public System.Collections.Generic.IEnumerable<StardewModdingAPI.Utilities.Keybind> GetControllerBindings(T action);
Parameters
action
T
The action to look up.
Returns
A sequence of Keybind elements that perform the specified action
and use at least one controller button.
GetCurrentActions()
Gets the actions that should be run right now, either because one of the triggering buttons/combinations was just pressed, or because it was held and is due to repeat.
Returns
Sequence of actions that should be handled this frame.
Remarks
Current actions reset on every frame regardless of whether the actions were "handled". Code that reads from GetCurrentActions
should generally do so at the end of an update tick, e.g. in SMAPI's UpdateTicked event.
GetKeyboardBindings(T)
Gets all keyboard bindings associated with a given action.
public System.Collections.Generic.IEnumerable<StardewModdingAPI.Utilities.Keybind> GetKeyboardBindings(T action);
Parameters
action
T
The action to look up.
Returns
A sequence of Keybind elements that perform the specified action
and use at least one keyboard key.