| 1 | #include "Layout/PlayGuideBgm.h" |
| 2 | |
| 3 | #include "Library/Bgm/BgmLineFunction.h" |
| 4 | #include "Library/Layout/LayoutActorUtil.h" |
| 5 | #include "Library/Nerve/NerveSetupUtil.h" |
| 6 | #include "Library/Nerve/NerveUtil.h" |
| 7 | #include "Library/Play/Layout/SimpleLayoutAppearWaitEnd.h" |
| 8 | |
| 9 | namespace { |
| 10 | NERVE_IMPL(PlayGuideBgm, Hide); |
| 11 | NERVE_IMPL(PlayGuideBgm, End); |
| 12 | NERVE_IMPL(PlayGuideBgm, EndForDead); |
| 13 | NERVE_IMPL(PlayGuideBgm, Show); |
| 14 | |
| 15 | NERVES_MAKE_NOSTRUCT(PlayGuideBgm, Show); |
| 16 | NERVES_MAKE_STRUCT(PlayGuideBgm, Hide, End, EndForDead); |
| 17 | } // namespace |
| 18 | |
| 19 | PlayGuideBgm::PlayGuideBgm(const char* name, const al::LayoutInitInfo& info) |
| 20 | : al::NerveStateBase(name) { |
| 21 | mLayout = new al::SimpleLayoutAppearWaitEnd("[シーン情報]BGM再生" , "PlayGuideBgm" , info, |
| 22 | nullptr, false); |
| 23 | al::killLayoutIfActive(mLayout); |
| 24 | initNerve(nerve: &NrvPlayGuideBgm.Hide, stateCount: 0); |
| 25 | appear(); |
| 26 | } |
| 27 | |
| 28 | void PlayGuideBgm::start() { |
| 29 | appear(); |
| 30 | if (al::isNerve(user: this, nerve: &NrvPlayGuideBgm.End) || al::isNerve(user: this, nerve: &NrvPlayGuideBgm.EndForDead)) |
| 31 | al::setNerve(user: this, nerve: &NrvPlayGuideBgm.Hide); |
| 32 | } |
| 33 | |
| 34 | void PlayGuideBgm::end() { |
| 35 | if (!al::isNerve(user: this, nerve: &NrvPlayGuideBgm.EndForDead)) |
| 36 | al::setNerve(user: this, nerve: &NrvPlayGuideBgm.EndForDead); |
| 37 | } |
| 38 | |
| 39 | void PlayGuideBgm::endImmediate() { |
| 40 | al::killLayoutIfActive(mLayout); |
| 41 | al::setNerve(user: this, nerve: &NrvPlayGuideBgm.EndForDead); |
| 42 | kill(); |
| 43 | } |
| 44 | |
| 45 | void PlayGuideBgm::exeHide() { |
| 46 | if (al::isRunningBgm(mLayout, "CollectBgm" )) |
| 47 | al::setNerve(user: this, nerve: &Show); |
| 48 | } |
| 49 | |
| 50 | void PlayGuideBgm::exeShow() { |
| 51 | if (al::isFirstStep(user: this)) |
| 52 | mLayout->appear(); |
| 53 | |
| 54 | if (!al::isRunningBgm(mLayout, "CollectBgm" )) |
| 55 | al::setNerve(user: this, nerve: &NrvPlayGuideBgm.End); |
| 56 | } |
| 57 | |
| 58 | void PlayGuideBgm::exeEnd() { |
| 59 | if (al::isFirstStep(user: this)) |
| 60 | mLayout->end(); |
| 61 | |
| 62 | if (al::isDead(mLayout)) |
| 63 | al::setNerve(user: this, nerve: &NrvPlayGuideBgm.Hide); |
| 64 | } |
| 65 | |
| 66 | void PlayGuideBgm::exeEndForDead() { |
| 67 | if (al::isFirstStep(user: this) && mLayout->isAppearOrWait()) |
| 68 | mLayout->end(); |
| 69 | |
| 70 | if (al::isDead(mLayout)) |
| 71 | kill(); |
| 72 | } |
| 73 | |