Skip to content

FSMNode_Base¶

Module: SMSystem

#include <SMNode_Base.h>

Inherited by FSMState_Base, FSMTransition

Description¶

struct FSMNode_Base;

Base struct for all state machine nodes. The Guid MUST be manually initialized right after construction.

Public Classes¶

Public Functions¶

Name
FSMNode_FunctionHandlers * GetFunctionHandlers() const
virtual void UpdateReadStates()
FSMNode_Base()
virtual ~FSMNode_Base() =default
FSMNode_Base(const FSMNode_Base & Node) =default
FSMNode_Base & operator=(const FSMNode_Base & Node)
virtual void Initialize(USMInstance * Instance)
const TSharedPtr< FSMNodeRuntimeData > & GetRuntimeData() const
template \<typename T >
TSharedPtr< T >
GetRuntimeDataAs() const
virtual void InitializeGraphFunctions()
virtual void Reset()
virtual void OnStartedByInstance(USMInstance * Instance)
virtual void OnStoppedByInstance(USMInstance * Instance)
bool HaveGraphFunctionsInitialized() const
bool IsInitializedForRun() const
const FGuid & GetNodeGuid() const
void GenerateNewNodeGuid()
const FGuid & GetGuid() const
virtual void CalculatePathGuid(TMap< FString, int32 > & InOutMappedPaths, bool bUseGuidCache =false)
FString GetGuidPath(TMap< FString, int32 > & InOutMappedPaths) const
FGuid CalculatePathGuidConst() const
void GenerateNewNodeGuidIfNotSet()
void SetNodeGuid(const FGuid & NewGuid)
void SetOwnerNodeGuid(const FGuid & NewGuid)
const FGuid & GetOwnerNodeGuid() const
void SetOwnerNode(FSMNode_Base * Owner)
virtual FSMNode_Base * GetOwnerNode() const
USMInstance * GetOwningInstance() const
void CreateNodeInstance()
void CreateStackInstances()
virtual void RunConstructionScripts()
void SetNodeInstanceClass(UClass * NewNodeInstanceClass)
virtual bool IsNodeInstanceClassCompatible(UClass * NewNodeInstanceClass) const
virtual USMNodeInstance * GetNodeInstance() const
virtual USMNodeInstance * GetOrCreateNodeInstance()
virtual bool CanEverCreateNodeInstance() const
const TArray< TObjectPtr< USMNodeInstance > > & GetStackInstancesConst() const
TArray< TObjectPtr< USMNodeInstance > > & GetStackInstances()
USMNodeInstance * GetNodeInStack(int32 Index) const
USMNodeInstance * GetNodeInStack(const FGuid & InTemplateGuid) const
virtual UClass * GetDefaultNodeInstanceClass() const
UClass * GetNodeInstanceClass() const
bool IsUsingDefaultNodeClass() const
void AddVariableGraphProperty(const FSMGraphProperty_Base_Runtime & GraphProperty, const FGuid & OwningTemplateGuid)
void SetNodeName(const FString & Name)
const FString & GetNodeName() const
void SetTemplateName(const FName & Name)
FName GetTemplateName(USMNodeInstance * InNodeInstance =nullptr) const
void AddStackTemplateName(const FName & Name, UClass * TemplateClass)
virtual bool IsActive() const
virtual void ExecuteInitializeNodes()
virtual void ExecuteShutdownNodes()
virtual void SetServerTimeInState(float InTime)
float GetServerTimeInState() const
virtual bool CanExecuteGraphProperties(ESMGraphPropertyEvalFlags OnEvent, const class USMStateInstance_Base * ForTemplate, ESMGraphPropertyDirection InDirection) const
virtual bool TryExecuteGraphProperties(ESMGraphPropertyEvalFlags OnEvent, ESMGraphPropertyDirection InDirection)
void TryExecuteGraphProperties(ESMGraphPropertyEvalFlags OnEvent)
void ExecuteGraphProperties(USMNodeInstance * ForNodeInstance, const FGuid * ForTemplateGuid)
void ExecuteGraphProperties(const FFilterGraphPropertyArgs & InArgs)
const TArray< FSMGraphProperty_Base_Runtime * > & GetGraphProperties() const
const TMap< FGuid, FSMGraphPropertyTemplateOwner > & GetTemplateGraphProperties() const
virtual void TryResetVariables()
virtual bool IsDebugActive() const
virtual bool WasDebugActive() const
virtual void EditorShutdown()
virtual void ResetGeneratedValues()
void TriggerDebugBreakpoint()
FName GetNodeGuidPropertyName()
FName GetPathGuidPropertyName()

Protected Functions¶

Name
virtual TSharedPtr< FSMNodeRuntimeData > CreateRuntimeData() const
virtual void InitializeFunctionHandlers()
virtual void PrepareGraphExecution()
virtual void SetActive(bool bValue)
void CreateGraphProperties()
void CreateGraphPropertiesForTemplate(USMNodeInstance * Template, const TMap< FGuid, FSMGraphProperty_Base_Runtime * > & MappedGraphPropertyInstances)

Public Attributes¶

Name
bool bValidateGuids
FVector2D NodePosition
float TimeInState
int32 DuplicateId
uint8 bIsInEndState
uint8 bHasUpdated
uint8 bHasInputEvents

Protected Attributes¶

Name
FGuid Guid
FGuid OwnerGuid
FGuid PathGuid
FString NodeName
FName TemplateName
TArray< FName > StackTemplateNames
TArray< TObjectPtr< USMNodeInstance > > StackNodeInstances
TObjectPtr< USMInstance > OwningInstance
TObjectPtr< USMNodeInstance > NodeInstance
TMap< FGuid, FSMGraphPropertyTemplateOwner > TemplateVariableGraphProperties
TObjectPtr< UClass > NodeInstanceClass

Friends¶

Public Functions Documentation¶

function GetFunctionHandlers¶

inline FSMNode_FunctionHandlers * GetFunctionHandlers() const

function UpdateReadStates¶

inline virtual void UpdateReadStates()

Reimplemented by: FSMState_Base::UpdateReadStates, FSMTransition::UpdateReadStates


function FSMNode_Base¶

FSMNode_Base()

function ~FSMNode_Base¶

virtual ~FSMNode_Base() =default

function FSMNode_Base¶

FSMNode_Base(
    const FSMNode_Base & Node
) =default

function operator=¶

FSMNode_Base & operator=(
    const FSMNode_Base & Node
)

function Initialize¶

virtual void Initialize(
    USMInstance * Instance
)

Initializes various properties and associate the node with its owning state machine instance.

Parameters:

Instance
The state machine instance used to initialize the node.

Reimplemented by: FSMConduit::Initialize, FSMState_Base::Initialize, FSMState::Initialize, FSMStateMachine::Initialize, FSMTransition::Initialize


function GetRuntimeData¶

inline const TSharedPtr< FSMNodeRuntimeData > & GetRuntimeData() const

Retrieve the runtime-only data relevant to this node.


function GetRuntimeDataAs¶

template <typename T >
inline TSharedPtr< T > GetRuntimeDataAs() const

function InitializeGraphFunctions¶

virtual void InitializeGraphFunctions()

Initialize all graph evaluator functions. Must be called from GameThread!

Reimplemented by: FSMConduit::InitializeGraphFunctions, FSMState_Base::InitializeGraphFunctions, FSMState::InitializeGraphFunctions, FSMStateMachine::InitializeGraphFunctions, FSMTransition::InitializeGraphFunctions


function Reset¶

virtual void Reset()

Resets persistent data.

Reimplemented by: FSMConduit::Reset, FSMState_Base::Reset, FSMState::Reset, FSMStateMachine::Reset, FSMTransition::Reset


function OnStartedByInstance¶

virtual void OnStartedByInstance(
    USMInstance * Instance
)

Called when the blueprint owning this node is started.

Reimplemented by: FSMState_Base::OnStartedByInstance, FSMState::OnStartedByInstance, FSMStateMachine::OnStartedByInstance


function OnStoppedByInstance¶

virtual void OnStoppedByInstance(
    USMInstance * Instance
)

Called when the blueprint owning this node has stopped.

Reimplemented by: FSMState_Base::OnStoppedByInstance, FSMState::OnStoppedByInstance, FSMStateMachine::OnStoppedByInstance


function HaveGraphFunctionsInitialized¶

inline bool HaveGraphFunctionsInitialized() const

If all graph function initialization has taken place once.


function IsInitializedForRun¶

inline bool IsInitializedForRun() const

If the node is currently initialized for this run.


function GetNodeGuid¶

const FGuid & GetNodeGuid() const

Unique identifier used in constructing nodes from a graph. May not be unique if this is from a parent graph or a reference.


function GenerateNewNodeGuid¶

void GenerateNewNodeGuid()

function GetGuid¶

const FGuid & GetGuid() const

Unique identifier taking into account qualified path. Unique across blueprints if called after Instance initialization.


function CalculatePathGuid¶

virtual void CalculatePathGuid(
    TMap< FString, int32 > & InOutMappedPaths,
    bool bUseGuidCache =false
)

Calculate the value returned from GetGuid(). Gets all owner nodes and builds a path to this node. Hashes the path and sets PathGuid.

Reimplemented by: FSMStateMachine::CalculatePathGuid


function GetGuidPath¶

FString GetGuidPath(
    TMap< FString, int32 > & InOutMappedPaths
) const

Unhashed string format of the guid path. MappedPaths are used to adjust for collisions.


function CalculatePathGuidConst¶

FGuid CalculatePathGuidConst() const

Calculate the path guid but do not set the guid.


function GenerateNewNodeGuidIfNotSet¶

void GenerateNewNodeGuidIfNotSet()

Only generate a new guid if the current guid is invalid. This needs to be called on new nodes.


function SetNodeGuid¶

inline void SetNodeGuid(
    const FGuid & NewGuid
)

function SetOwnerNodeGuid¶

inline void SetOwnerNodeGuid(
    const FGuid & NewGuid
)

The state machine's NodeGuid owning this node.


function GetOwnerNodeGuid¶

inline const FGuid & GetOwnerNodeGuid() const

Unique identifier to help determine which state machine this node belongs to.


function SetOwnerNode¶

inline void SetOwnerNode(
    FSMNode_Base * Owner
)

The node directly owning this node. Should be a StateMachine.


function GetOwnerNode¶

inline virtual FSMNode_Base * GetOwnerNode() const

The node directly owning this node. Should be a StateMachine.

Reimplemented by: FSMStateMachine::GetOwnerNode


function GetOwningInstance¶

inline USMInstance * GetOwningInstance() const

The state machine instance owning this node.


function CreateNodeInstance¶

void CreateNodeInstance()

Create the node instance if a node instance class is set.


function CreateStackInstances¶

void CreateStackInstances()

function RunConstructionScripts¶

virtual void RunConstructionScripts()

Reimplemented by: FSMStateMachine::RunConstructionScripts


function SetNodeInstanceClass¶

void SetNodeInstanceClass(
    UClass * NewNodeInstanceClass
)

Calls CheckNodeInstanceCompatible.


function IsNodeInstanceClassCompatible¶

virtual bool IsNodeInstanceClassCompatible(
    UClass * NewNodeInstanceClass
) const

Derived nodes should overload and check for the correct type.

Reimplemented by: FSMConduit::IsNodeInstanceClassCompatible, FSMState_Base::IsNodeInstanceClassCompatible, FSMStateMachine::IsNodeInstanceClassCompatible, FSMTransition::IsNodeInstanceClassCompatible


function GetNodeInstance¶

inline virtual USMNodeInstance * GetNodeInstance() const

Return the current node instance. Only valid after initialization and may be nullptr.

Reimplemented by: FSMStateMachine::GetNodeInstance


function GetOrCreateNodeInstance¶

virtual USMNodeInstance * GetOrCreateNodeInstance()

Create a node instance on demand if needed. Only required for default node classes. Initialization should be completed before calling.

Reimplemented by: FSMStateMachine::GetOrCreateNodeInstance


function CanEverCreateNodeInstance¶

inline virtual bool CanEverCreateNodeInstance() const

If the node can at some point create a node instance.

Reimplemented by: FSMStateMachine::CanEverCreateNodeInstance


function GetStackInstancesConst¶

inline const TArray< TObjectPtr< USMNodeInstance > > & GetStackInstancesConst() const

Returns the current stack instances.


function GetStackInstances¶

inline TArray< TObjectPtr< USMNodeInstance > > & GetStackInstances()

function GetNodeInStack¶

USMNodeInstance * GetNodeInStack(
    int32 Index
) const

Returns a specific state from the stack.


function GetNodeInStack¶

USMNodeInstance * GetNodeInStack(
    const FGuid & InTemplateGuid
) const

Returns a node in the stack the template guid.


function GetDefaultNodeInstanceClass¶

inline virtual UClass * GetDefaultNodeInstanceClass() const

The default node instance class. Each derived node class needs to implement.

Reimplemented by: FSMConduit::GetDefaultNodeInstanceClass, FSMState_Base::GetDefaultNodeInstanceClass, FSMStateMachine::GetDefaultNodeInstanceClass, FSMTransition::GetDefaultNodeInstanceClass


function GetNodeInstanceClass¶

inline UClass * GetNodeInstanceClass() const

The current in use node class.


function IsUsingDefaultNodeClass¶

inline bool IsUsingDefaultNodeClass() const

Is the default node class assigned.


function AddVariableGraphProperty¶

void AddVariableGraphProperty(
    const FSMGraphProperty_Base_Runtime & GraphProperty,
    const FGuid & OwningTemplateGuid
)

function SetNodeName¶

void SetNodeName(
    const FString & Name
)

function GetNodeName¶

inline const FString & GetNodeName() const

function SetTemplateName¶

void SetTemplateName(
    const FName & Name
)

function GetTemplateName¶

FName GetTemplateName(
    USMNodeInstance * InNodeInstance =nullptr
) const

Return the template name used to find a node instance archetype.

Parameters:

InNodeInstance
The current node instance we want the template name for. Can be either the main node instance or a stack instance. When nullptr the main node instance template name is used.

Return: The node template name used to discover node instance archetypes or NAME_None if not found.


function AddStackTemplateName¶

void AddStackTemplateName(
    const FName & Name,
    UClass * TemplateClass
)

function IsActive¶

inline virtual bool IsActive() const

If this node is active.


function ExecuteInitializeNodes¶

virtual void ExecuteInitializeNodes()

Reimplemented by: FSMConduit::ExecuteInitializeNodes, FSMState_Base::ExecuteInitializeNodes, FSMState::ExecuteInitializeNodes, FSMStateMachine::ExecuteInitializeNodes, FSMTransition::ExecuteInitializeNodes


function ExecuteShutdownNodes¶

virtual void ExecuteShutdownNodes()

Reimplemented by: FSMConduit::ExecuteShutdownNodes, FSMState_Base::ExecuteShutdownNodes, FSMState::ExecuteShutdownNodes, FSMStateMachine::ExecuteShutdownNodes, FSMTransition::ExecuteShutdownNodes


function SetServerTimeInState¶

virtual void SetServerTimeInState(
    float InTime
)

Set the time in state as recorded from the server.

Reimplemented by: FSMStateMachine::SetServerTimeInState


function GetServerTimeInState¶

inline float GetServerTimeInState() const

The time in state as recorded by the server. Kept in the base node as transitions can utilize it.


function CanExecuteGraphProperties¶

inline virtual bool CanExecuteGraphProperties(
    ESMGraphPropertyEvalFlags OnEvent,
    const class USMStateInstance_Base * ForTemplate,
    ESMGraphPropertyDirection InDirection
) const

Checks if the instance is allowed to execute properties automatically.

Parameters:

OnEvent
The event to execute on.
ForTemplate
The specific template to check against.
InDirection
The direction of the graph properties to evaluate.

function TryExecuteGraphProperties¶

virtual bool TryExecuteGraphProperties(
    ESMGraphPropertyEvalFlags OnEvent,
    ESMGraphPropertyDirection InDirection
)

Execute desired graph properties for the given event in a given direction.

Parameters:

OnEvent
The event to execute on.
InDirection
The direction of the graph property.

Reimplemented by: FSMState::TryExecuteGraphProperties


function TryExecuteGraphProperties¶

void TryExecuteGraphProperties(
    ESMGraphPropertyEvalFlags OnEvent
)

Try executing all directions of graph properties.

Parameters:

OnEvent
The event to execute on.

function ExecuteGraphProperties¶

void ExecuteGraphProperties(
    USMNodeInstance * ForNodeInstance,
    const FGuid * ForTemplateGuid
)

Evaluates graph properties.

Parameters:

ForNodeInstance
The node instance we are evaluating.
ForTemplateGuid
If specified only graph properties for this template will be executed. If null all properties will be executed.

Deprecated:

This function is deprecated. Use the version which takes FFilterGraphPropertyArgs instead.


function ExecuteGraphProperties¶

void ExecuteGraphProperties(
    const FFilterGraphPropertyArgs & InArgs
)

Evaluates graph properties.


function GetGraphProperties¶

inline const TArray< FSMGraphProperty_Base_Runtime * > & GetGraphProperties() const

Retrieve the embedded graph properties.


function GetTemplateGraphProperties¶

inline const TMap< FGuid, FSMGraphPropertyTemplateOwner > & GetTemplateGraphProperties() const

Retrieve the template variable graph properties.


function TryResetVariables¶

virtual void TryResetVariables()

See if the user wants variables reset.


function IsDebugActive¶

inline virtual bool IsDebugActive() const

Reimplemented by: FSMConduit::IsDebugActive, FSMTransition::IsDebugActive


function WasDebugActive¶

inline virtual bool WasDebugActive() const

Reimplemented by: FSMConduit::WasDebugActive, FSMTransition::WasDebugActive


function EditorShutdown¶

virtual void EditorShutdown()

Performs a safe reset. It's possible referenced structs have changed in the BP and may not be valid.


function ResetGeneratedValues¶

virtual void ResetGeneratedValues()

Reset any values set from state machine generation.

Reimplemented by: FSMState_Base::ResetGeneratedValues, FSMStateMachine::ResetGeneratedValues, FSMTransition::ResetGeneratedValues


function TriggerDebugBreakpoint¶

void TriggerDebugBreakpoint()

Triggers a debug breakpoint.


function GetNodeGuidPropertyName¶

static inline FName GetNodeGuidPropertyName()

Property name of the NodeGuid.


function GetPathGuidPropertyName¶

static inline FName GetPathGuidPropertyName()

Property name of the PathGuid.


Protected Functions Documentation¶

function CreateRuntimeData¶

inline virtual TSharedPtr< FSMNodeRuntimeData > CreateRuntimeData() const

Reimplemented by: FSMConduit::CreateRuntimeData, FSMState_Base::CreateRuntimeData, FSMStateMachine::CreateRuntimeData, FSMTransition::CreateRuntimeData


function InitializeFunctionHandlers¶

virtual void InitializeFunctionHandlers()

Map the FunctionHandler pointer. Must be implemented per child struct!

Reimplemented by: FSMConduit::InitializeFunctionHandlers, FSMState::InitializeFunctionHandlers, FSMStateMachine::InitializeFunctionHandlers, FSMTransition::InitializeFunctionHandlers


function PrepareGraphExecution¶

virtual void PrepareGraphExecution()

Execute the graph.


function SetActive¶

virtual void SetActive(
    bool bValue
)

function CreateGraphProperties¶

void CreateGraphProperties()

function CreateGraphPropertiesForTemplate¶

void CreateGraphPropertiesForTemplate(
    USMNodeInstance * Template,
    const TMap< FGuid, FSMGraphProperty_Base_Runtime * > & MappedGraphPropertyInstances
)

Public Attributes Documentation¶

variable bValidateGuids¶

static bool bValidateGuids;

Check whether compiled guid cache matches run-time guid calculation.


variable NodePosition¶

FVector2D NodePosition;

The node position in the graph. Set automatically.


variable TimeInState¶

float TimeInState;

The current time spent in the state.


variable DuplicateId¶

int32 DuplicateId;

Special indicator in case this node is a duplicate within the same blueprint. If this isn't 0 then the NodeGuid will have been adjusted.


variable bIsInEndState¶

uint8 bIsInEndState;

State Machine is in end state or the state is an end state.

The main case for this is when a local transition graph uses "Is State Machine in End State" (USMGraphK2Node_StateMachineReadNode_InEndState)

Todo:

This should be moved to transitions only, but the now deprecated USMNodeInstance::IsInEndState() uses this.


variable bHasUpdated¶

uint8 bHasUpdated;

State has updated at least once.


variable bHasInputEvents¶

uint8 bHasInputEvents;

This node has at least one input event present.


Protected Attributes Documentation¶

variable Guid¶

FGuid Guid;

NodeGuid must always be unique. Do not duplicate the guid in any other node in any blueprint.

This is not the same guid that is used at run-time. At run-time all NodeGuids in a path to a node are hashed to form the PathGuid. This is done to account for multiple references and parent graph calls.

If you need to change the path of a node (such as collapse it to a nested state machine) and you need to maintain the old guid for run-time saves to work, you should use the GuidRedirectMap on the primary state machine instance which accepts PathGuids.


variable OwnerGuid¶

FGuid OwnerGuid;

The state machine's NodeGuid owning this node.


variable PathGuid¶

FGuid PathGuid;

Unique identifier calculated from this node's place in an instance. Calculated by taking the MD5 hash of the full path of all owner NodeGuids and this NodeGuid. This is what is returned from GetGuid().

ReadWrite so it can be easily read from custom graph nodes.


variable NodeName¶

FString NodeName;

variable TemplateName¶

FName TemplateName;

The name of a template archetype to use when constructing an instance. This allows default values be passed into the instance.


variable StackTemplateNames¶

TArray< FName > StackTemplateNames;

The names of stack template archetypes used when constructing the stack.


variable StackNodeInstances¶

TArray< TObjectPtr< USMNodeInstance > > StackNodeInstances;

The node instances for this stack.


variable OwningInstance¶

TObjectPtr< USMInstance > OwningInstance;

The state machine instance owning this node.


variable NodeInstance¶

TObjectPtr< USMNodeInstance > NodeInstance;

The node instance for this node if it exists.


variable TemplateVariableGraphProperties¶

TMap< FGuid, FSMGraphPropertyTemplateOwner > TemplateVariableGraphProperties;

Set by the BP compiler. Template Guid -> GraphProperties. Contains data necessary to evaluate variables which have instanced BP graphs.


variable NodeInstanceClass¶

TObjectPtr< UClass > NodeInstanceClass;

The class to use to construct the node instance if one exists.


Private Attributes Documentation¶

variable RuntimeData¶

TSharedPtr< FSMNodeRuntimeData > RuntimeData;

Shared pointer to runtime data associated with a state machine node. Manages details relevant to the node during execution. Kept as a shared ptr to minimize the struct size of the node during blueprint compilation.


Friends¶

friend FSMEditorConstructionManager¶

friend class FSMEditorConstructionManager(
    FSMEditorConstructionManager 
);