summary refs log tree commit diff stats
path: root/src/effect_system.h
blob: 2cdcb10687dc206d3f67ae093a257b677bdabd13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef EFFECT_SYSTEM_H_0B497B39
#define EFFECT_SYSTEM_H_0B497B39

#include "system.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);

  /* Information */

  bool isScreenFaded() const { return screenFade_ > 0.0; }

  double getScreenFadeProgress() const { return screenFade_; }

  bool isScreenFadeComplete() const { return screenFade_ == screenFadeDest_; }

  bool isMapFaded() const { return mapFade_ > 0.0; }

  double getMapFadeProgress() const { return mapFade_; }

  bool isMapFadeComplete() const { return mapFade_ == mapFadeDest_; }

private:

  Game& game_;

  double screenFade_ = 0.0;
  double screenFadeDest_ = 0.0;
  double screenFadeStart_ = 0.0;
  double screenFadeLength_ = 0;
  double screenFadeThus_ = 0;

  double mapFade_ = 0.0;
  double mapFadeDest_ = 0.0;
  double mapFadeStart_ = 0.0;
  double mapFadeLength_ = 0.0;
  double mapFadeThus_ = 0.0;
};

#endif /* end of include guard: EFFECT_SYSTEM_H_0B497B39 */