Fixed crash when trying to jump, when no player is spawned.

This commit is contained in:
stiffly
2016-02-10 17:17:41 +01:00
parent c2128790af
commit 1ba9d97ab7
+9 -6
View File
@@ -25,7 +25,7 @@ void SoundSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cComp
void SoundSystem::Update(double dt)
{
// Temp for play test.
if(m_DrumsIsPlaying) {
if (m_DrumsIsPlaying) {
m_DrumsIsPlaying = !drumTimer(dt);
}
}
@@ -69,6 +69,9 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
void SoundSystem::playerJumps()
{
if (!m_LocalPlayer.Valid()) {
return;
}
bool grounded = (bool)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["IsOnGround"];
if (grounded) {
Events::PlaySoundOnEntity e;
@@ -124,11 +127,11 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
std::vector<std::string> paths;
paths.push_back("Audio/hurt/hurt" + std::to_string(rand) + ".wav");
// // Breathe
// int ammountOfbreaths = (static_cast<int>(e.Damage) / 10) + 2; // TEMP: Idk something stupid like this shit
// for (int i = 0; i < ammountOfbreaths; i++) {
// paths.push_back("Audio/exhausted/breath.wav");
// }
// // Breathe
// int ammountOfbreaths = (static_cast<int>(e.Damage) / 10) + 2; // TEMP: Idk something stupid like this shit
// for (int i = 0; i < ammountOfbreaths; i++) {
// paths.push_back("Audio/exhausted/breath.wav");
// }
Events::PlayQueueOnEntity ev;
ev.Emitter = m_LocalPlayer;
ev.FilePaths = paths;