Scripting API
Scripting API
PlayerInput
Class in Abyss.Core, from Abyss.Core.
One player's input actions, asked about each frame: context.Input.Pressed(Actions.Player.Jump), context.Input.Vector("Move").
public sealed class PlayerInputRemarks
The first question of a frame reads every action's state from the engine in one crossing; the rest of the frame's are answered from that, so asking is cheap and the same from every system, several at once included. An action is named as ActionName says: as the build writes it, Actions.Player.Jump, by its path or by its InputAction.
Player zero reads every keyboard, mouse and gamepad; a player after it reads nothing until devices can be given to players. Each player has its own maps on and off, and its own bindings in place of the game's: see PlayerInput.Rebind.
Properties
Rebindings
public IReadOnlyList<Rebinding> Rebindings { get; }This player's own bindings, in place of the game's.
Player
public int Player { get; }Which player it is, from zero.
LastDevice
public InputDevice LastDevice { get; }The device this player last used, of what the game is given — a key or a mouse button pressed, the mouse moved further than it drifts, or a gamepad's button or stick pushed past halfway — and for a gamepad, whose: what PlayerInput.Prompt names the buttons for.
Pointer
public Vector2? Pointer { get; }Where the mouse's cursor is over the game's picture this frame, in its logical pixels from the top left of where it is drawn: the point World.ScreenRay and World.ScreenToWorld take. In the editor it is measured in the Game panel's picture, as a built game's is in its window. Null while the cursor is off the picture or the mouse is not the game's, and for a player after the first, who reads no mouse.
DeviceChanged
public bool DeviceChanged { get; }Whether PlayerInput.LastDevice changed this frame: the frame to show the other device's prompts.
Methods
Rebind
public RebindResult Rebind(ActionName action, int binding, BindingSource source, string? part = null)Binds the bindingth binding of action — of its composite, the part part — to source for this player, in place of the game's, from the next frame; kept in the player's folder, where the game has one, and read back as it starts again.
Parameters
action: The action.binding: Which of its bindings, from zero, in the orderInputAction.Bindingshas them.source: What it reads now.part: For a composite, which part:up,down,leftorright;negativeorpositive.
Exceptions
ArgumentException: No action in use is the one named, a composite's part is not said or is not one of its, or the source does not fit.ArgumentOutOfRangeException: The action has no bindingbinding.
Bound even where another action of its map has the source too: the result says which, for the game to move theirs or tell the player. The game's own source put back is the game's binding again, nothing of the player's kept for it.
GameCode.Rebind listens for what the player presses next and binds it.
SourceOf
public BindingSource SourceOf(ActionName action, int binding = 0, string? part = null)What the bindingth binding of action, or the part part of it, reads for this player: theirs, or the game's.
Parameters
actionbindingpart
Exceptions
ArgumentException: AsPlayerInput.Rebind.ArgumentOutOfRangeException: AsPlayerInput.Rebind.
IsRebound
public bool IsRebound(ActionName action, int binding = 0, string? part = null)Whether this player has a binding of their own in place of that one.
Parameters
actionbindingpart
Exceptions
ArgumentException: AsPlayerInput.Rebind.ArgumentOutOfRangeException: AsPlayerInput.Rebind.
ResetBinding
public bool ResetBinding(ActionName action, int binding = 0, string? part = null)Puts the game's binding back in place of this player's own, or a composite's part.
Parameters
actionbindingpart
Returns Whether they had one there.
Exceptions
ArgumentException: AsPlayerInput.Rebind.ArgumentOutOfRangeException: AsPlayerInput.Rebind.
ResetBindings
public void ResetBindings()Puts the game's bindings back in place of every one of this player's own.
ClashesOf
public IReadOnlyList<InputAction> ClashesOf(ActionName action, BindingSource source)The other actions of action's map this player has on source.
Parameters
actionsource
Exceptions
ArgumentException: No action in use is the one named.
Prompt
public string Prompt(ActionName action)What to press for action, named for the device this player last used: Space, A on one maker's pad and Cross on another's, W/A/S/D for four keys — its first binding on that device, the player's own where they have one, or its first at all where none is; nothing for an action with no bindings.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named.
State
public InputActionState State(ActionName action)The action's state this frame.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
Pressed
public bool Pressed(ActionName action)Whether it went down this frame.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
Held
public bool Held(ActionName action)Whether it is held.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
Released
public bool Released(ActionName action)Whether it came up this frame.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
Value
public float Value(ActionName action)Its value: a button's how far pressed, an axis's, a vector's x.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
Vector
public Vector2 Vector(ActionName action)A vector's value, up positive.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
HeldTime
public float HeldTime(ActionName action)Seconds it has been held: zero the frame it is pressed and while it is not held, and on the frame it is let go, how long it was.
Parameters
action
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
HeldFor
public bool HeldFor(ActionName action, float seconds)Whether it has been held for seconds as of this frame and had not been the frame before: true on the one frame the hold gets there, so if (input.HeldFor("Interact", 0.5f)) OpenDoor(); opens it once.
Parameters
actionseconds
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
Tapped
public bool Tapped(ActionName action, float within = 0.2)Whether it came up this frame after being held no longer than within seconds: a tap.
Parameters
actionwithin
Exceptions
ArgumentException: No action in use is the one named, or more than one map has an action of the name its path says alone.
Enable
public void Enable(MapName map)Switches the map on for this player from the next frame.
Parameters
map
Exceptions
ArgumentException: No map in use is the one named.
Disable
public void Disable(MapName map)Switches the map off for this player from the next frame: its actions read zero, and one held comes up.
Parameters
map
Exceptions
ArgumentException: No map in use is the one named.
IsEnabled
public bool IsEnabled(MapName map)Whether this player has the map on.
Parameters
map
Exceptions
ArgumentException: No map in use is the one named.
