|
|
@ -9,7 +9,6 @@
|
|
|
|
#include <components/fallback/fallback.hpp>
|
|
|
|
#include <components/fallback/fallback.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
|
|
|
#include "../mwbase/soundmanager.hpp"
|
|
|
|
#include "../mwbase/soundmanager.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
|
|
@ -520,6 +519,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fall
|
|
|
|
, mSecunda("Secunda", fallback)
|
|
|
|
, mSecunda("Secunda", fallback)
|
|
|
|
, mWindSpeed(0.f)
|
|
|
|
, mWindSpeed(0.f)
|
|
|
|
, mIsStorm(false)
|
|
|
|
, mIsStorm(false)
|
|
|
|
|
|
|
|
, mPrecipitation(false)
|
|
|
|
, mStormDirection(0,1,0)
|
|
|
|
, mStormDirection(0,1,0)
|
|
|
|
, mCurrentRegion()
|
|
|
|
, mCurrentRegion()
|
|
|
|
, mTimePassed(0)
|
|
|
|
, mTimePassed(0)
|
|
|
@ -608,14 +608,11 @@ void WeatherManager::modRegion(const std::string& regionID, const std::vector<ch
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WeatherManager::playerTeleported()
|
|
|
|
void WeatherManager::playerTeleported(const std::string& playerRegion, bool isExterior)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If the player teleports to an outdoors cell in a new region (for instance, by travelling), the weather needs to
|
|
|
|
// If the player teleports to an outdoors cell in a new region (for instance, by travelling), the weather needs to
|
|
|
|
// be changed immediately, and any transitions for the previous region discarded.
|
|
|
|
// be changed immediately, and any transitions for the previous region discarded.
|
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
if(world->isCellExterior() || world->isCellQuasiExterior())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string playerRegion = Misc::StringUtils::lowerCase(world->getPlayerPtr().getCell()->getCell()->mRegion);
|
|
|
|
|
|
|
|
std::map<std::string, RegionWeather>::iterator it = mRegions.find(playerRegion);
|
|
|
|
std::map<std::string, RegionWeather>::iterator it = mRegions.find(playerRegion);
|
|
|
|
if(it != mRegions.end() && playerRegion != mCurrentRegion)
|
|
|
|
if(it != mRegions.end() && playerRegion != mCurrentRegion)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -625,11 +622,9 @@ void WeatherManager::playerTeleported()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WeatherManager::update(float duration, bool paused)
|
|
|
|
void WeatherManager::update(float duration, bool paused, const TimeStamp& time, bool isExterior)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::ConstPtr player = MWMechanics::getPlayer();
|
|
|
|
MWWorld::ConstPtr player = MWMechanics::getPlayer();
|
|
|
|
MWBase::World& world = *MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
TimeStamp time = world.getTimeStamp();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!paused || mFastForward)
|
|
|
|
if(!paused || mFastForward)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -647,8 +642,7 @@ void WeatherManager::update(float duration, bool paused)
|
|
|
|
updateWeatherTransitions(duration);
|
|
|
|
updateWeatherTransitions(duration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bool exterior = (world.isCellExterior() || world.isCellQuasiExterior());
|
|
|
|
if(!isExterior)
|
|
|
|
if(!exterior)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRendering.setSkyEnabled(false);
|
|
|
|
mRendering.setSkyEnabled(false);
|
|
|
|
stopSounds();
|
|
|
|
stopSounds();
|
|
|
@ -660,6 +654,10 @@ void WeatherManager::update(float duration, bool paused)
|
|
|
|
mWindSpeed = mResult.mWindSpeed;
|
|
|
|
mWindSpeed = mResult.mWindSpeed;
|
|
|
|
mIsStorm = mResult.mIsStorm;
|
|
|
|
mIsStorm = mResult.mIsStorm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For some reason Ash Storm is not considered as a precipitation weather in game
|
|
|
|
|
|
|
|
mPrecipitation = !(mResult.mParticleEffect.empty() && mResult.mRainEffect.empty())
|
|
|
|
|
|
|
|
&& mResult.mParticleEffect != "meshes\\ashcloud.nif";
|
|
|
|
|
|
|
|
|
|
|
|
if (mIsStorm)
|
|
|
|
if (mIsStorm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
osg::Vec3f playerPos (player.getRefData().getPosition().asVec3());
|
|
|
|
osg::Vec3f playerPos (player.getRefData().getPosition().asVec3());
|
|
|
@ -777,12 +775,11 @@ unsigned int WeatherManager::getWeatherID() const
|
|
|
|
return mCurrentWeather;
|
|
|
|
return mCurrentWeather;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WeatherManager::isDark() const
|
|
|
|
bool WeatherManager::useTorches(float hour) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TimeStamp time = MWBase::Environment::get().getWorld()->getTimeStamp();
|
|
|
|
bool isDark = hour < mSunriseTime || hour > mTimeSettings.mNightStart - 1;
|
|
|
|
bool exterior = (MWBase::Environment::get().getWorld()->isCellExterior()
|
|
|
|
|
|
|
|
|| MWBase::Environment::get().getWorld()->isCellQuasiExterior());
|
|
|
|
return isDark && !mPrecipitation;
|
|
|
|
return exterior && (time.getHour() < mSunriseTime || time.getHour() > mTimeSettings.mNightStart - 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WeatherManager::write(ESM::ESMWriter& writer, Loading::Listener& progress)
|
|
|
|
void WeatherManager::write(ESM::ESMWriter& writer, Loading::Listener& progress)
|
|
|
|