60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "AIControlHub.h"
|
|
|
|
#include "EnemyCharacter.h"
|
|
|
|
|
|
// Sets default values
|
|
AAIControlHub::AAIControlHub()
|
|
{
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
}
|
|
|
|
// Called when the game starts or when spawned
|
|
void AAIControlHub::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
for (AEnemyCharacter* EnemyActor : EnemyActors)
|
|
{
|
|
EnemyActor->SubscribeToAlertLevelEvent(this);
|
|
}
|
|
}
|
|
|
|
// Called every frame
|
|
void AAIControlHub::Tick(float DeltaTime)
|
|
{
|
|
Super::Tick(DeltaTime);
|
|
}
|
|
|
|
void AAIControlHub::IncreaseAlertLevel()
|
|
{
|
|
AlertLevel = FMath::Clamp(AlertLevel + 1, 0, 3);
|
|
OnAlertLevelChanged();
|
|
}
|
|
|
|
void AAIControlHub::DecreaseAlertLevel()
|
|
{
|
|
AlertLevel = FMath::Clamp(AlertLevel - 1, 0, 3);
|
|
OnAlertLevelChanged();
|
|
}
|
|
|
|
void AAIControlHub::SetAlertLevel(int NewAlertLevel)
|
|
{
|
|
AlertLevel = FMath::Clamp(NewAlertLevel, 0, 3);
|
|
OnAlertLevelChanged();
|
|
}
|
|
|
|
int AAIControlHub::GetAlertLevel() const
|
|
{
|
|
return AlertLevel;
|
|
}
|
|
|
|
void AAIControlHub::OnAlertLevelChanged() const
|
|
{
|
|
AlertLevelEvent.Broadcast(AlertLevel);
|
|
}
|