![]() |
R-Type
2
Doom but in better
|
The SoundLib class manages sound effects and interactions with ECS entities. More...
#include <SoundLib.hpp>
Public Member Functions | |
SoundLib (const std::uint32_t entityId=0) | |
Default constructor. | |
SoundLib (const std::unordered_map< std::type_index, std::vector< std::any > > &ecsEntities) | |
Constructor with ECS entities. | |
SoundLib (const std::uint32_t entityId, const std::unordered_map< std::type_index, std::vector< std::any > > &ecsEntities) | |
Constructor with entity ID and ECS entities. : | |
void | updateSoundLib (const std::unordered_map< std::type_index, std::vector< std::any > > &ecsEntities) |
Updates the sound library with the provided ECS entities. | |
void | setPlay (const bool play) |
Enables or disables sound playback. | |
const bool | isEnabled () const |
Checks if sound playback is enabled. | |
void | shootSound () |
Plays the shooting sound effect. | |
void | damageSound () |
Plays the damage sound effect. | |
void | deadSound () |
Plays the dead sound effect. | |
void | buttonSound () |
Plays the button interaction sound effect. | |
void | gameOverSound () |
Plays the game over sound effect. | |
void | winSound () |
Plays the game win sound effect. | |
![]() | |
EntityNode (const size_t entityId=0) | |
virtual | ~EntityNode ()=default |
virtual size_t | getEntityNodeId () const |
Additional Inherited Members | |
![]() | |
size_t | _entityID |
The SoundLib class manages sound effects and interactions with ECS entities.
This class provides functionality for handling different types of sounds such as shooting, damage, and game over, and allows control over their playback.
Definition at line 35 of file SoundLib.hpp.
SoundLib::SoundLib | ( | const std::uint32_t | entityId = 0 | ) |
Default constructor.
Construct a new Sound Lib:: Sound Lib object and optionally specify the id.
entityId | The unique ID of the entity. Default is 0. |
entityId |
Definition at line 21 of file SoundLib.cpp.
SoundLib::SoundLib | ( | const std::unordered_map< std::type_index, std::vector< std::any > > & | ecsEntities | ) |
Constructor with ECS entities.
Construct a new Sound Lib:: Sound Lib object and specify the location for the ressource.
ecsEntities | A map of ECS entity types and their respective data. |
ecsEntities |
Definition at line 32 of file SoundLib.cpp.
SoundLib::SoundLib | ( | const std::uint32_t | entityId, |
const std::unordered_map< std::type_index, std::vector< std::any > > & | ecsEntities ) |
Constructor with entity ID and ECS entities. :
Construct a new Sound Lib:: Sound Lib object and assign an entity id as well as the sound ressource.
entityId | The unique ID of the entity. |
ecsEntities | A map of ECS entity types and their respective data. |
entityId | |
ecsEntities |
Definition at line 43 of file SoundLib.cpp.
void SoundLib::buttonSound | ( | ) |
Plays the button interaction sound effect.
Plays the button click sound effect.
This function iterates through all music components in the entity-component system, finds the sound associated with button interactions, disables looping, and plays the sound.
CustomExceptions::MusicNotInitialised | If a music component cannot be cast to the expected type. |
Definition at line 197 of file SoundLib.cpp.
void SoundLib::damageSound | ( | ) |
Plays the damage sound effect.
This function iterates through all music components in the entity-component system, finds the sound associated with damage, disables looping, and plays the sound.
CustomExceptions::MusicNotInitialised | If a music component cannot be cast to the expected type. |
Definition at line 129 of file SoundLib.cpp.
void SoundLib::deadSound | ( | ) |
Plays the dead sound effect.
Plays the death sound effect.
This function iterates through all music components in the entity-component system, finds the sound associated with the player or entity death, disables looping, and plays the sound.
CustomExceptions::MusicNotInitialised | If a music component cannot be cast to the expected type. |
Definition at line 163 of file SoundLib.cpp.
void SoundLib::gameOverSound | ( | ) |
Plays the game over sound effect.
This function iterates through all music components in the entity-component system, finds the sound associated with the game over event, disables looping, and plays the sound.
CustomExceptions::MusicNotInitialised | If a music component cannot be cast to the expected type. |
Definition at line 231 of file SoundLib.cpp.
const bool SoundLib::isEnabled | ( | ) | const |
Checks if sound playback is enabled.
Check if the library was set to play sounds or not.
Definition at line 75 of file SoundLib.cpp.
void SoundLib::setPlay | ( | const bool | play | ) |
Enables or disables sound playback.
Set if to play or not the sounds contained in the library.
play | True to enable sound playback, false to disable it. |
play |
Definition at line 64 of file SoundLib.cpp.
void SoundLib::shootSound | ( | ) |
Plays the shooting sound effect.
This function iterates through all music components in the entity-component system, finds the sound associated with shooting, disables looping, and plays the sound.
CustomExceptions::MusicNotInitialised | If a music component cannot be cast to the expected type. |
Definition at line 88 of file SoundLib.cpp.
void SoundLib::updateSoundLib | ( | const std::unordered_map< std::type_index, std::vector< std::any > > & | ecsEntities | ) |
Updates the sound library with the provided ECS entities.
Update the ressource memory used to fetch the sound components.
ecsEntities | A map of ECS entity types and their respective data. |
ecsEntities |
Definition at line 53 of file SoundLib.cpp.
void SoundLib::winSound | ( | ) |
Plays the game win sound effect.
Plays the win sound effect.
This function iterates through all music components in the entity-component system, finds the sound associated with success or game completion, disables looping, and plays the sound.
CustomExceptions::MusicNotInitialised | If a music component cannot be cast to the expected type. |
Definition at line 265 of file SoundLib.cpp.