| 1 | #include "MapObj/MoonWorldCaptureParadeLift.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorActionFunction.h" |
| 4 | #include "Library/LiveActor/ActorAnimFunction.h" |
| 5 | #include "Library/LiveActor/ActorClippingFunction.h" |
| 6 | #include "Library/LiveActor/ActorInitUtil.h" |
| 7 | #include "Library/Nerve/NerveSetupUtil.h" |
| 8 | #include "Library/Nerve/NerveUtil.h" |
| 9 | #include "Library/Placement/PlacementFunction.h" |
| 10 | #include "Library/Rail/RailUtil.h" |
| 11 | #include "Library/Stage/StageSwitchUtil.h" |
| 12 | #include "Library/Thread/FunctorV0M.h" |
| 13 | |
| 14 | namespace { |
| 15 | NERVE_IMPL(MoonWorldCaptureParadeLift, Wait) |
| 16 | NERVE_IMPL(MoonWorldCaptureParadeLift, MoveSign) |
| 17 | NERVE_IMPL(MoonWorldCaptureParadeLift, Move) |
| 18 | NERVE_IMPL(MoonWorldCaptureParadeLift, Delay) |
| 19 | |
| 20 | NERVES_MAKE_NOSTRUCT(MoonWorldCaptureParadeLift, Move, Delay) |
| 21 | NERVES_MAKE_STRUCT(MoonWorldCaptureParadeLift, Wait, MoveSign) |
| 22 | } // namespace |
| 23 | |
| 24 | MoonWorldCaptureParadeLift::MoonWorldCaptureParadeLift(const char* name) : al::LiveActor(name) {} |
| 25 | |
| 26 | void MoonWorldCaptureParadeLift::init(const al::ActorInitInfo& info) { |
| 27 | using MoonWorldCaptureParadeLiftFunctor = |
| 28 | al::FunctorV0M<MoonWorldCaptureParadeLift*, void (MoonWorldCaptureParadeLift::*)()>; |
| 29 | |
| 30 | al::initActor(actor: this, initInfo: info); |
| 31 | al::initNerve(actor: this, nerve: &NrvMoonWorldCaptureParadeLift.Wait, maxStates: 0); |
| 32 | |
| 33 | if (al::isExistRail(railHolder: this)) { |
| 34 | f32 clippingRadius = al::getClippingRadius(actor: this); |
| 35 | al::setSyncRailToNearestPos(this); |
| 36 | al::setRailClippingInfo(&mRailClippingInfo, actor: this, 100.0f, clippingRadius); |
| 37 | } |
| 38 | |
| 39 | al::getArg(arg: &mSpeed, initInfo: info, key: "Speed" ); |
| 40 | al::getArg(arg: &mDelay, initInfo: info, key: "Delay" ); |
| 41 | |
| 42 | al::listenStageSwitchOnStart( |
| 43 | user: this, action: MoonWorldCaptureParadeLiftFunctor(this, &MoonWorldCaptureParadeLift::start)); |
| 44 | |
| 45 | makeActorAlive(); |
| 46 | } |
| 47 | |
| 48 | void MoonWorldCaptureParadeLift::start() { |
| 49 | if (al::isNerve(user: this, nerve: &NrvMoonWorldCaptureParadeLift.Wait)) |
| 50 | al::setNerve(user: this, nerve: &NrvMoonWorldCaptureParadeLift.MoveSign); |
| 51 | } |
| 52 | |
| 53 | void MoonWorldCaptureParadeLift::exeWait() {} |
| 54 | |
| 55 | void MoonWorldCaptureParadeLift::exeMoveSign() { |
| 56 | if (al::isFirstStep(user: this)) |
| 57 | al::startAction(actor: this, actionName: "MoveSign" ); |
| 58 | |
| 59 | if (al::isActionEnd(actor: this)) |
| 60 | al::setNerve(user: this, nerve: &Move); |
| 61 | } |
| 62 | |
| 63 | void MoonWorldCaptureParadeLift::exeMove() { |
| 64 | if (al::isFirstStep(user: this)) |
| 65 | al::startAction(actor: this, actionName: "Move" ); |
| 66 | |
| 67 | f32 rate = al::calcRailTotalRate(railHolder: this); |
| 68 | f32 length = al::getRailTotalLength(railHolder: this); |
| 69 | |
| 70 | if ((1.0f - rate) < (mSpeed / length) + 0.00001f) |
| 71 | al::startHitReaction(actor: this, name: "消滅" ); |
| 72 | |
| 73 | if (al::moveSyncRailLoop(actor: this, speed: mSpeed)) { |
| 74 | al::startHitReaction(actor: this, name: "出現" ); |
| 75 | |
| 76 | if (mDelay >= 1) { |
| 77 | al::startMtsAnim(this, "Wait" ); |
| 78 | al::setNerve(user: this, nerve: &Delay); |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | void MoonWorldCaptureParadeLift::exeDelay() { |
| 84 | if (al::isGreaterEqualStep(user: this, step: mDelay - 1)) |
| 85 | al::setNerve(user: this, nerve: &Move); |
| 86 | } |
| 87 | |