You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- connect GetWorld() of FStateTreeExecutionContext explicitly to the owner - take MassSignalSubsystem as parameter to FMassStateTreeExecutionContext directly - separated DataViewIndex (what others see) and InstanceIndex/bInstanceIsObject (where the pointert comes from) on StateTree items - allow item instance to be a struct or object - added editor support for both struct or object based instance - added Blueprint base classes for Eval, Task and Condition - Update UStateTreeBrainComponent #jira UE-135723 #ROBOMERGE-AUTHOR: mikko.mononen #ROBOMERGE-SOURCE: CL 18280804 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v895-18170469) #ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0 [CL 18280809 by mikko mononen in ue5-release-engine-test branch]
143 lines
4.1 KiB
C++
143 lines
4.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Engine/DataAsset.h"
|
|
#include "StateTreeTypes.h"
|
|
#include "StateTreeSchema.h"
|
|
#include "InstancedStruct.h"
|
|
#include "StateTreePropertyBindings.h"
|
|
#include "StateTree.generated.h"
|
|
|
|
/**
|
|
* StateTree asset. Contains the StateTree definition in both editor and runtime (baked) formats.
|
|
*/
|
|
UCLASS(BlueprintType)
|
|
class STATETREEMODULE_API UStateTree : public UDataAsset
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
UStateTree(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
|
~UStateTree();
|
|
|
|
/** @return Script Struct that can be used to instantiate the runtime storage */
|
|
const UScriptStruct* GetInstanceStorageStruct() const { return InstanceStorageStruct; }
|
|
|
|
/** @return Instance of the runtime storage that contains the default values */
|
|
const FInstancedStruct& GetInstanceStorageDefaultValue() const { return InstanceStorageDefaultValue; }
|
|
|
|
/** @return Number of runtime data (Evaluators, Tasks, Conditions) in the runtime storage. */
|
|
int32 GetNumInstances() const { return Instances.Num(); }
|
|
|
|
/** @return Number of data views required for StateTree execution (Evaluators, Tasks, Conditions, External data). */
|
|
int32 GetNumDataViews() const { return NumDataViews; }
|
|
|
|
/** @return Base index in data views for external data. */
|
|
int32 GetExternalDataBaseIndex() const { return ExternalDataBaseIndex; }
|
|
|
|
/** @return List of external data required by the state tree */
|
|
TConstArrayView<FStateTreeExternalDataDesc> GetExternalDataDescs() const { return ExternalDataDescs; }
|
|
|
|
/** @return Schema describing which inputs, evaluators, and tasks a StateTree can contain */
|
|
const UStateTreeSchema* GetSchema() const { return Schema; }
|
|
void SetSchema(UStateTreeSchema* InSchema) { Schema = InSchema; }
|
|
|
|
/** @return true is the tree asset is considered valid (e.g. at least one state) */
|
|
bool IsValidStateTree() const;
|
|
|
|
void ResolvePropertyPaths();
|
|
|
|
#if WITH_EDITOR
|
|
void OnPIEStarted(const bool bIsSimulating);
|
|
|
|
/** Resets the baked data to empty. */
|
|
void ResetBaked();
|
|
#endif
|
|
|
|
#if WITH_EDITORONLY_DATA
|
|
// Edit time data for the StateTree, instance of UStateTreeEditorData
|
|
UPROPERTY()
|
|
TObjectPtr<UObject> EditorData;
|
|
#endif
|
|
|
|
protected:
|
|
virtual void BeginDestroy() override;
|
|
virtual void PostLoad() override;
|
|
|
|
#if WITH_EDITOR
|
|
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
|
|
virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const override;
|
|
#endif
|
|
|
|
/** Initializes the types and default values related to StateTree runtime storage */
|
|
void InitInstanceStorageType();
|
|
|
|
/** Resolved references between data in the StateTree. */
|
|
void Link();
|
|
|
|
private:
|
|
|
|
// Properties
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = Common, Instanced)
|
|
TObjectPtr<UStateTreeSchema> Schema = nullptr;
|
|
|
|
/** Evaluators, Tasks, and Condition items */
|
|
UPROPERTY()
|
|
TArray<FInstancedStruct> Items;
|
|
|
|
/** Evaluators, Tasks, and Conditions runtime data. */
|
|
UPROPERTY()
|
|
TArray<FInstancedStruct> Instances;
|
|
|
|
/** Blueprint based Evaluators, Tasks, and Conditions runtime data. */
|
|
UPROPERTY()
|
|
TArray<TObjectPtr<UObject>> InstanceObjects;
|
|
|
|
/** Script Struct that can be used to instantiate the runtime storage */
|
|
UPROPERTY()
|
|
TObjectPtr<UScriptStruct> InstanceStorageStruct;
|
|
|
|
/** Offsets into the runtime type to quickly get a struct view to a specific Task or Evaluator */
|
|
TArray<FStateTreeInstanceStorageOffset> InstanceStorageOffsets;
|
|
|
|
/** Instance of the runtime storage that contains the default values. */
|
|
UPROPERTY()
|
|
FInstancedStruct InstanceStorageDefaultValue;
|
|
|
|
/** List of external data required by the state tree, creating during linking. */
|
|
UPROPERTY(Transient)
|
|
TArray<FStateTreeExternalDataDesc> ExternalDataDescs;
|
|
|
|
UPROPERTY(Transient)
|
|
int32 NumDataViews = 0;
|
|
|
|
UPROPERTY(Transient)
|
|
int32 ExternalDataBaseIndex = 0;
|
|
|
|
UPROPERTY()
|
|
FStateTreePropertyBindings PropertyBindings;
|
|
|
|
UPROPERTY()
|
|
TArray<FBakedStateTreeState> States;
|
|
|
|
UPROPERTY()
|
|
TArray<FBakedStateTransition> Transitions;
|
|
|
|
friend struct FStateTreeInstance;
|
|
friend struct FStateTreeExecutionContext;
|
|
#if WITH_EDITORONLY_DATA
|
|
friend struct FStateTreeBaker;
|
|
#endif
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|