DefaultSpawnScheduler.ixx File
Default scheduler that evaluates all spawn rules each frame. More...
Included Headers
#include <cassert>
#include <memory>
#include <queue>
#include <ranges>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <helios.engine.runtime.pooling.GameObjectPoolManager>
#include <helios.engine.runtime.spawn.policy.SpawnRuleState>
#include <helios.engine.runtime.spawn.policy.SpawnRule>
#include <helios.engine.runtime.spawn.types>
#include <helios.engine.runtime.spawn.scheduling.ScheduledSpawnPlan>
#include <helios.engine.runtime.spawn.scheduling.SpawnPlan>
#include <helios.engine.runtime.world.GameWorld>
#include <helios.engine.runtime.spawn.types.SpawnContext>
#include <helios.engine.runtime.world.UpdateContext>
#include <helios.engine.runtime.spawn.scheduling.DefaultRuleProcessor>
#include <helios.engine.runtime.spawn.SpawnManager>
#include <helios.engine.runtime.spawn.scheduling.SpawnScheduler>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | runtime |
|
Runtime infrastructure for game execution and lifecycle orchestration. More... | |
| namespace | spawn |
|
Entity spawning infrastructure for the helios engine. More... | |
| namespace | scheduling |
|
Spawn scheduling and plan management. More... | |
Classes Index
| class | DefaultSpawnScheduler |
|
Scheduler that evaluates spawn rules and produces spawn plans. More... | |
Description
Default scheduler that evaluates all spawn rules each frame.
File Listing
The file content with the documentation metadata removed is:
31using namespace helios::engine::runtime::spawn::types;
32using namespace helios::engine::runtime::world;
33export namespace helios::engine::runtime::spawn::scheduling {
67 class DefaultSpawnScheduler : public SpawnScheduler {
74 std::unordered_map<helios::engine::runtime::spawn::types::SpawnProfileId,
98 DefaultSpawnScheduler(const size_t initialSpanPlanSize = 20) {
99 scheduledSpawnPlans_.reserve(initialSpanPlanSize);
113 const GameWorld& gameWorld,
114 const UpdateContext& updateContext,
115 const SpawnContext& spawnContext) noexcept override{
117 scheduledSpawnPlans_.clear();
119 for (auto& [spawnProfileId, rule] : spawnRules_) {
121 auto spawnPlan = ruleProcessor_.processRule(
123 spawnRuleStates_[rule->spawnRuleId()]
127 scheduledSpawnPlans_.push_back({
147 const helios::engine::runtime::spawn::types::SpawnProfileId spawnProfileId,
150 assert(!spawnRules_.contains(spawnProfileId) && "Duplicate SpawnProfile entry");
151 assert(!spawnRuleStates_.contains(spawnRule->spawnRuleId()) && "Duplicate SpawnRuleId entry");
153 spawnRuleStates_.try_emplace(spawnRule->spawnRuleId());
154 spawnRules_.try_emplace(spawnProfileId, std::move(spawnRule));
169 void commit(const helios::engine::runtime::spawn::types::SpawnRuleId spawnRuleId, const size_t spawnCount) noexcept override{
171 for (auto& spawnRule : spawnRules_ | std::views::values) {
175 auto it = spawnRuleStates_.find(spawnRuleId);
176 assert(it != spawnRuleStates_.end() && "Unexpected missing spawnRuleState");
189 for (auto& spawnRule : spawnRules_ | std::views::values) {
191 auto it = spawnRuleStates_.find(spawnRule->spawnRuleId());
192 assert(it != spawnRuleStates_.end() && "Unexpected missing spawnRuleState");
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.