diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-12 09:53:02 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-12 09:53:02 -0500 |
| commit | 3996ccb4e2a0d81500d1b1370b2b97256d1ee465 (patch) | |
| tree | e422ab35c9edbb034e44eab00f7a13666eeea6f8 /src/muxer.cpp | |
| parent | de7ee5ef022a8ccaece0ea5f5402adedeafe36b4 (diff) | |
| download | ether-3996ccb4e2a0d81500d1b1370b2b97256d1ee465.tar.gz ether-3996ccb4e2a0d81500d1b1370b2b97256d1ee465.tar.bz2 ether-3996ccb4e2a0d81500d1b1370b2b97256d1ee465.zip | |
added transition and the world music
Diffstat (limited to 'src/muxer.cpp')
| -rw-r--r-- | src/muxer.cpp | 58 |
1 files changed, 57 insertions, 1 deletions
| diff --git a/src/muxer.cpp b/src/muxer.cpp index 5b09ef8..3450187 100644 --- a/src/muxer.cpp +++ b/src/muxer.cpp | |||
| @@ -62,9 +62,65 @@ void Muxer::playSoundAtPosition(std::string name, float x, float y) { | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | void Muxer::setMusicLevel(int level) { | 64 | void Muxer::setMusicLevel(int level) { |
| 65 | ERRCHECK(exploration_event_->setParameterByName("level", level)); | 65 | if (transition_state_ == TransitionState::Pre) { |
| 66 | if (level >= 3) { | ||
| 67 | transition_state_ = TransitionState::Transition; | ||
| 68 | ERRCHECK(exploration_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); | ||
| 69 | ERRCHECK(exploration_event_->release()); | ||
| 70 | |||
| 71 | FMOD::Studio::EventDescription* eventDescription = nullptr; | ||
| 72 | ERRCHECK(system_->getEvent("event:/transition", &eventDescription)); | ||
| 73 | ERRCHECK(eventDescription->createInstance(&transition_event_)); | ||
| 74 | ERRCHECK(transition_event_->start()); | ||
| 75 | } else { | ||
| 76 | ERRCHECK(exploration_event_->setParameterByName("level", level)); | ||
| 77 | } | ||
| 78 | } else if (transition_state_ == TransitionState::Post) { | ||
| 79 | if (level <= 3) { | ||
| 80 | ERRCHECK(the_world_event_->setParameterByName("level_full", 0)); | ||
| 81 | } else { | ||
| 82 | ERRCHECK(the_world_event_->setParameterByName("level_full", level - 3)); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | void Muxer::stopMusic() { | ||
| 88 | switch (transition_state_) { | ||
| 89 | case TransitionState::Pre: { | ||
| 90 | ERRCHECK(exploration_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); | ||
| 91 | break; | ||
| 92 | } | ||
| 93 | case TransitionState::Transition: { | ||
| 94 | ERRCHECK(transition_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); | ||
| 95 | break; | ||
| 96 | } | ||
| 97 | case TransitionState::Post: { | ||
| 98 | ERRCHECK(the_world_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); | ||
| 99 | break; | ||
| 100 | } | ||
| 101 | case TransitionState::Stopped: { | ||
| 102 | // Do nothing. | ||
| 103 | break; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | transition_state_ = TransitionState::Stopped; | ||
| 66 | } | 108 | } |
| 67 | 109 | ||
| 68 | void Muxer::update() { | 110 | void Muxer::update() { |
| 111 | if (transition_state_ == TransitionState::Transition) { | ||
| 112 | FMOD_STUDIO_PLAYBACK_STATE playbackState; | ||
| 113 | ERRCHECK(transition_event_->getPlaybackState(&playbackState)); | ||
| 114 | if (playbackState == FMOD_STUDIO_PLAYBACK_STOPPED) { | ||
| 115 | transition_state_ = TransitionState::Post; | ||
| 116 | transition_event_->release(); | ||
| 117 | |||
| 118 | FMOD::Studio::EventDescription* eventDescription = nullptr; | ||
| 119 | ERRCHECK(system_->getEvent("event:/the_world", &eventDescription)); | ||
| 120 | ERRCHECK(eventDescription->createInstance(&the_world_event_)); | ||
| 121 | ERRCHECK(the_world_event_->start()); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 69 | ERRCHECK(system_->update()); | 125 | ERRCHECK(system_->update()); |
| 70 | } | 126 | } |
