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

Component for items that can be picked up by players. More...

#include <Collectible.hpp>

Inheritance diagram for ecs::Collectible:
Inheritance graph
Collaboration diagram for ecs::Collectible:
Collaboration graph

Public Member Functions

 Collectible (BuffType buffType, float duration, float value)
 Constructor for buff-granting collectible.
 
 Collectible (int healthRestore)
 Constructor for health pack.
 
 Collectible (int scoreValue, bool isScoreType)
 Constructor for score pickup.
 
 ~Collectible () override=default
 
CollectibleType getCollectibleType () const
 Get collectible type.
 
BuffType getBuffType () const
 Get buff type (if applicable)
 
float getDuration () const
 Get buff duration.
 
float getValue () const
 Get buff value.
 
int getHealthRestore () const
 Get health restore amount.
 
int getScoreValue () const
 Get score value.
 
bool grantsBuff () const
 Check if this grants a buff.
 
bool restoresHealth () const
 Check if this restores health.
 
bool awardsScore () const
 Check if this awards score.
 
ComponentType getType () const override
 Get the component type ID.
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Private Attributes

CollectibleType _type
 Type of collectible.
 
BuffType _buffType
 Buff granted (if applicable)
 
float _duration
 Buff duration.
 
float _value
 Buff value.
 
int _healthRestore
 Health restored (if health pack)
 
int _scoreValue
 Score points (if score pickup)
 

Detailed Description

Component for items that can be picked up by players.

Defines pickup items with their effects when collected. Can grant buffs, restore health, or award points.

Definition at line 33 of file Collectible.hpp.

Constructor & Destructor Documentation

◆ Collectible() [1/3]

ecs::Collectible::Collectible ( BuffType  buffType,
float  duration,
float  value 
)
inline

Constructor for buff-granting collectible.

Parameters
buffTypeType of buff to grant
durationDuration of buff (0.0f for permanent)
valueBuff value/multiplier

Definition at line 41 of file Collectible.hpp.

◆ Collectible() [2/3]

ecs::Collectible::Collectible ( int  healthRestore)
inlineexplicit

Constructor for health pack.

Parameters
healthRestoreAmount of health to restore

Definition at line 53 of file Collectible.hpp.

◆ Collectible() [3/3]

ecs::Collectible::Collectible ( int  scoreValue,
bool  isScoreType 
)
inline

Constructor for score pickup.

Parameters
scoreValueScore points awarded
isScoreTypeDummy parameter to differentiate from health constructor

Definition at line 66 of file Collectible.hpp.

◆ ~Collectible()

ecs::Collectible::~Collectible ( )
overridedefault

Member Function Documentation

◆ awardsScore()

bool ecs::Collectible::awardsScore ( ) const
inline

Check if this awards score.

Returns
True if collectible awards score

Definition at line 132 of file Collectible.hpp.

References _type, and ecs::Score.

Referenced by ecs::CollisionSystem::handlePickup().

◆ getBuffType()

BuffType ecs::Collectible::getBuffType ( ) const
inline

Get buff type (if applicable)

Returns
BuffType Type of buff granted

Definition at line 88 of file Collectible.hpp.

References _buffType.

Referenced by ecs::CollisionSystem::handlePickup().

◆ getCollectibleType()

CollectibleType ecs::Collectible::getCollectibleType ( ) const
inline

Get collectible type.

Returns
CollectibleType Type of item

Definition at line 82 of file Collectible.hpp.

References _type.

◆ getDuration()

float ecs::Collectible::getDuration ( ) const
inline

Get buff duration.

Returns
float Duration in seconds

Definition at line 94 of file Collectible.hpp.

References _duration.

Referenced by ecs::CollisionSystem::handlePickup().

◆ getHealthRestore()

int ecs::Collectible::getHealthRestore ( ) const
inline

Get health restore amount.

Returns
int Health points restored

Definition at line 106 of file Collectible.hpp.

References _healthRestore.

Referenced by ecs::CollisionSystem::handlePickup().

◆ getScoreValue()

int ecs::Collectible::getScoreValue ( ) const
inline

Get score value.

Returns
int Score points awarded

Definition at line 112 of file Collectible.hpp.

References _scoreValue.

Referenced by ecs::CollisionSystem::handlePickup().

◆ getType()

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

Get the component type ID.

Returns
ComponentType Unique ID for Collectible component

Implements ecs::IComponent.

Definition at line 138 of file Collectible.hpp.

◆ getValue()

float ecs::Collectible::getValue ( ) const
inline

Get buff value.

Returns
float Buff value/multiplier

Definition at line 100 of file Collectible.hpp.

References _value.

Referenced by ecs::CollisionSystem::handlePickup().

◆ grantsBuff()

bool ecs::Collectible::grantsBuff ( ) const
inline

Check if this grants a buff.

Returns
True if collectible grants a buff

Definition at line 118 of file Collectible.hpp.

References _type, ecs::PowerUp, and ecs::Upgrade.

Referenced by ecs::CollisionSystem::handlePickup().

◆ restoresHealth()

bool ecs::Collectible::restoresHealth ( ) const
inline

Check if this restores health.

Returns
True if collectible restores health

Definition at line 126 of file Collectible.hpp.

References _type, and ecs::HealthPack.

Referenced by ecs::CollisionSystem::handlePickup().

Member Data Documentation

◆ _buffType

BuffType ecs::Collectible::_buffType
private

Buff granted (if applicable)

Definition at line 142 of file Collectible.hpp.

Referenced by getBuffType().

◆ _duration

float ecs::Collectible::_duration
private

Buff duration.

Definition at line 143 of file Collectible.hpp.

Referenced by getDuration().

◆ _healthRestore

int ecs::Collectible::_healthRestore
private

Health restored (if health pack)

Definition at line 145 of file Collectible.hpp.

Referenced by getHealthRestore().

◆ _scoreValue

int ecs::Collectible::_scoreValue
private

Score points (if score pickup)

Definition at line 146 of file Collectible.hpp.

Referenced by getScoreValue().

◆ _type

CollectibleType ecs::Collectible::_type
private

Type of collectible.

Definition at line 141 of file Collectible.hpp.

Referenced by awardsScore(), getCollectibleType(), grantsBuff(), and restoresHealth().

◆ _value

float ecs::Collectible::_value
private

Buff value.

Definition at line 144 of file Collectible.hpp.

Referenced by getValue().


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