Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
WaveManagerSubsystem.h
이 파일의 문서화 페이지로 가기
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Subsystems/WorldSubsystem.h"
8#include "WaveManagerSubsystem.generated.h"
9
10
11class ULevelRuleData;
12
13DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnWaveStarted, int32, WaveIndex);
14DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnWaveCleared, int32, WaveIndex);
16
17
18// 스폰 큐 단위 작업 (내부용)
19USTRUCT()
21{
22 GENERATED_BODY()
23
24 UPROPERTY()
25 TSubclassOf<ACK_CharacterEnemy> MonsterClass;
26
27 float SpawnInterval = 1.0f;
28};
29
30
31UCLASS()
32class CK_UE_API UWaveManagerSubsystem : public UWorldSubsystem
33{
34 GENERATED_BODY()
35
36public:
37 void SetLevelRule(ULevelRuleData* InLevelRule);
38
39 // LevelRuleSubsystem에 Rule이 세팅된 후 호출
40 UFUNCTION(BlueprintCallable, Category = "Wave")
41 void StartWaves();
42
43 // 레벨 내 스폰 포인트 액터 등록 (BeginPlay에서 호출)
44 UFUNCTION(BlueprintCallable, Category = "Wave")
45 void RegisterSpawnPoints(const TArray<AActor*>& InSpawnPoints);
46
47 UFUNCTION(BlueprintPure, Category = "Wave")
48 int32 GetCurrentWaveIndex() const { return CurrentWaveIndex; }
49
50 UFUNCTION(BlueprintPure, Category = "Wave")
51 int32 GetAliveEnemyCount() const { return AliveEnemyCount; }
52
53 UFUNCTION(BlueprintPure, Category = "Wave")
54 int32 GetTotalWaveCount() const;
55
56private:
57 void BeginWave(int32 WaveIndex);
58 void BuildSpawnQueue(const struct FWaveData& Wave);
59 void ProcessSpawnQueue();
60 void CheckWaveClearCondition();
61 void AdvanceToNextWave();
62 FVector GetSpawnLocation() const;
63
64 UFUNCTION()
65 void OnEnemyDead();
66
67 UFUNCTION()
68 void OnWaveDelayFinished();
69
70private:
71 int32 CurrentWaveIndex = -1;
72 int32 AliveEnemyCount = 0;
73 int32 EffectiveMaxAlive = 0;
74 int32 SpawnQueueIndex = 0;
75 bool bSpawnQueueDone = false;
76 bool bCurrentWaveWaitsForClear = true;
77
78private:
79public:
80 UPROPERTY(BlueprintAssignable, Category = "Wave")
81 FOnWaveStarted OnWaveStarted;
82
83 UPROPERTY(BlueprintAssignable, Category = "Wave")
84 FOnWaveCleared OnWaveCleared;
85
86 UPROPERTY(BlueprintAssignable, Category = "Wave")
87 FOnAllWavesCleared OnAllWavesCleared;
88
89
90private:
91 UPROPERTY()
92 ULevelRuleData* LevelRule;
93
94 UPROPERTY()
95 TArray<FSpawnTask> SpawnQueue;
96 TArray<TWeakObjectPtr<AActor>> SpawnPoints;
97
98 FTimerHandle WaveDelayTimer;
99 FTimerHandle SpawnTimer;
100};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnAllWavesCleared)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnWaveStarted, int32, WaveIndex)
Definition CK_CharacterEnemy.h:20
Definition LevelRuleData.h:63
Definition WaveManagerSubsystem.h:33
Definition WaveManagerSubsystem.h:21
Definition LevelRuleData.h:41