From 40d164ea3d8437cd5a06a06d5b89bd938d3dd906 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 29 Apr 2017 18:28:28 -0400 Subject: no more getSystem --- include/weather.hpp | 55 +++++------------------------------------------------ 1 file changed, 5 insertions(+), 50 deletions(-) (limited to 'include/weather.hpp') diff --git a/include/weather.hpp b/include/weather.hpp index 58a0cfa..c19a52d 100644 --- a/include/weather.hpp +++ b/include/weather.hpp @@ -5,8 +5,7 @@ #include -#include -#include +#include extern vec2 offset; @@ -22,60 +21,16 @@ enum class Weather : unsigned char { count }; -constexpr const char *weatherStrings[] = { - "Sunny", - "Rainy", - "Snowy" -}; - class WeatherSystem : public entityx::System { private: - Weather weather; + static Weather weather; public: - WeatherSystem(Weather w = Weather::Sunny) - : weather(w) {} - - void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override { - (void)en; - (void)ev; - (void)dt; - - static auto& partSystem = *game::engine.getSystem(); - static int newPartDelay = 0; // TODO no + WeatherSystem(Weather w = Weather::Sunny); - switch (weather) { - case Weather::Sunny: - break; - case Weather::Rainy: - if (newPartDelay++ == 4) { - newPartDelay = 0; - partSystem.add(vec2(offset.x - game::SCREEN_WIDTH / 2 + randGet() % game::SCREEN_WIDTH, - offset.y + game::SCREEN_HEIGHT / 2 + 100), - ParticleType::Drop, 3000, 3); - } - break; - case Weather::Snowy: - if (newPartDelay++ == 6) { - newPartDelay = 0; - partSystem.add(vec2(offset.x - game::SCREEN_WIDTH + randGet() % game::SCREEN_WIDTH * 2, - offset.y + game::SCREEN_HEIGHT / 2 + 50), - ParticleType::Confetti, 10000, 0); - } - break; - default: - break; - } - } + void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; - inline void setWeather(const std::string& w) { - for (int i = 0; i < static_cast(Weather::count); i++) { - if (w == weatherStrings[i]) { - weather = static_cast(i); - return; - } - } - } + static void setWeather(const std::string& w); }; #endif // WEATHER_HPP_ -- cgit v1.2.3