2021-09-28 13:33:00 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# pragma once
2024-04-05 03:37:02 -04:00
# include "StateTreeNodeBase.h"
2022-05-31 04:51:18 -04:00
# include "StateTreeTypes.h"
2024-01-11 04:24:45 -05:00
# include "StateTreePropertyRefHelpers.h"
2024-06-19 16:42:16 -04:00
# include "StructUtils/StructView.h"
2024-06-04 03:56:38 -04:00
# include "StateTreeIndexTypes.h"
2021-09-28 13:33:00 -04:00
# include "StateTreePropertyBindings.generated.h"
class FProperty ;
2023-02-10 07:22:48 -05:00
struct FStateTreePropertyPath ;
struct FStateTreePropertyBindingCompiler ;
2024-01-11 04:24:45 -05:00
struct FStateTreePropertyRef ;
2023-02-10 07:22:48 -05:00
class UStateTree ;
2024-04-05 03:37:02 -04:00
enum EStateTreeNodeFormatting : uint8 ;
2021-09-28 13:33:00 -04:00
2022-04-14 06:28:13 -04:00
UENUM ( )
enum class EStateTreeBindableStructSource : uint8
{
2022-09-19 19:47:11 -04:00
/** Source is StateTree context object */
Context ,
/** Source is StateTree parameter */
Parameter ,
/** Source is StateTree evaluator */
2022-04-14 06:28:13 -04:00
Evaluator ,
2023-01-10 15:44:28 -05:00
/** Source is StateTree global task */
GlobalTask ,
2022-09-19 19:47:11 -04:00
/** Source is State parameter */
2024-03-11 04:54:44 -04:00
StateParameter ,
2022-09-19 19:47:11 -04:00
/** Source is State task */
Task ,
/** Source is State condition */
2022-04-28 03:54:07 -04:00
Condition ,
2024-05-15 14:50:35 -04:00
/** Source is State utility consideration */
Consideration ,
2024-03-11 04:54:44 -04:00
/** Source is StateTree event used by transition */
TransitionEvent ,
/** Source is StateTree event used by state selection */
StateEvent ,
2024-06-04 03:56:38 -04:00
/** Source is Property Function */
PropertyFunction ,
2022-04-14 06:28:13 -04:00
} ;
2021-09-28 13:33:00 -04:00
/**
* The type of access a property path describes .
*/
UENUM ( )
enum class EStateTreePropertyAccessType : uint8
{
Offset , // Access node is a simple basePtr + offset
Object , // Access node needs to dereference an object at its current address
WeakObject , // Access is a weak object
SoftObject , // Access is a soft object
2023-02-10 07:22:48 -05:00
ObjectInstance , // Access node needs to dereference an object of specific type at its current address
StructInstance , // Access node needs to dereference an instanced struct of specific type at its current address
2021-09-28 13:33:00 -04:00
IndexArray , // Access node indexes a dynamic array
} ;
/**
* Describes how the copy should be performed .
*/
UENUM ( )
enum class EStateTreePropertyCopyType : uint8
{
None , // No copying
CopyPlain , // For plain old data types, we do a simple memcpy.
CopyComplex , // For more complex data types, we need to call the properties copy function
CopyBool , // Read and write properties using bool property helpers, as source/dest could be bitfield or boolean
CopyStruct , // Use struct copy operation, as this needs to correctly handle CPP struct ops
CopyObject , // Read and write properties using object property helpers, as source/dest could be regular/weak/soft etc.
CopyName , // FName needs special case because its size changes between editor/compiler and runtime.
CopyFixedArray , // Array needs special handling for fixed size TArrays
2022-06-29 04:52:18 -04:00
StructReference , // Copies pointer to a source struct into a FStateTreeStructRef.
2021-09-28 13:33:00 -04:00
/* Promote the type during the copy */
/* Bool promotions */
PromoteBoolToByte ,
PromoteBoolToInt32 ,
PromoteBoolToUInt32 ,
PromoteBoolToInt64 ,
PromoteBoolToFloat ,
PromoteBoolToDouble ,
/* Byte promotions */
PromoteByteToInt32 ,
PromoteByteToUInt32 ,
PromoteByteToInt64 ,
PromoteByteToFloat ,
PromoteByteToDouble ,
/* Int32 promotions */
PromoteInt32ToInt64 ,
PromoteInt32ToFloat , // This is strictly sketchy because of potential data loss, but it is usually OK in the general case
PromoteInt32ToDouble ,
/* UInt32 promotions */
PromoteUInt32ToInt64 ,
2022-09-09 07:14:47 -04:00
PromoteUInt32ToFloat , // This is strictly sketchy because of potential data loss, but it is usually OK in the general case
PromoteUInt32ToDouble ,
2021-09-28 13:33:00 -04:00
/* Float promotions */
2022-09-09 07:14:47 -04:00
PromoteFloatToInt32 ,
PromoteFloatToInt64 ,
2021-09-28 13:33:00 -04:00
PromoteFloatToDouble ,
2022-09-09 07:14:47 -04:00
/* Double promotions */
DemoteDoubleToInt32 ,
DemoteDoubleToInt64 ,
DemoteDoubleToFloat ,
2021-09-28 13:33:00 -04:00
} ;
2023-02-10 07:22:48 -05:00
/** Enum describing property compatibility */
enum class EStateTreePropertyAccessCompatibility
{
/** Properties are incompatible */
Incompatible ,
/** Properties are directly compatible */
Compatible ,
/** Properties can be copied with a simple type promotion */
Promotable ,
} ;
2021-09-28 13:33:00 -04:00
/**
2023-02-10 07:22:48 -05:00
* Descriptor for a struct or class that can be a binding source or target .
* Each struct has unique identifier , which is used to distinguish them , and name that is mostly for debugging and UI .
2021-09-28 13:33:00 -04:00
*/
USTRUCT ( )
2023-02-10 07:22:48 -05:00
struct STATETREEMODULE_API FStateTreeBindableStructDesc
{
GENERATED_BODY ( )
FStateTreeBindableStructDesc ( ) = default ;
# if WITH_EDITORONLY_DATA
2024-05-14 02:41:50 -04:00
FStateTreeBindableStructDesc ( const FString & InStatePath , const FName InName , const UStruct * InStruct , const FStateTreeDataHandle InDataHandle , const EStateTreeBindableStructSource InDataSource , const FGuid InGuid )
: Struct ( InStruct )
, Name ( InName )
, DataHandle ( InDataHandle )
, DataSource ( InDataSource )
, ID ( InGuid )
, StatePath ( InStatePath )
{
}
UE_DEPRECATED ( 5.5 , " Use constructor with StatePath instead. " )
2023-11-22 04:08:33 -05:00
FStateTreeBindableStructDesc ( const FName InName , const UStruct * InStruct , const FStateTreeDataHandle InDataHandle , const EStateTreeBindableStructSource InDataSource , const FGuid InGuid )
: Struct ( InStruct )
, Name ( InName )
, DataHandle ( InDataHandle )
, DataSource ( InDataSource )
, ID ( InGuid )
{
}
UE_DEPRECATED ( 5.4 , " Use constructor with DataHandle instead. " )
2023-02-10 07:22:48 -05:00
FStateTreeBindableStructDesc ( const FName InName , const UStruct * InStruct , const EStateTreeBindableStructSource InDataSource , const FGuid InGuid )
2023-11-22 04:08:33 -05:00
: Struct ( InStruct )
, Name ( InName )
, DataSource ( InDataSource )
, ID ( InGuid )
2023-02-10 07:22:48 -05:00
{
}
bool operator = = ( const FStateTreeBindableStructDesc & RHS ) const
{
return ID = = RHS . ID & & Struct = = RHS . Struct ; // Not checking name, it's cosmetic.
}
# endif
bool IsValid ( ) const { return Struct ! = nullptr ; }
2023-06-26 06:34:49 -04:00
FString ToString ( ) const ;
2023-02-10 07:22:48 -05:00
/** The type of the struct or class. */
UPROPERTY ( )
TObjectPtr < const UStruct > Struct = nullptr ;
/** Name of the container (cosmetic). */
UPROPERTY ( )
FName Name ;
2023-11-22 04:08:33 -05:00
/** Runtime data the struct represents. */
UPROPERTY ( )
FStateTreeDataHandle DataHandle = FStateTreeDataHandle : : Invalid ;
/** Type of the source. */
2023-02-10 07:22:48 -05:00
UPROPERTY ( )
EStateTreeBindableStructSource DataSource = EStateTreeBindableStructSource : : Context ;
2023-11-22 04:08:33 -05:00
2023-02-10 07:22:48 -05:00
# if WITH_EDITORONLY_DATA
/** Unique identifier of the struct. */
UPROPERTY ( )
FGuid ID ;
2024-05-14 02:41:50 -04:00
/** In Editor path to State containting the data. */
UPROPERTY ( Transient )
FString StatePath ;
2024-08-06 07:42:19 -04:00
/** Category of the bindable struct. Can be used to display the category in a menu. */
UPROPERTY ( )
FString Category ;
2023-02-10 07:22:48 -05:00
# endif
} ;
/** Struct describing a path segment in FStateTreePropertyPath. */
USTRUCT ( )
struct STATETREEMODULE_API FStateTreePropertyPathSegment
{
GENERATED_BODY ( )
FStateTreePropertyPathSegment ( ) = default ;
explicit FStateTreePropertyPathSegment ( const FName InName , const int32 InArrayIndex = INDEX_NONE , const UStruct * InInstanceStruct = nullptr )
: Name ( InName )
, ArrayIndex ( InArrayIndex )
, InstanceStruct ( InInstanceStruct )
{
}
bool operator = = ( const FStateTreePropertyPathSegment & RHS ) const
{
return Name = = RHS . Name & & InstanceStruct = = RHS . InstanceStruct & & ArrayIndex = = RHS . ArrayIndex ;
}
bool operator ! = ( const FStateTreePropertyPathSegment & RHS ) const
{
return ! ( * this = = RHS ) ;
}
void SetName ( const FName InName )
{
Name = InName ;
}
FName GetName ( ) const
{
return Name ;
}
void SetArrayIndex ( const int32 InArrayIndex )
{
ArrayIndex = InArrayIndex ;
}
int32 GetArrayIndex ( ) const
{
return ArrayIndex ;
}
void SetInstanceStruct ( const UStruct * InInstanceStruct )
{
InstanceStruct = InInstanceStruct ;
}
const UStruct * GetInstanceStruct ( ) const
{
return InstanceStruct ;
}
2023-06-21 10:25:47 -04:00
# if WITH_EDITORONLY_DATA
FGuid GetPropertyGuid ( ) const
{
return PropertyGuid ;
}
void SetPropertyGuid ( const FGuid NewGuid )
{
PropertyGuid = NewGuid ;
}
# endif
2023-02-10 07:22:48 -05:00
private :
/** Name of the property */
UPROPERTY ( )
FName Name ;
2023-06-21 10:25:47 -04:00
# if WITH_EDITORONLY_DATA
/** Guid of the property for Blueprint classes or User Defined Structs. */
FGuid PropertyGuid ;
# endif
2023-02-10 07:22:48 -05:00
/** Array index if the property is dynamic or static array. */
UPROPERTY ( )
int32 ArrayIndex = INDEX_NONE ;
/** Type of the instanced struct or object reference by the property at the segment. This allows the path to be resolved when it points to a specific instance. */
UPROPERTY ( )
TObjectPtr < const UStruct > InstanceStruct = nullptr ;
} ;
/**
* Struct describing an indirection at specific segment at path .
* Returned by FStateTreePropertyPath : : ResolveIndirections ( ) and FStateTreePropertyPath : : ResolveIndirectionsWithValue ( ) .
* Generally there ' s one indirection per FProperty . Containers have one path segment but two indirection ( container + inner type ) .
*/
struct FStateTreePropertyPathIndirection
{
FStateTreePropertyPathIndirection ( ) = default ;
explicit FStateTreePropertyPathIndirection ( const UStruct * InContainerStruct )
: ContainerStruct ( InContainerStruct )
{
}
const FProperty * GetProperty ( ) const { return Property ; }
const uint8 * GetContainerAddress ( ) const { return ContainerAddress ; }
const UStruct * GetInstanceStruct ( ) const { return InstanceStruct ; }
const UStruct * GetContainerStruct ( ) const { return ContainerStruct ; }
int32 GetArrayIndex ( ) const { return ArrayIndex ; }
int32 GetPropertyOffset ( ) const { return PropertyOffset ; }
int32 GetPathSegmentIndex ( ) const { return PathSegmentIndex ; }
EStateTreePropertyAccessType GetAccessType ( ) const { return AccessType ; }
const uint8 * GetPropertyAddress ( ) const { return ContainerAddress + PropertyOffset ; }
2023-06-21 10:25:47 -04:00
# if WITH_EDITORONLY_DATA
FName GetRedirectedName ( ) const { return RedirectedName ; }
FGuid GetPropertyGuid ( ) const { return PropertyGuid ; }
# endif
2023-02-10 07:22:48 -05:00
private :
/** Property at the indirection. */
const FProperty * Property = nullptr ;
/** Address of the container class/struct where the property belongs to. Only valid if created with ResolveIndirectionsWithValue() */
const uint8 * ContainerAddress = nullptr ;
/** Type of the container class/struct. */
const UStruct * ContainerStruct = nullptr ;
/** Type of the instance class/struct of when AccessType is ObjectInstance or StructInstance. */
const UStruct * InstanceStruct = nullptr ;
2023-06-21 10:25:47 -04:00
# if WITH_EDITORONLY_DATA
/** Redirected name, if the give property name was not found but was reconciled using core redirect or property Guid. Requires ResolveIndirections/WithValue() to be called with bHandleRedirects = true. */
FName RedirectedName ;
/** Guid of the property for Blueprint classes or User Defined Structs. Requires ResolveIndirections/WithValue() to be called with bHandleRedirects = true. */
FGuid PropertyGuid ;
# endif
2023-02-10 07:22:48 -05:00
/** Array index for static and dynamic arrays. Note: static array indexing is baked in the PropertyOffset. */
int32 ArrayIndex = 0 ;
/** Offset of the property relative to ContainerAddress. Includes static array indexing. */
int32 PropertyOffset = 0 ;
/** Index of the path segment where indirection originated from. */
int32 PathSegmentIndex = 0 ;
/** How to access the data through the indirection. */
EStateTreePropertyAccessType AccessType = EStateTreePropertyAccessType : : Offset ;
friend FStateTreePropertyPath ;
} ;
/**
* Representation of a property path used for property binding in StateTree .
*/
USTRUCT ( )
struct STATETREEMODULE_API FStateTreePropertyPath
{
GENERATED_BODY ( )
FStateTreePropertyPath ( ) = default ;
# if WITH_EDITORONLY_DATA
explicit FStateTreePropertyPath ( const FGuid InStructID )
: StructID ( InStructID )
{
}
explicit FStateTreePropertyPath ( const FGuid InStructID , const FName PropertyName )
: StructID ( InStructID )
{
Segments . Emplace ( PropertyName ) ;
}
explicit FStateTreePropertyPath ( const FGuid InStructID , TConstArrayView < FStateTreePropertyPathSegment > InSegments )
: StructID ( InStructID )
, Segments ( InSegments )
{
}
# endif // WITH_EDITORONLY_DATA
/**
* Parses path from string . The path should be in format : Foo . Bar [ 1 ] . Baz
* @ param InPath Path string to parse
* @ return true if path was parsed successfully .
*/
bool FromString ( const FString & InPath ) ;
/**
* Returns the property path as a one string . Highlight allows to decorate a specific segment .
* @ param HighlightedSegment Index of the highlighted path segment
* @ param HighlightPrefix String to append before highlighted segment
* @ param HighlightPostfix String to append after highlighted segment
* @ param bOutputInstances if true , the instance struct types will be output .
2024-06-04 03:56:38 -04:00
* @ param FirstSegment Index of the first path segment to be stringified .
2023-02-10 07:22:48 -05:00
*/
2024-06-04 03:56:38 -04:00
FString ToString ( const int32 HighlightedSegment = INDEX_NONE , const TCHAR * HighlightPrefix = nullptr , const TCHAR * HighlightPostfix = nullptr , const bool bOutputInstances = false , const int32 FirstSegment = 0 ) const ;
2023-02-10 07:22:48 -05:00
/**
* Resolves the property path against base struct type . The path is assumed to be relative to the BaseStruct .
* @ param BaseStruct Base struct / class type the path is relative to .
* @ param OutIndirections Indirections describing how the properties were accessed .
* @ param OutError Optional , pointer to string where error will be logged if update fails .
2023-06-21 10:25:47 -04:00
* @ param bHandleRedirects If true , the method will try to resolve missing properties using core redirects , and properties on Blueprint and User Defined Structs by ID . Available only in editor builds !
2023-02-10 07:22:48 -05:00
* @ return true of path could be resolved against the base value , and instance types were updated .
*/
2023-06-21 10:25:47 -04:00
bool ResolveIndirections ( const UStruct * BaseStruct , TArray < FStateTreePropertyPathIndirection > & OutIndirections , FString * OutError = nullptr , bool bHandleRedirects = false ) const ;
2023-02-10 07:22:48 -05:00
/**
* Resolves the property path against base value . The path is assumed to be relative to the BaseValueView .
* @ param BaseValueView Base value the path is relative to .
* @ param OutIndirections Indirections describing how the properties were accessed .
* @ param OutError Optional , pointer to string where error will be logged if update fails .
2023-06-21 10:25:47 -04:00
* @ param bHandleRedirects If true , the method will try to resolve missing properties using core redirects , and properties on Blueprint and User Defined Structs by ID . Available only in editor builds !
2023-02-10 07:22:48 -05:00
* @ return true of path could be resolved against the base value , and instance types were updated .
*/
2023-06-21 10:25:47 -04:00
bool ResolveIndirectionsWithValue ( const FStateTreeDataView BaseValueView , TArray < FStateTreePropertyPathIndirection > & OutIndirections , FString * OutError = nullptr , bool bHandleRedirects = false ) const ;
2023-02-10 07:22:48 -05:00
/**
2023-06-21 10:25:47 -04:00
* Updates property segments from base struct type . The path is expected to be relative to the BaseStruct .
* The method handles renamed properties ( core redirect , Blueprint and User Defined Structs by ID ) .
* @ param BaseValueView Base value the path is relative to .
* @ param OutError Optional , pointer to string where error will be logged if update fails .
* @ return true of path could be resolved against the base value , and instance types were updated .
*/
bool UpdateSegments ( const UStruct * BaseStruct , FString * OutError = nullptr ) ;
/**
* Updates property segments from base value . The path is expected to be relative to the base value .
* The method updates instance types , and handles renamed properties ( core redirect , Blueprint and User Defined Structs by ID ) .
2023-02-10 07:22:48 -05:00
* By storing the instance types on the path , we can resolve the path without the base value later .
* @ param BaseValueView Base value the path is relative to .
* @ param OutError Optional , pointer to string where error will be logged if update fails .
* @ return true of path could be resolved against the base value , and instance types were updated .
*/
2023-06-21 10:25:47 -04:00
bool UpdateSegmentsFromValue ( const FStateTreeDataView BaseValueView , FString * OutError = nullptr ) ;
2023-02-10 07:22:48 -05:00
2023-06-21 10:25:47 -04:00
UE_DEPRECATED ( 5.3 , " Use UpdateSegmentsFromValue instead " )
bool UpdateInstanceStructsFromValue ( const FStateTreeDataView BaseValueView , FString * OutError = nullptr )
{
return UpdateSegmentsFromValue ( BaseValueView , OutError ) ;
}
2023-02-10 07:22:48 -05:00
/** @return true if the path is empty. In that case the path points to the struct. */
bool IsPathEmpty ( ) const { return Segments . IsEmpty ( ) ; }
/** @return true if any of the path segments is and indirection via instanced struct or object. */
bool HasAnyInstancedIndirection ( ) const
{
return Segments . ContainsByPredicate ( [ ] ( const FStateTreePropertyPathSegment & Segment )
{
return Segment . GetInstanceStruct ( ) ! = nullptr ;
} ) ;
}
/** Reset the path to empty. */
void Reset ( )
{
# if WITH_EDITORONLY_DATA
StructID = FGuid ( ) ;
# endif
Segments . Reset ( ) ;
}
# if WITH_EDITORONLY_DATA
const FGuid & GetStructID ( ) const { return StructID ; }
void SetStructID ( const FGuid NewStructID ) { StructID = NewStructID ; }
# endif // WITH_EDITORONLY_DATA
TConstArrayView < FStateTreePropertyPathSegment > GetSegments ( ) const { return Segments ; }
TArrayView < FStateTreePropertyPathSegment > GetMutableSegments ( ) { return Segments ; }
int32 NumSegments ( ) const { return Segments . Num ( ) ; }
const FStateTreePropertyPathSegment & GetSegment ( const int32 Index ) const { return Segments [ Index ] ; }
/** Adds a path segment to the path. */
void AddPathSegment ( const FName InName , const int32 InArrayIndex = INDEX_NONE , const UStruct * InInstanceType = nullptr )
{
Segments . Emplace ( InName , InArrayIndex , InInstanceType ) ;
}
/** Adds a path segment to the path. */
void AddPathSegment ( const FStateTreePropertyPathSegment & PathSegment )
{
Segments . Add ( PathSegment ) ;
}
2024-09-03 10:04:08 -04:00
/**
* Test if this paths includes the provided path .
* A path includes another one when they are = = but this path can be longer .
*/
bool Includes ( const FStateTreePropertyPath & Other ) const ;
2023-02-10 07:22:48 -05:00
/** Test if paths are equal. */
bool operator = = ( const FStateTreePropertyPath & RHS ) const ;
private :
# if WITH_EDITORONLY_DATA
/** ID of the struct this property path is relative to. */
UPROPERTY ( )
FGuid StructID ;
# endif // WITH_EDITORONLY_DATA
/** Path segments pointing to a specific property on the path. */
UPROPERTY ( )
TArray < FStateTreePropertyPathSegment > Segments ;
} ;
USTRUCT ( )
struct UE_DEPRECATED ( 5.3 , " Use FStateTreePropertyPath instead. " ) STATETREEMODULE_API FStateTreeEditorPropertyPath
{
GENERATED_BODY ( )
FStateTreeEditorPropertyPath ( ) = default ;
FStateTreeEditorPropertyPath ( const FGuid & InStructID , const TCHAR * PropertyName ) : StructID ( InStructID ) { Path . Add ( PropertyName ) ; }
/**
* Returns the property path as a one string . Highlight allows to decorate a specific segment .
* @ param HighlightedSegment Index of the highlighted path segment
* @ param HighlightPrefix String to append before highlighted segment
* @ param HighlightPostfix String to append after highlighted segment
*/
FString ToString ( const int32 HighlightedSegment = INDEX_NONE , const TCHAR * HighlightPrefix = nullptr , const TCHAR * HighlightPostfix = nullptr ) const ;
/** Handle of the struct this property path is relative to. */
UPROPERTY ( )
FGuid StructID ;
/** Property path segments */
UPROPERTY ( )
TArray < FString > Path ;
bool IsValid ( ) const { return StructID . IsValid ( ) ; }
PRAGMA_DISABLE_DEPRECATION_WARNINGS
bool operator = = ( const FStateTreeEditorPropertyPath & RHS ) const ;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
} ;
/**
* Representation of a property binding in StateTree
*/
USTRUCT ( )
struct STATETREEMODULE_API FStateTreePropertyPathBinding
{
GENERATED_BODY ( )
PRAGMA_DISABLE_DEPRECATION_WARNINGS
FStateTreePropertyPathBinding ( ) = default ;
FStateTreePropertyPathBinding ( const FStateTreePropertyPath & InSourcePath , const FStateTreePropertyPath & InTargetPath )
: SourcePropertyPath ( InSourcePath )
, TargetPropertyPath ( InTargetPath )
{
}
2023-11-22 04:08:33 -05:00
FStateTreePropertyPathBinding ( const FStateTreeDataHandle InSourceDataHandle , const FStateTreePropertyPath & InSourcePath , const FStateTreePropertyPath & InTargetPath )
: SourcePropertyPath ( InSourcePath )
, TargetPropertyPath ( InTargetPath )
, SourceDataHandle ( InSourceDataHandle )
{
}
2024-06-04 03:56:38 -04:00
# if WITH_EDITOR
FStateTreePropertyPathBinding ( FConstStructView InFunctionNodeStruct , const FStateTreePropertyPath & InSourcePath , const FStateTreePropertyPath & InTargetPath )
: SourcePropertyPath ( InSourcePath )
, TargetPropertyPath ( InTargetPath )
, PropertyFunctionNode ( InFunctionNodeStruct )
{
}
# endif
2023-11-22 04:08:33 -05:00
UE_DEPRECATED ( 5.4 , " Use constructor with DataHandle instead. " )
2023-02-10 07:22:48 -05:00
FStateTreePropertyPathBinding ( const FStateTreeIndex16 InCompiledSourceStructIndex , const FStateTreePropertyPath & InSourcePath , const FStateTreePropertyPath & InTargetPath )
: SourcePropertyPath ( InSourcePath )
, TargetPropertyPath ( InTargetPath )
{
}
UE_DEPRECATED ( 5.3 , " Use constructor with FStateTreePropertyPath instead. " )
2023-11-22 04:08:33 -05:00
FStateTreePropertyPathBinding ( const FStateTreeEditorPropertyPath & InSourcePath , const FStateTreeEditorPropertyPath & InTargetPath )
{
}
2023-02-10 07:22:48 -05:00
PRAGMA_ENABLE_DEPRECATION_WARNINGS
void PostSerialize ( const FArchive & Ar ) ;
const FStateTreePropertyPath & GetSourcePath ( ) const { return SourcePropertyPath ; }
const FStateTreePropertyPath & GetTargetPath ( ) const { return TargetPropertyPath ; }
FStateTreePropertyPath & GetMutableSourcePath ( ) { return SourcePropertyPath ; }
FStateTreePropertyPath & GetMutableTargetPath ( ) { return TargetPropertyPath ; }
2023-11-22 04:08:33 -05:00
UE_DEPRECATED ( 5.4 , " Use GetSourceDataHandle instead. " )
FStateTreeIndex16 GetCompiledSourceStructIndex ( ) const { return { } ; }
void SetSourceDataHandle ( const FStateTreeDataHandle NewSourceDataHandle ) { SourceDataHandle = NewSourceDataHandle ; }
FStateTreeDataHandle GetSourceDataHandle ( ) const { return SourceDataHandle ; }
2023-02-10 07:22:48 -05:00
2024-06-04 03:56:38 -04:00
# if WITH_EDITOR
FConstStructView GetPropertyFunctionNode ( ) const { return FConstStructView ( PropertyFunctionNode ) ; }
FStructView GetMutablePropertyFunctionNode ( ) { return FStructView ( PropertyFunctionNode ) ; }
# endif
2023-02-10 07:22:48 -05:00
private :
/** Source property path of the binding */
UPROPERTY ( )
FStateTreePropertyPath SourcePropertyPath ;
/** Target property path of the binding */
UPROPERTY ( )
FStateTreePropertyPath TargetPropertyPath ;
2023-11-22 04:08:33 -05:00
/** Describes how to get the source data pointer for the binding. */
2023-02-10 07:22:48 -05:00
UPROPERTY ( )
2023-11-22 04:08:33 -05:00
FStateTreeDataHandle SourceDataHandle = FStateTreeDataHandle : : Invalid ;
2023-02-10 07:22:48 -05:00
# if WITH_EDITORONLY_DATA
2024-06-04 03:56:38 -04:00
/** Instance of bound PropertyFunction. */
UPROPERTY ( )
FInstancedStruct PropertyFunctionNode ;
2023-02-10 07:22:48 -05:00
PRAGMA_DISABLE_DEPRECATION_WARNINGS
UPROPERTY ( )
FStateTreeEditorPropertyPath SourcePath_DEPRECATED ;
UPROPERTY ( )
FStateTreeEditorPropertyPath TargetPath_DEPRECATED ;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
# endif // WITH_EDITORONLY_DATA
} ;
template < >
struct TStructOpsTypeTraits < FStateTreePropertyPathBinding > : public TStructOpsTypeTraitsBase2 < FStateTreePropertyPathBinding >
{
enum
{
WithPostSerialize = true ,
} ;
} ;
using FStateTreeEditorPropertyBinding UE_DEPRECATED ( 5.3 , " Deprecated struct. Please use FStateTreePropertyPathBinding instead. " ) = FStateTreePropertyPathBinding ;
2024-01-11 04:24:45 -05:00
/**
* Representation of a property reference binding in StateTree .
*/
USTRUCT ( )
struct STATETREEMODULE_API FStateTreePropertyRefPath
{
GENERATED_BODY ( )
FStateTreePropertyRefPath ( ) = default ;
FStateTreePropertyRefPath ( FStateTreeDataHandle InSourceDataHandle , const FStateTreePropertyPath & InSourcePath )
: SourcePropertyPath ( InSourcePath )
, SourceDataHandle ( InSourceDataHandle )
{
}
const FStateTreePropertyPath & GetSourcePath ( ) const { return SourcePropertyPath ; }
FStateTreePropertyPath & GetMutableSourcePath ( ) { return SourcePropertyPath ; }
void SetSourceDataHandle ( const FStateTreeDataHandle NewSourceDataHandle ) { SourceDataHandle = NewSourceDataHandle ; }
FStateTreeDataHandle GetSourceDataHandle ( ) const { return SourceDataHandle ; }
private :
/** Source property path of the reference */
UPROPERTY ( )
FStateTreePropertyPath SourcePropertyPath ;
/** Describes how to get the source data pointer */
UPROPERTY ( )
FStateTreeDataHandle SourceDataHandle = FStateTreeDataHandle : : Invalid ;
} ;
2023-02-10 07:22:48 -05:00
/**
* Deprecated . Describes a segment of a property path . Used for storage only .
*/
USTRUCT ( )
struct UE_DEPRECATED ( 5.3 , " Use FStateTreePropertyPath instead. " ) STATETREEMODULE_API FStateTreePropertySegment
2021-09-28 13:33:00 -04:00
{
GENERATED_BODY ( )
2022-06-03 04:55:42 -04:00
/** @return true if the segment is empty. */
bool IsEmpty ( ) const { return Name . IsNone ( ) ; }
2021-09-28 13:33:00 -04:00
/** Property name. */
UPROPERTY ( )
FName Name ;
/** Index in the array the property points at. */
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
FStateTreeIndex16 ArrayIndex = FStateTreeIndex16 : : Invalid ;
/** Index to next segment. */
UPROPERTY ( )
FStateTreeIndex16 NextIndex = FStateTreeIndex16 : : Invalid ;
2021-09-28 13:33:00 -04:00
/** Type of access/indirection. */
UPROPERTY ( )
EStateTreePropertyAccessType Type = EStateTreePropertyAccessType : : Offset ;
} ;
/**
2023-02-10 07:22:48 -05:00
* Deprecated . Describes property binding , the property from source path is copied into the property at the target path .
2021-09-28 13:33:00 -04:00
*/
USTRUCT ( )
2023-02-10 07:22:48 -05:00
struct UE_DEPRECATED ( 5.3 , " Use FStateTreePropertyPath instead. " ) STATETREEMODULE_API FStateTreePropertyBinding
2021-09-28 13:33:00 -04:00
{
2023-02-10 07:22:48 -05:00
PRAGMA_DISABLE_DEPRECATION_WARNINGS
2021-09-28 13:33:00 -04:00
GENERATED_BODY ( )
2022-05-31 04:51:18 -04:00
/** Source property path. */
2021-09-28 13:33:00 -04:00
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
FStateTreePropertySegment SourcePath ;
2021-09-28 13:33:00 -04:00
2022-05-31 04:51:18 -04:00
/** Target property path. */
2021-09-28 13:33:00 -04:00
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
FStateTreePropertySegment TargetPath ;
2021-09-28 13:33:00 -04:00
/** Index to the source struct the source path refers to, sources are stored in FStateTreePropertyBindings. */
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
FStateTreeIndex16 SourceStructIndex = FStateTreeIndex16 : : Invalid ;
2021-09-28 13:33:00 -04:00
/** The type of copy to use between the properties. */
UPROPERTY ( )
EStateTreePropertyCopyType CopyType = EStateTreePropertyCopyType : : None ;
2023-02-10 07:22:48 -05:00
PRAGMA_ENABLE_DEPRECATION_WARNINGS
2021-09-28 13:33:00 -04:00
} ;
2023-02-10 07:22:48 -05:00
2021-09-28 13:33:00 -04:00
/**
2023-02-10 07:22:48 -05:00
* Used internally .
2021-09-28 13:33:00 -04:00
* Property indirection is a resolved property path segment , used for accessing properties in structs .
*/
USTRUCT ( )
struct STATETREEMODULE_API FStateTreePropertyIndirection
{
GENERATED_BODY ( )
/** Index in the array the property points at. */
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
FStateTreeIndex16 ArrayIndex = FStateTreeIndex16 : : Invalid ;
2021-09-28 13:33:00 -04:00
/** Cached offset of the property */
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
uint16 Offset = 0 ;
/** Cached offset of the property */
UPROPERTY ( )
FStateTreeIndex16 NextIndex = FStateTreeIndex16 : : Invalid ;
2021-09-28 13:33:00 -04:00
/** Type of access/indirection. */
UPROPERTY ( )
EStateTreePropertyAccessType Type = EStateTreePropertyAccessType : : Offset ;
2023-02-10 07:22:48 -05:00
/** Type of the struct or object instance in case the segment is pointing into an instanced data. */
UPROPERTY ( )
TObjectPtr < const UStruct > InstanceStruct = nullptr ;
2021-09-28 13:33:00 -04:00
/** Cached array property. */
const FArrayProperty * ArrayProperty = nullptr ;
} ;
2023-02-10 07:22:48 -05:00
2021-09-28 13:33:00 -04:00
/**
2023-02-10 07:22:48 -05:00
* Used internally .
2021-09-28 13:33:00 -04:00
* Describes property copy , the property from source is copied into the property at the target .
* Copy target struct is described in the property copy batch .
*/
USTRUCT ( )
2023-02-10 07:22:48 -05:00
struct STATETREEMODULE_API FStateTreePropertyCopy
2021-09-28 13:33:00 -04:00
{
GENERATED_BODY ( )
2023-11-22 04:08:33 -05:00
PRAGMA_DISABLE_DEPRECATION_WARNINGS
FStateTreePropertyCopy ( ) = default ;
FStateTreePropertyCopy ( const FStateTreePropertyCopy & ) = default ;
FStateTreePropertyCopy ( FStateTreePropertyCopy & & ) = default ;
FStateTreePropertyCopy & operator = ( const FStateTreePropertyCopy & ) = default ;
FStateTreePropertyCopy & operator = ( FStateTreePropertyCopy & & ) = default ;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
2022-05-31 04:51:18 -04:00
/** Source property access. */
2021-09-28 13:33:00 -04:00
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
FStateTreePropertyIndirection SourceIndirection ;
2021-09-28 13:33:00 -04:00
2022-05-31 04:51:18 -04:00
/** Target property access. */
2021-09-28 13:33:00 -04:00
UPROPERTY ( )
2022-05-31 04:51:18 -04:00
FStateTreePropertyIndirection TargetIndirection ;
2021-09-28 13:33:00 -04:00
2022-05-31 04:51:18 -04:00
/** Cached pointer to the leaf property of the access. */
const FProperty * SourceLeafProperty = nullptr ;
2021-09-28 13:33:00 -04:00
2022-05-31 04:51:18 -04:00
/** Cached pointer to the leaf property of the access. */
const FProperty * TargetLeafProperty = nullptr ;
2021-09-28 13:33:00 -04:00
2023-11-22 04:08:33 -05:00
/** Type of the source data, used for validation. */
UPROPERTY ( Transient )
TObjectPtr < const UStruct > SourceStructType = nullptr ;
2021-09-28 13:33:00 -04:00
/** Cached property element size * dim. */
UPROPERTY ( )
int32 CopySize = 0 ;
2023-11-22 04:08:33 -05:00
/** Describes how to get the source data pointer for the copy. */
2022-05-31 04:51:18 -04:00
UPROPERTY ( )
2023-11-22 04:08:33 -05:00
FStateTreeDataHandle SourceDataHandle = FStateTreeDataHandle : : Invalid ;
2022-05-31 04:51:18 -04:00
/** Type of the copy */
UPROPERTY ( )
EStateTreePropertyCopyType Type = EStateTreePropertyCopyType : : None ;
2023-11-22 04:08:33 -05:00
UE_DEPRECATED ( 5.4 , " Use SourceDataHandle instead " )
UPROPERTY ( )
FStateTreeIndex16 SourceStructIndex_DEPRECATED = FStateTreeIndex16 : : Invalid ;
2022-05-31 04:51:18 -04:00
} ;
2021-09-28 13:33:00 -04:00
2023-02-10 07:22:48 -05:00
using FStateTreePropCopy UE_DEPRECATED ( 5.3 , " Deprecated struct. Please use FStateTreePropertyCopy instead. " ) = FStateTreePropertyCopy ;
2021-09-28 13:33:00 -04:00
/**
* Describes a batch of property copies from many sources to one target struct .
* Note : The batch is used to reference both bindings and copies ( a binding turns into copy when resolved ) .
*/
USTRUCT ( )
2023-02-10 07:22:48 -05:00
struct STATETREEMODULE_API FStateTreePropertyCopyBatch
2021-09-28 13:33:00 -04:00
{
GENERATED_BODY ( )
/** Expected target struct */
UPROPERTY ( )
FStateTreeBindableStructDesc TargetStruct ;
/** Index to first binding/copy. */
UPROPERTY ( )
2024-06-04 03:56:38 -04:00
FStateTreeIndex16 BindingsBegin ;
2021-09-28 13:33:00 -04:00
/** Index to one past the last binding/copy. */
UPROPERTY ( )
2024-06-04 03:56:38 -04:00
FStateTreeIndex16 BindingsEnd ;
/** Index to first property function. */
UPROPERTY ( )
FStateTreeIndex16 PropertyFunctionsBegin ;
/** Index to one past the last property function. */
UPROPERTY ( )
FStateTreeIndex16 PropertyFunctionsEnd ;
2021-09-28 13:33:00 -04:00
} ;
2023-02-10 07:22:48 -05:00
using FStateTreePropCopyBatch UE_DEPRECATED ( 5.3 , " Deprecated struct. Please use FStateTreePropertyCopy instead. " ) = FStateTreePropertyCopyBatch ;
2024-01-11 04:24:45 -05:00
/**
* Describes access to referenced property .
*/
USTRUCT ( )
struct STATETREEMODULE_API FStateTreePropertyAccess
{
GENERATED_BODY ( )
/** Source property access. */
UPROPERTY ( )
FStateTreePropertyIndirection SourceIndirection ;
/** Cached pointer to the leaf property of the access. */
const FProperty * SourceLeafProperty = nullptr ;
/** Type of the source data, used for validation. */
UPROPERTY ( Transient )
TObjectPtr < const UStruct > SourceStructType = nullptr ;
/** Describes how to get the source data pointer. */
UPROPERTY ( )
FStateTreeDataHandle SourceDataHandle = FStateTreeDataHandle : : Invalid ;
} ;
2023-02-10 07:22:48 -05:00
2021-09-28 13:33:00 -04:00
/**
* Runtime storage and execution of property bindings .
*/
USTRUCT ( )
struct STATETREEMODULE_API FStateTreePropertyBindings
{
GENERATED_BODY ( )
/**
* Clears all bindings .
*/
void Reset ( ) ;
/**
* Resolves paths to indirections .
* @ return True if resolve succeeded .
*/
2022-04-06 10:04:05 -04:00
[ [ nodiscard ] ] bool ResolvePaths ( ) ;
2021-09-28 13:33:00 -04:00
/**
* @ return True if bindings have been resolved .
*/
bool IsValid ( ) const { return bBindingsResolved ; }
/**
* @ return Number of source structs the copy expects .
*/
int32 GetSourceStructNum ( ) const { return SourceStructs . Num ( ) ; }
/**
2023-11-22 04:08:33 -05:00
* Copies a property from Source to Target based on the provided Copy .
* @ param Copy Describes which parameter and how is copied .
* @ param SourceStructView Pointer and type for the source containing the property to be copied .
* @ param TargetStructView Pointer and type for the target containing the property to be copied .
* @ return true if the property was copied successfully .
2021-09-28 13:33:00 -04:00
*/
2023-11-22 04:08:33 -05:00
bool CopyProperty ( const FStateTreePropertyCopy & Copy , FStateTreeDataView SourceStructView , FStateTreeDataView TargetStructView ) const ;
2021-09-28 13:33:00 -04:00
2023-11-22 04:08:33 -05:00
/** @return copy batch at specified index. */
const FStateTreePropertyCopyBatch & GetBatch ( const FStateTreeIndex16 TargetBatchIndex ) const
{
check ( TargetBatchIndex . IsValid ( ) ) ;
return CopyBatches [ TargetBatchIndex . Get ( ) ] ;
}
/** @return All the property copies for a specific batch. */
TConstArrayView < FStateTreePropertyCopy > GetBatchCopies ( const FStateTreeIndex16 TargetBatchIndex ) const
{
return GetBatchCopies ( GetBatch ( TargetBatchIndex ) ) ;
}
/** @return All the property copies for a specific batch. */
TConstArrayView < FStateTreePropertyCopy > GetBatchCopies ( const FStateTreePropertyCopyBatch & Batch ) const
{
2024-06-04 03:56:38 -04:00
const int32 Count = Batch . BindingsEnd . Get ( ) - Batch . BindingsBegin . Get ( ) ;
2023-11-22 04:08:33 -05:00
if ( Count = = 0 )
{
return { } ;
}
2024-06-04 03:56:38 -04:00
return MakeArrayView ( & PropertyCopies [ Batch . BindingsBegin . Get ( ) ] , Count ) ;
2023-11-22 04:08:33 -05:00
}
2024-01-11 04:24:45 -05:00
/**
* @ return Referenced property access for provided PropertyRef .
*/
const FStateTreePropertyAccess * GetPropertyAccess ( const FStateTreePropertyRef & Reference ) const ;
/**
* Pointer to referenced property
* @ param SourceView Data view to referenced property ' s owner .
* @ param PropertyAccess Access to the property for which we want to obtain a pointer .
* @ return Pointer to referenced property if it ' s type match , nullptr otherwise .
*/
2024-02-14 09:04:52 -05:00
template < class T >
2024-01-11 04:24:45 -05:00
T * GetMutablePropertyPtr ( FStateTreeDataView SourceView , const FStateTreePropertyAccess & PropertyAccess ) const
{
check ( SourceView . GetStruct ( ) = = PropertyAccess . SourceStructType ) ;
if ( ! UE : : StateTree : : PropertyRefHelpers : : Validator < T > : : IsValid ( * PropertyAccess . SourceLeafProperty ) )
{
return nullptr ;
}
return reinterpret_cast < T * > ( GetAddress ( SourceView , PropertyAccess . SourceIndirection , PropertyAccess . SourceLeafProperty ) ) ;
}
2023-02-10 07:22:48 -05:00
/**
* Resets copied properties in TargetStructView . Can be used e . g . to erase UObject references .
* @ param TargetBatchIndex Batch index to copy ( see FStateTreePropertyBindingCompiler ) .
* @ param TargetStructView View to struct where properties are copied to .
* @ return true if all resets succeeded ( a reset can fail e . g . if source or destination struct view is invalid ) .
*/
2022-11-30 07:17:26 -05:00
bool ResetObjects ( const FStateTreeIndex16 TargetBatchIndex , FStateTreeDataView TargetStructView ) const ;
2023-04-14 16:36:43 -04:00
/**
* @ return true if any of the elements in the property bindings contains any of the structs in the set .
*/
bool ContainsAnyStruct ( const TSet < const UStruct * > & Structs ) ;
2021-09-28 13:33:00 -04:00
2023-02-10 07:22:48 -05:00
/** @return how properties are compatible for copying. */
static EStateTreePropertyAccessCompatibility GetPropertyCompatibility ( const FProperty * FromProperty , const FProperty * ToProperty ) ;
2023-06-26 06:34:49 -04:00
/**
* Resolves what kind of copy type to use between specified property indirections .
* @ param SourceIndirection Property path indirections of the copy source ,
* @ param TargetIndirection Property path indirections of the copy target .
* @ param OutCopy Resulting copy type .
* @ return true if copy was resolved , or false if no copy could be resolved between paths .
*/
[ [ nodiscard ] ] static bool ResolveCopyType ( const FStateTreePropertyPathIndirection & SourceIndirection , const FStateTreePropertyPathIndirection & TargetIndirection , FStateTreePropertyCopy & OutCopy ) ;
2023-11-22 04:08:33 -05:00
UE_DEPRECATED ( 5.3 , " Should not be used, will be removed in a future version. " )
TArrayView < FStateTreeBindableStructDesc > GetSourceStructs ( ) { return SourceStructs ; } ;
UE_DEPRECATED ( 5.3 , " Use GetBatch() instead. " )
TArrayView < FStateTreePropertyCopyBatch > GetCopyBatches ( ) { return CopyBatches ; } ;
UE_DEPRECATED ( 5.4 , " Use GetBatchCopies() and Copy() instead. " )
bool CopyTo ( TConstArrayView < FStateTreeDataView > SourceStructViews , const FStateTreeIndex16 TargetBatchIndex , FStateTreeDataView TargetStructView ) const
{
return false ;
}
2024-08-16 09:07:06 -04:00
UE_DEPRECATED ( 5.5 , " DebugPrintInternalLayout is deprecated. Use GetDebugInfo instead. " )
void DebugPrintInternalLayout ( FString & OutString ) const ;
# if WITH_EDITOR || WITH_STATETREE_DEBUG
[ [ nodiscard ] ] FString DebugInternalLayoutAsString ( ) const ;
# endif
2023-02-10 07:22:48 -05:00
private :
2024-02-14 09:04:52 -05:00
[ [ nodiscard ] ] bool ResolvePath ( const UStruct * Struct , const FStateTreePropertyPath & Path , FStateTreePropertyIndirection & OutFirstIndirection , FStateTreePropertyPathIndirection & OutLeafIndirection ) ;
2023-11-22 04:08:33 -05:00
const FStateTreeBindableStructDesc * GetSourceDescByHandle ( const FStateTreeDataHandle SourceDataHandle ) ;
2023-02-10 07:22:48 -05:00
void PerformCopy ( const FStateTreePropertyCopy & Copy , uint8 * SourceAddress , uint8 * TargetAddress ) const ;
void PerformResetObjects ( const FStateTreePropertyCopy & Copy , uint8 * TargetAddress ) const ;
2024-02-14 09:04:52 -05:00
uint8 * GetAddress ( FStateTreeDataView InStructView , const FStateTreePropertyIndirection & FirstIndirection , const FProperty * LeafProperty ) const ;
2021-09-28 13:33:00 -04:00
/** Array of expected source structs. */
UPROPERTY ( )
TArray < FStateTreeBindableStructDesc > SourceStructs ;
/** Array of copy batches. */
UPROPERTY ( )
2023-02-10 07:22:48 -05:00
TArray < FStateTreePropertyCopyBatch > CopyBatches ;
2021-09-28 13:33:00 -04:00
/** Array of property bindings, resolved into arrays of copies before use. */
UPROPERTY ( )
2023-02-10 07:22:48 -05:00
TArray < FStateTreePropertyPathBinding > PropertyPathBindings ;
2021-09-28 13:33:00 -04:00
/** Array of property copies */
UPROPERTY ( Transient )
2023-02-10 07:22:48 -05:00
TArray < FStateTreePropertyCopy > PropertyCopies ;
2021-09-28 13:33:00 -04:00
2024-01-11 04:24:45 -05:00
/** Array of referenced property paths */
UPROPERTY ( )
TArray < FStateTreePropertyRefPath > PropertyReferencePaths ;
/** Array of individually accessed properties */
UPROPERTY ( )
TArray < FStateTreePropertyAccess > PropertyAccesses ;
2021-09-28 13:33:00 -04:00
/** Array of property indirections, indexed by accesses*/
UPROPERTY ( Transient )
TArray < FStateTreePropertyIndirection > PropertyIndirections ;
/** Flag indicating if the properties has been resolved successfully . */
bool bBindingsResolved = false ;
2023-11-22 04:08:33 -05:00
# if WITH_EDITORONLY_DATA
PRAGMA_DISABLE_DEPRECATION_WARNINGS
UE_DEPRECATED_FORGAME ( 5.3 , " Use PropertyPathBindings instead. " )
UPROPERTY ( )
TArray < FStateTreePropertyBinding > PropertyBindings_DEPRECATED ;
UE_DEPRECATED_FORGAME ( 5.3 , " Use PropertyPathBindings instead. " )
UPROPERTY ( )
TArray < FStateTreePropertySegment > PropertySegments_DEPRECATED ;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
# endif // WITH_EDITORONLY_DATA
2023-02-10 07:22:48 -05:00
friend FStateTreePropertyBindingCompiler ;
friend UStateTree ;
2021-09-28 13:33:00 -04:00
} ;
/**
* Helper interface to reason about bound properties . The implementation is in the editor plugin .
*/
struct STATETREEMODULE_API IStateTreeBindingLookup
{
2024-04-05 03:37:02 -04:00
virtual ~ IStateTreeBindingLookup ( ) { }
2021-09-28 13:33:00 -04:00
/** @return Source path for given target path, or null if binding does not exists. */
2023-02-10 07:22:48 -05:00
virtual const FStateTreePropertyPath * GetPropertyBindingSource ( const FStateTreePropertyPath & InTargetPath ) const PURE_VIRTUAL ( IStateTreeBindingLookup : : GetPropertyBindingSource , return nullptr ; ) ;
2021-09-28 13:33:00 -04:00
/** @return Display name given property path. */
2024-04-05 03:37:02 -04:00
virtual FText GetPropertyPathDisplayName ( const FStateTreePropertyPath & InPath , EStateTreeNodeFormatting Formatting = EStateTreeNodeFormatting : : Text ) const PURE_VIRTUAL ( IStateTreeBindingLookup : : GetPropertyPathDisplayName , return FText : : GetEmpty ( ) ; ) ;
/** @return Display name of binding source, or empty if binding does not exists. */
virtual FText GetBindingSourceDisplayName ( const FStateTreePropertyPath & InTargetPath , EStateTreeNodeFormatting Formatting = EStateTreeNodeFormatting : : Text ) const PURE_VIRTUAL ( IStateTreeBindingLookup : : GetPropertyPathDisplayName , return FText : : GetEmpty ( ) ; ) ;
2021-09-28 13:33:00 -04:00
/** @return Leaf property based on property path. */
2023-02-10 07:22:48 -05:00
virtual const FProperty * GetPropertyPathLeafProperty ( const FStateTreePropertyPath & InPath ) const PURE_VIRTUAL ( IStateTreeBindingLookup : : GetPropertyPathLeafProperty , return nullptr ; ) ;
PRAGMA_DISABLE_DEPRECATION_WARNINGS
UE_DEPRECATED ( 5.3 , " Use version with FStateTreePropertyPath instead. " )
virtual const FStateTreeEditorPropertyPath * GetPropertyBindingSource ( const FStateTreeEditorPropertyPath & InTargetPath ) const final { return nullptr ; }
UE_DEPRECATED ( 5.3 , " Use version with FStateTreePropertyPath instead. " )
virtual FText GetPropertyPathDisplayName ( const FStateTreeEditorPropertyPath & InPath ) const final { return FText : : GetEmpty ( ) ; }
UE_DEPRECATED ( 5.3 , " Use version with FStateTreePropertyPath instead. " )
virtual const FProperty * GetPropertyPathLeafProperty ( const FStateTreeEditorPropertyPath & InPath ) const final { return nullptr ; }
PRAGMA_ENABLE_DEPRECATION_WARNINGS
2021-09-28 13:33:00 -04:00
} ;
2023-01-25 02:42:36 -05:00
2023-02-10 07:22:48 -05:00
2023-06-26 06:34:49 -04:00
namespace UE : : StateTree
{
/** @return desc and path as a display string. */
extern STATETREEMODULE_API FString GetDescAndPathAsString ( const FStateTreeBindableStructDesc & Desc , const FStateTreePropertyPath & Path ) ;
2024-01-11 04:24:45 -05:00
# if WITH_EDITOR
/**
* Returns property usage based on the Category metadata of given property .
* @ param Property Handle to property where value is got from .
* @ return found usage type , or EStateTreePropertyUsage : : Invalid if not found .
*/
STATETREEMODULE_API EStateTreePropertyUsage GetUsageFromMetaData ( const FProperty * Property ) ;
2024-06-04 03:56:38 -04:00
/** @return struct's property which is the only one marked as Output. Returns null otherwise. */
STATETREEMODULE_API const FProperty * GetStructSingleOutputProperty ( const UStruct & InStruct ) ;
2024-01-11 04:24:45 -05:00
# endif
2023-06-26 06:34:49 -04:00
} // UE::StateTree
2023-02-10 07:22:48 -05:00
namespace UE : : StateTree : : Private
{
# if WITH_EDITORONLY_DATA
// Helper functions to convert between property path types.
PRAGMA_DISABLE_DEPRECATION_WARNINGS
UE_DEPRECATED ( 5.3 , " Will be removed when FStateTreeEditorPropertyPath is removed. " )
extern STATETREEMODULE_API FStateTreePropertyPath ConvertEditorPath ( const FStateTreeEditorPropertyPath & InEditorPath ) ;
UE_DEPRECATED ( 5.3 , " Will be removed when FStateTreeEditorPropertyPath is removed. " )
extern STATETREEMODULE_API FStateTreeEditorPropertyPath ConvertEditorPath ( const FStateTreePropertyPath & InPath ) ;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
# endif // WITH_EDITORONLY_DATA
2023-06-26 06:34:49 -04:00
} // UE::StateTree::Private
2023-02-10 07:22:48 -05:00
2023-01-25 02:42:36 -05:00
# if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
# include "CoreMinimal.h"
# endif