Skip to main content

RequestedAmountIsAvailableCondition Class

Condition verifying the pool has enough inactive entities. More...

Declaration

class helios::engine::runtime::spawn::policy::conditions::RequestedAmountIsAvailableCondition { ... }

Base class

classSpawnCondition

Abstract interface for determining when spawning should occur. More...

Public Member Functions Index

boolisSatisfied (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...

voidonCommit (SpawnRuleState &spawnRuleState, const size_t spawnAmount) const override

Resets the spawn timer after a successful spawn. More...

voidonReset (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

SpawnCondition

See Also

SpawnConditionAll

See Also

GameObjectPoolSnapshot

Definition at line 47 of file RequestedAmountIsAvailableCondition.ixx.

Public Member Functions

isSatisfied()

bool helios::engine::runtime::spawn::policy::conditions::RequestedAmountIsAvailableCondition::isSatisfied (const size_t requestedAmount, const SpawnRuleState & spawnState, const helios::engine::runtime::pooling::GameObjectPoolSnapshot poolSnapshot, const helios::engine::runtime::world::UpdateContext & updateContext)
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.

61 [[nodiscard]] bool isSatisfied(
62 const size_t requestedAmount,
63 const SpawnRuleState& spawnState,
66 ) const noexcept override {
67 return requestedAmount <= poolSnapshot.inactiveCount;
68 }

onCommit()

void helios::engine::runtime::spawn::policy::conditions::RequestedAmountIsAvailableCondition::onCommit (SpawnRuleState & spawnRuleState, const size_t spawnAmount)
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.

79 void onCommit(
80 SpawnRuleState& spawnRuleState,
81 const size_t spawnAmount
82 ) const override {
83 spawnRuleState.setSinceLastSpawn(0.0f);
84 }

Reference helios::engine::runtime::spawn::policy::SpawnRuleState::setSinceLastSpawn.

onReset()

void helios::engine::runtime::spawn::policy::conditions::RequestedAmountIsAvailableCondition::onReset (SpawnRuleState & spawnRuleState)
inline noexcept virtual

Resets the spawn timer.

Parameters
spawnRuleState

The rule's runtime state to reset.

Definition at line 91 of file RequestedAmountIsAvailableCondition.ixx.

91 void onReset(
92 SpawnRuleState& spawnRuleState
93 ) const noexcept override {
94 spawnRuleState.setSinceLastSpawn(0.0f);
95 }

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.