@ -14,6 +14,7 @@
namespace ESM
{
struct Region ;
struct RegionWeatherState ;
class ESMWriter ;
class ESMReader ;
}
@ -31,6 +32,7 @@ namespace Loading
namespace MWWorld
{
class Fallback ;
class TimeStamp ;
/// Defines a single weather setting (according to INI)
class Weather
@ -110,7 +112,7 @@ namespace MWWorld
// Note: For Weather Blight, there is a "Disease Chance" (=0.1) setting. But according to MWSFD this feature
// is broken in the vanilla game and was disabled.
float transition Seconds ( ) const ;
float transition Delta ( ) const ;
float cloudBlendFactor ( float transitionRatio ) const ;
private :
@ -118,12 +120,35 @@ namespace MWWorld
float mCloudsMaximumPercent ;
} ;
/// A class for storing a region's weather.
class RegionWeather
{
public :
explicit RegionWeather ( const ESM : : Region & region ) ;
explicit RegionWeather ( const ESM : : RegionWeatherState & state ) ;
explicit operator ESM : : RegionWeatherState ( ) const ;
void setChances ( const std : : vector < char > & chances ) ;
void setWeather ( int weatherID ) ;
int getWeather ( ) ;
private :
int mWeather ;
std : : vector < char > mChances ;
void chooseNewWeather ( ) ;
} ;
/// A class that acts as a model for the moons.
class MoonModel
{
public :
MoonModel ( const std : : string & name , const MWWorld : : Fallback & fallback ) ;
MWRender : : MoonState calculateState ( unsigned int daysPassed , float gameHour ) const ;
MWRender : : MoonState calculateState ( const TimeStamp & gameTime ) const ;
private :
float mFadeInStart ;
@ -137,23 +162,23 @@ namespace MWWorld
float mFadeEndAngle ;
float mMoonShadowEarlyFadeAngle ;
float angle ( unsigned int daysPassed , float gameHour ) const ;
float angle ( const TimeStamp & gameTime ) const ;
float moonRiseHour ( unsigned int daysPassed ) const ;
float rotation ( float hours ) const ;
unsigned int phase ( unsigned int daysPassed , float gameHour ) const ;
unsigned int phase ( const TimeStamp & gameTime ) const ;
float shadowBlend ( float angle ) const ;
float hourlyAlpha ( float gameHour ) const ;
float earlyMoonShadowAlpha ( float angle ) const ;
} ;
///
/// Interface for weather settings
///
class WeatherManager
{
public :
// Have to pass fallback and Store, can't use singleton since World isn't fully constructed yet at the time
WeatherManager ( MWRender : : RenderingManager * , MWWorld : : Fallback * fallback , MWWorld : : ESMStore * store ) ;
WeatherManager ( MWRender : : RenderingManager & rendering ,
const MWWorld : : Fallback & fallback ,
MWWorld : : ESMStore & store ) ;
~ WeatherManager ( ) ;
/**
@ -161,8 +186,9 @@ namespace MWWorld
* @ param region that should be changed
* @ param ID of the weather setting to shift to
*/
void changeWeather ( const std : : string & region , const unsigned int id ) ;
void switchToNextWeather ( bool instantly = true ) ;
void changeWeather ( const std : : string & regionID , const unsigned int weatherID ) ;
void modRegion ( const std : : string & regionID , const std : : vector < char > & chances ) ;
void playerTeleported ( ) ;
/**
* Per - frame update
@ -173,8 +199,6 @@ namespace MWWorld
void stopSounds ( ) ;
void setHour ( const float hour ) ;
float getWindSpeed ( ) const ;
/// Are we in an ash or blight storm?
@ -183,11 +207,10 @@ namespace MWWorld
osg : : Vec3f getStormDirection ( ) const ;
void advanceTime ( double hours ) ;
void advanceTimeByFrame ( double hours ) ;
unsigned int getWeatherID ( ) const ;
void modRegion ( const std : : string & regionid , const std : : vector < char > & chances ) ;
/// @see World::isDark
bool isDark ( ) const ;
@ -198,73 +221,77 @@ namespace MWWorld
void clear ( ) ;
private :
float mHour ;
float mWindSpeed ;
bool mIsStorm ;
osg : : Vec3f mStormDirection ;
MWBase : : SoundPtr mAmbientSound ;
std : : string mPlayingSoundID ;
MWWorld : : ESMStore * mStore ;
MWRender : : RenderingManager * mRendering ;
std : : map < std : : string , Weather > mWeatherSettings ;
std : : map < std : : string , std : : string > mRegionOverrides ;
std : : string mCurrentWeather ;
std : : string mNextWeather ;
std : : string mCurrentRegion ;
bool mFirstUpdate ;
float mRemainingTransitionTime ;
float mThunderFlash ;
float mThunderChance ;
float mThunderChanceNeeded ;
double mTimePassed ; // time passed since last update
void transition ( const float factor ) ;
void setResult ( const std : : string & weatherType ) ;
void setWeather ( const std : : string & weatherType , bool instant = false ) ;
std : : string nextWeather ( const ESM : : Region * region ) const ;
MWRender : : WeatherResult mResult ;
typedef std : : map < std : : string , std : : vector < char > > RegionModMap ;
RegionModMap mRegionMods ;
float mRainSpeed ;
MWWorld : : ESMStore & mStore ;
MWRender : : RenderingManager & mRendering ;
float mSunriseTime ;
float mSunsetTime ;
float mSunriseDuration ;
float mSunsetDuration ;
float mWeatherUpdateTime ;
float mHoursBetweenWeatherChanges ;
float mThunderFrequency ;
float mThunderThreshold ;
float mThunderSoundDelay ;
// Some useful values
/* TODO: Use pre-sunrise_time, pre-sunset_time,
* post - sunrise_time , and post - sunset_time to better
* describe sunrise / sunset time .
* These values are fallbacks attached to weather .
*/
float mNightStart ;
float mNightEnd ;
float mDayStart ;
float mDayEnd ;
float mHoursBetweenWeatherChanges ;
float mRainSpeed ;
std : : vector < Weather > mWeatherSettings ;
MoonModel mMasser ;
MoonModel mSecunda ;
float mThunderFrequency ;
float mThunderThreshold ;
std : : string mThunderSoundID0 ;
std : : string mThunderSoundID1 ;
std : : string mThunderSoundID2 ;
std : : string mThunderSoundID3 ;
MoonModel mMasser ;
MoonModel mSecunda ;
float mWindSpeed ;
bool mIsStorm ;
osg : : Vec3f mStormDirection ;
float mThunderSoundDelay ;
float mThunderFlash ;
float mThunderChance ;
float mThunderChanceNeeded ;
std : : string mCurrentRegion ;
float mTimePassed ;
bool mFastForward ;
float mWeatherUpdateTime ;
float mTransitionFactor ;
int mCurrentWeather ;
int mNextWeather ;
int mQueuedWeather ;
std : : map < std : : string , RegionWeather > mRegions ;
MWRender : : WeatherResult mResult ;
MWBase : : SoundPtr mAmbientSound ;
std : : string mPlayingSoundID ;
void addWeather ( const std : : string & name ,
const MWWorld : : Fallback & fallback ,
const std : : string & ambientLoopSoundID = " " ,
const std : : string & particleEffect = " " ) ;
Weather & findWeather ( const std : : string & name ) ;
void importRegions ( ) ;
void regionalWeatherChanged ( const std : : string & regionID , RegionWeather & region ) ;
bool updateWeatherTime ( ) ;
bool updateWeatherRegion ( const std : : string & playerRegion ) ;
void updateWeatherTransitions ( const float elapsedRealSeconds ) ;
void forceWeather ( const int weatherID ) ;
bool inTransition ( ) ;
void addWeatherTransition ( const int weatherID ) ;
void calculateWeatherResult ( const float gameHour ) ;
void calculateResult ( const int weatherID , const float gameHour ) ;
void calculateTransitionResult ( const float factor , const float gameHour ) ;
} ;
}