SpawnRule Class
Combines a condition and amount provider into a complete spawn rule. More...
Declaration
Public Constructors Index
| SpawnRule (std::unique_ptr< const SpawnCondition > spawnCondition, std::unique_ptr< const amount::SpawnAmountProvider > spawnAmountProvider, const helios::engine::core::data::SpawnRuleId spawnRuleId) | |
|
Constructs a SpawnRule with condition, amount provider, and ID. More... | |
Public Member Functions Index
| void | commit (SpawnRuleState &spawnRuleState, const size_t spawnAmount) |
|
Commits a completed spawn to update rule state. More... | |
| const SpawnCondition & | spawnCondition () const noexcept |
|
Returns the spawn condition. More... | |
| helios::engine::runtime::spawn::scheduling::SpawnPlan | evaluate (const helios::engine::core::data::GameObjectPoolId gameObjectPoolId, const helios::engine::runtime::pooling::GameObjectPoolSnapshot &poolSnapshot, const SpawnRuleState &spawnRuleState, const helios::engine::runtime::world::UpdateContext &updateContext) |
|
Evaluates the rule and returns a spawn plan. More... | |
| helios::engine::core::data::SpawnRuleId | spawnRuleId () const noexcept |
|
Returns the rule's unique identifier. More... | |
Private Member Attributes Index
| std::unique_ptr< const amount::SpawnAmountProvider > | spawnAmountProvider_ |
|
Provider that determines spawn quantity. More... | |
| std::unique_ptr< const SpawnCondition > | spawnCondition_ |
|
Condition that determines if spawning should occur. More... | |
| const helios::engine::core::data::SpawnRuleId | spawnRuleId_ |
|
Unique identifier for this rule. More... | |
Description
Combines a condition and amount provider into a complete spawn rule.
SpawnRule encapsulates the logic for when and how many entities to spawn. It combines:
- **SpawnCondition:** Determines if spawning should occur
- **SpawnAmountProvider:** Determines how many to spawn
The SpawnScheduler evaluates rules each frame and creates SpawnPlans for rules whose conditions are satisfied.
Example: ```cpp auto rule = std::make_unique<SpawnRule>( std::make_unique<TimerSpawnCondition>(2.0f), std::make_unique<FixedSpawnAmount>(3), SpawnRuleId{1} ); ```
- See Also
- See Also
SpawnAmountProvider
- See Also
SpawnScheduler
Definition at line 47 of file SpawnRule.ixx.
Public Constructors
SpawnRule()
| inline explicit |
Constructs a SpawnRule with condition, amount provider, and ID.
- Parameters
-
spawnCondition Condition determining when to spawn.
spawnAmountProvider Provider determining how many to spawn.
spawnRuleId Unique identifier for this rule.
Definition at line 73 of file SpawnRule.ixx.
References spawnCondition and spawnRuleId.
Public Member Functions
commit()
| inline |
Commits a completed spawn to update rule state.
- Parameters
-
spawnRuleState The state to update.
spawnAmount The number of entities spawned.
Definition at line 88 of file SpawnRule.ixx.
evaluate()
| inline nodiscard |
Evaluates the rule and returns a spawn plan.
- Parameters
-
gameObjectPoolId The pool to spawn from.
poolSnapshot Current pool state.
spawnRuleState The rule's runtime state.
updateContext The current frame's context.
- Returns
A SpawnPlan with amount > 0 if condition satisfied, 0 otherwise.
Definition at line 111 of file SpawnRule.ixx.
spawnCondition()
| inline nodiscard noexcept |
Returns the spawn condition.
- Returns
Reference to the spawn condition.
Definition at line 97 of file SpawnRule.ixx.
Referenced by SpawnRule.
spawnRuleId()
| inline nodiscard noexcept |
Returns the rule's unique identifier.
- Returns
The SpawnRuleId.
Definition at line 131 of file SpawnRule.ixx.
Referenced by SpawnRule.
Private Member Attributes
spawnAmountProvider_
|
Provider that determines spawn quantity.
Definition at line 52 of file SpawnRule.ixx.
spawnCondition_
|
Condition that determines if spawning should occur.
Definition at line 57 of file SpawnRule.ixx.
spawnRuleId_
|
Unique identifier for this rule.
Definition at line 62 of file SpawnRule.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.