R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
Projectile.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** RTYPE
4** File description:
5** Projectile
6*/
7
8#pragma once
9
10#include <cstdint>
11#include "IComponent.hpp"
12
13namespace ecs {
21 class Projectile : public IComponent {
22 public:
30 Projectile(float damage, float lifetime, std::uint32_t ownerId, bool friendly)
31 : _damage(damage), _lifetime(lifetime), _ownerId(ownerId), _friendly(friendly) {}
32 ~Projectile() override = default;
33
38 [[nodiscard]] float getDamage() const { return _damage; }
39
44 [[nodiscard]] float getLifetime() const { return _lifetime; }
45
50 [[nodiscard]] std::uint32_t getOwnerId() const { return _ownerId; }
51
56 [[nodiscard]] bool isFriendly() const { return _friendly; }
57
62 void setDamage(float damage) { _damage = damage; }
63
68 void setLifetime(float lifetime) { _lifetime = lifetime; }
69
74 void setOwnerId(std::uint32_t ownerId) { _ownerId = ownerId; }
75
80 void setFriendly(bool friendly) { _friendly = friendly; }
81
86 ComponentType getType() const override { return getComponentType<Projectile>(); }
87
88 private:
89 float _damage;
90 float _lifetime;
91 std::uint32_t _ownerId;
92 bool _friendly;
93 };
94} // namespace ecs
Base interface for all ECS components.
Component for projectile entities (bullets, missiles, etc.).
void setLifetime(float lifetime)
Set remaining lifetime.
bool isFriendly() const
Check if projectile is friendly.
float _lifetime
Remaining lifetime in seconds.
void setDamage(float damage)
Set damage value.
void setFriendly(bool friendly)
Set friendly status.
float _damage
Damage dealt on impact.
std::uint32_t getOwnerId() const
Get owner entity ID.
std::uint32_t _ownerId
Entity ID of the shooter.
float getLifetime() const
Get remaining lifetime.
ComponentType getType() const override
Get the component type ID.
Projectile(float damage, float lifetime, std::uint32_t ownerId, bool friendly)
Constructor with projectile parameters.
void setOwnerId(std::uint32_t ownerId)
Set owner entity ID.
float getDamage() const
Get damage value.
bool _friendly
Team affiliation (true=friendly, false=enemy)
~Projectile() override=default
Maximum number of distinct component types supported by the Registry.
Definition GameLogic.hpp:26
std::size_t ComponentType
Type alias for component identification.