R-Type  2
Doom but in better
Loading...
Searching...
No Matches
SoundLib Class Reference

The SoundLib class manages sound effects and interactions with ECS entities. More...

#include <SoundLib.hpp>

Inheritance diagram for SoundLib:
Inheritance graph
Collaboration diagram for SoundLib:
Collaboration graph

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.
 
- Public Member Functions inherited from GUI::ECS::EntityNode
 EntityNode (const size_t entityId=0)
 
virtual ~EntityNode ()=default
 
virtual size_t getEntityNodeId () const
 

Additional Inherited Members

- Protected Attributes inherited from GUI::ECS::EntityNode
size_t _entityID
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SoundLib() [1/3]

SoundLib::SoundLib ( const std::uint32_t entityId = 0)

Default constructor.

Construct a new Sound Lib:: Sound Lib object and optionally specify the id.

Parameters
entityIdThe unique ID of the entity. Default is 0.
entityId

Definition at line 21 of file SoundLib.cpp.

◆ SoundLib() [2/3]

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.

Parameters
ecsEntitiesA map of ECS entity types and their respective data.
ecsEntities

Definition at line 32 of file SoundLib.cpp.

◆ SoundLib() [3/3]

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.

Parameters
entityIdThe unique ID of the entity.
ecsEntitiesA map of ECS entity types and their respective data.
entityId
ecsEntities

Definition at line 43 of file SoundLib.cpp.

Member Function Documentation

◆ buttonSound()

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.

Exceptions
CustomExceptions::MusicNotInitialisedIf a music component cannot be cast to the expected type.

Definition at line 197 of file SoundLib.cpp.

◆ damageSound()

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.

Exceptions
CustomExceptions::MusicNotInitialisedIf a music component cannot be cast to the expected type.

Definition at line 129 of file SoundLib.cpp.

◆ deadSound()

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.

Exceptions
CustomExceptions::MusicNotInitialisedIf a music component cannot be cast to the expected type.

Definition at line 163 of file SoundLib.cpp.

◆ gameOverSound()

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.

Exceptions
CustomExceptions::MusicNotInitialisedIf a music component cannot be cast to the expected type.

Definition at line 231 of file SoundLib.cpp.

◆ isEnabled()

const bool SoundLib::isEnabled ( ) const

Checks if sound playback is enabled.

Check if the library was set to play sounds or not.

Returns
True if sound playback is enabled, false otherwise.
true it is set to play sounds
false it is set to not play sounds

Definition at line 75 of file SoundLib.cpp.

◆ setPlay()

void SoundLib::setPlay ( const bool play)

Enables or disables sound playback.

Set if to play or not the sounds contained in the library.

Parameters
playTrue to enable sound playback, false to disable it.
play

Definition at line 64 of file SoundLib.cpp.

◆ shootSound()

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.

Exceptions
CustomExceptions::MusicNotInitialisedIf a music component cannot be cast to the expected type.

Definition at line 88 of file SoundLib.cpp.

◆ updateSoundLib()

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.

Parameters
ecsEntitiesA map of ECS entity types and their respective data.
ecsEntities

Definition at line 53 of file SoundLib.cpp.

◆ winSound()

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.

Exceptions
CustomExceptions::MusicNotInitialisedIf a music component cannot be cast to the expected type.

Definition at line 265 of file SoundLib.cpp.


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