2021-09-28 13:33:00 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "StateTreeTypes.h"
|
2021-12-01 03:41:24 -05:00
|
|
|
#include "StateTreeExecutionContext.h"
|
2021-11-30 03:53:20 -05:00
|
|
|
#if WITH_EDITOR
|
2021-12-01 03:41:24 -05:00
|
|
|
#include "StateTreePropertyBindings.h"
|
2021-11-30 03:53:20 -05:00
|
|
|
#endif
|
2021-09-28 13:33:00 -04:00
|
|
|
#include "StateTreeConditionBase.generated.h"
|
|
|
|
|
|
2021-11-30 03:53:20 -05:00
|
|
|
#if WITH_EDITOR
|
2021-09-28 13:33:00 -04:00
|
|
|
struct IStateTreeBindingLookup;
|
|
|
|
|
struct FStateTreeEditorPropertyPath;
|
2021-11-30 03:53:20 -05:00
|
|
|
#endif
|
2021-09-28 13:33:00 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base struct for all conditions.
|
|
|
|
|
*/
|
|
|
|
|
USTRUCT()
|
|
|
|
|
struct STATETREEMODULE_API FStateTreeConditionBase
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
virtual ~FStateTreeConditionBase() {}
|
|
|
|
|
|
2021-12-01 03:41:24 -05:00
|
|
|
/** @return Struct that represents the runtime data of the condition. */
|
2021-11-30 03:53:20 -05:00
|
|
|
virtual const UStruct* GetInstanceDataType() const { return nullptr; };
|
|
|
|
|
|
2021-11-12 05:49:31 -05:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool Link(FStateTreeLinker& Linker) { return true; }
|
|
|
|
|
|
2021-09-28 13:33:00 -04:00
|
|
|
#if WITH_EDITOR
|
|
|
|
|
/** @return Rich text description of the condition. */
|
2021-12-01 03:41:24 -05:00
|
|
|
virtual FText GetDescription(const FGuid& ID, FStateTreeDataView InstanceData, const IStateTreeBindingLookup& BindingLookup) const { return FText::GetEmpty(); }
|
2021-09-28 13:33:00 -04:00
|
|
|
/**
|
|
|
|
|
* Called when binding of any of the properties in the condition changes.
|
2021-12-01 03:41:24 -05:00
|
|
|
* @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.
|
2021-09-28 13:33:00 -04:00
|
|
|
* @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.
|
|
|
|
|
*/
|
2021-12-01 03:41:24 -05:00
|
|
|
virtual void OnBindingChanged(const FGuid& ID, FStateTreeDataView InstanceData, const FStateTreeEditorPropertyPath& SourcePath, const FStateTreeEditorPropertyPath& TargetPath, const IStateTreeBindingLookup& BindingLookup) {}
|
2021-09-28 13:33:00 -04:00
|
|
|
#endif
|
|
|
|
|
/** @return True if the condition passes. */
|
2021-11-12 05:49:31 -05:00
|
|
|
virtual bool TestCondition(FStateTreeExecutionContext& Context) const { return false; }
|
2021-09-28 13:33:00 -04:00
|
|
|
|
|
|
|
|
/** Property binding copy batch handle. */
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
FStateTreeHandle BindingsBatch = FStateTreeHandle::Invalid;
|
2021-11-12 05:49:31 -05:00
|
|
|
|
|
|
|
|
/** The runtime data's data view index in the StateTreeExecutionContext, and source struct index in property binding. */
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
uint16 DataViewIndex = 0;
|
2021-11-24 04:26:12 -05:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
uint16 InstanceIndex = 0;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
uint8 bInstanceIsObject : 1;
|
2021-09-28 13:33:00 -04:00
|
|
|
};
|
2021-12-09 05:38:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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()
|
|
|
|
|
};
|
|
|
|
|
|