SpawnAmountByCallback Class
Amount provider that delegates to a user-provided callback. More...
Declaration
Base class
| class | SpawnAmountProvider |
|
Abstract interface for determining spawn quantity. More... | |
Private Member Typedefs Index
| using | AmountEvaluator = std::function< size_t( const helios::engine::runtime::pooling::types::GameObjectPoolId, const SpawnRuleState &, const helios::engine::runtime::world::GameWorld &gameWorld, const helios::engine::runtime::world::UpdateContext &)> |
|
Function signature for amount evaluation. More... | |
Public Constructors Index
| SpawnAmountByCallback (AmountEvaluator evaluator) | |
|
Constructs a SpawnAmountByCallback with the given evaluator. More... | |
Public Member Functions Index
| size_t | getAmount (const helios::engine::runtime::pooling::types::GameObjectPoolId gameObjectPoolId, const SpawnRuleState &spawnRuleState, const helios::engine::runtime::world::GameWorld &gameWorld, const helios::engine::runtime::world::UpdateContext &updateContext) const override |
|
Returns the number of entities to spawn. More... | |
Private Member Attributes Index
| AmountEvaluator | evaluator_ |
|
The callback function for calculating spawn amount. More... | |
Description
Amount provider that delegates to a user-provided callback.
SpawnAmountByCallback allows dynamic spawn quantity calculation by delegating to a std::function. This enables complex logic based on game state, difficulty, pool availability, or other runtime factors.
Example: ```cpp auto dynamicAmount = std::make_unique<SpawnAmountByCallback>( [&DIFFICULTY_LEVEL](const GameObjectPoolId& poolId, const SpawnRuleState& state, const UpdateContext& ctx) -> size_t { // Scale spawn count with difficulty return 2 * DIFFICULTY_LEVEL; } ); ```
- See Also
- See Also
Definition at line 39 of file SpawnAmountByCallback.ixx.
Private Member Typedefs
AmountEvaluator
|
Function signature for amount evaluation.
Definition at line 44 of file SpawnAmountByCallback.ixx.
Public Constructors
SpawnAmountByCallback()
| inline explicit |
Constructs a SpawnAmountByCallback with the given evaluator.
- Parameters
-
evaluator The callback function to calculate spawn amount.
Definition at line 63 of file SpawnAmountByCallback.ixx.
Public Member Functions
getAmount()
| inline nodiscard virtual |
Returns the number of entities to spawn.
- Parameters
-
gameObjectPoolId The pool to spawn from.
spawnRuleState The rule's current runtime state.
gameWorld The game world in which the spawn occurs.
updateContext The current frame's context.
- Returns
Number of entities to spawn.
Definition at line 69 of file SpawnAmountByCallback.ixx.
Private Member Attributes
evaluator_
|
The callback function for calculating spawn amount.
Definition at line 54 of file SpawnAmountByCallback.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.