Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeEditorModule/Public/StateTreeCompiler.h
mikko mononen f6770cf154 StateTree: Parametrized states
- Added specific "subtree" states which can be linked to via a "linked" state
- Subtrees can only bind data back to the their root state (or tree "global" data)
- Added property bag based parameters to subtree and linked states
- Update (transient) property bag structs before resolving property paths
- Linked states reflect their parameters from the state they link to
- Added property binding to and from parameters
- Relaxed the property binding to fail if the source data is not available
- Allow enter conditions to bind to tasks, and fail the expression if trying to access unaccessible data
- Added icon for linked and subtree states
- Added source type for all binding source structs
- Added UStateTreeEditorData::VisitHierarchy to simplify iterating over all states

#jira UE-147507
#rb Yoan.StAmant
#preflight 626a47182d28b9d0f77223f5

[CL 19954567 by mikko mononen in ue5-main branch]
2022-04-28 03:54:07 -04:00

55 lines
2.0 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);
bool CreateStates();
bool CreateStateRecursive(UStateTreeState& State, const FStateTreeHandle Parent);
bool CreateStateTasksAndParameters();
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;
FStateTreeCompilerLog& Log;
UStateTree* StateTree = nullptr;
UStateTreeEditorData* TreeData = nullptr;
TMap<FGuid, int32> IDToState;
TArray<UStateTreeState*> SourceStates;
FStateTreePropertyBindingCompiler BindingsCompiler;
};