Skip to main content

SpawnAmountByCallback Class

Amount provider that delegates to a user-provided callback. More...

Declaration

class helios::engine::runtime::spawn::policy::amount::SpawnAmountByCallback { ... }

Base class

classSpawnAmountProvider

Abstract interface for determining spawn quantity. More...

Private Member Typedefs Index

usingAmountEvaluator = 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_tgetAmount (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

AmountEvaluatorevaluator_

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

SpawnAmountProvider

See Also

FixedSpawnAmount

Definition at line 39 of file SpawnAmountByCallback.ixx.

Private Member Typedefs

AmountEvaluator

using helios::engine::runtime::spawn::policy::amount::SpawnAmountByCallback::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.

Definition at line 44 of file SpawnAmountByCallback.ixx.

44 using AmountEvaluator = std::function<size_t(

Public Constructors

SpawnAmountByCallback()

helios::engine::runtime::spawn::policy::amount::SpawnAmountByCallback::SpawnAmountByCallback (AmountEvaluator evaluator)
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.

63 explicit SpawnAmountByCallback(AmountEvaluator evaluator)
64 : evaluator_(std::move(evaluator)) {}

Public Member Functions

getAmount()

size_t helios::engine::runtime::spawn::policy::amount::SpawnAmountByCallback::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)
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.

69 [[nodiscard]] size_t getAmount(
71 const SpawnRuleState& spawnRuleState,
74 ) const override {
75 return evaluator_(gameObjectPoolId, spawnRuleState, gameWorld, updateContext);
76 }

Private Member Attributes

evaluator_

AmountEvaluator helios::engine::runtime::spawn::policy::amount::SpawnAmountByCallback::evaluator_

The callback function for calculating spawn amount.

Definition at line 54 of file SpawnAmountByCallback.ixx.

54 AmountEvaluator evaluator_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.