Player State
The PlayerState
is responsible from the state of a player character and handles the execution of specific actions when the player's state changes.
Properties
private PlayerWorker playerWorker
: References thePlayerWorker
associated withPlayerState
.public Dictionary<StateType, List<Action>> resetActions
: Represents lists of reset actions to be triggered when transitioning out of each state.public StateType state
: Represents the current state of the player.
Constructor
public PlayerState(PlayerWorker playerWorker)
: Initializes a new instance of thePlayerState
class, assigning thePlayerWorker
. It sets the default state toIdle
and initializes theresetActions
dictionary for all state types.
Methods
public void AddResetAction(StateType state, Action resetAction)
: Adds a new reset action to the list of actions to be triggered when transitioning out of the specified state.public bool CheckState(StateType state)
: Checks if the current state matches the specified state.public void ResetState()
: Resets the player's state to the defaultIdle
state.public void SetState(StateType state)
: Sets the player's state to the specified state, triggers all reset actions associated with the old state, and updates the current state.
Last updated