Add Weapon Cooldown Decorator
This commit is contained in:
parent
3b5da9c0ad
commit
8be9a8269e
BIN
Content/Enemy/BT_Attacking_State.uasset (Stored with Git LFS)
BIN
Content/Enemy/BT_Attacking_State.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
};
|
Loading…
Reference in New Issue