RequestedAmountIsAvailableCondition Class
Condition verifying the pool has enough inactive entities. More...
Declaration
Base class
| class | SpawnCondition |
|
Abstract interface for determining when spawning should occur. 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 pool has enough inactive entities. More... | |
| void | onCommit (SpawnRuleState &spawnRuleState, const size_t spawnAmount) const override |
|
Resets the spawn timer after a successful spawn. More... | |
| void | onReset (SpawnRuleState &spawnRuleState) const noexcept override |
|
Resets the spawn timer. More... | |
Description
Condition verifying the pool has enough inactive entities.
RequestedAmountIsAvailableCondition checks whether the entity pool contains at least as many inactive (recyclable) entities as the spawn request requires. This prevents spawn failures due to pool exhaustion.
## Behavior
- Returns `true` if `requestedAmount <= poolSnapshot.inactiveCount`
- Resets the spawn timer on commit (via `setSinceLastSpawn(0)`)
## Usage
```cpp auto condition = std::make_unique<RequestedAmountIsAvailableCondition>();
// Often combined with other conditions auto combined = std::make_unique<SpawnConditionAll>( std::make_unique<TimerCondition>(2.0f), std::make_unique<RequestedAmountIsAvailableCondition>() ); ```
- See Also
- See Also
- See Also
GameObjectPoolSnapshot
Definition at line 47 of file RequestedAmountIsAvailableCondition.ixx.
Public Member Functions
isSatisfied()
| inline nodiscard noexcept virtual |
Checks if the pool has enough inactive entities.
- Parameters
-
requestedAmount Number of entities requested for spawn.
spawnState Current state of the spawn rule (unused).
poolSnapshot Snapshot containing pool availability info.
updateContext Current frame context (unused).
- Returns
`true` if inactive count >= requested amount.
Definition at line 61 of file RequestedAmountIsAvailableCondition.ixx.
onCommit()
| inline virtual |
Resets the spawn timer after a successful spawn.
Sets `sinceLastSpawn` to zero, restarting the timer for conditions that depend on spawn intervals.
- Parameters
-
spawnRuleState The rule's runtime state to update.
spawnAmount The number of entities that were spawned (unused).
Definition at line 79 of file RequestedAmountIsAvailableCondition.ixx.
Reference helios::engine::runtime::spawn::policy::SpawnRuleState::setSinceLastSpawn.
onReset()
| inline noexcept virtual |
Resets the spawn timer.
- Parameters
-
spawnRuleState The rule's runtime state to reset.
Definition at line 91 of file RequestedAmountIsAvailableCondition.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.