Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
UWaveManagerSubsystem 클래스 참조

#include <WaveManagerSubsystem.h>

UWaveManagerSubsystem에 대한 상속 다이어그램 :
Inheritance graph
UWaveManagerSubsystem에 대한 협력 다이어그램:
Collaboration graph

Public 멤버 함수

void SetLevelRule (ULevelRuleData *InLevelRule)
 
void StartWaves ()
 
void RegisterSpawnPoints (const TArray< AActor * > &InSpawnPoints)
 
int32 GetCurrentWaveIndex () const
 
int32 GetAliveEnemyCount () const
 
int32 GetTotalWaveCount () const
 

Public 속성

FOnWaveStarted OnWaveStarted
 
FOnWaveCleared OnWaveCleared
 
FOnAllWavesCleared OnAllWavesCleared
 

Private 멤버 함수

void BeginWave (int32 WaveIndex)
 
void BuildSpawnQueue (const struct FWaveData &Wave)
 
void ProcessSpawnQueue ()
 
void CheckWaveClearCondition ()
 
void AdvanceToNextWave ()
 
FVector GetSpawnLocation () const
 
void OnEnemyDead ()
 
void OnWaveDelayFinished ()
 

Private 속성

int32 CurrentWaveIndex = -1
 
int32 AliveEnemyCount = 0
 
int32 EffectiveMaxAlive = 0
 
int32 SpawnQueueIndex = 0
 
bool bSpawnQueueDone = false
 
bool bCurrentWaveWaitsForClear = true
 
ULevelRuleDataLevelRule
 
TArray< FSpawnTaskSpawnQueue
 
TArray< TWeakObjectPtr< AActor > > SpawnPoints
 
FTimerHandle WaveDelayTimer
 
FTimerHandle SpawnTimer
 

멤버 함수 문서화

◆ AdvanceToNextWave()

void UWaveManagerSubsystem::AdvanceToNextWave ( )
private
55{
57
58 if (LevelRule == nullptr || CurrentWaveIndex >= LevelRule->Waves.Num())
59 {
60 OnAllWavesCleared.Broadcast();
61 return;
62 }
63
64 const float Delay = FMath::Max(LevelRule->Waves[CurrentWaveIndex].WaveStartDelay, 0.01f);
65 GetWorld()->GetTimerManager().SetTimer(WaveDelayTimer, this, &UWaveManagerSubsystem::OnWaveDelayFinished, Delay, false);
66}
TArray< FWaveData > Waves
Definition LevelRuleData.h:77
FTimerHandle WaveDelayTimer
Definition WaveManagerSubsystem.h:98
void OnWaveDelayFinished()
Definition WaveManagerSubsystem.cpp:69
ULevelRuleData * LevelRule
Definition WaveManagerSubsystem.h:92
int32 CurrentWaveIndex
Definition WaveManagerSubsystem.h:71
FOnAllWavesCleared OnAllWavesCleared
Definition WaveManagerSubsystem.h:87
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ BeginWave()

void UWaveManagerSubsystem::BeginWave ( int32  WaveIndex)
private
76{
77 if (LevelRule == nullptr)
78 {
79 return;
80 }
81
82 const FWaveData& Wave = LevelRule->Waves[WaveIndex];
83
85 bSpawnQueueDone = false;
86
87 const int32 WaveMax = Wave.MaxAliveMonsters;
88
89 if (WaveMax > 0)
90 {
91 EffectiveMaxAlive = WaveMax;
92 }
93 else
94 {
96 }
97
98 BuildSpawnQueue(Wave);
99 OnWaveStarted.Broadcast(WaveIndex);
101}
int32 GlobalMaxAliveMonsters
Definition LevelRuleData.h:81
int32 EffectiveMaxAlive
Definition WaveManagerSubsystem.h:73
bool bCurrentWaveWaitsForClear
Definition WaveManagerSubsystem.h:76
bool bSpawnQueueDone
Definition WaveManagerSubsystem.h:75
void BuildSpawnQueue(const struct FWaveData &Wave)
Definition WaveManagerSubsystem.cpp:103
void ProcessSpawnQueue()
Definition WaveManagerSubsystem.cpp:126
FOnWaveStarted OnWaveStarted
Definition WaveManagerSubsystem.h:81
Definition LevelRuleData.h:41
int32 MaxAliveMonsters
Definition LevelRuleData.h:49
bool bWaitForClear
Definition LevelRuleData.h:57
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ BuildSpawnQueue()

void UWaveManagerSubsystem::BuildSpawnQueue ( const struct FWaveData Wave)
private
104{
105 SpawnQueue.Reset();
106 SpawnQueueIndex = 0;
107
108 for (const FMonsterSpawnEntry& Entry : Wave.MonsterEntries)
109 {
110 TSubclassOf<ACK_CharacterEnemy> LoadedClass = Entry.MonsterClass.LoadSynchronous();
111
112 if (LoadedClass == nullptr)
113 {
114 continue;
115 }
116
117 for (int32 i = 0; i < Entry.SpawnCount; i++)
118 {
119 FSpawnTask& Task = SpawnQueue.AddDefaulted_GetRef();
120 Task.MonsterClass = LoadedClass;
121 Task.SpawnInterval = Entry.SpawnInterval;
122 }
123 }
124}
TArray< FSpawnTask > SpawnQueue
Definition WaveManagerSubsystem.h:95
int32 SpawnQueueIndex
Definition WaveManagerSubsystem.h:74
Definition LevelRuleData.h:23
Definition WaveManagerSubsystem.h:21
float SpawnInterval
Definition WaveManagerSubsystem.h:27
TSubclassOf< ACK_CharacterEnemy > MonsterClass
Definition WaveManagerSubsystem.h:25
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ CheckWaveClearCondition()

void UWaveManagerSubsystem::CheckWaveClearCondition ( )
private
182{
183 //bWaitForClear가 false면 스폰 완료 시 이미 처리임.
185 {
186 return;
187 }
188
189 if (bSpawnQueueDone == false || AliveEnemyCount > 0)
190 {
191 return;
192 }
193
196}
FOnWaveCleared OnWaveCleared
Definition WaveManagerSubsystem.h:84
void AdvanceToNextWave()
Definition WaveManagerSubsystem.cpp:54
int32 AliveEnemyCount
Definition WaveManagerSubsystem.h:72
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetAliveEnemyCount()

int32 UWaveManagerSubsystem::GetAliveEnemyCount ( ) const
inline
51{ return AliveEnemyCount; }

◆ GetCurrentWaveIndex()

int32 UWaveManagerSubsystem::GetCurrentWaveIndex ( ) const
inline
48{ return CurrentWaveIndex; }

◆ GetSpawnLocation()

FVector UWaveManagerSubsystem::GetSpawnLocation ( ) const
private
199{
200 if (SpawnPoints.IsEmpty() == false) //등록된 스폰 포인트 중 랜덤 선택.
201 {
202 const int32 RandIdx = FMath::RandRange(0, SpawnPoints.Num() - 1);
203
204 if (SpawnPoints[RandIdx].IsValid())
205 {
206 return SpawnPoints[RandIdx]->GetActorLocation();
207 }
208 }
209
210 if (const APlayerController* PC = GetWorld()->GetFirstPlayerController()) //없으면 플레이어 기준 랜덤 위치.
211 {
212 if (PC->GetPawn() == nullptr)
213 {
214 return FVector::ZeroVector;
215 }
216
217 const float Angle = FMath::FRandRange(0.f, 360.f);
218 const float Radius = FMath::FRandRange(800.f, 1500.f);
219
220 float Cos = FMath::Cos(FMath::DegreesToRadians(Angle));
221 float Sin = FMath::Sin(FMath::DegreesToRadians(Angle));
222
223 const FVector Center = PC->GetPawn()->GetActorLocation();
224 return Center + FVector(Cos * Radius, Sin * Radius, 0.f);
225 }
226
227 return FVector::ZeroVector;
228}
TArray< TWeakObjectPtr< AActor > > SpawnPoints
Definition WaveManagerSubsystem.h:96
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetTotalWaveCount()

int32 UWaveManagerSubsystem::GetTotalWaveCount ( ) const
31{
32 if (LevelRule)
33 {
34 return LevelRule->Waves.Num();
35 }
36 else
37 {
38 return 0;
39 }
40}

◆ OnEnemyDead()

void UWaveManagerSubsystem::OnEnemyDead ( )
private
170{
171 AliveEnemyCount = FMath::Max(0, AliveEnemyCount - 1);
173
174 //MaxAlive 제한으로 스폰이 멈춰있었으면 재개.
175 if (bSpawnQueueDone == false && GetWorld()->GetTimerManager().IsTimerActive(SpawnTimer) == false)
176 {
178 }
179}
FTimerHandle SpawnTimer
Definition WaveManagerSubsystem.h:99
void CheckWaveClearCondition()
Definition WaveManagerSubsystem.cpp:181
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ OnWaveDelayFinished()

void UWaveManagerSubsystem::OnWaveDelayFinished ( )
private
70{
72}
void BeginWave(int32 WaveIndex)
Definition WaveManagerSubsystem.cpp:75
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ProcessSpawnQueue()

void UWaveManagerSubsystem::ProcessSpawnQueue ( )
private
127{
128 if (SpawnQueueIndex >= SpawnQueue.Num())
129 {
130 bSpawnQueueDone = true;
131
132 // bWaitForClear = false면 스폰 완료 시점에 다음 웨이브 진행
133 if (bCurrentWaveWaitsForClear == false)
134 {
137 }
138
139 return;
140 }
141
142 // MaxAlive 초과 시 잠시 후 재시도
144 {
145 GetWorld()->GetTimerManager().SetTimer(SpawnTimer, this, &UWaveManagerSubsystem::ProcessSpawnQueue, 0.5f, false);
146 return;
147 }
148
149 const FSpawnTask& Task = SpawnQueue[SpawnQueueIndex++];
150
151 FActorSpawnParameters Params;
152 Params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
153
154 if (auto Enemy = GetWorld()->SpawnActor<ACK_CharacterEnemy>(Task.MonsterClass, GetSpawnLocation(), FRotator::ZeroRotator, Params))
155 {
157
158 if (const UEnemyAttributeSet* AS = Enemy->GetEnemyAttributeSet())
159 {
160 AS->OnDeathDelegate.AddDynamic(this, &UWaveManagerSubsystem::OnEnemyDead);
161 }
162 }
163
164 const float Interval = FMath::Max(Task.SpawnInterval, 0.01f);
165 GetWorld()->GetTimerManager().SetTimer(SpawnTimer, this, &UWaveManagerSubsystem::ProcessSpawnQueue, Interval, false);
166}
Definition EnemyAttributeSet.h:11
void OnEnemyDead()
Definition WaveManagerSubsystem.cpp:169
FVector GetSpawnLocation() const
Definition WaveManagerSubsystem.cpp:198
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ RegisterSpawnPoints()

void UWaveManagerSubsystem::RegisterSpawnPoints ( const TArray< AActor * > &  InSpawnPoints)
44{
45 SpawnPoints.Reset();
46
47 Algo::CopyIf(InSpawnPoints, SpawnPoints, [](AActor* Point)
48 {
49 return Point;
50 });
51}

◆ SetLevelRule()

void UWaveManagerSubsystem::SetLevelRule ( ULevelRuleData InLevelRule)
11{
12 LevelRule = InLevelRule;
13 LOG_SCREEN("%s의 레벨 데이터를 변경하는데에 성공했습니다. ", NAMEOF(UWaveManagerSubsystem));
14}
#define LOG_SCREEN(Format,...)
Definition CK_UE.h:41
#define NAMEOF(Type)
Definition CK_UE.h:26
Definition WaveManagerSubsystem.h:33

◆ StartWaves()

void UWaveManagerSubsystem::StartWaves ( )
18{
19 if (LevelRule == nullptr || LevelRule->Waves.IsEmpty())
20 {
21 return;
22 }
23
27}
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ AliveEnemyCount

int32 UWaveManagerSubsystem::AliveEnemyCount = 0
private

◆ bCurrentWaveWaitsForClear

bool UWaveManagerSubsystem::bCurrentWaveWaitsForClear = true
private

◆ bSpawnQueueDone

bool UWaveManagerSubsystem::bSpawnQueueDone = false
private

◆ CurrentWaveIndex

int32 UWaveManagerSubsystem::CurrentWaveIndex = -1
private

◆ EffectiveMaxAlive

int32 UWaveManagerSubsystem::EffectiveMaxAlive = 0
private

◆ LevelRule

ULevelRuleData* UWaveManagerSubsystem::LevelRule
private

◆ OnAllWavesCleared

FOnAllWavesCleared UWaveManagerSubsystem::OnAllWavesCleared

◆ OnWaveCleared

FOnWaveCleared UWaveManagerSubsystem::OnWaveCleared

◆ OnWaveStarted

FOnWaveStarted UWaveManagerSubsystem::OnWaveStarted

◆ SpawnPoints

TArray<TWeakObjectPtr<AActor> > UWaveManagerSubsystem::SpawnPoints
private

◆ SpawnQueue

TArray<FSpawnTask> UWaveManagerSubsystem::SpawnQueue
private

◆ SpawnQueueIndex

int32 UWaveManagerSubsystem::SpawnQueueIndex = 0
private

◆ SpawnTimer

FTimerHandle UWaveManagerSubsystem::SpawnTimer
private

◆ WaveDelayTimer

FTimerHandle UWaveManagerSubsystem::WaveDelayTimer
private

이 클래스에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.: