Details

Last Updated
2 years ago
First Uploaded
2 years ago
Downloads
137K
Likes
0
Size
21KB
Dependency string
willreuploadscuzheruinedstuff-PlayerActionsHelper-0.0.1
Dependants

Categories

Player Actions Helper

A mod designed to make creating player actions simpler.

Register an action with PlayerActionManager.RegisterPlayerAction() in your mod's awake function.

Access that action with player.data.playerActions.GetPlayerAction() in your mod.

Change log

v0.0.1

  • Fixed a small bug

v0.0.0

  • Initial Release
Properties

RegisteredActions

ReadOnlyDictionary<string, ActionInfo> RegisteredActions { get; }

Description

A list of all actions registered so far.

Classes

ActionInfo

class ActionInfo

Fields

  • string name;
  • BindingSource keyboardlayout;
  • BindingSource controllerLayout;

Constructors

ActionInfo()

ActionInfo ActionInfo(string name, BindingSource keyboardlayout = null, BindingSource controllerLayout = null)

Description

Creates a set of information for usage in binding player actions.

Parameters

  • string name The name for the action.
  • BindingSource keyboardlayout An optional parameter for setting the default keyboard layout.
  • BindingSource controllerLayout An optional parameter for setting the default controller layout.

Example Usage

PlayerActionManager.RegisterPlayerAction(new ActionInfo("ToggleFlight", new KeyBindingSource(Key.Key1), new DeviceBindingSource(InputControlType.Action3)));
Functions

RegisterPlayerAction()

void RegisterPlayerAction(ActionInfo actionInfo)

Description

Registers an action to be automatically generated for players.

NOTE: You should only be registering actions in your mod's awake function. If you register them any later, they will not show in rebind controls.

Parameters

  • ActionInfo actionInfo the details of the action to be registered.

Example Usage

PlayerActionManager.RegisterPlayerAction(new ActionInfo("ToggleFlight", new KeyBindingSource(Key.Key1), new DeviceBindingSource(InputControlType.Action3)));
ExtensionMethods

GetPlayerAction()

PlayerAction GetPlayerAction(this PlayerActions playerActions, string name)

Description

Returns a registered PlayerAction that has been created for the player. Returns null if the action doesn't exist.

Parameters

  • string name the name of the registered action.

Example Usage

player.data.playerActions.GetPlayerAction(name);

ActionWasPressed()

bool ActionWasPressed(this PlayerActions playerActions, string name)

Description

Returns whether a registered action was pressed. Returns false if the action doesn't exist.

Note that this is an alternative to fetching the action and then checking the PlayerAction::WasPressed property.

Parameters

  • string name the name of the registered action.

Example Usage

player.data.playerActions.ActionWasPressed(name);

ActionIsPressed()

bool ActionIsPressed(this PlayerActions playerActions, string name)

Description

Returns whether a registered action is pressed. Returns false if the action doesn't exist.

Note that this is an alternative to fetching the action and then checking the PlayerAction::IsPressed property.

Parameters

  • string name the name of the registered action.

Example Usage

player.data.playerActions.ActionIsPressed(name);

ActionWasReleased()

bool ActionWasReleased(this PlayerActions playerActions, string name)

Description

Returns whether a registered action was released. Returns false if the action doesn't exist.

Note that this is an alternative to fetching the action and then checking the PlayerAction::WasReleased property.

Parameters

  • string name the name of the registered action.

Example Usage

player.data.playerActions.ActionWasReleased(name);
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.