Navigation
API > API/Plugins > API/Plugins/StateTreeModule
Inheritance Hierarchy
- FStateTreeExecutionContext
- FMassStateTreeExecutionContext
References
| Module | StateTreeModule |
| Header | /Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Public/StateTreeExecutionContext.h |
| Include | #include "StateTreeExecutionContext.h" |
Syntax
struct FStateTreeExecutionContext
Remarks
StateTree Execution Context is a helper that is used to update and access StateTree instance data.
The context is meant to be temporary, you should not store a context across multiple frames.
The owner is used as the owner of the instantiated UObjects in the instance data and logging, it should have same or greater lifetime as the InstanceData.
In common case you can use the constructor or Init() to initialize the context: FStateTreeExecutionContext Context(*GetOwner(), *StateTreeRef.GetStateTree(), InstanceData); if (SetContextRequirements(Context)) { Context.Tick(DeltaTime); }
bool UMyComponent::SetContextRequirements(FStateTreeExecutionContext& Context) { if (!Context.IsValid()) { return false; } // Setup context data return true; }
Variables
| Type | Name | Description | |
|---|---|---|---|
| bool | bAllowDirectTransitions | True if transitions are allowed to be requested directly instead of buffering. | |
| FStateTreeStateHandle | CurrentlyProcessedState | Current state we're processing, or invalid if not applicable. | |
| TArray< FStateTreeDataView, TConcurrentLinearArrayAllocator< FDefaultBlockAllocationTag > > | DataViews | Array of data pointers (external data, tasks, evaluators, conditions), used during evaluation. | |
| TArray< FStateTreeEvent, TConcurrentLinearArrayAllocator< FDefaultBlockAllocationTag > > | EventsToProcess | Events to process in current tick. | |
| FStateTreeInstanceData & | InstanceData | Instance data used during current tick. | |
| FStateTreeTransitionResult | NextTransition | Next transition, used by RequestTransition(). | |
| FStateTreeTransitionSource | NextTransitionSource | Structure describing the origin of the state transition that caused the state change. | |
| UObject & | Owner | Owner of the instance data. | |
| TSharedPtr< FStateTreeInstanceData > | SharedInstanceData | Shared instance data for the duration of the context. | |
| const UStateTree & | StateTree | The StateTree asset the context is initialized for |
Constructors
| Type | Name | Description | |
|---|---|---|---|
FStateTreeExecutionContext
(
UObject& InOwner, |
Destructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| bool | |||
| void | BeginDelayedTransition
(
const FStateTreeTransitionDelayedState& DelayedState |
Callback when delayed transition is triggered. | |
| FString | |||
| FString | DebugGetStatePath
(
const FStateTreeActiveStates& ActiveStates, |
||
| void | |||
| EStateTreeRunStatus | EnterState
(
const FStateTreeTransitionResult& Transition |
Handles logic for entering State. | |
| void | ExitState
(
const FStateTreeTransitionResult& Transition |
Handles logic for exiting State. | |
| void | ForEachEvent
(
TFunc&& Function |
Iterates over all events. | |
| FString | |||
| TArray< FName > | |||
| const FStateTreeActiveStates & | |||
| TConstArrayView< FStateTreeExternalDataDesc > | |||
| FStateTreeStateHandle | |||
| const FStateTreeEventQueue & | |||
| TConstArrayView< FStateTreeEvent > | |||
| const FStateTreeExecutionState & | GetExecState () |
||
| FStateTreeExecutionState & | GetExecState () |
||
| T::DataType & | GetExternalData
(
const T Handle |
Returns reference to external data based on provided handle. | |
| TConstArrayView< FStateTreeExternalDataDesc > | |||
| FStateTreeExternalDataHandle | GetExternalDataHandleByStruct
(
const UStruct* InStruct |
||
| T::DataType * | GetExternalDataPtr
(
const T Handle |
Returns pointer to external data based on provided item handle. | |
| FStateTreeDataView | GetExternalDataView
(
const FStateTreeExternalDataHandle Handle |
||
| const FStateTreeInstanceData * | |||
| T & | GetInstanceData
(
const FStateTreeNodeBase& Node |
||
| T::FInstanceDataType & | GetInstanceData
(
const T& Node |
||
| T * | GetInstanceDataPtr
(
const FStateTreeNodeBase& Node |
||
| TStateTreeInstanceDataStructRef< typename T::FInstanceDataType > | GetInstanceDataStructRef
(
const T& Node |
||
| FString | |||
| EStateTreeRunStatus | |||
| FStateTreeEventQueue & | |||
| FStateTreeInstanceData * | Mutable references to the instance data in use, or nullptr if the context is not valid. | ||
| UObject * | GetOwner () |
||
| FStateTreeStateHandle | GetParentLinkedStateHandle
(
const FStateTreeActiveStates& ActiveStates, |
||
| FStateTreeStateHandle | GetParentLinkedStateHandle
(
const FStateTreeActiveStates& ActiveStates, |
Traverses the ActiveStates from StartStateIndex to 0 and returns first linked state. | |
| FString | GetSafeStateName
(
const FStateTreeStateHandle State |
||
| int32 | |||
| const FCompactStateTreeState * | GetStateFromHandle
(
const FStateTreeStateHandle StateHandle |
||
| FString | GetStateStatusString
(
const FStateTreeExecutionState& ExecState |
||
| const UStateTree * | GetStateTree () |
||
| EStateTreeRunStatus | |||
| UWorld * | GetWorld () |
||
| bool | HasEventToProcess
(
const FGameplayTag Tag |
||
| bool | IsValid () |
||
| bool | RequestTransition
(
const FStateTreeStateHandle NextState, |
Requests transition to a specified state with specified priority. | |
| void | RequestTransition
(
const FStateTreeTransitionRequest& Request |
Requests transition to a state. | |
| bool | SelectState
(
const FStateTreeStateHandle NextState, |
Runs state selection logic starting at the specified state, walking towards the leaf states. | |
| bool | SelectStateInternal
(
const FStateTreeStateHandle NextState, |
Used internally to do the recursive part of the SelectState(). | |
| void | SendEvent
(
const FGameplayTag Tag, |
Sends event for the StateTree. | |
| void | Updates data view of the parameters by using the default values defined in the StateTree asset. | ||
| void | SetExternalData
(
const FStateTreeExternalDataHandle Handle, |
Sets external data view value for specific item. | |
| void | SetNodeDataView
(
T& Node, |
Helper function to update struct or object dataview of a node. | |
| void | SetParameters
(
const FInstancedPropertyBag& Parameters |
Updates data view of the parameters by replacing the default values defined in the StateTree asset by the provided values. | |
| EStateTreeRunStatus | Start () |
Start executing. | |
| EStateTreeRunStatus | StartEvaluatorsAndGlobalTasks
(
FStateTreeIndex16& OutLastInitializedTaskIndex |
Starts evaluators and global tasks. | |
| void | Handles logic for signalling State completed. | ||
| EStateTreeRunStatus | Stop
(
const EStateTreeRunStatus CompletionStatus |
Stop executing if the tree is running. | |
| void | StopEvaluatorsAndGlobalTasks
(
const EStateTreeRunStatus CompletionStatus, |
Stops evaluators and global tasks. | |
| bool | TestAllConditions
(
const int32 ConditionsOffset, |
Checks all conditions at given range | |
| EStateTreeRunStatus | Tick
(
const float DeltaTime |
Tick the state tree logic. | |
| EStateTreeRunStatus | TickEvaluatorsAndGlobalTasks
(
const float DeltaTime, |
Tick evaluators and global tasks by delta time. | |
| EStateTreeRunStatus | TickTasks
(
const float DeltaTime |
Ticks tasks of all active states starting from current state by delta time. | |
| bool | Triggers transitions based on current run status. | ||
| void | UpdateInstanceData
(
const FStateTreeActiveStates& CurrentActiveStates, |
||
| void | UpdateLinkedStateParameters
(
const FCompactStateTreeState& State, |
Sets up parameter data view for a linked state and copies bound properties. | |
| void | UpdateSubtreeStateParameters
(
const FCompactStateTreeState& State |
Sets up parameter data view for subtree state. |
Classes
| Type | Name | Description | |
|---|---|---|---|
| FAllowDirectTransitionsScope | Helper struct to track when it is allowed to request transitions. | ||
| FCurrentlyProcessedStateScope | Helper struct to track currently processed state. |
Deprecated Functions
| Type | Name | Description | |
|---|---|---|---|
| void | BeginGatedTransition
(
const FStateTreeExecutionState& Exec |
Use BeginDelayedTransition() instead. | |
| void | SendEvent
(
const FStateTreeEvent& Event |
Use AddEvent() with individual parameters instead. |