| 1 | #include "Enemy/FlyerStateWander.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorActionFunction.h" |
| 4 | #include "Library/LiveActor/ActorMovementFunction.h" |
| 5 | #include "Library/LiveActor/ActorParamMove.h" |
| 6 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 7 | #include "Library/Math/MathUtil.h" |
| 8 | #include "Library/Nerve/NerveSetupUtil.h" |
| 9 | #include "Library/Nerve/NerveUtil.h" |
| 10 | |
| 11 | namespace { |
| 12 | NERVE_IMPL(FlyerStateWander, Wander) |
| 13 | NERVE_IMPL(FlyerStateWander, Wait) |
| 14 | |
| 15 | NERVES_MAKE_NOSTRUCT(FlyerStateWander, Wander, Wait) |
| 16 | } // namespace |
| 17 | |
| 18 | FlyerStateWanderParam::FlyerStateWanderParam(s32 ukn, s32 wanderTime, s32 waitTime, |
| 19 | const char* actionName, |
| 20 | const al::ActorParamMove* actorParamMove) |
| 21 | : _0(ukn), mWanderTime(wanderTime), mWaitTime(waitTime), mActionName(actionName), |
| 22 | mActorParamMove(actorParamMove) {} |
| 23 | |
| 24 | FlyerStateWander::FlyerStateWander(al::LiveActor* actor, const FlyerStateWanderParam* param) |
| 25 | : al::ActorStateBase("飛行型うろつき状態" , actor), mFlyerStateWanderParam(param) { |
| 26 | initNerve(nerve: &Wander, stateCount: 0); |
| 27 | } |
| 28 | |
| 29 | void FlyerStateWander::appear() { |
| 30 | al::NerveStateBase::appear(); |
| 31 | al::setNerve(user: this, nerve: &Wander); |
| 32 | } |
| 33 | |
| 34 | void FlyerStateWander::exeWander() { |
| 35 | if (al::isFirstStep(user: this)) { |
| 36 | mStartTrans.set(al::getTrans(actor: mActor)); |
| 37 | al::startAction(actor: mActor, actionName: mFlyerStateWanderParam->getActionName()); |
| 38 | mNerveTime = mFlyerStateWanderParam->getWanderTime() + |
| 39 | mFlyerStateWanderParam->get_0() * al::getRandom(max: 3); |
| 40 | } |
| 41 | |
| 42 | const al::ActorParamMove* actorParamMove = mFlyerStateWanderParam->getActorParamMove(); |
| 43 | al::flyAndTurnToTarget(actor: mActor, target: mStartTrans, forceFront: actorParamMove->forceFront, |
| 44 | forceGravity: actorParamMove->forceGravity, decay: actorParamMove->decay, |
| 45 | deg: actorParamMove->turnDegrees); |
| 46 | |
| 47 | if (al::isGreaterEqualStep(user: this, step: mNerveTime)) |
| 48 | al::setNerve(user: this, nerve: &Wait); |
| 49 | } |
| 50 | |
| 51 | void FlyerStateWander::exeWait() { |
| 52 | if (al::isFirstStep(user: this)) { |
| 53 | mNerveTime = mFlyerStateWanderParam->getWaitTime() + |
| 54 | mFlyerStateWanderParam->get_0() * al::getRandom(max: 3); |
| 55 | } |
| 56 | |
| 57 | al::setVelocityZero(mActor); |
| 58 | |
| 59 | if (al::isGreaterEqualStep(user: this, step: mNerveTime)) |
| 60 | al::setNerve(user: this, nerve: &Wander); |
| 61 | } |
| 62 | |