2021-09-28 13:33:17 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Components/ActorComponent.h"
|
|
|
|
|
#include "GameplayTagAssetInterface.h"
|
|
|
|
|
#include "GameplayTagContainer.h"
|
2021-10-21 04:08:20 -04:00
|
|
|
#include "StateTreeExecutionContext.h"
|
2021-09-28 13:33:17 -04:00
|
|
|
#include "BrainComponent.h"
|
|
|
|
|
#include "Tasks/AITask.h"
|
2021-11-24 04:26:12 -05:00
|
|
|
#include "StateTreeBrainComponent.generated.h"
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
class UStateTree;
|
|
|
|
|
|
2021-10-21 04:08:20 -04:00
|
|
|
|
2021-11-24 04:26:12 -05:00
|
|
|
UCLASS(BlueprintType, EditInlineNew, CollapseCategories, meta = (DisplayName = "Brain Component"))
|
2021-10-21 04:08:20 -04:00
|
|
|
class STATETREEMODULE_API UBrainComponentStateTreeSchema : public UStateTreeSchema
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool IsStructAllowed(const UScriptStruct* InScriptStruct) const override;
|
2021-11-24 04:26:12 -05:00
|
|
|
virtual bool IsClassAllowed(const UClass* InScriptStruct) const override;
|
|
|
|
|
virtual bool IsExternalItemAllowed(const UStruct& InStruct) const override;
|
2021-10-21 04:08:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-09-28 13:33:17 -04:00
|
|
|
UCLASS(ClassGroup = AI, HideCategories = (Activation, Collision), meta = (BlueprintSpawnableComponent))
|
2021-11-24 04:26:12 -05:00
|
|
|
class STATETREEMODULE_API UStateTreeBrainComponent : public UBrainComponent, public IGameplayTaskOwnerInterface
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
public:
|
2021-11-24 04:26:12 -05:00
|
|
|
UStateTreeBrainComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
// BEGIN UActorComponent overrides
|
|
|
|
|
virtual void InitializeComponent() override;
|
|
|
|
|
virtual void UninitializeComponent() override;
|
|
|
|
|
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
|
|
|
|
|
// END UActorComponent overrides
|
|
|
|
|
|
|
|
|
|
// BEGIN UBrainComponent overrides
|
|
|
|
|
virtual void StartLogic() override;
|
|
|
|
|
virtual void RestartLogic() override;
|
|
|
|
|
virtual void StopLogic(const FString& Reason) override;
|
|
|
|
|
virtual void Cleanup() override;
|
|
|
|
|
virtual void PauseLogic(const FString& Reason) override;
|
|
|
|
|
virtual EAILogicResuming::Type ResumeLogic(const FString& Reason) override;
|
|
|
|
|
virtual bool IsRunning() const override;
|
|
|
|
|
virtual bool IsPaused() const override;
|
|
|
|
|
// END UBrainComponent overrides
|
|
|
|
|
|
|
|
|
|
// BEGIN IGameplayTaskOwnerInterface
|
|
|
|
|
virtual UGameplayTasksComponent* GetGameplayTasksComponent(const UGameplayTask& Task) const override;
|
|
|
|
|
virtual AActor* GetGameplayTaskOwner(const UGameplayTask* Task) const override;
|
|
|
|
|
virtual AActor* GetGameplayTaskAvatar(const UGameplayTask* Task) const override;
|
|
|
|
|
virtual uint8 GetGameplayTaskDefaultPriority() const override;
|
|
|
|
|
virtual void OnGameplayTaskInitialized(UGameplayTask& Task) override;
|
|
|
|
|
// END IGameplayTaskOwnerInterface
|
|
|
|
|
|
|
|
|
|
#if WITH_GAMEPLAY_DEBUGGER
|
|
|
|
|
virtual FString GetDebugInfoString() const override;
|
|
|
|
|
#endif // WITH_GAMEPLAY_DEBUGGER
|
|
|
|
|
|
|
|
|
|
protected:
|
2021-11-24 04:26:12 -05:00
|
|
|
|
|
|
|
|
bool SetContextRequirements();
|
2021-10-21 04:08:20 -04:00
|
|
|
|
|
|
|
|
UPROPERTY(EditDefaultsOnly, Category = AI, meta=(RequiredAssetDataTags="Schema=BrainComponentStateTreeSchema"))
|
2021-09-28 13:33:17 -04:00
|
|
|
UStateTree* StateTree;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-10-21 04:08:20 -04:00
|
|
|
FStateTreeExecutionContext StateTreeContext;
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
/** if set, state tree execution is allowed */
|
|
|
|
|
uint8 bIsRunning : 1;
|
|
|
|
|
|
|
|
|
|
/** if set, execution requests will be postponed */
|
|
|
|
|
uint8 bIsPaused : 1;
|
|
|
|
|
};
|