Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Public/StateTreeNodeBase.h
mikko mononen cd197fcb3e StateTree: refactored index types
- Changed FStateTreeHandle to FStateTreeStateHandle, used only for indexing states
- Added uint16 and uin8 index types, which can represent invalid index (aka INDEX_NONE)
- Changed indices that can be optional to the index types above
- Added validation and error loggic when index types overflow during compile
- Removed 2 indirections (in common case) and halved the memory usage of property copies

#jira none
#rb Mieszko.Zielinski
#preflight 6295d26e91004dd61ced370b

[CL 20434838 by mikko mononen in ue5-main branch]
2022-05-31 04:51:18 -04:00

54 lines
1.5 KiB
C

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "StateTreeTypes.h"
#include "StateTreeNodeBase.generated.h"
struct FStateTreeLinker;
/**
* Base struct of StateTree Conditions, Evaluators, and Tasks.
*/
USTRUCT()
struct STATETREEMODULE_API FStateTreeNodeBase
{
GENERATED_BODY()
FStateTreeNodeBase() = default;
virtual ~FStateTreeNodeBase() {}
/** @return Struct that represents the runtime data of the node. */
virtual const UStruct* GetInstanceDataType() const { return nullptr; };
/**
* Called when the StateTree asset is linked. Allows to resolve references to other StateTree data.
* @see TStateTreeExternalDataHandle
* @see TStateTreeInstanceDataPropertyHandle
* @param Linker Reference to the linker
* @return true if linking succeeded.
*/
[[nodiscard]] virtual bool Link(FStateTreeLinker& Linker) { return true; }
/** Name of the node. */
UPROPERTY(EditDefaultsOnly, Category = "", meta=(EditCondition = "false", EditConditionHides))
FName Name;
/** Property binding copy batch handle. */
UPROPERTY()
FStateTreeIndex16 BindingsBatch = FStateTreeIndex16::Invalid;
/** The runtime data's data view index in the StateTreeExecutionContext, and source struct index in property binding. */
UPROPERTY()
FStateTreeIndex16 DataViewIndex = FStateTreeIndex16::Invalid;
/** Index in runtime instance storage. */
UPROPERTY()
FStateTreeIndex16 InstanceIndex = FStateTreeIndex16::Invalid;
/** True if the instance is an UObject. */
UPROPERTY()
uint8 bInstanceIsObject : 1;
};