Night Sky Engine
A fighting game framework made in Unreal Engine
Loading...
Searching...
No Matches
FStateMachine Struct Reference

The player object's state machine. More...

#include <StateMachine.h>

Collaboration diagram for FStateMachine:

Public Member Functions

void AddState (const FGameplayTag &Name, UState *Config)
 
FORCEINLINE bool IsCurrentState (const FGameplayTag &Name) const
 
FGameplayTag GetStateName (int Index)
 
int GetStateIndex (FGameplayTag Name) const
 
bool SetState (const FGameplayTag Name, bool bIsAlias=false)
 
bool ForceSetState (const FGameplayTag Name, bool bIsAlias=false)
 
bool ForceSetState (TSubclassOf< UState > Class, bool bIsAlias=false)
 
bool ForceRollbackState (const FGameplayTag Name)
 
void Update () const
 

Static Public Member Functions

static bool CheckStateStanceCondition (const EEntryStance StateStance, const int PlayerStance)
 

Public Attributes

UStateCurrentState
 
TArray< UState * > States
 
TArray< FGameplayTag > StateNames
 
APlayerObjectParent
 

Detailed Description

The player object's state machine.

Contains all player states and state names, as well as the currently active state.

Definition at line 15 of file StateMachine.h.

Member Function Documentation

◆ AddState()

void FStateMachine::AddState ( const FGameplayTag & Name,
UState * Config )

Adds a state to the state machine. If no current state is set, the input state will be used as the current state. Only call at the beginning of a match!

Definition at line 7 of file StateMachine.cpp.

◆ CheckStateStanceCondition()

bool FStateMachine::CheckStateStanceCondition ( const EEntryStance StateStance,
const int PlayerStance )
static

Checks if the state allows the player's current stance.

Parameters
StateStanceThe state's required stance.
PlayerStanceThe current player's stance.
Returns
If the state stance allows the player's stance, return true. Otherwise return false.

Definition at line 152 of file StateMachine.cpp.

◆ ForceRollbackState()

bool FStateMachine::ForceRollbackState ( const FGameplayTag Name)

Sets the current state for rollback. Code called when entering a state normally will not be called.

Parameters
NameThe state to set as current.
Returns
If the state was successfully set, return true. Otherwise return false.

Definition at line 140 of file StateMachine.cpp.

◆ ForceSetState() [1/2]

bool FStateMachine::ForceSetState ( const FGameplayTag Name,
bool bIsAlias = false )

Sets the current state. If the state to set is the same as the current state, the state will be reset.

Parameters
NameThe state to set as current.
bIsAliasIf the state is being set via an alias.
Returns
If the state was successfully set, return true. Otherwise return false.

Definition at line 73 of file StateMachine.cpp.

◆ ForceSetState() [2/2]

bool FStateMachine::ForceSetState ( TSubclassOf< UState > Class,
bool bIsAlias = false )

Sets the current state. If the state to set is the same as the current state, the state will be reset.

Parameters
ClassThe state to set as current.
bIsAliasIf the state is being set via an alias.
Returns
If the state was successfully set, return true. Otherwise return false.

Definition at line 106 of file StateMachine.cpp.

◆ GetStateIndex()

int FStateMachine::GetStateIndex ( FGameplayTag Name) const

Gets the current state index.

Definition at line 29 of file StateMachine.cpp.

◆ GetStateName()

FGameplayTag FStateMachine::GetStateName ( int Index)

Gets the current state name.

Definition at line 20 of file StateMachine.cpp.

◆ IsCurrentState()

FORCEINLINE bool FStateMachine::IsCurrentState ( const FGameplayTag & Name) const
inline

Checks a name against the current state name.

Definition at line 51 of file StateMachine.h.

◆ SetState()

bool FStateMachine::SetState ( const FGameplayTag Name,
bool bIsAlias = false )

Sets the current state. If attempting to set the state to the same as the current state, nothing will happen.

Parameters
NameThe state to set as current.
bIsAliasIf the state is being set via an alias.
Returns
If the state was successfully set, return true. Otherwise return false.

Definition at line 34 of file StateMachine.cpp.

◆ Update()

void FStateMachine::Update ( ) const

Calls the current state's exec function.

Definition at line 166 of file StateMachine.cpp.

Member Data Documentation

◆ CurrentState

UState* FStateMachine::CurrentState

The currently active state.

Definition at line 23 of file StateMachine.h.

◆ Parent

APlayerObject* FStateMachine::Parent

The parent of this state machine.

Definition at line 39 of file StateMachine.h.

◆ StateNames

TArray<FGameplayTag> FStateMachine::StateNames

An array of all player state names. Used to lookup states.

Definition at line 34 of file StateMachine.h.

◆ States

TArray<UState*> FStateMachine::States

An array of all player states.

Definition at line 28 of file StateMachine.h.


The documentation for this struct was generated from the following files: