| 1 | #include "Layout/PlayGuideCamera.h" |
| 2 | |
| 3 | #include "Library/Camera/CameraUtil.h" |
| 4 | #include "Library/Layout/LayoutActionFunction.h" |
| 5 | #include "Library/Layout/LayoutActorUtil.h" |
| 6 | #include "Library/Layout/LayoutInitInfo.h" |
| 7 | #include "Library/Nerve/NerveSetupUtil.h" |
| 8 | #include "Library/Nerve/NerveUtil.h" |
| 9 | |
| 10 | #include "Util/DemoUtil.h" |
| 11 | #include "Util/PlayerUtil.h" |
| 12 | |
| 13 | namespace { |
| 14 | NERVE_IMPL(PlayGuideCamera, Hide); |
| 15 | NERVE_IMPL(PlayGuideCamera, Appear); |
| 16 | NERVE_IMPL(PlayGuideCamera, Wait); |
| 17 | NERVE_IMPL(PlayGuideCamera, End); |
| 18 | |
| 19 | NERVES_MAKE_NOSTRUCT(PlayGuideCamera, Wait); |
| 20 | NERVES_MAKE_STRUCT(PlayGuideCamera, Hide, Appear, End); |
| 21 | } // namespace |
| 22 | |
| 23 | PlayGuideCamera::PlayGuideCamera(const char* name, const al::LayoutInitInfo& info, |
| 24 | const al::LiveActor* player) |
| 25 | : al::LayoutActor(name), mPlayer(player) { |
| 26 | al::initLayoutActor(this, info, "PlayGuideCamera" , nullptr); |
| 27 | initNerve(&NrvPlayGuideCamera.Hide, 0); |
| 28 | appear(); |
| 29 | hide(); |
| 30 | } |
| 31 | |
| 32 | void PlayGuideCamera::hide() { |
| 33 | al::hidePaneRoot(this); |
| 34 | al::setNerve(user: this, nerve: &NrvPlayGuideCamera.Hide); |
| 35 | } |
| 36 | |
| 37 | void PlayGuideCamera::start() { |
| 38 | if (!rs::isActiveDemo(mPlayer)) |
| 39 | al::setNerve(user: this, nerve: &NrvPlayGuideCamera.Appear); |
| 40 | } |
| 41 | |
| 42 | void PlayGuideCamera::exeHide() { |
| 43 | if (!mIsShown && tryAppear()) |
| 44 | return; |
| 45 | |
| 46 | if (!al::isExistCameraInputAtDisableTiming(user: this, inputIdx: 0)) |
| 47 | mIsShown = false; |
| 48 | } |
| 49 | |
| 50 | bool PlayGuideCamera::tryAppear() { |
| 51 | if (!rs::isActiveDemo(mPlayer) && al::isExistCameraInputAtDisableTiming(user: this, inputIdx: 0) && |
| 52 | !rs::isPlayerHackGroupUseCameraStick(mPlayer)) { |
| 53 | al::setNerve(user: this, nerve: &NrvPlayGuideCamera.Appear); |
| 54 | return true; |
| 55 | } |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | void PlayGuideCamera::exeAppear() { |
| 60 | if (al::isFirstStep(user: this)) { |
| 61 | al::startAction(layout: this, actionName: "Appear" , paneName: nullptr); |
| 62 | al::showPaneRoot(this); |
| 63 | mIsShown = true; |
| 64 | } |
| 65 | if (al::isActionEnd(layout: this, paneName: nullptr)) |
| 66 | al::setNerve(user: this, nerve: &Wait); |
| 67 | else if (!al::isExistCameraInputAtDisableTiming(user: this, inputIdx: 0)) |
| 68 | mIsShown = false; |
| 69 | } |
| 70 | |
| 71 | void PlayGuideCamera::exeWait() { |
| 72 | if (al::isFirstStep(user: this)) |
| 73 | al::startAction(layout: this, actionName: "Wait" , paneName: nullptr); |
| 74 | |
| 75 | if (al::isGreaterEqualStep(user: this, step: 30)) { |
| 76 | al::setNerve(user: this, nerve: &NrvPlayGuideCamera.End); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | if (al::isExistCameraInputAtDisableTiming(user: this, inputIdx: 0)) { |
| 81 | if (mIsShown) |
| 82 | return; |
| 83 | } else |
| 84 | mIsShown = false; |
| 85 | |
| 86 | tryAppear(); |
| 87 | } |
| 88 | |
| 89 | void PlayGuideCamera::exeEnd() { |
| 90 | if (al::isFirstStep(user: this)) |
| 91 | al::startAction(layout: this, actionName: "End" , paneName: nullptr); |
| 92 | |
| 93 | if (al::isActionEnd(layout: this, paneName: nullptr)) { |
| 94 | al::hidePaneRoot(this); |
| 95 | al::setNerve(user: this, nerve: &NrvPlayGuideCamera.Hide); |
| 96 | } |
| 97 | |
| 98 | if (al::isExistCameraInputAtDisableTiming(user: this, inputIdx: 0)) { |
| 99 | if (mIsShown) |
| 100 | return; |
| 101 | } else |
| 102 | mIsShown = false; |
| 103 | |
| 104 | tryAppear(); |
| 105 | } |
| 106 | |