2022-05-02 09:15:14 -04:00
|
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "StateTreeSchema.h"
|
2022-08-29 14:49:38 -04:00
|
|
|
|
#include "GameFramework/Actor.h"
|
2023-06-27 09:07:17 -04:00
|
|
|
|
#include "StateTreeExecutionTypes.h"
|
2022-05-02 09:15:14 -04:00
|
|
|
|
#include "StateTreeComponentSchema.generated.h"
|
|
|
|
|
|
|
2024-03-25 19:58:58 -04:00
|
|
|
|
class UBrainComponent;
|
|
|
|
|
|
class UStateTree;
|
|
|
|
|
|
|
|
|
|
|
|
struct FStateTreeExecutionContext;
|
|
|
|
|
|
|
2022-07-01 04:36:16 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* StateTree for Actors with StateTree component.
|
|
|
|
|
|
*/
|
|
|
|
|
|
UCLASS(BlueprintType, EditInlineNew, CollapseCategories, meta = (DisplayName = "StateTree Component", CommonSchema))
|
2023-03-24 07:57:37 -04:00
|
|
|
|
class GAMEPLAYSTATETREEMODULE_API UStateTreeComponentSchema : public UStateTreeSchema
|
2022-05-02 09:15:14 -04:00
|
|
|
|
{
|
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
2022-08-29 14:47:43 -04:00
|
|
|
|
public:
|
|
|
|
|
|
UStateTreeComponentSchema();
|
|
|
|
|
|
|
|
|
|
|
|
UClass* GetContextActorClass() const { return ContextActorClass; };
|
|
|
|
|
|
|
2024-03-25 19:58:58 -04:00
|
|
|
|
static bool SetContextRequirements(UBrainComponent& BrainComponent, FStateTreeExecutionContext& Context, bool bLogErrors = false);
|
|
|
|
|
|
static bool CollectExternalData(const FStateTreeExecutionContext& Context, const UStateTree* StateTree, TArrayView<const FStateTreeExternalDataDesc> Descs, TArrayView<FStateTreeDataView> OutDataViews);
|
|
|
|
|
|
|
2022-05-02 09:15:14 -04:00
|
|
|
|
protected:
|
|
|
|
|
|
virtual bool IsStructAllowed(const UScriptStruct* InScriptStruct) const override;
|
|
|
|
|
|
virtual bool IsClassAllowed(const UClass* InScriptStruct) const override;
|
|
|
|
|
|
virtual bool IsExternalItemAllowed(const UStruct& InStruct) const override;
|
2022-08-29 14:47:43 -04:00
|
|
|
|
|
2023-06-27 09:07:17 -04:00
|
|
|
|
virtual TConstArrayView<FStateTreeExternalDataDesc> GetContextDataDescs() const override;
|
2022-08-29 14:47:43 -04:00
|
|
|
|
|
2022-09-05 09:08:59 -04:00
|
|
|
|
virtual void PostLoad() override;
|
|
|
|
|
|
|
2022-08-29 14:47:43 -04:00
|
|
|
|
#if WITH_EDITOR
|
|
|
|
|
|
virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override;
|
|
|
|
|
|
#endif // WITH_EDITOR
|
|
|
|
|
|
|
2024-03-26 00:33:28 -04:00
|
|
|
|
const FStateTreeExternalDataDesc& GetContextActorDataDesc() const { return ContextDataDescs[0]; }
|
|
|
|
|
|
FStateTreeExternalDataDesc& GetContextActorDataDesc() { return ContextDataDescs[0]; }
|
|
|
|
|
|
|
2022-08-29 14:47:43 -04:00
|
|
|
|
/** Actor class the StateTree is expected to run on. Allows to bind to specific Actor class' properties. */
|
2024-03-26 00:33:28 -04:00
|
|
|
|
UPROPERTY(EditAnywhere, Category="Defaults", NoClear)
|
2022-08-29 14:47:43 -04:00
|
|
|
|
TSubclassOf<AActor> ContextActorClass;
|
|
|
|
|
|
|
2024-03-26 00:33:28 -04:00
|
|
|
|
UE_DEPRECATED(5.4, "ContextActorDataDesc is being replaced with ContextDataDescs. Call GetContextActorDataDesc to access the equivalent.")
|
2022-08-29 14:47:43 -04:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
|
FStateTreeExternalDataDesc ContextActorDataDesc;
|
2024-03-26 00:33:28 -04:00
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
|
TArray<FStateTreeExternalDataDesc> ContextDataDescs;
|
2022-05-02 09:15:14 -04:00
|
|
|
|
};
|