Compare commits

..

2 Commits

Author SHA1 Message Date
baz 03d5b80a0b Create Clear Focus Task 2024-02-08 18:30:39 +00:00
baz 408954c96d Create Set Focus Task 2024-02-08 18:30:33 +00:00
4 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "../Tasks/BTTClearFocus.h"
#include "Nakatomi/EnemyAIController.h"
EBTNodeResult::Type UBTTClearFocus::ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory)
{
auto enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
enemyController->ClearFocus(EAIFocusPriority::Default);
enemyController->SetFocus();
return EBTNodeResult::Succeeded;
}

View File

@ -0,0 +1,20 @@
// 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()
public:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
};

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;
};