Skip to main content

SpawnCondition Class

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

Declaration

class helios::engine::runtime::spawn::policy::SpawnCondition { ... }

Derived Classes

classSpawnConditionAll

Composite condition requiring all child conditions to pass. More...

classRequestedAmountIsAvailableCondition

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

classTimerSpawnCondition

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

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

voidonCommit (SpawnRuleState &spawnRuleState, const size_t spawnAmount) const

Called after a successful spawn to update condition state. More...

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

SpawnRule

See Also

SpawnScheduler

Definition at line 49 of file SpawnCondition.ixx.

Public Destructor

~SpawnCondition()

virtual helios::engine::runtime::spawn::policy::SpawnCondition::~SpawnCondition ()
virtual default

Virtual destructor for proper polymorphic cleanup.

Definition at line 56 of file SpawnCondition.ixx.

Public Member Functions

isSatisfied()

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

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

90 virtual void onCommit(
91 SpawnRuleState& spawnRuleState,
92 const size_t spawnAmount
93 ) const {
94 // noop
95 }

onReset()

virtual void helios::engine::runtime::spawn::policy::SpawnCondition::onReset (SpawnRuleState & spawnRuleState)
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.