GameObjectSpawnSystem Class
System that evaluates spawn conditions and enqueues spawn commands. More...
Declaration
Base class
| class | System |
|
Abstract base class for game systems. More... | |
Public Constructors Index
| GameObjectSpawnSystem (std::vector< std::unique_ptr< helios::engine::runtime::spawn::scheduling::SpawnScheduler > > spawnSchedulers) | |
|
Constructs a GameObjectSpawnSystem with the given schedulers. More... | |
Public Member Functions Index
| void | update (helios::engine::runtime::world::UpdateContext &updateContext) noexcept override |
|
Processes spawn scheduling and enqueues spawn commands. More... | |
Private Member Attributes Index
| std::vector< std::unique_ptr< helios::engine::runtime::spawn::scheduling::SpawnScheduler > > | spawnSchedulers_ |
|
Collection of schedulers that manage spawn rules and conditions. More... | |
Description
System that evaluates spawn conditions and enqueues spawn commands.
GameObjectSpawnSystem bridges the spawn scheduling logic with the command-based spawning pipeline. It manages multiple SpawnScheduler instances and performs the following each frame:
1. **Read Frame Events:** Consumes `SpawnPlanCommandExecutedEvent` from the previous frame to commit completed spawn operations to all schedulers.
2. **Evaluate Conditions:** Calls `SpawnScheduler::evaluate()` on each scheduler to check all registered spawn rules against their conditions.
3. **Drain Scheduled Plans:** Retrieves all plans that are ready to execute and enqueues them as `ScheduledSpawnPlanCommand` into the CommandBuffer.
The actual spawning is performed by the command dispatcher/manager layer, keeping this system focused on scheduling logic only.
Example setup: ```cpp std::vector<std::unique_ptr<SpawnScheduler>> schedulers;
auto enemyScheduler = std::make_unique<SpawnScheduler>(); enemyScheduler->addRule(enemyProfileId, std::move(enemyRule)); schedulers.push_back(std::move(enemyScheduler));
auto powerupScheduler = std::make_unique<SpawnScheduler>(); powerupScheduler->addRule(powerupProfileId, std::move(powerupRule)); schedulers.push_back(std::move(powerupScheduler));
auto spawnSystem = std::make_unique<GameObjectSpawnSystem>(schedulers); mainPhase.addPass().add(std::move(spawnSystem)); ```
This system reads frame-level events via `readFrame()`, meaning it processes spawn confirmations from the previous frame.
- See Also
SpawnScheduler
- See Also
ScheduledSpawnPlanCommand
- See Also
SpawnPlanCommandExecutedEvent
Definition at line 64 of file GameObjectSpawnSystem.ixx.
Public Constructors
GameObjectSpawnSystem()
| inline explicit |
Constructs a GameObjectSpawnSystem with the given schedulers.
- Parameters
-
spawnSchedulers Vector of schedulers managing spawn rules. Ownership of all schedulers is transferred to this system.
Definition at line 84 of file GameObjectSpawnSystem.ixx.
Public Member Functions
update()
| inline noexcept virtual |
Processes spawn scheduling and enqueues spawn commands.
Iterates through all schedulers and performs these steps for each: 1. Reads `SpawnPlanCommandExecutedEvent` from frame event bus 2. Commits completed spawns to the scheduler (for tracking/cooldowns) 3. Evaluates all spawn rules against current conditions 4. Drains ready spawn plans and enqueues them as commands
- Parameters
-
updateContext The current frame's update context.
Definition at line 100 of file GameObjectSpawnSystem.ixx.
Private Member Attributes
spawnSchedulers_
|
Collection of schedulers that manage spawn rules and conditions.
Each scheduler owns and evaluates its registered spawn rules independently. When conditions are met, the scheduler produces ScheduledSpawnPlan instances for execution. Multiple schedulers allow grouping spawn rules by category (e.g., enemies, powerups, projectiles).
Definition at line 74 of file GameObjectSpawnSystem.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.