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 FName &Name, UState *Config)
 
FORCEINLINE bool IsCurrentState (const FName &Name) const
 
FName GetStateName (int Index)
 
int GetStateIndex (FName Name) const
 
bool SetState (const FName Name, bool bIsAlias=false)
 
bool ForceSetState (const FName Name, bool bIsAlias=false)
 
bool ForceRollbackState (const FName Name)
 
void Update () const
 

Static Public Member Functions

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

Public Attributes

UStateCurrentState
 
TArray< UState * > States
 
TArray< FName > 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 FName & 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 118 of file StateMachine.cpp.

◆ ForceRollbackState()

bool FStateMachine::ForceRollbackState ( const FName 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 106 of file StateMachine.cpp.

◆ ForceSetState()

bool FStateMachine::ForceSetState ( const FName 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.

◆ GetStateIndex()

int FStateMachine::GetStateIndex ( FName Name) const

Gets the current state index.

Definition at line 29 of file StateMachine.cpp.

◆ GetStateName()

FName FStateMachine::GetStateName ( int Index)

Gets the current state name.

Definition at line 20 of file StateMachine.cpp.

◆ IsCurrentState()

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

Checks a name against the current state name.

Definition at line 51 of file StateMachine.h.

◆ SetState()

bool FStateMachine::SetState ( const FName 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 132 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<FName> 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: