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 the PlayerWorker associated with PlayerState.

  • 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 the PlayerState class, assigning the PlayerWorker. It sets the default state to Idle and initializes the resetActions 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 default Idle 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