2021-09-28 13:33:17 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "StateTreeTypes.h"
|
|
|
|
|
#include "StateTreePropertyBindingCompiler.h"
|
2021-10-29 04:33:21 -04:00
|
|
|
#include "StateTreeCompilerLog.h"
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
class UStateTree;
|
|
|
|
|
class UStateTreeState;
|
|
|
|
|
class UStateTreeEditorData;
|
2022-02-03 09:13:49 -05:00
|
|
|
struct FStateTreeEditorNode;
|
2021-09-28 13:33:17 -04:00
|
|
|
struct FStateTreeStateLink;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-04-05 09:44:28 -04:00
|
|
|
* Helper class to convert StateTree editor representation into a compact data.
|
|
|
|
|
* Holds data needed during compiling.
|
2021-09-28 13:33:17 -04:00
|
|
|
*/
|
2022-04-05 09:44:28 -04:00
|
|
|
struct STATETREEEDITORMODULE_API FStateTreeCompiler
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2022-04-12 15:55:39 -04:00
|
|
|
explicit FStateTreeCompiler(FStateTreeCompilerLog& InLog)
|
2021-10-29 04:33:21 -04:00
|
|
|
: Log(InLog)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 09:44:28 -04:00
|
|
|
bool Compile(UStateTree& InStateTree);
|
2021-09-28 13:33:17 -04:00
|
|
|
private:
|
|
|
|
|
|
2021-10-29 04:33:21 -04:00
|
|
|
bool ResolveTransitionState(const UStateTreeState& SourceState, const FStateTreeStateLink& Link, FStateTreeHandle& OutTransitionHandle) const;
|
2021-09-28 13:33:17 -04:00
|
|
|
FStateTreeHandle GetStateHandle(const FGuid& StateID) const;
|
2022-04-05 03:20:57 -04:00
|
|
|
UStateTreeState* GetState(const FGuid& StateID);
|
2021-09-28 13:33:17 -04:00
|
|
|
|
2021-10-21 04:08:20 -04:00
|
|
|
bool CreateStates();
|
|
|
|
|
bool CreateStateRecursive(UStateTreeState& State, const FStateTreeHandle Parent);
|
2021-12-08 03:29:30 -05:00
|
|
|
|
2022-04-28 03:54:07 -04:00
|
|
|
bool CreateStateTasksAndParameters();
|
2022-04-05 03:20:57 -04:00
|
|
|
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;
|
|
|
|
|
|
2021-10-29 04:33:21 -04:00
|
|
|
FStateTreeCompilerLog& Log;
|
2021-09-28 13:33:17 -04:00
|
|
|
UStateTree* StateTree = nullptr;
|
|
|
|
|
UStateTreeEditorData* TreeData = nullptr;
|
|
|
|
|
TMap<FGuid, int32> IDToState;
|
|
|
|
|
TArray<UStateTreeState*> SourceStates;
|
|
|
|
|
FStateTreePropertyBindingCompiler BindingsCompiler;
|
|
|
|
|
};
|