| 1 | #include "MapObj/StageSwitchSelector.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorClippingFunction.h" |
| 4 | #include "Library/LiveActor/ActorInitFunction.h" |
| 5 | #include "Library/LiveActor/ActorInitUtil.h" |
| 6 | #include "Library/Nerve/NerveSetupUtil.h" |
| 7 | #include "Library/Nerve/NerveUtil.h" |
| 8 | #include "Library/Placement/PlacementFunction.h" |
| 9 | #include "Library/Stage/StageSwitchUtil.h" |
| 10 | |
| 11 | #include "MapObj/AppearSwitchSave.h" |
| 12 | |
| 13 | namespace { |
| 14 | NERVE_IMPL(StageSwitchSelector, WaitStatUp) |
| 15 | NERVE_IMPL(StageSwitchSelector, WaitStartSwitching) |
| 16 | NERVE_IMPL(StageSwitchSelector, WaitDelaySwitching) |
| 17 | |
| 18 | NERVES_MAKE_NOSTRUCT(StageSwitchSelector, WaitDelaySwitching) |
| 19 | NERVES_MAKE_STRUCT(StageSwitchSelector, WaitStatUp, WaitStartSwitching) |
| 20 | } // namespace |
| 21 | |
| 22 | StageSwitchSelector::StageSwitchSelector(const char* name) : al::LiveActor(name) {} |
| 23 | |
| 24 | void StageSwitchSelector::init(const al::ActorInitInfo& info) { |
| 25 | al::initActorSceneInfo(actor: this, info); |
| 26 | al::initExecutorUpdate(actor: this, info, "監視オブジェ" ); |
| 27 | al::initStageSwitch(this, info); |
| 28 | al::initActorPoseTRSV(actor: this); |
| 29 | al::initActorClipping(actor: this, initInfo: info); |
| 30 | al::invalidateClipping(actor: this); |
| 31 | |
| 32 | mAppearSwitchSave = new AppearSwitchSave(this, info); |
| 33 | |
| 34 | if (mAppearSwitchSave->isOn()) { |
| 35 | al::tryOnStageSwitch(user: this, linkName: "AfterSwitchingOn" ); |
| 36 | makeActorDead(); |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | al::tryGetArg(arg: &mSwitchingStartFrameNum, initInfo: info, key: "SwitchingStartFrameNum" ); |
| 41 | if (al::isValidStageSwitch(user: this, linkName: "SwitchStart" )) { |
| 42 | al::initNerve(actor: this, nerve: &NrvStageSwitchSelector.WaitStatUp, maxStates: 0); |
| 43 | } else { |
| 44 | al::tryOnStageSwitch(user: this, linkName: "BeforeSwitchingOn" ); |
| 45 | al::initNerve(actor: this, nerve: &NrvStageSwitchSelector.WaitStartSwitching, maxStates: 0); |
| 46 | } |
| 47 | makeActorAlive(); |
| 48 | } |
| 49 | |
| 50 | void StageSwitchSelector::exeWaitStatUp() { |
| 51 | if (al::isOnStageSwitch(user: this, linkName: "SwitchStart" )) { |
| 52 | al::tryOnStageSwitch(user: this, linkName: "BeforeSwitchingOn" ); |
| 53 | al::setNerve(user: this, nerve: &NrvStageSwitchSelector.WaitStartSwitching); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | void StageSwitchSelector::exeWaitStartSwitching() { |
| 58 | if (al::isOnStageSwitch(user: this, linkName: "StartSwitching" )) |
| 59 | al::setNerve(user: this, nerve: &WaitDelaySwitching); |
| 60 | } |
| 61 | |
| 62 | void StageSwitchSelector::exeWaitDelaySwitching() { |
| 63 | if (al::isFirstStep(user: this)) |
| 64 | mSwitchingDelay = mSwitchingStartFrameNum; |
| 65 | |
| 66 | if (mSwitchingDelay != 0) |
| 67 | mSwitchingDelay--; |
| 68 | else { |
| 69 | al::tryOffStageSwitch(user: this, linkName: "BeforeSwitchingOn" ); |
| 70 | al::tryOnStageSwitch(user: this, linkName: "AfterSwitchingOn" ); |
| 71 | mAppearSwitchSave->onSwitch(); |
| 72 | makeActorDead(); |
| 73 | } |
| 74 | } |
| 75 | |