R-Type 0.1
Loading...
Searching...
No Matches
rtk::systems::EnemySpawnerSystem Class Referencefinal

Spawns a Bydos enemy at a random position right of the screen every 1.5 seconds. More...

#include <systems/EnemySpawnerSystem.hpp>

Inheritance diagram for rtk::systems::EnemySpawnerSystem:
[legend]

Public Member Functions

 EnemySpawnerSystem (rtk::factory::EntityFactory &factory, busEvent &eventBus, std::function< bool()> canSpawn=nullptr)
 Creates the spawner.
 
void onStart (rtk::ecs::Registry &) override
 Logs that the system is loaded.
 
void update (rtk::ecs::Registry &reg, float dt) override
 Advances the spawn timer and spawns an enemy when it expires.
 
void onStop (rtk::ecs::Registry &) override
 Does nothing.
 

Detailed Description

Spawns a Bydos enemy at a random position right of the screen every 1.5 seconds.

Constructor & Destructor Documentation

◆ EnemySpawnerSystem()

rtk::systems::EnemySpawnerSystem::EnemySpawnerSystem ( rtk::factory::EntityFactory & factory,
busEvent & eventBus,
std::function< bool()> canSpawn = nullptr )
inline

Creates the spawner.

Parameters
factoryFactory used to build the enemyBidos blueprint.
eventBusBus on which EnemySpawnedEvent is published.
canSpawnOptional predicate, spawning pauses while it returns false.

Member Function Documentation

◆ update()

void rtk::systems::EnemySpawnerSystem::update ( rtk::ecs::Registry & reg,
float dt )
inlineoverride

Advances the spawn timer and spawns an enemy when it expires.

Parameters
regRegistry receiving the new enemy.
dtElapsed time since the last frame, in seconds.