Liberi Developer Guide: Controls
From EQUIS Lab Wiki
Contents |
About
The Controls class is a client-side class which allows game scripts to read and respond to player controls in a meaningful manner. In order for the Controls class to function, there must be a device(s) present and providing controls information via injection (see below). The idea is that, no matter what kind of physical input device is used, ultimately player controls will be translated into a common schema consisting of power, direction, and actions. For full details, read the source file at Scripts/Core/Controls.cs.
API
Enumerations
-
ControlsAction
- Enumeration of player control actions. The interpretations of these actions can be context-sensitive. For example, the primary action can be used to interact with objects, to use an avatar skill, or to confirm a selection. Possible values:
Primary
,Secondary
,CycleNext
,CyclePrevious
,Menu
.
Interfaces
-
IActionInfoProvider
- Provides additional runtime information about an action. Specifically, whether or not the action is currently enabled, and the current caption for the action. Providers for each action can be registered or unregistered at any time during the game. Multiple providers may be simultaneously registered for each action, but the latest provider will have authority. For example, an avatar may provide information for the primary action as a skill use action, but if the avatar is touching an interactive object, the object can provide information for the primary action as an interaction action, and this will override the information provided by the avatar.
Properties
-
Power
- An abstract value representing the amount of "power" a player is generating at any given moment. This is a continuous value between 0 and 1, with 0 representing no power, and 1 representing full power. The most common interpretation of this value is as a normalized desired avatar speed.
-
Direction
- The direction the player is currently trying to communicate to the game. Depending on context, this could be interpreted as a desired orientation for the avatar, or as a desired scroll / highlight direction in a menu. Other interpretations are possible.
-
RawCadence
- Returns the raw pedaling cadence for logging use or other study reasons.
-
PowerCurve
- Mapping of cadence to in-game avatar speed.
-
MinPower
- The value below which power is simply considered zero.
Methods
-
InjectPower
- Call this method from a device script in order to provide a power value. For example, a bike device can be used in conjunction with the local player's health profile in order to convert cadence values into effort-normalized power values.
-
InjectDirection
- Call this method from a device script in order to provide a directional value. For example, this can come from the left control stick on a gamepad, or from the WASD keys on a keyboard.
-
InjectActionState
- Call this method from a device script in order to provide the state of an action (boolean). This is usually provided by buttons or keys on any device.
-
GetAction/GetActionDown/GetActionUp/GetActionHoldTime
- Queries action state information. e.g., whether it is currently down, whether it just became down, whether it just became up, and the time it has stayed down.
-
Register/UnregisterActionInfoProvider
- Register or unregister an
IActionInfoProvider
for a specific action. Once registered, a provider will become solely responsible for providing the enabled/disabled state as well as the caption for the action.
-
GetActionCaption
- Queries the current caption for an action.
-
IsActionEnabled
- Checks whether or not the action is currently enabled.