Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
AAudioManager.cpp
Go to the documentation of this file.
1#include "AAudioManager.hpp"
2
3#include <type_traits>
4#include <variant>
5
7{
8 std::visit(
9 [this](auto&& arg) {
10 using T = std::decay_t<decltype(arg)>;
11
12 if constexpr (std::is_same_v<T, PlayerDeath>) {
13 playSound("death", "gui/assets/sounds/minecraft-villager-death.mp3");
14 } else if constexpr (std::is_same_v<T, IncantationStart>) {
15 playSound("incantation", "gui/assets/sounds/minecraft-villager.mp3");
16 } else if constexpr (std::is_same_v<T, IncantationEnd>) {
17 if (arg.success) {
18 playSound("incantation_success",
19 "gui/assets/sounds/minecraft-villager-trade.mp3");
20 } else {
21 playSound("incantation_fail", "gui/assets/sounds/minecraft-hit.mp3");
22 }
23 } else if constexpr (std::is_same_v<T, PlayerLevel>) {
24 playSound("levelup", "gui/assets/sounds/minecraft-levelup.mp3");
25 } else if constexpr (std::is_same_v<T, PlayerBroadcast>) {
26 playSound("broadcast", "gui/assets/sounds/discord.mp3");
27 } else if constexpr (std::is_same_v<T, PlayerNew>) {
28 playSound("newplayer", "gui/assets/sounds/discord-join.mp3");
29 }
30 // else if constexpr (std::is_same_v<T, PlayerResourceDrop>) {
31 // playSound("drop", "gui/assets/sounds/minecraft-drop.mp3");
32 // } else if constexpr (std::is_same_v<T, PlayerResourceTake>) {
33 // playSound("take", "gui/assets/sounds/minecraft-take.mp3");
34 // } else if constexpr (std::is_same_v<T, EggNew>) {
35 // playSound("eggnew", "gui/assets/sounds/minecraft-egg.mp3");
36 // } else if constexpr (std::is_same_v<T, EggHatch>) {
37 // playSound("egghatch", "gui/assets/sounds/minecraft-egg-hatch.mp3");
38 // } else if constexpr (std::is_same_v<T, EggDeath>) {
39 // playSound("eggdeath", "gui/assets/sounds/minecraft-egg-death.mp3");
40 // } else if constexpr (std::is_same_v<T, GameEnd>) {
41 // playSound("gameend", "gui/assets/sounds/minecraft-game-end.mp3");
42 // }
43 },
44 event);
45}
Abstract audio manager providing common event mapping logic.
std::variant< MapSize, TileContent, TeamName, PlayerNew, PlayerPosition, PlayerLevel, PlayerInventory, PlayerExpulsion, PlayerBroadcast, IncantationStart, IncantationEnd, PlayerFork, PlayerResourceDrop, PlayerResourceTake, PlayerDeath, EggNew, EggHatch, EggDeath, TimeUnit, TimeUnitChange, GameEnd, ServerMessage, UnknownCommand, BadParameters, ServerUptime, ServerSpawnedEgg, WinDuration > Event
Represents an event received from the server. Is a variant of all possible events,...
Definition Event.hpp:188
virtual void playSound(const std::string &key, const std::string &filepath)=0
Plays a sound associated with a specific key.
void handleEvent(const Event &event) override
Handles a game event to trigger the appropriate sound.