Create Set Focus Task

This commit is contained in:
baz 2024-02-08 18:30:33 +00:00
parent a13083e1fe
commit 408954c96d
4 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Tasks/BTTClearFocus.h"

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTTaskNode.h"
#include "BTTClearFocus.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UBTTClearFocus : public UBTTaskNode
{
GENERATED_BODY()
};

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "../Tasks/BTTSetFocus.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "Nakatomi/EnemyAIController.h"
#include "Nakatomi/PlayerCharacter.h"
EBTNodeResult::Type UBTTSetFocus::ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory)
{
UBlackboardComponent* BlackboardComponent = owner.GetBlackboardComponent();
UObject* actor = BlackboardComponent->GetValueAsObject(TargetActorKey.SelectedKeyName);
APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(actor);
AEnemyAIController* enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
enemyController->SetFocus(PlayerCharacter, EAIFocusPriority::Gameplay);
return EBTNodeResult::Succeeded;
}

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTTaskNode.h"
#include "BTTSetFocus.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UBTTSetFocus : public UBTTaskNode
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = "Options",
Meta = (AllowPrivateAccess = "true", DisplayName = "Target Actor Key"))
FBlackboardKeySelector TargetActorKey;
public:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
};