22 : EntityNode(entityId)
33 : EntityNode(0), _ecsEntities(ecsEntities)
43SoundLib::SoundLib(
const std::uint32_t entityId,
const std::unordered_map<std::type_index, std::vector<std::any>> &ecsEntities)
44 : EntityNode(entityId), _ecsEntities(ecsEntities)
55 _ecsEntities = ecsEntities;
91 std::cout <<
"Play Sound is disabled" << std::endl;
92 PRETTY_WARNING <<
"The sound playing has been disabled, skipping sound" << std::endl;
95 std::cout <<
"The shoot sound is enabled" << std::endl;
97 std::cout <<
"The music vector length is: " << std::to_string(musics.size()) << std::endl;
98 for (std::any music : musics) {
99 std::cout <<
"Getting the music node" << std::endl;
101 std::cout <<
"Fetched the music node" << std::endl;
102 if (!node.has_value()) {
103 std::cout <<
"The sound value node is empty" << std::endl;
106 std::cout <<
"Sound application: " << node.value()->getApplication() <<
", name: " << node.value()->getMusicName() << std::endl;
108 node.value()->getApplication() ==
"shooting" ||
109 node.value()->getMusicName() ==
"shooting" ||
110 node.value()->getApplication() ==
"Shooting" ||
111 node.value()->getMusicName() ==
"Shooting"
113 node.value()->setLoopMusic(
false);
115 node.value()->play();
132 PRETTY_WARNING <<
"The sound playing has been disabled, skipping sound" << std::endl;
136 for (std::any music : musics) {
138 if (!node.has_value()) {
142 node.value()->getApplication() ==
"damage" ||
143 node.value()->getMusicName() ==
"damage" ||
144 node.value()->getApplication() ==
"Damage" ||
145 node.value()->getMusicName() ==
"Damage"
147 node.value()->setLoopMusic(
false);
149 node.value()->play();
166 PRETTY_WARNING <<
"The sound playing has been disabled, skipping sound" << std::endl;
170 for (std::any music : musics) {
172 if (!node.has_value()) {
176 node.value()->getApplication() ==
"dead" ||
177 node.value()->getMusicName() ==
"dead" ||
178 node.value()->getApplication() ==
"Dead" ||
179 node.value()->getMusicName() ==
"Dead"
181 node.value()->setLoopMusic(
false);
183 node.value()->play();
200 PRETTY_WARNING <<
"The sound playing has been disabled, skipping sound" << std::endl;
204 for (std::any music : musics) {
206 if (!node.has_value()) {
210 node.value()->getApplication() ==
"button" ||
211 node.value()->getMusicName() ==
"button" ||
212 node.value()->getApplication() ==
"Button" ||
213 node.value()->getMusicName() ==
"Button"
215 node.value()->setLoopMusic(
false);
217 node.value()->play();
234 PRETTY_WARNING <<
"The sound playing has been disabled, skipping sound" << std::endl;
238 for (std::any music : musics) {
240 if (!node.has_value()) {
244 node.value()->getApplication() ==
"gameOver" ||
245 node.value()->getMusicName() ==
"gameOver" ||
246 node.value()->getApplication() ==
"Game Over" ||
247 node.value()->getMusicName() ==
"Game Over"
249 node.value()->setLoopMusic(
false);
250 PRETTY_DEBUG <<
"Playing sound: Game Over" << std::endl;
251 node.value()->play();
268 PRETTY_WARNING <<
"The sound playing has been disabled, skipping sound" << std::endl;
272 for (std::any music : musics) {
274 if (!node.has_value()) {
278 node.value()->getApplication() ==
"success" ||
279 node.value()->getMusicName() ==
"success" ||
280 node.value()->getApplication() ==
"Success" ||
281 node.value()->getMusicName() ==
"Success"
283 node.value()->setLoopMusic(
false);
285 node.value()->play();
#define PRETTY_DEBUG
Debug log with details and colour.
#define PRETTY_WARNING
Warning log with details and colour.
Declaration of the SoundLib class for managing sounds in the ECS architecture.
This is the class in charge of informing the user that they tried to play music from a class that has...
Manages music playback and properties for an entity in the ECS system.
void updateSoundLib(const std::unordered_map< std::type_index, std::vector< std::any > > &ecsEntities)
Updates the sound library with the provided ECS entities.
void buttonSound()
Plays the button interaction sound effect.
void winSound()
Plays the game win sound effect.
void damageSound()
Plays the damage sound effect.
void setPlay(const bool play)
Enables or disables sound playback.
SoundLib(const std::uint32_t entityId=0)
Default constructor.
void shootSound()
Plays the shooting sound effect.
void gameOverSound()
Plays the game over sound effect.
const bool isEnabled() const
Checks if sound playback is enabled.
void deadSound()
Plays the dead sound effect.
std::optional< T > unCast(const std::any &classNode, const bool raiseOnError=true, const std::string customErrorMessage="")
Casts the content of a std::any back to its original type.