* Initial commit.

:)
This commit is contained in:
iProgramInCpp
2023-07-30 22:22:02 +03:00
commit 9642818a88
613 changed files with 151754 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#include "SoundRepository.hpp"
#include "Utils.hpp"
#include "Mth.hpp"
void SoundRepository::add(const std::string& name, SoundDesc& sd)
{
auto iter = m_repo.find(name);
if (iter == m_repo.end())
{
std::vector<SoundDesc> sdv;
sdv.push_back(sd);
m_repo.insert({ name, sdv });
}
else
{
iter->second.push_back(sd);
}
}
bool SoundRepository::get(const std::string& name, SoundDesc& sd)
{
auto iter = m_repo.find(name);
if (iter == m_repo.end())
{
printf("Couldn't find a sound with id: %s\n", name.c_str());
return false;
}
int index = Mth::random(int(iter->second.size()));
sd = iter->second[index];
return true;
}