Skip to main content

SpawnCommand.ixx File

Command for requesting GameObject spawning from a pool. 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...

namespacecommands

Commands for spawn and despawn operations. More...

Classes Index

classSpawnCommand

Command to request spawning of GameObjects from a pool. More...

Description

Command for requesting GameObject spawning from a pool.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SpawnCommand.ixx
3 * @brief Command for requesting GameObject spawning from a pool.
4 */
5module;
6
7#include <cassert>
8#include <cinttypes>
9#include <expected>
10
11export module helios.engine.runtime.spawn.commands.SpawnCommand;
12
13import helios.engine.runtime.spawn.SpawnContext;
14
15import helios.engine.runtime.messaging.command.WorldCommand;
16import helios.engine.runtime.messaging.command.WorldCommandDispatcher;
17
18import helios.math.types;
19
20import helios.engine.core.data.SpawnProfileId;
21
22
24
25 /**
26 * @brief Command to request spawning of GameObjects from a pool.
27 *
28 * @details SpawnCommand is a WorldCommand that requests the activation of
29 * GameObjects from a specific pool. The command carries a spawn budget
30 * indicating how many objects should be spawned.
31 *
32 * The command itself does not execute spawning directly. Instead, it is
33 * dispatched to a SpawnCommandDispatcher which forwards the command to the
34 * appropriate SpawnManager for deferred processing.
35 *
36 * @see SpawnCommandDispatcher
37 * @see SpawnManager
38 * @see GameObjectSpawnSystem
39 */
41
42 /**
43 * @brief The number of GameObjects to spawn.
44 */
45 const size_t spawnBudget_;
46
47
49
51
52 public:
53
54
55 explicit SpawnCommand(
58 const size_t spawnBudget = 1
59 ) :
60 spawnProfileId_(spawnProfileId),
61 spawnContext_(spawnContext),
62 spawnBudget_(spawnBudget)
63 {}
64
65 /**
66 * @brief Direct execution is a no-op; dispatching is required.
67 *
68 * @param gameWorld The game world (unused).
69 */
70 void execute(helios::engine::runtime::world::GameWorld& gameWorld) const noexcept override {
71 assert(false && "Unexpected execute() on SpawnCommand");
72 }
73
74 /**
75 * @brief Accepts a dispatcher for command routing.
76 *
77 * @param gameWorld The game world.
78 * @param dispatcher The dispatcher to route this command to.
79 */
80 virtual void accept(
83
84 dispatcher.dispatch(gameWorld, *this);
85
86 };
87
88 /**
89 * @brief Returns the target pool ID.
90 *
91 * @return The GameObjectPoolId to spawn from.
92 */
94 return spawnProfileId_;
95 }
96
97 /**
98 * @brief Returns the spawn budget.
99 *
100 * @return The number of objects to spawn.
101 */
102 [[nodiscard]] size_t spawnBudget() const noexcept {
103 return spawnBudget_;
104 }
105
106 /**
107 * @brief Returns the spawn context.
108 *
109 * @return The spawn context of this command.
110 */
112 return spawnContext_;
113 }
114 };
115
116
117}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.