Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Public/Components/StateTreeBrainComponent.h
mikko mononen 11ea4b3fa0 StateTree: UObject and BP support
- connect GetWorld() of FStateTreeExecutionContext explicitly to the owner
- take MassSignalSubsystem as parameter to FMassStateTreeExecutionContext directly
- separated DataViewIndex (what others see) and InstanceIndex/bInstanceIsObject (where the pointert comes from) on StateTree items
- allow item instance to be a struct or object
- added editor support for both struct or object based instance
- added Blueprint base classes for Eval, Task and Condition
- Update UStateTreeBrainComponent

#jira UE-135723

#ROBOMERGE-AUTHOR: mikko.mononen
#ROBOMERGE-SOURCE: CL 18280804 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v895-18170469)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 18280809 by mikko mononen in ue5-release-engine-test branch]
2021-11-24 04:26:29 -05:00

82 lines
2.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/ActorComponent.h"
#include "GameplayTagAssetInterface.h"
#include "GameplayTagContainer.h"
#include "StateTreeExecutionContext.h"
#include "BrainComponent.h"
#include "Tasks/AITask.h"
#include "StateTreeBrainComponent.generated.h"
class UStateTree;
UCLASS(BlueprintType, EditInlineNew, CollapseCategories, meta = (DisplayName = "Brain Component"))
class STATETREEMODULE_API UBrainComponentStateTreeSchema : public UStateTreeSchema
{
GENERATED_BODY()
public:
virtual bool IsStructAllowed(const UScriptStruct* InScriptStruct) const override;
virtual bool IsClassAllowed(const UClass* InScriptStruct) const override;
virtual bool IsExternalItemAllowed(const UStruct& InStruct) const override;
};
UCLASS(ClassGroup = AI, HideCategories = (Activation, Collision), meta = (BlueprintSpawnableComponent))
class STATETREEMODULE_API UStateTreeBrainComponent : public UBrainComponent, public IGameplayTaskOwnerInterface
{
GENERATED_BODY()
public:
UStateTreeBrainComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
// 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
private:
protected:
bool SetContextRequirements();
UPROPERTY(EditDefaultsOnly, Category = AI, meta=(RequiredAssetDataTags="Schema=BrainComponentStateTreeSchema"))
UStateTree* StateTree;
UPROPERTY()
FStateTreeExecutionContext StateTreeContext;
/** if set, state tree execution is allowed */
uint8 bIsRunning : 1;
/** if set, execution requests will be postponed */
uint8 bIsPaused : 1;
};