SpawnCondition Class
Abstract interface for determining when spawning should occur. More...
Declaration
Derived Classes
| class | SpawnConditionAll |
|
Composite condition requiring all child conditions to pass. More... | |
| class | RequestedAmountIsAvailableCondition |
|
Condition verifying the pool has enough inactive entities. More... | |
| class | TimerSpawnCondition |
|
A SpawnCondition that triggers spawning at fixed time intervals. More... | |
Public Destructor Index
| ~SpawnCondition ()=default | |
|
Virtual destructor for proper polymorphic cleanup. More... | |
Public Member Functions Index
| bool | isSatisfied (const size_t requestedAmount, const SpawnRuleState &spawnState, const helios::engine::runtime::pooling::GameObjectPoolSnapshot poolSnapshot, const helios::engine::runtime::world::UpdateContext &updateContext) const noexcept=0 |
|
Evaluates whether the spawn condition is satisfied. More... | |
| void | onCommit (SpawnRuleState &spawnRuleState, const size_t spawnAmount) const |
|
Called after a successful spawn to update condition state. More... | |
| void | onReset (SpawnRuleState &spawnRuleState) const noexcept=0 |
|
Called when the spawn system is reset. More... | |
Description
Abstract interface for determining when spawning should occur.
SpawnCondition implements the Strategy pattern for spawn timing control. Concrete implementations determine whether spawning should occur based on time, game state, pool availability, or other conditions.
## Responsibilities
- **isSatisfied():** Evaluates whether the condition is met for spawning
- **onCommit():** Updates state after a successful spawn (e.g., reset timer)
## Implementation Example
```cpp class WaveSpawnCondition : public SpawnCondition { public: bool isSatisfied(size_t amount, const SpawnRuleState& state, GameObjectPoolSnapshot pool, const UpdateContext& ctx) const noexcept override { return state.sinceLastSpawn() >= waveInterval_ && pool.inactiveCount >= amount; }
void onCommit(SpawnRuleState& state, size_t count) const override { state.setSinceLastSpawn(0.0f); } }; ```
- See Also
TimerSpawnCondition
- See Also
- See Also
SpawnScheduler
Definition at line 49 of file SpawnCondition.ixx.
Public Destructor
~SpawnCondition()
| virtual default |
Virtual destructor for proper polymorphic cleanup.
Definition at line 56 of file SpawnCondition.ixx.
Public Member Functions
isSatisfied()
| nodiscard noexcept |
Evaluates whether the spawn condition is satisfied.
Called by SpawnRule::evaluate() to determine if spawning should occur. The implementation should check all required conditions (time elapsed, pool capacity, game state, etc.).
- Parameters
-
requestedAmount The number of entities requested to spawn.
spawnState The rule's current runtime state.
poolSnapshot Snapshot of the pool's current capacity.
updateContext The current frame's context.
- Returns
true if spawning should occur, false otherwise.
Definition at line 72 of file SpawnCondition.ixx.
onCommit()
| inline virtual |
Called after a successful spawn to update condition state.
Override this method to reset timers, increment counters, or perform other state updates after spawning completes.
The default implementation is a no-op.
- Parameters
-
spawnRuleState The rule's runtime state to update.
spawnAmount The number of entities that were spawned.
Definition at line 90 of file SpawnCondition.ixx.
onReset()
| noexcept |
Called when the spawn system is reset.
Override to reset condition state (e.g., timers, counters).
- Parameters
-
spawnRuleState The rule's runtime state to reset.
Definition at line 104 of file SpawnCondition.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.