| 41 | } |
| 42 | |
| 43 | void SoundController::onUpdate(float deltaTime) |
| 44 | { |
| 45 | switch (m_SoundMode) |
| 46 | { |
| 47 | case ZenLoad::SM_LOOPING: |
| 48 | if (!m_World.getAudioWorld().soundIsPlaying(m_PlayedSound) && isInHearingRange()) |
| 49 | { |
| 50 | playSound(m_SoundFile); |
| 51 | } |
| 52 | break; |
| 53 | |
| 54 | case ZenLoad::SM_ONCE: |
| 55 | /*if(m_NumTimesPlayed == 0) // FIXME: Should probably be activated by a trigger |
| 56 | { |
| 57 | playSound(m_SoundFile); |
| 58 | }*/ |
| 59 | break; |
| 60 | |
| 61 | case ZenLoad::SM_RANDOM: |
| 62 | // Loop this sound after some time |
| 63 | float totalSeconds = (float)m_World.getEngine()->getGameClock().getTotalSecondsRealtime(); |
| 64 | |
| 65 | // If that is the first time playing, just calculate the random amount without playing the sound. |
| 66 | // This will keep sound vobs from all starting at the same time |
| 67 | if (m_NumTimesPlayed == 0) |
| 68 | { |
| 69 | setNextPlayingTimeRandomized(); |
| 70 | } |
| 71 | else if (totalSeconds >= m_SoundTimePlayNextRandom && !m_World.getAudioWorld().soundIsPlaying(m_PlayedSound) && isInHearingRange()) |
| 72 | { |
| 73 | playSound(m_SoundFile); |
| 74 | |
| 75 | // Calculate on what time this should be played again |
| 76 | setNextPlayingTimeRandomized(); |
| 77 | } |
| 78 | break; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void SoundController::setNextPlayingTimeRandomized() |
| 83 | { |
nothing calls this directly
no test coverage detected