Skip to main content

SchedulerBuilder.ixx File

Builder for configuring SpawnSchedulers within the spawn system. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

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

namespacebuilder

Fluent builder pattern for constructing GameObjects. More...

namespacespawnSystem
namespacebuilders

Classes Index

classSchedulerBuilder

Builder for configuring and registering SpawnSchedulers. More...

Description

Builder for configuring SpawnSchedulers within the spawn system.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SchedulerBuilder.ixx
3 * @brief Builder for configuring SpawnSchedulers within the spawn system.
4 */
5module;
6
7#include <memory>
8#include <array>
9#include <utility>
10
11export module helios.engine.builder.spawnSystem.builders.SchedulerBuilder;
12
13import helios.engine.runtime.spawn.types.SpawnProfileId;
14import helios.engine.runtime.spawn.types.SpawnRuleId;
15import helios.engine.runtime.spawn.SpawnManager;
16import helios.engine.runtime.spawn.scheduling.SpawnScheduler;
17import helios.engine.runtime.spawn.scheduling.DefaultSpawnScheduler;
18import helios.engine.runtime.spawn.scheduling.CyclicSpawnScheduler;
19import helios.engine.builder.spawnSystem.builders.configs;
20
22
23 /**
24 * @brief Builder for configuring and registering SpawnSchedulers.
25 *
26 * Provides factory methods for creating default and cyclic
27 * schedulers, and adding rules to them via fluent SchedulerConfig.
28 */
30
31 /**
32 * @brief The spawn manager to register schedulers with.
33 */
35
36 /**
37 * @brief Adds rules from a parameter pack to a scheduler.
38 *
39 * @tparam Scheduler The scheduler type.
40 * @tparam Configs The SchedulerConfig parameter pack.
41 * @param scheduler The scheduler to add rules to.
42 * @param configs The rule configurations.
43 */
44 template<typename Scheduler, typename... Configs>
45 void addRules(Scheduler& scheduler, Configs&&... configs) {
46 (scheduler.addRule(
47 configs.profileId(), configs.build()
48 ), ...);
49 }
50
51 public:
52
53 /**
54 * @brief Constructs a SchedulerBuilder.
55 *
56 * @param spawnManager The spawn manager to register schedulers with.
57 */
60 ) : spawnManager_(spawnManager) {}
61
62 /**
63 * @brief Creates and registers a DefaultSpawnScheduler with the given rules.
64 *
65 * @tparam Configs SchedulerConfig parameter pack.
66 * @param configs Rule configurations to add.
67 */
68 template<typename... Configs>
69 void defaultScheduler(Configs&&... configs) {
70 auto scheduler = std::make_unique<
72
73 addRules(*scheduler, std::forward<Configs>(configs)...);
74
75 spawnManager_.addScheduler(std::move(scheduler));
76 }
77
78 /**
79 * @brief Creates and registers a CyclicSpawnScheduler with the given rules.
80 *
81 * The number of rules determines the template parameter N.
82 *
83 * @tparam Configs SchedulerConfig parameter pack.
84 * @param configs Rule configurations to add in cycle order.
85 */
86 template<typename... Configs>
87 void cyclicScheduler(Configs&&... configs) {
88 constexpr std::size_t N = sizeof...(Configs);
89
90 auto scheduler = std::make_unique<
92
93 addRules(*scheduler, std::forward<Configs>(configs)...);
94
95 spawnManager_.addScheduler(std::move(scheduler));
96 }
97
98 /**
99 * @brief Registers a custom scheduler directly.
100 *
101 * @param scheduler Ownership is transferred.
102 */
104 std::unique_ptr<helios::engine::runtime::spawn::scheduling::SpawnScheduler> scheduler
105 ) {
106 spawnManager_.addScheduler(std::move(scheduler));
107 }
108 };
109
110}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.