summary refs log tree commit diff stats
path: root/src/message_system.cpp
blob: 71e8a5a3c88ca757766b89986c4c72cb625e8d88 (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
#include "message_system.h"

void MessageSystem::tick(double dt) {
  if (barsState_ == BarsState::Opening || barsState_ == BarsState::Closing) {
    accum_ += dt;

    if (accum_ >= length_) {
      if (barsState_ == BarsState::Opening) {
        barsState_ = BarsState::Open;
      } else {
        barsState_ = BarsState::Closed;
      }
    }
  }
}

void MessageSystem::displayCutsceneBars() {
  accum_ = 0.0;
  barsState_ = BarsState::Opening;
}

void MessageSystem::hideCutsceneBars() {
  accum_ = 0.0;
  barsState_ = BarsState::Closing;
}

double MessageSystem::getCutsceneBarsProgress() const {
  switch (barsState_) {
    case BarsState::Closed: return 0.0;
    case BarsState::Opening: return accum_ / length_;
    case BarsState::Open: return 1.0;
    case BarsState::Closing: return 1.0 - (accum_ / length_);
  }
}