| 1 | #include "Enemy/EnemyStateReset.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorActionFunction.h" |
| 4 | #include "Library/LiveActor/ActorAnimFunction.h" |
| 5 | #include "Library/LiveActor/ActorClippingFunction.h" |
| 6 | #include "Library/LiveActor/ActorModelFunction.h" |
| 7 | #include "Library/LiveActor/ActorMovementFunction.h" |
| 8 | #include "Library/LiveActor/ActorSensorUtil.h" |
| 9 | #include "Library/Nerve/NerveSetupUtil.h" |
| 10 | #include "Library/Nerve/NerveUtil.h" |
| 11 | #include "Library/Placement/PlacementFunction.h" |
| 12 | #include "Library/Player/PlayerHolder.h" |
| 13 | #include "Library/Player/PlayerUtil.h" |
| 14 | |
| 15 | #include "Enemy/EnemyCap.h" |
| 16 | #include "Util/Hack.h" |
| 17 | |
| 18 | namespace { |
| 19 | NERVE_IMPL(EnemyStateReset, Wait); |
| 20 | |
| 21 | NERVES_MAKE_STRUCT(EnemyStateReset, Wait); |
| 22 | } // namespace |
| 23 | |
| 24 | EnemyStateReset::EnemyStateReset(al::LiveActor* actor, const al::ActorInitInfo& info, EnemyCap* cap) |
| 25 | : al::ActorStateBase("リセット状態" , actor), mEnemyCap(cap) { |
| 26 | initNerve(nerve: &NrvEnemyStateReset.Wait, stateCount: 0); |
| 27 | al::tryGetTrans(trans: &mPos, initInfo: info); |
| 28 | al::tryGetRotate(rotate: &mRot, initInfo: info); |
| 29 | al::tryGetArg(arg: &mIsRevive, initInfo: info, key: "IsRevive" ); |
| 30 | } |
| 31 | |
| 32 | void EnemyStateReset::appear() { |
| 33 | al::LiveActor* actor = mActor; // getting the actor in each function call below causes |
| 34 | // mismatch, have to declare a variable up here for it |
| 35 | |
| 36 | al::NerveStateBase::appear(); |
| 37 | if (!mIsRevive) { |
| 38 | actor->kill(); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | al::setVelocityZero(actor); |
| 43 | al::invalidateClipping(actor); |
| 44 | al::hideModelIfShow(actor); |
| 45 | al::stopAction(actor); |
| 46 | rs::startReset(actor); |
| 47 | |
| 48 | if (!mIsInvalidateSensors) |
| 49 | al::invalidateHitSensors(actor); |
| 50 | |
| 51 | al::setNerve(user: this, nerve: &NrvEnemyStateReset.Wait); |
| 52 | } |
| 53 | |
| 54 | void EnemyStateReset::kill() { |
| 55 | al::NerveStateBase::kill(); |
| 56 | if (!mIsRevive) |
| 57 | return; |
| 58 | |
| 59 | al::LiveActor* actor = mActor; |
| 60 | |
| 61 | al::validateClipping(actor); |
| 62 | al::showModelIfHide(actor); |
| 63 | rs::endReset(actor); |
| 64 | al::restartAction(actor); |
| 65 | if (!mIsInvalidateSensors) |
| 66 | al::validateHitSensors(actor); |
| 67 | if (rs::tryAppearEnemyCap(mEnemyCap)) |
| 68 | al::tryStartVisAnimIfExist(mActor, "CapOn" ); // mActor is used here instead of the declared |
| 69 | // actor variable. Requires for match |
| 70 | } |
| 71 | |
| 72 | void EnemyStateReset::exeWait() { |
| 73 | if (al::isStep(user: this, step: 2)) |
| 74 | al::resetRotatePosition(actor: mActor, rot: mRot, trans: mPos); |
| 75 | if (al::isGreaterEqualStep(user: this, step: 2) && al::isResetablePlayerPos(mActor, mValidDistance)) |
| 76 | kill(); |
| 77 | } |
| 78 | |