Fluent configuration for a complete spawn pool with profiles and scheduling. More...
Namespaces Index
Classes Index
Description
Fluent configuration for a complete spawn pool with profiles and scheduling.
This file contains SpawnSystemConfigurator, SpawnRuleConfig, SpawnProfileConfig, and SpawnPoolConfig in a single translation unit. These classes form a cyclic done()-chaining dependency (Rule → Profile → Pool → Configurator → Pool) so we will not split them in separate files.
File Listing
The file content with the documentation metadata removed is:
15export module helios.engine.builder.spawnSystem.builders.configs.SpawnPoolConfig;
17import helios.engine.ecs;
19import helios.engine.runtime.pooling.types.GameObjectPoolId;
20import helios.engine.common.types.PrefabId;
22import helios.engine.runtime.pooling;
24import helios.engine.runtime.spawn;
25import helios.engine.runtime.spawn.types;
66 ) noexcept : poolManager_(poolManager), spawnManager_(spawnManager) {}
105 std::unique_ptr<const helios::engine::runtime::spawn::policy::SpawnCondition> condition_;
110 std::unique_ptr<const helios::engine::runtime::spawn::policy::amount::SpawnAmountProvider> amountProvider_;
123 ) : parent_(parent), ruleId_(ruleId),
124 condition_(nullptr), amountProvider_(nullptr) {}
134 condition_ = std::make_unique<
148 condition_ = std::make_unique<
150 std::make_unique<helios::engine::runtime::spawn::policy::conditions::TimerSpawnCondition>(intervalSeconds),
151 std::make_unique<helios::engine::runtime::spawn::policy::conditions::RequestedAmountIsAvailableCondition>()
164 std::unique_ptr<const helios::engine::runtime::spawn::policy::SpawnCondition> customCondition
166 condition_ = std::move(customCondition);
178 amountProvider_ = std::make_unique<
191 std::unique_ptr<const helios::engine::runtime::spawn::policy::amount::SpawnAmountProvider> customProvider
193 amountProvider_ = std::move(customProvider);
202 [[nodiscard]] std::unique_ptr<helios::engine::runtime::spawn::policy::SpawnRule> build() {
203 return std::make_unique<helios::engine::runtime::spawn::policy::SpawnRule>(
204 std::move(condition_),
205 std::move(amountProvider_),
250 std::unique_ptr<helios::engine::runtime::spawn::behavior::SpawnPlacer> placer_;
255 std::unique_ptr<helios::engine::runtime::spawn::behavior::SpawnInitializer> initializer_;
260 std::vector<std::unique_ptr<SpawnRuleConfig>> rules_;
277 ) : parent_(parent), spawnManager_(spawnManager),
278 profileId_(profileId), poolId_(poolId) {}
286 placer_ = std::make_unique<
288 initializer_ = std::make_unique<
299 placer_ = std::make_unique<
316 placer_ = std::make_unique<
329 std::unique_ptr<helios::engine::runtime::spawn::behavior::SpawnPlacer> customPlacer
331 placer_ = std::move(customPlacer);
341 initializer_ = std::make_unique<
355 initializer_ = std::make_unique<
368 std::unique_ptr<helios::engine::runtime::spawn::behavior::SpawnInitializer> customInitializer
370 initializer_ = std::move(customInitializer);
382 rules_.push_back(std::make_unique<SpawnRuleConfig>(*this, ruleId));
383 return *rules_.back();
401 std::unique_ptr<helios::engine::runtime::spawn::policy::SpawnRule>>>
403 spawnManager_.addSpawnProfile(
405 std::make_unique<SpawnProfile>(
407 .gameObjectPoolId = poolId_,
408 .spawnPlacer = std::move(placer_),
409 .spawnInitializer = std::move(initializer_)
415 std::unique_ptr<helios::engine::runtime::spawn::policy::SpawnRule>>> result;
416 for (auto& rule : rules_) {
417 result.emplace_back(profileId_, rule->build());
472 std::vector<std::unique_ptr<SpawnProfileConfig>> profiles_;
493 ) : poolManager_(poolManager), spawnManager_(spawnManager),
494 poolId_(poolId), prefabId_(prefabId), size_(poolSize) {}
505 profiles_.push_back(std::make_unique<SpawnProfileConfig>(
506 *this, spawnManager_, profileId, poolId_
508 return *profiles_.back();
521 commitProfiles(false);
554 commitProfiles(true);
569 template<std::size_t N>
573 auto scheduler = std::make_unique<
576 for (auto& profileConfig : profiles_) {
577 auto rules = profileConfig->commit();
578 for (auto& [profileId, rule] : rules) {
579 scheduler->addRule(profileId, std::move(rule));
583 spawnManager_.addScheduler(std::move(scheduler));
595 std::make_unique<helios::engine::runtime::pooling::GameObjectPoolConfig>(
596 poolId_, prefabId_, size_
606 void commitProfiles(bool skipSchedulers) {
607 for (auto& profileConfig : profiles_) {
608 auto rules = profileConfig->commit();
609 if (!skipSchedulers && !rules.empty()) {
610 auto scheduler = std::make_unique<
612 for (auto& [profileId, rule] : rules) {
613 scheduler->addRule(profileId, std::move(rule));
636 return SpawnPoolConfig{poolManager_, spawnManager_, poolId, prefabId, poolSize};
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.