Skip to main content

DefaultRuleProcessor.ixx File

Default implementation of RuleProcessor for spawn rule evaluation. 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...

namespacescheduling

Spawn scheduling and plan management. More...

Classes Index

classDefaultRuleProcessor

Default implementation of RuleProcessor. More...

Description

Default implementation of RuleProcessor for spawn rule evaluation.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file DefaultRuleProcessor.ixx
3 * @brief Default implementation of RuleProcessor for spawn rule evaluation.
4 */
5module;
6
7#include <cassert>
8#include <queue>
9
10
11export module helios.engine.runtime.spawn.scheduling.DefaultRuleProcessor;
12
13import helios.engine.runtime.spawn.scheduling.RuleProcessor;
14
15import helios.engine.runtime.world.UpdateContext;
16import helios.engine.runtime.spawn.SpawnManager;
17import helios.engine.runtime.spawn.types.SpawnContext;
18import helios.engine.runtime.world.GameWorld;
19import helios.engine.runtime.spawn.scheduling.SpawnPlan;
20import helios.engine.runtime.spawn.scheduling.ScheduledSpawnPlan;
21import helios.engine.runtime.spawn.types;
22import helios.engine.runtime.spawn.policy.SpawnRule;
23import helios.engine.runtime.spawn.policy.SpawnRuleState;
24import helios.engine.runtime.pooling.GameObjectPoolManager;
25
29
31
32 /**
33 * @brief Default implementation of RuleProcessor.
34 *
35 * @details DefaultRuleProcessor provides the standard rule processing logic:
36 *
37 * 1 Retrieves the SpawnProfile from the SpawnManager
38 * 2 Gets a pool snapshot from the GameObjectPoolManager
39 * 3 Updates the rule state with the current delta time
40 * 4 Evaluates the rule and returns the resulting SpawnPlan
41 *
42 * This processor is used by both DefaultSpawnScheduler and CyclicSpawnScheduler.
43 *
44 * @see RuleProcessor
45 * @see DefaultSpawnScheduler
46 * @see CyclicSpawnScheduler
47 */
49
50 public:
51
52 /**
53 * @brief Processes a spawn rule using standard evaluation logic.
54 *
55 * @details Retrieves pool state, updates the rule's timer/state,
56 * and evaluates the rule to produce a spawn plan.
57 *
58 * @param gameWorld The game world where the rule is processed.
59 * @param updateContext Current frame context.
60 * @param spawnContext Context for the spawn operation.
61 * @param spawnProfileId Profile ID to look up spawn configuration.
62 * @param spawnRule The rule to evaluate.
63 * @param spawnRuleState Mutable state tracking timers and counts.
64 *
65 * @return SpawnPlan indicating how many entities to spawn.
66 */
68 const world::GameWorld& gameWorld,
69 const UpdateContext& updateContext,
70 const SpawnContext& spawnContext,
71 const SpawnProfileId spawnProfileId,
72 SpawnRule& spawnRule,
73 SpawnRuleState& spawnRuleState
74 ) noexcept override {
75 const auto* poolManager = gameWorld.tryManager<helios::engine::runtime::pooling::GameObjectPoolManager>();
76 const auto* spawnManager = gameWorld.tryManager<helios::engine::runtime::spawn::SpawnManager>();
77
78 const auto* spawnProfile = spawnManager->spawnProfile(spawnProfileId);
79 assert(spawnProfile != nullptr);
80
81 const auto& [gameObjectPoolId, _, __] = *spawnProfile;
82
83 const auto poolSnapshot = poolManager->poolSnapshot(gameObjectPoolId);
84
85 // tick the rule state
86 spawnRuleState.update(updateContext.deltaTime());
87
88 return spawnRule.evaluate(
89 gameObjectPoolId, poolSnapshot,
90 spawnRuleState,
91 gameWorld,
92 updateContext
93 );
94 }
95
96 };
97
98}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.