Skip to main content

TargetedCommand Class

Abstract base class for commands targeting a specific GameObject. More...

Declaration

class helios::engine::runtime::messaging::command::TargetedCommand { ... }

Derived Classes

classAim2DCommand

Command that applies 2D aiming direction to a GameObject. More...

classShootCommand

Command that triggers a shooting action on a GameObject. More...

classMove2DCommand

Command that applies 2D directional movement to a GameObject. More...

classSteeringCommand

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

voidexecute (helios::engine::ecs::GameObject gameObject) const noexcept=0

Executes the command on the specified GameObject. More...

voidaccept (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 helios::engine::runtime::messaging::command::TargetedCommand::~TargetedCommand ()
virtual default

Virtual destructor to ensure proper cleanup of derived classes.

Definition at line 54 of file TargetedCommand.ixx.

Public Member Functions

accept()

virtual void helios::engine::runtime::messaging::command::TargetedCommand::accept (helios::engine::ecs::GameObject gameObject, helios::engine::runtime::messaging::command::TargetedCommandDispatcher & dispatcher)
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.

75 virtual void accept(
78 // no-op by default
79 }

execute()

virtual void helios::engine::runtime::messaging::command::TargetedCommand::execute (helios::engine::ecs::GameObject gameObject)
noexcept

Executes the command on the specified GameObject.

Parameters
gameObject

The target GameObject to apply the command to.

info

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.