diff options
Diffstat (limited to 'src/message_system.cpp')
| -rw-r--r-- | src/message_system.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
| diff --git a/src/message_system.cpp b/src/message_system.cpp new file mode 100644 index 0000000..71e8a5a --- /dev/null +++ b/src/message_system.cpp | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #include "message_system.h" | ||
| 2 | |||
| 3 | void MessageSystem::tick(double dt) { | ||
| 4 | if (barsState_ == BarsState::Opening || barsState_ == BarsState::Closing) { | ||
| 5 | accum_ += dt; | ||
| 6 | |||
| 7 | if (accum_ >= length_) { | ||
| 8 | if (barsState_ == BarsState::Opening) { | ||
| 9 | barsState_ = BarsState::Open; | ||
| 10 | } else { | ||
| 11 | barsState_ = BarsState::Closed; | ||
| 12 | } | ||
| 13 | } | ||
| 14 | } | ||
| 15 | } | ||
| 16 | |||
| 17 | void MessageSystem::displayCutsceneBars() { | ||
| 18 | accum_ = 0.0; | ||
| 19 | barsState_ = BarsState::Opening; | ||
| 20 | } | ||
| 21 | |||
| 22 | void MessageSystem::hideCutsceneBars() { | ||
| 23 | accum_ = 0.0; | ||
| 24 | barsState_ = BarsState::Closing; | ||
| 25 | } | ||
| 26 | |||
| 27 | double MessageSystem::getCutsceneBarsProgress() const { | ||
| 28 | switch (barsState_) { | ||
| 29 | case BarsState::Closed: return 0.0; | ||
| 30 | case BarsState::Opening: return accum_ / length_; | ||
| 31 | case BarsState::Open: return 1.0; | ||
| 32 | case BarsState::Closing: return 1.0 - (accum_ / length_); | ||
| 33 | } | ||
| 34 | } | ||
