#ifndef EFFECT_SYSTEM_H_0B497B39 #define EFFECT_SYSTEM_H_0B497B39 #include "interpolation.h" #include "system.h" #include "timer.h" #include "vector.h" class Game; class EffectSystem : public System { public: static constexpr SystemKey Key = SystemKey::Effect; explicit EffectSystem(Game& game) : game_(game) {} void tick(double dt) override; /* Commands */ // Fades the entire screen in or out // - length is in milliseconds // - amount is [0,1] void fadeScreen(int length, double amount); // Fades just the map, leaving the sprites, messages, etc unfaded. // - length is in milliseconds // - amount is [0,1] void fadeMap(int length, double amount); // Shakes the viewport by 1 tile in both directions. // - period is in milliseconds, it's actually a half period void shakeCamera(int period); void stopShakingCamera(); // Hides or reveals the screen using a circle transition. // - length is the time in milliseconds // - amount is [0,1], where 0 is fully revealed and 1 is fully hidden void circleTransition(int length, double amount); /* Information */ bool isScreenFaded() const { return screenFade_.getProgress() > 0.0; } double getScreenFadeProgress() const { return screenFade_.getProgress(); } bool isScreenFadeComplete() const { return screenFade_.isComplete(); } bool isMapFaded() const { return mapFade_.getProgress() > 0.0; } double getMapFadeProgress() const { return mapFade_.getProgress(); } bool isMapFadeComplete() const { return mapFade_.isComplete(); } const vec2i& getCameraShakeOffset() const { return cameraShakeOffset_; } bool isCameraShaking() const { return cameraShaking_; } bool isCircleTransitionActive() const { return circleEffect_.getProgress() > 0.0; } double getCircleTransitionProgress() const { return circleEffect_.getProgress(); } bool isCircleTransitionComplete() const { return circleEffect_.isComplete(); } private: Game& game_; Interpolation screenFade_; Interpolation mapFade_; Interpolation circleEffect_; bool cameraShaking_ = false; vec2i cameraShakeOffset_ { 0, 0 }; bool cameraShakeOn_ = false; Timer cameraShakeTimer_ { 0 }; }; #endif /* end of include guard: EFFECT_SYSTEM_H_0B497B39 */