R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::Velocity Class Reference

Component representing movement direction and speed. More...

#include <Velocity.hpp>

Inheritance diagram for ecs::Velocity:
Inheritance graph
Collaboration diagram for ecs::Velocity:
Collaboration graph

Classes

struct  Vector2
 2D vector for direction. More...
 

Public Member Functions

 Velocity (float dirX, float dirY, float speed)
 Constructor with direction and speed.
 
 ~Velocity () override=default
 
Vector2 getDirection () const
 Get the direction vector.
 
float getSpeed () const
 Get the movement speed.
 
float getBaseSpeed () const
 Get the base movement speed (before buffs).
 
void setDirection (float dirX, float dirY)
 Set the direction vector.
 
void setSpeed (float speed)
 Set the movement speed.
 
ComponentType getType () const override
 Get the component type ID.
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Private Attributes

Vector2 _direction
 Movement direction vector.
 
float _speed
 Movement speed in units per second.
 
float _baseSpeed
 Base speed (before buffs)
 

Detailed Description

Component representing movement direction and speed.

This component stores the velocity data for moving entities. Direction should typically be normalized, and speed determines magnitude.

Definition at line 20 of file Velocity.hpp.

Constructor & Destructor Documentation

◆ Velocity()

ecs::Velocity::Velocity ( float  dirX,
float  dirY,
float  speed 
)
inline

Constructor with direction and speed.

Parameters
dirXX direction component
dirYY direction component
speedMovement speed in units per second

Definition at line 37 of file Velocity.hpp.

◆ ~Velocity()

ecs::Velocity::~Velocity ( )
overridedefault

Member Function Documentation

◆ getBaseSpeed()

float ecs::Velocity::getBaseSpeed ( ) const
inline

Get the base movement speed (before buffs).

Returns
float The base speed value

Definition at line 57 of file Velocity.hpp.

References _baseSpeed.

Referenced by ecs::BuffSystem::_applySpeedBoost().

◆ getDirection()

Vector2 ecs::Velocity::getDirection ( ) const
inline

Get the direction vector.

Returns
Vector2 The movement direction.

Definition at line 45 of file Velocity.hpp.

References _direction.

Referenced by scripting::bindings::bindComponents(), ecs::WeaponSystem::createProjectile(), and server::GameStateSerializer::serializeEntity().

◆ getSpeed()

float ecs::Velocity::getSpeed ( ) const
inline

Get the movement speed.

Returns
float The speed value in units per second.

Definition at line 51 of file Velocity.hpp.

References _speed.

Referenced by server::GameLogic::_applyPlayerInput(), scripting::bindings::bindComponents(), ecs::WeaponSystem::createProjectile(), and server::GameStateSerializer::serializeEntity().

◆ getType()

ComponentType ecs::Velocity::getType ( ) const
inlineoverridevirtual

Get the component type ID.

Returns
ComponentType Unique ID for Velocity component.

Implements ecs::IComponent.

Definition at line 79 of file Velocity.hpp.

◆ setDirection()

void ecs::Velocity::setDirection ( float  dirX,
float  dirY 
)
inline

Set the direction vector.

Parameters
dirXNew X direction
dirYNew Y direction

Definition at line 64 of file Velocity.hpp.

References _direction, ecs::Velocity::Vector2::x, and ecs::Velocity::Vector2::y.

Referenced by server::GameLogic::_applyPlayerInput(), and scripting::bindings::bindComponents().

◆ setSpeed()

void ecs::Velocity::setSpeed ( float  speed)
inline

Set the movement speed.

Parameters
speedNew speed value in units per second

Definition at line 73 of file Velocity.hpp.

References _speed.

Referenced by ecs::BuffSystem::_applySpeedBoost(), and scripting::bindings::bindComponents().

Member Data Documentation

◆ _baseSpeed

float ecs::Velocity::_baseSpeed
private

Base speed (before buffs)

Definition at line 84 of file Velocity.hpp.

Referenced by getBaseSpeed().

◆ _direction

Vector2 ecs::Velocity::_direction
private

Movement direction vector.

Definition at line 82 of file Velocity.hpp.

Referenced by getDirection(), and setDirection().

◆ _speed

float ecs::Velocity::_speed
private

Movement speed in units per second.

Definition at line 83 of file Velocity.hpp.

Referenced by getSpeed(), and setSpeed().


The documentation for this class was generated from the following file: