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

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.