Manages wave-based enemy spawning with configurable patterns and timing. More...
#include <WaveManager.hpp>
Collaboration diagram for gme::WaveManager:Public Member Functions | |
| WaveManager (EntityManager &entityManager) | |
| Constructor. | |
| ~WaveManager ()=default | |
| Destructor. | |
| WaveManager (const WaveManager &)=delete | |
| Deleted copy constructor (non-copyable) | |
| WaveManager & | operator= (const WaveManager &)=delete |
| Deleted copy assignment operator (non-copyable) | |
| WaveManager (WaveManager &&)=delete | |
| Deleted move constructor (non-movable) | |
| WaveManager & | operator= (WaveManager &&)=delete |
| Deleted move assignment operator (non-movable) | |
| void | update (ecs::Registry ®istry, float dt, int screenWidth) |
| Update wave manager logic (called each frame) | |
| bool | isReady () const |
| Check if initial delay has passed and waves can start. | |
| void | start () |
| Start the wave system. | |
| void | reset () |
| Stop and reset the wave system to initial state. | |
| bool | isActive () const |
| Check if wave system is currently active. | |
| int | getCurrentWave () const |
| Get current wave index. | |
| size_t | getTotalWaves () const |
| Get total number of configured waves. | |
| bool | isCompleted () const |
| Check if all waves have been completed. | |
| void | addWave (const Wave &wave) |
| Add a custom wave to the wave list. | |
| void | clearWaves () |
| Clear all configured waves. | |
| void | setupDefaultWaves () |
| Initialize with default wave patterns. | |
Private Member Functions | |
| void | startNextWave () |
| Start the next wave in sequence. | |
| bool | isWaveCleared () const |
| Check if current wave is cleared of all enemies. | |
| void | processSpawns (float dt, int screenWidth) |
| Process enemy spawns for current wave. | |
| void | createWave1 () |
| Create wave 1 configuration (basic introduction wave) | |
| void | createWave2 () |
| Create wave 2 configuration (mixed enemies) | |
| void | createWave3 () |
| Create wave 3 configuration (increased difficulty) | |
| void | createWave4 () |
| Create wave 4 configuration (final standard wave) | |
| void | createBossWave () |
| Create boss wave configuration (final challenge) | |
Private Attributes | |
| EntityManager & | m_entityManager |
| Reference to entity manager for spawning. | |
| std::vector< Wave > | m_waves |
| List of all configured waves. | |
| int | m_currentWaveIndex |
| Index of current/next wave (0-based) | |
| float | m_waveTimer |
| Timer for current wave duration. | |
| float | m_spawnTimer |
| Timer for processing enemy spawns. | |
| bool | m_active |
| Whether wave system is active. | |
| bool | m_completed |
| Whether all waves are completed. | |
| bool | m_waveInProgress |
| Whether a wave is currently spawning. | |
| bool | m_initialDelayPassed |
| Whether initial delay has elapsed. | |
| float | m_initialDelayTimer |
| Timer for initial delay countdown. | |
| std::vector< bool > | m_enemiesSpawned |
| Track which enemies in current wave have spawned. | |
Static Private Attributes | |
| static constexpr float | INITIAL_DELAY = 0.5f |
| Initial delay in seconds (synced with client) | |
Manages wave-based enemy spawning with configurable patterns and timing.
This class provides a complete wave management system for the R-Type server. Features include:
The manager maintains internal state for current wave, spawn timers, and completion status. It coordinates with the EntityManager to spawn enemies at appropriate times and ensures proper game progression through all waves.
Definition at line 73 of file WaveManager.hpp.
|
explicit |
Constructor.
| entityManager | Reference to entity manager for spawning enemies |
Initializes the wave manager with default wave configurations
Definition at line 13 of file WaveManager.cpp.
|
default |
Destructor.
|
delete |
Deleted copy constructor (non-copyable)
|
delete |
Deleted move constructor (non-movable)
| void gme::WaveManager::addWave | ( | const Wave & | wave | ) |
Add a custom wave to the wave list.
| wave | Wave configuration to add |
Appends a wave to the end of the wave sequence
Definition at line 134 of file WaveManager.cpp.
References m_waves.
| void gme::WaveManager::clearWaves | ( | ) |
Clear all configured waves.
Removes all waves from the manager. Use setupDefaultWaves() to restore defaults.
Definition at line 136 of file WaveManager.cpp.
References m_waves, and reset().
Referenced by setupDefaultWaves().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Create boss wave configuration (final challenge)
60-second wave featuring the boss enemy
Definition at line 352 of file WaveManager.cpp.
References gme::BOSS, gme::Wave::duration, gme::Wave::enemies, gme::ENEMY_ADVANCED, gme::ENEMY_BASIC, m_waves, gme::Wave::waitForClear, and gme::Wave::waveNumber.
Referenced by setupDefaultWaves().
Here is the caller graph for this function:
|
private |
Create wave 1 configuration (basic introduction wave)
30-second wave with basic enemies
Definition at line 241 of file WaveManager.cpp.
References gme::Wave::duration, gme::Wave::enemies, gme::ENEMY_BASIC, m_waves, gme::Wave::waitForClear, and gme::Wave::waveNumber.
Referenced by setupDefaultWaves().
Here is the caller graph for this function:
|
private |
Create wave 2 configuration (mixed enemies)
30-second wave with basic and advanced enemies
Definition at line 265 of file WaveManager.cpp.
References gme::Wave::duration, gme::Wave::enemies, gme::ENEMY_ADVANCED, gme::ENEMY_BASIC, m_waves, gme::Wave::waitForClear, and gme::Wave::waveNumber.
Referenced by setupDefaultWaves().
Here is the caller graph for this function:
|
private |
Create wave 3 configuration (increased difficulty)
30-second wave with more advanced enemies
Definition at line 291 of file WaveManager.cpp.
References gme::Wave::duration, gme::Wave::enemies, gme::ENEMY_ADVANCED, gme::ENEMY_BASIC, m_waves, gme::Wave::waitForClear, and gme::Wave::waveNumber.
Referenced by setupDefaultWaves().
Here is the caller graph for this function:
|
private |
Create wave 4 configuration (final standard wave)
30-second wave with challenging enemy patterns
Definition at line 319 of file WaveManager.cpp.
References gme::Wave::duration, gme::Wave::enemies, gme::ENEMY_ADVANCED, gme::ENEMY_BASIC, m_waves, gme::Wave::waitForClear, and gme::Wave::waveNumber.
Referenced by setupDefaultWaves().
Here is the caller graph for this function:
|
inline |
Get current wave index.
Returns the index of the currently active or next wave
Definition at line 137 of file WaveManager.hpp.
References m_currentWaveIndex.
|
inline |
Get total number of configured waves.
Definition at line 143 of file WaveManager.hpp.
References m_waves.
|
inline |
Check if wave system is currently active.
Definition at line 130 of file WaveManager.hpp.
References m_active.
|
inline |
Check if all waves have been completed.
Returns true when the last wave has completed and no more waves remain
Definition at line 150 of file WaveManager.hpp.
References m_completed.
|
inline |
Check if initial delay has passed and waves can start.
Initial delay synchronizes wave spawning with client stage initialization
Definition at line 112 of file WaveManager.hpp.
References m_initialDelayPassed.
|
private |
Check if current wave is cleared of all enemies.
Used for waves with waitForClear flag to determine wave completion
Definition at line 176 of file WaveManager.cpp.
References gme::EntityManager::getEnemies(), and m_entityManager.
Referenced by update().
Here is the call graph for this function:
Here is the caller graph for this function:
|
delete |
Deleted copy assignment operator (non-copyable)
|
delete |
Deleted move assignment operator (non-movable)
|
private |
Process enemy spawns for current wave.
| dt | Delta time since last frame |
| screenWidth | Screen width for spawn positioning |
Checks spawn delays and creates enemies at appropriate times
Definition at line 183 of file WaveManager.cpp.
References gme::BOSS, gme::EntityManager::createAdvancedEnemy(), gme::EntityManager::createBasicEnemy(), gme::EntityManager::createBoss(), gme::Wave::enemies, gme::ENEMY_ADVANCED, gme::ENEMY_BASIC, gme::EnemySpawn::health, m_currentWaveIndex, m_enemiesSpawned, m_entityManager, m_spawnTimer, m_waves, gme::EnemySpawn::spawnDelay, gme::EnemySpawn::type, gme::EnemySpawn::x, and gme::EnemySpawn::y.
Referenced by update().
Here is the call graph for this function:
Here is the caller graph for this function:| void gme::WaveManager::reset | ( | ) |
Stop and reset the wave system to initial state.
Stops wave processing, resets all timers, and clears wave progress
Definition at line 120 of file WaveManager.cpp.
References m_active, m_completed, m_currentWaveIndex, m_enemiesSpawned, m_initialDelayPassed, m_initialDelayTimer, m_spawnTimer, m_waveInProgress, and m_waveTimer.
Referenced by clearWaves().
Here is the caller graph for this function:| void gme::WaveManager::setupDefaultWaves | ( | ) |
Initialize with default wave patterns.
Creates 5 predefined waves: 4 standard waves (30s each) + 1 boss wave (60s)
Definition at line 142 of file WaveManager.cpp.
References clearWaves(), createBossWave(), createWave1(), createWave2(), createWave3(), createWave4(), and m_waves.
Here is the call graph for this function:| void gme::WaveManager::start | ( | ) |
Start the wave system.
Activates wave processing and begins initial delay countdown
Definition at line 106 of file WaveManager.cpp.
References INITIAL_DELAY, m_active, m_completed, m_currentWaveIndex, m_initialDelayPassed, m_initialDelayTimer, m_spawnTimer, m_waveInProgress, m_waves, and m_waveTimer.
|
private |
Start the next wave in sequence.
Advances to next wave, resets timers, and initializes spawn tracking
Definition at line 153 of file WaveManager.cpp.
References gme::Wave::enemies, m_completed, m_currentWaveIndex, m_enemiesSpawned, m_spawnTimer, m_waveInProgress, m_waves, and m_waveTimer.
Referenced by update().
Here is the caller graph for this function:| void gme::WaveManager::update | ( | ecs::Registry & | registry, |
| float | dt, | ||
| int | screenWidth ) |
Update wave manager logic (called each frame)
| registry | ECS registry containing all game entities |
| dt | Delta time since last frame (in seconds) |
| screenWidth | Screen width for spawn X positioning |
Processes initial delay, advances wave timers, spawns enemies according to wave configurations, and checks for wave completion conditions
Definition at line 20 of file WaveManager.cpp.
References gme::Wave::duration, INITIAL_DELAY, isWaveCleared(), m_active, m_completed, m_currentWaveIndex, m_initialDelayPassed, m_initialDelayTimer, m_spawnTimer, m_waveInProgress, m_waves, m_waveTimer, gme::Wave::onComplete, processSpawns(), startNextWave(), and gme::Wave::waitForClear.
Here is the call graph for this function:
|
staticconstexprprivate |
Initial delay in seconds (synced with client)
Definition at line 184 of file WaveManager.hpp.
|
private |
Whether wave system is active.
Definition at line 177 of file WaveManager.hpp.
Referenced by isActive(), reset(), start(), and update().
|
private |
Whether all waves are completed.
Definition at line 178 of file WaveManager.hpp.
Referenced by isCompleted(), reset(), start(), startNextWave(), and update().
|
private |
Index of current/next wave (0-based)
Definition at line 174 of file WaveManager.hpp.
Referenced by getCurrentWave(), processSpawns(), reset(), start(), startNextWave(), and update().
|
private |
Track which enemies in current wave have spawned.
Definition at line 182 of file WaveManager.hpp.
Referenced by processSpawns(), reset(), and startNextWave().
|
private |
Reference to entity manager for spawning.
Definition at line 172 of file WaveManager.hpp.
Referenced by isWaveCleared(), and processSpawns().
|
private |
|
private |
Timer for initial delay countdown.
Definition at line 181 of file WaveManager.hpp.
|
private |
Timer for processing enemy spawns.
Definition at line 176 of file WaveManager.hpp.
Referenced by processSpawns(), reset(), start(), startNextWave(), and update().
|
private |
Whether a wave is currently spawning.
Definition at line 179 of file WaveManager.hpp.
Referenced by reset(), start(), startNextWave(), and update().
|
private |
List of all configured waves.
Definition at line 173 of file WaveManager.hpp.
Referenced by addWave(), clearWaves(), createBossWave(), createWave1(), createWave2(), createWave3(), createWave4(), getTotalWaves(), processSpawns(), setupDefaultWaves(), start(), startNextWave(), and update().
|
private |
Timer for current wave duration.
Definition at line 175 of file WaveManager.hpp.
Referenced by reset(), start(), startNextWave(), and update().