Skip to main content

SpawnConditionAll Class

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

Declaration

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

Base class

classSpawnCondition

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

Public Constructors Index

template <typename... Args>
SpawnConditionAll (Args &&... args)

Constructs a composite condition from variadic arguments. 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 all child conditions are satisfied. More...

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

Propagates commit to all child conditions. More...

voidonReset (SpawnRuleState &spawnRuleState) const noexcept override

Propagates reset to all child conditions. More...

Private Member Attributes Index

std::vector< std::unique_ptr< helios::engine::runtime::spawn::policy::SpawnCondition > >spawnConditions_

Collection of child conditions to evaluate. More...

Description

Composite condition requiring all child conditions to pass.

SpawnConditionAll implements a logical AND over multiple SpawnCondition instances. The spawn is permitted only when every child condition returns `true` from `isSatisfied()`.

## Behavior

  • Short-circuits on first failing condition
  • Propagates `onCommit()` to all child conditions
  • Accepts variadic condition arguments via constructor

## Usage

```cpp auto condition = std::make_unique<SpawnConditionAll>( std::make_unique<TimerCondition>(2.0f), std::make_unique<RequestedAmountIsAvailableCondition>(), std::make_unique<MaxActiveCondition>(10) );

// Spawns only when: timer elapsed AND pool available AND under max ```

See Also

SpawnCondition

See Also

TimerCondition

See Also

RequestedAmountIsAvailableCondition

Definition at line 51 of file SpawnConditionAll.ixx.

Public Constructors

SpawnConditionAll()

template <typename... Args>
helios::engine::runtime::spawn::policy::SpawnConditionAll::SpawnConditionAll (Args &&... args)
inline explicit

Constructs a composite condition from variadic arguments.

Template Parameters
Args

Types of spawn conditions (must be unique_ptr<SpawnCondition>).

Parameters
args

Spawn conditions to combine. Ownership transferred.

Definition at line 68 of file SpawnConditionAll.ixx.

68 explicit SpawnConditionAll(Args&&... args) {
69
70 spawnConditions_.reserve(10);
71
72 (spawnConditions_.push_back(std::forward<Args>(args)), ...);
73
74 }

Public Member Functions

isSatisfied()

bool helios::engine::runtime::spawn::policy::SpawnConditionAll::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 all child conditions are satisfied.

Iterates through all conditions and returns `false` on the first condition that fails (short-circuit evaluation).

Parameters
requestedAmount

Number of entities requested for spawn.

spawnState

Current state of the spawn rule.

poolSnapshot

Snapshot of the entity pool.

updateContext

Current frame context.

Returns

`true` if all conditions pass, `false` otherwise.

Definition at line 89 of file SpawnConditionAll.ixx.

89 [[nodiscard]] bool isSatisfied(
90 const size_t requestedAmount,
91 const SpawnRuleState& spawnState,
94 ) const noexcept override {
95
96
97 for (auto& condition : spawnConditions_) {
98 if (!condition->isSatisfied(requestedAmount, spawnState, poolSnapshot, updateContext)) {
99 return false;
100 }
101 }
102
103 return true;
104
105 };

onCommit()

void helios::engine::runtime::spawn::policy::SpawnConditionAll::onCommit (SpawnRuleState & spawnRuleState, const size_t spawnAmount)
inline virtual

Propagates commit to all child conditions.

Calls `onCommit()` on each child condition to allow them to update their internal state after a successful spawn.

Parameters
spawnRuleState

The rule's runtime state to update.

spawnAmount

The number of entities that were spawned.

Definition at line 116 of file SpawnConditionAll.ixx.

117 SpawnRuleState& spawnRuleState,
118 const size_t spawnAmount
119 ) const override {
120 for (auto& condition : spawnConditions_) {
121 condition->onCommit(spawnRuleState, spawnAmount);
122 }
123
124 }

onReset()

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

Propagates reset to all child conditions.

Parameters
spawnRuleState

The rule's runtime state to reset.

Definition at line 131 of file SpawnConditionAll.ixx.

131 void onReset(
132 SpawnRuleState& spawnRuleState
133 ) const noexcept override {
134 for (auto& condition : spawnConditions_) {
135 condition->onReset(spawnRuleState);
136 }
137
138 }

Private Member Attributes

spawnConditions_

std::vector<std::unique_ptr<helios::engine::runtime::spawn::policy::SpawnCondition> > helios::engine::runtime::spawn::policy::SpawnConditionAll::spawnConditions_

Collection of child conditions to evaluate.

Definition at line 56 of file SpawnConditionAll.ixx.

56 std::vector<std::unique_ptr<helios::engine::runtime::spawn::policy::SpawnCondition>> spawnConditions_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.