Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Public/StateTreeConditionBase.h
mikko mononen 34a1e22051 StateTree: Allow to bind to deep property paths (including arrays and instanced struct/object)
- refactored the property binding representation, editor binding shave now more structure, and removed intermediate representation
- added functionality to resolve property paths agains a known value
- added instanced struct and object indirection types
- added editor functionality to allow to bind to further than first level of properties
- refactored editor tree traversal, allow to access values too
- simplified statetree node ui
- requires to recompile trees, bumped version

#rb Mieszko.Zielinski
#preflight 63e6204ff15c83b79312aca5

[CL 24117094 by mikko mononen in ue5-main branch]
2023-02-10 07:22:48 -05:00

80 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "StateTreeNodeBase.h"
#include "StateTreeConditionBase.generated.h"
struct FStateTreeEditorPropertyPath;
struct FStateTreePropertyPath;
struct FStateTreeExecutionContext;
struct IStateTreeBindingLookup;
enum class EStateTreeCompare : uint8
{
Default,
Invert,
};
/**
* Base struct for all conditions.
*/
USTRUCT(meta = (Hidden))
struct STATETREEMODULE_API FStateTreeConditionBase : public FStateTreeNodeBase
{
GENERATED_BODY()
#if WITH_EDITOR
PRAGMA_DISABLE_DEPRECATION_WARNINGS
UE_DEPRECATED(5.3, "Use version with FStateTreePropertyPath instead.")
virtual void OnBindingChanged(const FGuid& ID, FStateTreeDataView InstanceData, const FStateTreeEditorPropertyPath& SourcePath, const FStateTreeEditorPropertyPath& TargetPath, const IStateTreeBindingLookup& BindingLookup) final {}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
/**
* Called when binding of any of the properties in the condition changes.
* @param ID ID of the item, can be used make property paths to this item.
* @param InstanceData view to the instance data, can be struct or class.
* @param SourcePath Source path of the new binding.
* @param TargetPath Target path of the new binding (the property in the condition).
* @param BindingLookup Reference to binding lookup which can be used to reason about property paths.
*/
virtual void OnBindingChanged(const FGuid& ID, FStateTreeDataView InstanceData, const FStateTreePropertyPath& SourcePath, const FStateTreePropertyPath& TargetPath, const IStateTreeBindingLookup& BindingLookup) {}
#endif
/** @return True if the condition passes. */
virtual bool TestCondition(FStateTreeExecutionContext& Context) const { return false; }
UPROPERTY()
EStateTreeConditionOperand Operand = EStateTreeConditionOperand::And;
UPROPERTY()
int8 DeltaIndent = 0;
};
/**
* Base class (namespace) for all common Conditions that are generally applicable.
* This allows schemas to safely include all conditions child of this struct.
*/
USTRUCT(meta = (Hidden))
struct STATETREEMODULE_API FStateTreeConditionCommonBase : public FStateTreeConditionBase
{
GENERATED_BODY()
};
/** Helper macro to define instance data as simple constructible. */
#define STATETREE_POD_INSTANCEDATA(Type) \
template <> struct TIsPODType<Type> { enum { Value = true }; }; \
template<> \
struct TStructOpsTypeTraits<Type> : public TStructOpsTypeTraitsBase2<Type> \
{ \
enum \
{ \
WithZeroConstructor = true, \
WithNoDestructor = true, \
}; \
};
#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
#include "StateTreeExecutionContext.h"
#include "StateTreePropertyBindings.h"
#endif