3 #include <BLIB/Util/Random.hpp>
20 const std::string Types[] = {
"None",
56 BL_LOG_INFO <<
"Set weather to " << Types[t];
61 if (im) weather.release();
69 if (weather) weather->update(dt);
74 if (stateTime <= 0.f) {
75 BL_LOG_INFO <<
"Stopping current weather";
84 if (stateTime <= 0.f) {
85 BL_LOG_INFO <<
"Starting new weather";
86 stateTime = bl::util::Random::get<float>(300.f, 600.f);
87 state = WaitingWeather;
93 if (!weather || weather->stopped()) {
95 BL_LOG_INFO <<
"Weather stopped";
96 bl::event::Dispatcher::dispatch<event::WeatherStopped>({weather->type()});
105 state = WaitingStopped;
106 stateTime = bl::util::Random::get<float>(200.f, 400.f);
124 void Weather::makeWeather() {
125 const auto makeRain = [
this](
bool hard,
bool thunder) {
126 BL_LOG_INFO <<
"Created rain";
129 const auto makeSnow = [
this](
bool hard,
bool thunder) {
130 BL_LOG_INFO <<
"Created snow";
131 this->weather.reset(
new weather::Snow(hard, thunder));
133 const auto makeFog = [
this](
bool thick) {
134 BL_LOG_INFO <<
"Created fog";
135 this->weather.reset(
new weather::Fog(thick));
137 const auto makeSunny = [
this]() {
138 BL_LOG_INFO <<
"Created sunny";
139 this->weather.reset(
new weather::Sunny());
141 const auto makeSandstorm = [
this]() {
142 BL_LOG_INFO <<
"Created sandstorm";
143 this->weather.reset(
new weather::Sandstorm());
146 using Maker = std::function<void()>;
147 const Maker makers[] = {
148 [&makeFog]() { makeFog(
true); },
149 [&makeFog]() { makeFog(
false); },
150 [&makeRain]() { makeRain(
false,
false); },
151 [&makeRain]() { makeRain(
false,
true); },
152 [&makeRain]() { makeRain(
true,
false); },
153 [&makeRain]() { makeRain(
true,
true); },
154 [&makeSnow]() { makeSnow(
false,
false); },
155 [&makeSnow]() { makeSnow(
false,
true); },
156 [&makeSnow]() { makeSnow(
true,
false); },
157 [&makeSnow]() { makeSnow(
true,
true); },
164 makers[bl::util::Random::get<unsigned int>(0, 12)]();
167 makers[bl::util::Random::get<unsigned int>(2, 6)]();
170 makers[bl::util::Random::get<unsigned int>(6, 10)]();
173 makers[bl::util::Random::get<unsigned int>(10, 12)]();
176 makeRain(
false,
false);
179 makeRain(
false,
true);
182 makeRain(
true,
false);
185 makeRain(
true,
true);
188 makeSnow(
false,
false);
191 makeSnow(
false,
true);
194 makeSnow(
true,
false);
197 makeSnow(
true,
true);
212 BL_LOG_WARN <<
"Unknown weather type: " << type;
218 bl::event::Dispatcher::dispatch<event::WeatherStarted>({weather->type()});
Core classes and functionality for both the editor and game.
The primary map class that represents a usable map in the game.
@ HardSnowThunder
Hard snow with thunder.
@ Sunny
A very sunny day with pulsating light.
@ ThinFog
Thin fog covers the area.
@ SandStorm
A sandstorm ravages you.
@ HardRain
Hard rain with no thunder.
@ HardRainThunder
Hard rain with thunder.
@ LightRainThunder
Light rain with thunder.
@ None
No weather will occur.
@ WaterRandom
Periodically triggers one of LightRain, HardRain, LightRainThunder, HardRainThunder.
@ LightSnowThunder
Light snow with thunder.
@ LightRain
Light rain with no thunder.
@ SnowRandom
Periodically triggers one of LightSnow, HardSnow, LightSnowThunder, HardSnowThunder.
@ ThickFog
Thick fog obscures everything.
@ LightSnow
Light snow with no thunder.
@ DesertRandom
Periodically triggers one of Sunny, Sandstorm.
@ HardSnow
Hard snow with no thunder.
@ AllRandom
All types of weather may occur over time.
Weather()
Initializes the weather system with None.
void update(float dt)
Updates the current weather.
void activate(system::Systems &systems, Map &map)
Activates the weather system.
~Weather()
Terminates active weather.
Type getType() const
Returns the current type of weather.
void set(Type type, bool immediate=false)
Sets the current weather type.
bl::rc::RenderTarget & getMainRenderTarget()
Returns the engine observer that the main game is rendering to.
Owns all primary systems and a reference to the engine.
const bl::engine::Engine & engine() const
Const accessor for the Engine.
Render & render()
Returns the render system.
Weather type for rainy days. Handles light and hard rain and owns thunder if need be.