Skip to main content

SpawnCondition.ixx File

Abstract interface for determining spawn timing. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespaceruntime

Runtime infrastructure for game execution and lifecycle orchestration. More...

namespacespawn

Entity spawning infrastructure for the helios engine. More...

namespacepolicy

Spawn rules, conditions, and amount providers. More...

Classes Index

classSpawnCondition

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

Description

Abstract interface for determining spawn timing.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SpawnCondition.ixx
3 * @brief Abstract interface for determining spawn timing.
4 */
5module;
6
7export module helios.engine.runtime.spawn.policy.SpawnCondition;
8
9import helios.engine.runtime.spawn.policy.SpawnRuleState;
10import helios.engine.runtime.pooling.GameObjectPoolSnapshot;
11import helios.engine.runtime.world.UpdateContext;
12
14
15 /**
16 * @brief Abstract interface for determining when spawning should occur.
17 *
18 * @details SpawnCondition implements the Strategy pattern for spawn timing
19 * control. Concrete implementations determine whether spawning should occur
20 * based on time, game state, pool availability, or other conditions.
21 *
22 * ## Responsibilities
23 *
24 * - **isSatisfied():** Evaluates whether the condition is met for spawning
25 * - **onCommit():** Updates state after a successful spawn (e.g., reset timer)
26 *
27 * ## Implementation Example
28 *
29 * ```cpp
30 * class WaveSpawnCondition : public SpawnCondition {
31 * public:
32 * bool isSatisfied(size_t amount, const SpawnRuleState& state,
33 * GameObjectPoolSnapshot pool,
34 * const UpdateContext& ctx) const noexcept override {
35 * return state.sinceLastSpawn() >= waveInterval_
36 * && pool.inactiveCount >= amount;
37 * }
38 *
39 * void onCommit(SpawnRuleState& state, size_t count) const override {
40 * state.setSinceLastSpawn(0.0f);
41 * }
42 * };
43 * ```
44 *
45 * @see TimerSpawnCondition
46 * @see SpawnRule
47 * @see SpawnScheduler
48 */
50
51 public:
52
53 /**
54 * @brief Virtual destructor for proper polymorphic cleanup.
55 */
56 virtual ~SpawnCondition() = default;
57
58 /**
59 * @brief Evaluates whether the spawn condition is satisfied.
60 *
61 * @details Called by SpawnRule::evaluate() to determine if spawning
62 * should occur. The implementation should check all required conditions
63 * (time elapsed, pool capacity, game state, etc.).
64 *
65 * @param requestedAmount The number of entities requested to spawn.
66 * @param spawnState The rule's current runtime state.
67 * @param poolSnapshot Snapshot of the pool's current capacity.
68 * @param updateContext The current frame's context.
69 *
70 * @return true if spawning should occur, false otherwise.
71 */
72 [[nodiscard]] virtual bool isSatisfied(
73 const size_t requestedAmount,
74 const SpawnRuleState& spawnState,
77 ) const noexcept = 0;
78
79 /**
80 * @brief Called after a successful spawn to update condition state.
81 *
82 * @details Override this method to reset timers, increment counters,
83 * or perform other state updates after spawning completes.
84 *
85 * The default implementation is a no-op.
86 *
87 * @param spawnRuleState The rule's runtime state to update.
88 * @param spawnAmount The number of entities that were spawned.
89 */
90 virtual void onCommit(
91 SpawnRuleState& spawnRuleState,
92 const size_t spawnAmount
93 ) const {
94 // noop
95 }
96
97 /**
98 * @brief Called when the spawn system is reset.
99 *
100 * @details Override to reset condition state (e.g., timers, counters).
101 *
102 * @param spawnRuleState The rule's runtime state to reset.
103 */
104 virtual void onReset(
105 SpawnRuleState& spawnRuleState
106 ) const noexcept = 0;
107
108
109 };
110
111}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.