Skip to main content

SpawnScheduler Class

Abstract base class for spawn schedulers. More...

Declaration

class helios::engine::runtime::spawn::scheduling::SpawnScheduler { ... }

Derived Classes

classCyclicSpawnScheduler<N>

Scheduler that cycles through spawn rules in round-robin order. More...

classDefaultSpawnScheduler

Scheduler that evaluates spawn rules and produces spawn plans. More...

Public Constructors Index

SpawnScheduler ()=default

Default constructor. More...

Public Destructor Index

~SpawnScheduler ()=default

Virtual destructor for proper cleanup. More...

Public Member Functions Index

voidevaluate (const GameWorld &gameWorld, const UpdateContext &updateContext, const SpawnContext &spawnContext={}) noexcept=0

Evaluates spawn rules and schedules spawn plans. More...

std::span< const ScheduledSpawnPlan >scheduledPlans ()

Returns a read-only view of scheduled spawn plans. More...

std::vector< ScheduledSpawnPlan >drainScheduledPlans ()

Drains and returns all scheduled spawn plans. More...

voidcommit (SpawnRuleId spawnRuleId, const size_t spawnCount) noexcept=0

Commits a completed spawn operation to update rule state. More...

voidreset () noexcept=0

Resets all rule states to their initial values. More...

Protected Member Attributes Index

std::vector< ScheduledSpawnPlan >scheduledSpawnPlans_

Buffer for scheduled spawn plans awaiting processing. More...

Description

Abstract base class for spawn schedulers.

SpawnScheduler defines the interface for evaluating spawn rules and producing scheduled spawn plans. Concrete implementations determine the evaluation strategy (all rules vs. cyclic, priority-based, etc.).

## Responsibilities

  • Maintain a buffer of scheduled spawn plans
  • Provide `evaluate()` for rule processing
  • Provide `drainScheduledPlans()` for retrieving pending spawns
  • Provide `commit()` for post-spawn state updates

## Implementations

| Class | Strategy | |-------|----------| | `DefaultSpawnScheduler` | Evaluates all rules each frame | | `CyclicSpawnScheduler` | Round-robin evaluation, advances on successful spawn |

See Also

DefaultSpawnScheduler

See Also

CyclicSpawnScheduler

See Also

ScheduledSpawnPlan

Definition at line 54 of file SpawnScheduler.ixx.

Public Constructors

SpawnScheduler()

helios::engine::runtime::spawn::scheduling::SpawnScheduler::SpawnScheduler ()
default

Default constructor.

Definition at line 73 of file SpawnScheduler.ixx.

Public Destructor

~SpawnScheduler()

virtual helios::engine::runtime::spawn::scheduling::SpawnScheduler::~SpawnScheduler ()
virtual default

Virtual destructor for proper cleanup.

Definition at line 68 of file SpawnScheduler.ixx.

Public Member Functions

commit()

virtual void helios::engine::runtime::spawn::scheduling::SpawnScheduler::commit (SpawnRuleId spawnRuleId, const size_t spawnCount)
noexcept

Commits a completed spawn operation to update rule state.

Called when a spawn request has been executed to update the associated rule's state (e.g., reset timers, update counts).

Parameters
spawnRuleId

The rule that triggered the spawn.

spawnCount

The number of entities actually spawned.

Definition at line 125 of file SpawnScheduler.ixx.

drainScheduledPlans()

std::vector< ScheduledSpawnPlan > helios::engine::runtime::spawn::scheduling::SpawnScheduler::drainScheduledPlans ()
inline nodiscard

Drains and returns all scheduled spawn plans.

Moves all pending plans out of the scheduler and returns them. The internal buffer is left empty.

Returns

Vector of scheduled spawn plans.

Definition at line 109 of file SpawnScheduler.ixx.

109 [[nodiscard]] std::vector<ScheduledSpawnPlan> drainScheduledPlans() {
110 std::vector<ScheduledSpawnPlan> plans{};
111 plans.swap(scheduledSpawnPlans_);
112 return plans;
113 }

Reference scheduledSpawnPlans_.

evaluate()

virtual void helios::engine::runtime::spawn::scheduling::SpawnScheduler::evaluate (const GameWorld & gameWorld, const UpdateContext & updateContext, const SpawnContext & spawnContext={})
noexcept

Evaluates spawn rules and schedules spawn plans.

Processes registered spawn rules according to the scheduler's strategy. Produces ScheduledSpawnPlan instances for rules whose conditions are met.

Parameters
gameWorld

The game world where evaluation takes place.

updateContext

Current frame context with delta time and world.

spawnContext

Optional spawn context for the operation.

Definition at line 86 of file SpawnScheduler.ixx.

reset()

virtual void helios::engine::runtime::spawn::scheduling::SpawnScheduler::reset ()
noexcept

Resets all rule states to their initial values.

Called during level transitions or game restarts.

Definition at line 132 of file SpawnScheduler.ixx.

scheduledPlans()

std::span< const ScheduledSpawnPlan > helios::engine::runtime::spawn::scheduling::SpawnScheduler::scheduledPlans ()
inline nodiscard

Returns a read-only view of scheduled spawn plans.

Returns

Span of currently scheduled plans.

Definition at line 97 of file SpawnScheduler.ixx.

97 [[nodiscard]] std::span<const ScheduledSpawnPlan> scheduledPlans() {
99 }

Reference scheduledSpawnPlans_.

Protected Member Attributes

scheduledSpawnPlans_

std::vector<ScheduledSpawnPlan> helios::engine::runtime::spawn::scheduling::SpawnScheduler::scheduledSpawnPlans_
protected

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.