forked from teamnwah/openmw-tes3coop
added weather sounds
This commit is contained in:
parent
69127fa8f1
commit
2196e1321b
2 changed files with 37 additions and 1 deletions
|
@ -722,6 +722,40 @@ void WeatherManager::update(float duration)
|
|||
mRendering->skyDisable();
|
||||
mRendering->getSkyManager()->setThunder(0.f);
|
||||
}
|
||||
|
||||
// play sounds
|
||||
std::string ambientSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mAmbientLoopSoundID : "");
|
||||
if (ambientSnd != "")
|
||||
{
|
||||
if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), ambientSnd) == mSoundsPlaying.end())
|
||||
{
|
||||
mSoundsPlaying.push_back(ambientSnd);
|
||||
mEnvironment->mSoundManager->playSound(ambientSnd, 1.0, 1.0, true);
|
||||
}
|
||||
}
|
||||
|
||||
std::string rainSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mRainLoopSoundID : "");
|
||||
if (rainSnd != "")
|
||||
{
|
||||
if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), rainSnd) == mSoundsPlaying.end())
|
||||
{
|
||||
mSoundsPlaying.push_back(rainSnd);
|
||||
mEnvironment->mSoundManager->playSound(rainSnd, 1.0, 1.0, true);
|
||||
}
|
||||
}
|
||||
|
||||
// stop sounds
|
||||
std::vector<std::string>::iterator it=mSoundsPlaying.begin();
|
||||
while (it!=mSoundsPlaying.end())
|
||||
{
|
||||
if ( *it != ambientSnd && *it != rainSnd)
|
||||
{
|
||||
mEnvironment->mSoundManager->stopSound(*it);
|
||||
it = mSoundsPlaying.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void WeatherManager::setHour(const float hour)
|
||||
|
|
|
@ -246,6 +246,8 @@ namespace MWWorld
|
|||
|
||||
std::map<std::string, std::string> mRegionOverrides;
|
||||
|
||||
std::vector<std::string> mSoundsPlaying;
|
||||
|
||||
Ogre::String mCurrentWeather;
|
||||
Ogre::String mNextWeather;
|
||||
|
||||
|
|
Loading…
Reference in a new issue