Add Weapon Cooldown Decorator

This commit is contained in:
baz 2024-02-27 21:44:07 +00:00
parent 3b5da9c0ad
commit 8be9a8269e
3 changed files with 44 additions and 2 deletions

BIN
Content/Enemy/BT_Attacking_State.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "../Decorators/BTDWeaponCooldown.h"
#include "AIController.h"
#include "Nakatomi/EnemyCharacter.h"
void UBTDWeaponCooldown::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
AEnemyCharacter* EnemyCharacter = Cast<AEnemyCharacter>(OwnerComp.GetAIOwner()->GetPawn());
if (EnemyCharacter && EnemyCharacter->GetCurrentWeapon())
{
const float Cooldown = EnemyCharacter->GetCurrentWeapon()->GetWeaponProperties()->WeaponCooldown;
if (CoolDownTime != Cooldown)
{
CoolDownTime = Cooldown;
}
}
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
}

View File

@ -0,0 +1,19 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/Decorators/BTDecorator_Cooldown.h"
#include "BTDWeaponCooldown.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UBTDWeaponCooldown : public UBTDecorator_Cooldown
{
GENERATED_BODY()
protected:
virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override;
};