Skip to main content

SchedulerConfig.ixx File

Fluent configuration for adding spawn rules to a scheduler. 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
namespaceconfigs

Classes Index

classSchedulerConfig

Fluent configuration for a single spawn rule. More...

Description

Fluent configuration for adding spawn rules to a scheduler.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SchedulerConfig.ixx
3 * @brief Fluent configuration for adding spawn rules to a scheduler.
4 */
5module;
6
7#include <memory>
8
9export module helios.engine.builder.spawnSystem.builders.configs.SchedulerConfig;
10
11import helios.engine.runtime.spawn.types.SpawnProfileId;
12import helios.engine.runtime.spawn.types.SpawnRuleId;
13
14import helios.engine.runtime.spawn.policy.SpawnRule;
15import helios.engine.runtime.spawn.policy.SpawnCondition;
16import helios.engine.runtime.spawn.policy.SpawnConditionAll;
17import helios.engine.runtime.spawn.policy.conditions;
18import helios.engine.runtime.spawn.policy.amount;
19
21
22 /**
23 * @brief Fluent configuration for a single spawn rule.
24 *
25 * Provides convenience methods for assembling a SpawnRule
26 * from condition and amount providers.
27 */
29
30 /**
31 * @brief Profile this rule is bound to.
32 */
34
35 /**
36 * @brief Unique identifier for the rule.
37 */
39
40 /**
41 * @brief Condition determining when to spawn.
42 */
43 std::unique_ptr<const helios::engine::runtime::spawn::policy::SpawnCondition> condition_;
44
45 /**
46 * @brief Provider determining how many to spawn.
47 */
48 std::unique_ptr<const helios::engine::runtime::spawn::policy::amount::SpawnAmountProvider> amountProvider_;
49
50 public:
51
52 /**
53 * @brief Constructs a SchedulerConfig.
54 *
55 * @param profileId The spawn profile this rule targets.
56 * @param ruleId Unique identifier for this rule.
57 */
61 ) : profileId_(profileId), ruleId_(ruleId), condition_(nullptr), amountProvider_(nullptr) {}
62
63 /**
64 * @brief Sets a timer-based spawn condition.
65 *
66 * @param intervalSeconds Seconds between spawn evaluations.
67 *
68 * @return Reference to this config for chaining.
69 */
70 SchedulerConfig& timerCondition(const float intervalSeconds) {
71 condition_ = std::make_unique<
73 intervalSeconds
74 );
75 return *this;
76 }
77
78 /**
79 * @brief Sets a combined condition: timer + pool availability.
80 *
81 * @param intervalSeconds Seconds between spawn evaluations.
82 *
83 * @return Reference to this config for chaining.
84 */
85 SchedulerConfig& timerWithAvailabilityCondition(const float intervalSeconds) {
86 condition_ = std::make_unique<
88 std::make_unique<helios::engine::runtime::spawn::policy::conditions::TimerSpawnCondition>(intervalSeconds),
89 std::make_unique<helios::engine::runtime::spawn::policy::conditions::RequestedAmountIsAvailableCondition>()
90 );
91 return *this;
92 }
93
94 /**
95 * @brief Sets a custom spawn condition.
96 *
97 * @param customCondition Ownership is transferred.
98 *
99 * @return Reference to this config for chaining.
100 */
102 std::unique_ptr<const helios::engine::runtime::spawn::policy::SpawnCondition> customCondition
103 ) {
104 condition_ = std::move(customCondition);
105 return *this;
106 }
107
108 /**
109 * @brief Sets a fixed spawn amount.
110 *
111 * @param count Number of entities to spawn per trigger.
112 *
113 * @return Reference to this config for chaining.
114 */
115 SchedulerConfig& fixedAmount(const size_t count) {
116 amountProvider_ = std::make_unique<
118 return *this;
119 }
120
121 /**
122 * @brief Sets a custom amount provider.
123 *
124 * @param customProvider Ownership is transferred.
125 *
126 * @return Reference to this config for chaining.
127 */
129 std::unique_ptr<const helios::engine::runtime::spawn::policy::amount::SpawnAmountProvider> customProvider
130 ) {
131 amountProvider_ = std::move(customProvider);
132 return *this;
133 }
134
135 /**
136 * @brief Returns the profile ID for this rule.
137 *
138 * @return The spawn profile ID.
139 */
141 return profileId_;
142 }
143
144 /**
145 * @brief Builds and returns the configured SpawnRule.
146 *
147 * @return The assembled SpawnRule. Ownership is transferred to the caller.
148 */
149 [[nodiscard]] std::unique_ptr<helios::engine::runtime::spawn::policy::SpawnRule> build() {
150 return std::make_unique<helios::engine::runtime::spawn::policy::SpawnRule>(
151 std::move(condition_),
152 std::move(amountProvider_),
153 ruleId_
154 );
155 }
156 };
157
158}
159
160

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.