TargetedCommand Class
Abstract base class for commands targeting a specific GameObject. More...
Declaration
Derived Classes
| class | Aim2DCommand |
|
Command that applies 2D aiming direction to a GameObject. More... | |
| class | ShootCommand |
|
Command that triggers a shooting action on a GameObject. More... | |
| class | Move2DCommand |
|
Command that applies 2D directional movement to a GameObject. More... | |
| class | SteeringCommand |
|
Command that updates the heading direction of a GameObject. More... | |
Public Destructor Index
| ~TargetedCommand ()=default | |
|
Virtual destructor to ensure proper cleanup of derived classes. More... | |
Public Member Functions Index
| void | execute (helios::engine::ecs::GameObject gameObject) const noexcept=0 |
|
Executes the command on the specified GameObject. More... | |
| void | accept (helios::engine::ecs::GameObject gameObject, helios::engine::runtime::messaging::command::TargetedCommandDispatcher &dispatcher) const noexcept |
|
Accepts a dispatcher for type-safe command handling. More... | |
Description
Abstract base class for commands targeting a specific GameObject.
A TargetedCommand encapsulates a single game action (e.g., movement, attack) to be performed on a specific GameObject identified by its Guid.
Concrete commands are typically created by input systems and queued in a CommandBuffer. The buffer then executes them against the target GameObject during the command flush phase.
Commands support the Visitor pattern through accept(), enabling type-safe dispatch to specialized handlers without explicit type checking.
Example implementation: ```cpp class MoveCommand : public TargetedCommand { helios::math::vec3f direction_; float speed_; public: MoveCommand(helios::math::vec3f dir, float speed) : direction_(dir), speed_(speed) {}
void execute(helios::engine::ecs::GameObject obj) const noexcept override { auto* move = obj.get<Move2DComponent>(); if (move) move->setVelocity(direction_ * speed_); } }; ```
- See Also
WorldCommand for commands operating on the entire GameWorld
- See Also
TargetedCommandDispatcher for type-safe command dispatch
Definition at line 47 of file TargetedCommand.ixx.
Public Destructor
~TargetedCommand()
| virtual default |
Virtual destructor to ensure proper cleanup of derived classes.
Definition at line 54 of file TargetedCommand.ixx.
Public Member Functions
accept()
| inline noexcept virtual |
Accepts a dispatcher for type-safe command handling.
- Parameters
-
gameObject The target GameObject context.
dispatcher The dispatcher to delegate command handling to.
Override this method in derived commands to enable dispatch to specialized handlers. The default implementation is a no-op.
Definition at line 75 of file TargetedCommand.ixx.
execute()
| noexcept |
Executes the command on the specified GameObject.
- Parameters
-
gameObject The target GameObject to apply the command to.
Implementations must be noexcept. If execute() could fail, handle errors internally (e.g., log and skip).
Definition at line 64 of file TargetedCommand.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.