ControllerAction
A class in Root.Township, the global namespace.
Client: one input action (such as interact or jump) for a player's hand, bound to one or more buttons, key pairs, D-pad directions or swipes from the platform mapping. Reads as a bool for whether it is held.
- Listed in Global namespace: C to D
- Inherits or implements
IControllerAction
Constructors
| Member | What it is |
|---|---|
ControllerAction() | Creates a ControllerAction with default values. |
Fields
3 private and internal fields
| Member | What it is |
|---|---|
private List<InputSourcePair> allInputSources | Every input pair currently bound to this action, across platform mappings. |
private bool isChanged | Unused flag. |
private bool state | Whether the action is currently held. Backing field for State. |
Properties
| Member | What it is |
|---|---|
bool State { get; } | True while any binding is held. |
ControllerActionType Type { get; set; } | Which action this is. |
Events
| Member | What it is |
|---|---|
event ClickedEndEventHandler Ended | Raised when the action stops being held, or is disabled while held. |
event ClickedEventHandler Started | Raised when the action becomes held. |
Methods
| Member | What it is |
|---|---|
void AddInputAndListeners(List<object[]> buttonsList, PlayerInput controller, PlatformActionMapping mapping) | Adds more bindings from a mapping without removing the current ones. |
static bool op_Implicit(ControllerAction input) | Lets the action be used as a bool, giving State. |
void RemoveAllInputsAndListeners(PlayerInput controller) | Removes every binding and ends the action if it was held. |
void RemoveInputsAndListeners(PlatformActionMapping mapping, PlayerInput controller) | Removes the bindings that came from one mapping. Ends the action if none are left. |
void SetInputAndListeners(List<object[]> buttonsList, PlayerInput controller, PlatformActionMapping mapping) | Replaces the bindings with ones from a mapping. For a pair, the second input must be pressed while the first is held. |
7 private and internal methods
| Member | What it is |
|---|---|
private void OnActionEnded(InputSource inputSource, PlayerInput controller) | Sets the state to off and raises Ended if it was on; the overload taking an input source is the per-input listener. |
private void OnActionEnded(PlayerInput controller, bool isDisabling) | Sets the state to off and raises Ended if it was on; the overload taking an input source is the per-input listener. |
private void OnActionStarted(InputSource inputSource, PlayerInput controller) | Sets the state to on and raises Started if it was off; for two-key combos it first checks the primary input is held. |
private void OnActionStarted(PlayerInput controller) | Sets the state to on and raises Started if it was off; for two-key combos it first checks the primary input is held. |
private void PopulateInputSourcePair(object[] buttons, InputSourcePair inputSourcePair, PlayerInput controller) | Builds the primary and optional secondary input for one binding from a key code or a GeneralInputType. |
private void RemoveInputSource(InputSourcePair inputToRemove) | Unhooks one input pair's listeners and removes it from the action. |
private void SetupListeners(List<InputSourcePair> sourceToListenTo) | Hooks the press and release events of each input pair to this action. |
Used in
Members of other types that take, return or hold a ControllerAction: