TimerSpawnCondition Class
A SpawnCondition that triggers spawning at fixed time intervals. More...
Declaration
Base class
| class | SpawnCondition |
|
Abstract interface for determining when spawning should occur. More... | |
Public Constructors Index
| TimerSpawnCondition (const float interval) | |
|
Constructs a TimerSpawnCondition with the specified interval. 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 override |
|
Checks if the timer interval has elapsed. More... | |
| void | onCommit (SpawnRuleState &spawnRuleState, const size_t spawnAmount) const override |
|
Resets the spawn timer after a successful spawn. More... | |
Private Member Attributes Index
| float | interval_ = 0.0f |
|
The time interval between spawns in seconds. More... | |
Description
A SpawnCondition that triggers spawning at fixed time intervals.
TimerSpawnCondition checks if enough time has elapsed since the last spawn to satisfy the interval requirement.
## Behavior
- **isSatisfied():** Returns true when `sinceLastSpawn >= interval`.
- **onCommit():** Resets the `sinceLastSpawn` timer to 0
Example: ```cpp // Spawn every 2 seconds auto condition = std::make_unique<TimerSpawnCondition>(2.0f);
auto rule = std::make_unique<SpawnRule>( std::move(condition), std::make_unique<FixedSpawnAmount>(3), SpawnRuleId{1} ); ```
- See Also
- See Also
- See Also
Definition at line 45 of file TimerSpawnCondition.ixx.
Public Constructors
TimerSpawnCondition()
| inline explicit |
Constructs a TimerSpawnCondition with the specified interval.
The first spawn will occur after the interval has elapsed, not immediately.
- Parameters
-
interval The time in seconds between spawn events.
- Precondition
interval > 0.0f
Definition at line 66 of file TimerSpawnCondition.ixx.
Public Member Functions
isSatisfied()
| inline nodiscard noexcept virtual |
Checks if the timer interval has elapsed.
- Parameters
-
requestedAmount The number of entities requested to spawn.
spawnState The rule's runtime state containing time since last spawn.
poolSnapshot Snapshot of the pool's current capacity.
updateContext The current frame's context.
- Returns
true if interval elapsed AND pool has enough inactive entities.
Definition at line 81 of file TimerSpawnCondition.ixx.
onCommit()
| inline virtual |
Resets the spawn timer after a successful spawn.
- Parameters
-
spawnRuleState The rule's runtime state to update.
spawnAmount The number of entities that were spawned (unused).
Definition at line 96 of file TimerSpawnCondition.ixx.
Reference helios::engine::runtime::spawn::policy::SpawnRuleState::setSinceLastSpawn.
Private Member Attributes
interval_
|
The time interval between spawns in seconds.
Definition at line 52 of file TimerSpawnCondition.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.