R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
Collectible.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** RTYPE
4** File description:
5** Collectible - Component for pickup items
6*/
7
8#pragma once
9
10#include "Buff.hpp"
11#include "IComponent.hpp"
12
13namespace ecs {
14
19 enum class CollectibleType {
20 PowerUp,
21 Upgrade,
23 Score
24 };
25
33 class Collectible : public IComponent {
34 public:
41 Collectible(BuffType buffType, float duration, float value)
42 : _type(duration > 0.0f ? CollectibleType::PowerUp : CollectibleType::Upgrade),
43 _buffType(buffType),
44 _duration(duration),
45 _value(value),
47 _scoreValue(0) {}
48
53 explicit Collectible(int healthRestore)
55 _buffType(BuffType::SpeedBoost), // Unused
56 _duration(0.0f),
57 _value(0.0f),
58 _healthRestore(healthRestore),
59 _scoreValue(0) {}
60
66 Collectible(int scoreValue, bool isScoreType)
68 _buffType(BuffType::SpeedBoost), // Unused
69 _duration(0.0f),
70 _value(0.0f),
72 _scoreValue(scoreValue) {
73 (void)isScoreType; // Unused, just for overload resolution
74 }
75
76 ~Collectible() override = default;
77
83
88 BuffType getBuffType() const { return _buffType; }
89
94 float getDuration() const { return _duration; }
95
100 float getValue() const { return _value; }
101
106 int getHealthRestore() const { return _healthRestore; }
107
112 int getScoreValue() const { return _scoreValue; }
113
118 bool grantsBuff() const {
120 }
121
127
132 bool awardsScore() const { return _type == CollectibleType::Score; }
133
138 ComponentType getType() const override { return getComponentType<Collectible>(); }
139
140 private:
143 float _duration;
144 float _value;
147 };
148
149} // namespace ecs
Component for items that can be picked up by players.
float _duration
Buff duration.
CollectibleType getCollectibleType() const
Get collectible type.
bool grantsBuff() const
Check if this grants a buff.
bool awardsScore() const
Check if this awards score.
Collectible(int scoreValue, bool isScoreType)
Constructor for score pickup.
bool restoresHealth() const
Check if this restores health.
CollectibleType _type
Type of collectible.
float getDuration() const
Get buff duration.
Collectible(int healthRestore)
Constructor for health pack.
~Collectible() override=default
BuffType _buffType
Buff granted (if applicable)
int _healthRestore
Health restored (if health pack)
Collectible(BuffType buffType, float duration, float value)
Constructor for buff-granting collectible.
int _scoreValue
Score points (if score pickup)
BuffType getBuffType() const
Get buff type (if applicable)
float _value
Buff value.
ComponentType getType() const override
Get the component type ID.
int getHealthRestore() const
Get health restore amount.
float getValue() const
Get buff value.
int getScoreValue() const
Get score value.
Base interface for all ECS components.
Maximum number of distinct component types supported by the Registry.
Definition GameLogic.hpp:26
CollectibleType
Types of collectible items.
@ PowerUp
Temporary power-up (buffs)
@ Score
Score bonus.
@ HealthPack
Restores health.
@ Upgrade
Permanent upgrade.
BuffType
Types of buffs that can be applied to entities.
Definition Buff.hpp:20
@ SpeedBoost
Increases movement speed.
std::size_t ComponentType
Type alias for component identification.