diff --git a/assets/sound/ambient/ocean/wave001.flac b/assets/sound/ambient/ocean/wave001.flac new file mode 100644 index 0000000..fbd38a3 Binary files /dev/null and b/assets/sound/ambient/ocean/wave001.flac differ diff --git a/assets/sound/ambient/ocean/wave002.flac b/assets/sound/ambient/ocean/wave002.flac new file mode 100644 index 0000000..0851f04 Binary files /dev/null and b/assets/sound/ambient/ocean/wave002.flac differ diff --git a/assets/sound/ambient/ocean/wave003.flac b/assets/sound/ambient/ocean/wave003.flac new file mode 100644 index 0000000..a718a39 Binary files /dev/null and b/assets/sound/ambient/ocean/wave003.flac differ diff --git a/assets/sound/ambient/ocean/wave004.flac b/assets/sound/ambient/ocean/wave004.flac new file mode 100644 index 0000000..731d40e Binary files /dev/null and b/assets/sound/ambient/ocean/wave004.flac differ diff --git a/include/Cubed/gameplay/client_world.hpp b/include/Cubed/gameplay/client_world.hpp index 99e065e..db42f56 100644 --- a/include/Cubed/gameplay/client_world.hpp +++ b/include/Cubed/gameplay/client_world.hpp @@ -6,6 +6,7 @@ #include "Cubed/gameplay/client_player.hpp" #include "Cubed/gameplay/game_time.hpp" #include "Cubed/gameplay/network_client.hpp" +#include "Cubed/tools/cubed_random.hpp" #include "Cubed/tools/priority_thread_pool.hpp" #include @@ -153,6 +154,8 @@ private: std::atomic> m_thread_pool; + Random m_random; + void client_run(std::stop_token token); void report_player_info(); diff --git a/src/gameplay/client_world.cpp b/src/gameplay/client_world.cpp index 7a4eb47..016f7d5 100644 --- a/src/gameplay/client_world.cpp +++ b/src/gameplay/client_world.cpp @@ -1,6 +1,7 @@ #include "Cubed/gameplay/client_world.hpp" #include "Cubed/config.hpp" +#include "Cubed/gameplay/chunk_generator.hpp" #include "Cubed/gameplay/game_time.hpp" #include "Cubed/gameplay/packet.hpp" #include "Cubed/tools/math_tools.hpp" @@ -357,6 +358,8 @@ void ClientWorld::init(std::string_view player_name, std::shared_ptr client) { m_player.init(player_name); m_client = client; + m_random.init(ChunkGenerator::seed()); + // timer register_ticktimer("player_pos", 1, [this]() { report_player_info(); }); m_timers.try_emplace("Birds Sound", 60.0f, [this]() { @@ -375,6 +378,26 @@ void ClientWorld::init(std::string_view player_name, } }); + m_timers.try_emplace("Ocean Wave", 3.0f, [this]() { + auto player_pos = m_player.get_player_pos(); + if (player_pos.y < SEA_LEVEL - 10 || player_pos.y > SEA_LEVEL + 10) { + return; + } + + auto ans = m_random.random_int(1, 4); + std::string sound = + "ambient/ocean/wave00" + std::to_string(ans) + ".flac"; + ChunkPos pos = get_chunk_pos(player_pos.x, player_pos.z); + { + chunk_cacc cacc; + if (m_chunks.find(cacc, pos)) { + if (cacc->second->get_biome() == BiomeType::OCEAN) { + m_audio.play_2d(sound, true); + } + } + } + }); + LoginReq req; req.set_name(m_player.get_name()); while (!client->is_connected()) {