Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeEditorModule/Public/StateTreeCompiler.h
Yoan StAmant c135ebcd95 [StateTree]
+ Added StateTree parameters usable for data bindings and that could be overriden on context initialization by a StateTreeReference
+ Added StateTreeReference struct to hold a reference to a StateTree asset along with a list of values to parameterized the tree.
+ Added named external data items that are defined bt the Schema and for which values must be provided at runtime through the execution context.
+ Added delegate OnPostCompile after successful compilation. The StateTreeReference listens to it to validate its parameters
+ EditorData now contains its own version of the schema and parameters. On successful compilation they are copied over the StateTree own properties.
#rnx
#rb mikko.mononen
#preflight 6255d281647ad886b3593cb0

[CL 19727363 by Yoan StAmant in ue5-main branch]
2022-04-12 15:55:39 -04:00

73 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "StateTreeTypes.h"
#include "StateTreePropertyBindingCompiler.h"
#include "StateTreeCompilerLog.h"
class UStateTree;
class UStateTreeState;
class UStateTreeEditorData;
struct FStateTreeEditorNode;
struct FStateTreeStateLink;
/**
* Helper class to convert StateTree editor representation into a compact data.
* Holds data needed during compiling.
*/
struct STATETREEEDITORMODULE_API FStateTreeCompiler
{
public:
explicit FStateTreeCompiler(FStateTreeCompilerLog& InLog)
: Log(InLog)
{
}
bool Compile(UStateTree& InStateTree);
private:
bool ResolveTransitionState(const UStateTreeState& SourceState, const FStateTreeStateLink& Link, FStateTreeHandle& OutTransitionHandle) const;
FStateTreeHandle GetStateHandle(const FGuid& StateID) const;
UStateTreeState* GetState(const FGuid& StateID);
static FString GetExecutionPathString(const TConstArrayView<const UStateTreeState*> Path);
static bool IsPathLinked(const TConstArrayView<const UStateTreeState*> Path);
bool CreateExecutionInfos();
bool CreateExecutionInfosRecursive(UStateTreeState& State, TArray<const UStateTreeState*>& Path);
bool CreateStates();
bool CreateStateRecursive(UStateTreeState& State, const FStateTreeHandle Parent);
bool CreateStateTasks();
bool CreateStateEvaluators();
bool CreateStateTransitions();
bool CreateConditions(UStateTreeState& State, TConstArrayView<FStateTreeEditorNode> Conditions);
bool CreateCondition(UStateTreeState& State, const FStateTreeEditorNode& CondNode, const EStateTreeConditionOperand Operand, const int8 DeltaIndent);
bool CreateTask(UStateTreeState& State, const FStateTreeEditorNode& TaskNode);
bool CreateEvaluator(UStateTreeState& State, const FStateTreeEditorNode& EvalNode);
bool GetAndValidateBindings(UStateTreeState& State, const FStateTreeBindableStructDesc& TargetStruct, TArray<FStateTreeEditorPropertyBinding>& OutBindings) const;
bool IsPropertyAnyEnum(const FStateTreeBindableStructDesc& Struct, FStateTreeEditorPropertyPath Path) const;
struct FExecutionPath
{
FExecutionPath() = default;
explicit FExecutionPath(const TConstArrayView<const UStateTreeState*> InPath) : Path(InPath) {}
TArray<const UStateTreeState*> Path;
};
struct FStateExecutionInfo
{
TArray<FExecutionPath> ExecutionPaths;
};
FStateTreeCompilerLog& Log;
UStateTree* StateTree = nullptr;
UStateTreeEditorData* TreeData = nullptr;
TMap<FGuid, int32> IDToState;
TArray<UStateTreeState*> SourceStates;
TMap<UStateTreeState*, FStateExecutionInfo> ExecutionInfos;
FStateTreePropertyBindingCompiler BindingsCompiler;
};