R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::Spawner Class Reference

Component that holds spawn requests to be processed by SpawnSystem. More...

#include <Spawner.hpp>

Inheritance diagram for ecs::Spawner:
Inheritance graph
Collaboration diagram for ecs::Spawner:
Collaboration graph

Public Member Functions

 Spawner ()=default
 
 ~Spawner () override=default
 
void queueSpawn (const SpawnRequest &request)
 Queue a spawn request.
 
const std::vector< SpawnRequest > & getSpawnRequests () const
 Get all pending spawn requests.
 
void clearSpawnRequests ()
 Clear all pending spawn requests (called after processing)
 
bool hasPendingSpawns () const
 Check if there are pending spawns.
 
ComponentType getType () const override
 Get component type ID.
 
void setConfig (const SpawnerConfig &config)
 
const SpawnerConfiggetConfig () const
 
SpawnerConfiggetConfigMutable ()
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Public Attributes

float waveElapsedTime = 0.0f
 
int currentWaveIndex = 0
 
bool isActive = true
 

Private Attributes

std::vector< SpawnRequest_spawnRequests
 
SpawnerConfig _config = {}
 

Detailed Description

Component that holds spawn requests to be processed by SpawnSystem.

Entities with this component act as spawners. They queue up spawn requests that the SpawnSystem will process each frame. This is the clean ECS way to handle dynamic spawning without direct entity creation in Lua.

Definition at line 48 of file Spawner.hpp.

Constructor & Destructor Documentation

◆ Spawner()

ecs::Spawner::Spawner ( )
default

◆ ~Spawner()

ecs::Spawner::~Spawner ( )
overridedefault

Member Function Documentation

◆ clearSpawnRequests()

void ecs::Spawner::clearSpawnRequests ( )
inline

Clear all pending spawn requests (called after processing)

Definition at line 68 of file Spawner.hpp.

References _spawnRequests.

◆ getConfig()

const SpawnerConfig & ecs::Spawner::getConfig ( ) const
inline

Definition at line 95 of file Spawner.hpp.

References _config.

Referenced by ecs::SpawnSystem::update().

◆ getConfigMutable()

SpawnerConfig & ecs::Spawner::getConfigMutable ( )
inline

Definition at line 96 of file Spawner.hpp.

References _config.

Referenced by ecs::SpawnSystem::update().

◆ getSpawnRequests()

const std::vector< SpawnRequest > & ecs::Spawner::getSpawnRequests ( ) const
inline

Get all pending spawn requests.

Returns
Vector of spawn requests

Definition at line 63 of file Spawner.hpp.

References _spawnRequests.

◆ getType()

ComponentType ecs::Spawner::getType ( ) const
inlineoverridevirtual

Get component type ID.

Returns
ComponentType

Implements ecs::IComponent.

Definition at line 80 of file Spawner.hpp.

◆ hasPendingSpawns()

bool ecs::Spawner::hasPendingSpawns ( ) const
inline

Check if there are pending spawns.

Returns
true if spawn requests exist

Definition at line 74 of file Spawner.hpp.

References _spawnRequests.

◆ queueSpawn()

void ecs::Spawner::queueSpawn ( const SpawnRequest request)
inline

Queue a spawn request.

Parameters
requestThe spawn request to queue

Definition at line 57 of file Spawner.hpp.

References _spawnRequests.

Referenced by scripting::bindings::bindServerGame().

◆ setConfig()

void ecs::Spawner::setConfig ( const SpawnerConfig config)
inline

Member Data Documentation

◆ _config

SpawnerConfig ecs::Spawner::_config = {}
private

Definition at line 105 of file Spawner.hpp.

Referenced by getConfig(), getConfigMutable(), and setConfig().

◆ _spawnRequests

std::vector<SpawnRequest> ecs::Spawner::_spawnRequests
private

Definition at line 104 of file Spawner.hpp.

Referenced by clearSpawnRequests(), getSpawnRequests(), hasPendingSpawns(), and queueSpawn().

◆ currentWaveIndex

int ecs::Spawner::currentWaveIndex = 0

Definition at line 99 of file Spawner.hpp.

Referenced by setConfig(), and ecs::SpawnSystem::update().

◆ isActive

bool ecs::Spawner::isActive = true

◆ waveElapsedTime

float ecs::Spawner::waveElapsedTime = 0.0f

Definition at line 98 of file Spawner.hpp.

Referenced by setConfig(), and ecs::SpawnSystem::update().


The documentation for this class was generated from the following file: