// Fill out your copyright notice in the Description page of Project Settings.


#include "BTService_StopAttack.h"

#include "EndlessVendetta/AI/AI_EnemyController.h"
#include "EndlessVendetta/AI/EnemyCharacter.h"

UBTService_StopAttack::UBTService_StopAttack()
{
	NodeName = "Stop Attack";
}

void UBTService_StopAttack::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
	Super::OnBecomeRelevant(OwnerComp, NodeMemory);
	if (const AAI_EnemyController* const EnemyController = Cast<AAI_EnemyController>(OwnerComp.GetAIOwner()))
	{
		if (AEnemyCharacter* const EnemyCharacter = Cast<AEnemyCharacter>(EnemyController->GetPawn()))
		{
			EnemyCharacter->SetFiring(false);
		}
	}
}
