| 1 | #include "Library/Obj/KeyMoveFollowTarget.h" |
| 2 | |
| 3 | #include "Library/KeyPose/KeyPoseKeeperUtil.h" |
| 4 | #include "Library/LiveActor/ActorActionFunction.h" |
| 5 | #include "Library/LiveActor/ActorClippingFunction.h" |
| 6 | #include "Library/LiveActor/ActorInitUtil.h" |
| 7 | #include "Library/LiveActor/ActorMovementFunction.h" |
| 8 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 9 | #include "Library/Nerve/NerveSetupUtil.h" |
| 10 | #include "Library/Nerve/NerveUtil.h" |
| 11 | |
| 12 | namespace { |
| 13 | using namespace al; |
| 14 | |
| 15 | NERVE_ACTION_IMPL(KeyMoveFollowTarget, Wait) |
| 16 | NERVE_ACTION_IMPL(KeyMoveFollowTarget, Move) |
| 17 | NERVE_ACTION_IMPL(KeyMoveFollowTarget, Stop) |
| 18 | |
| 19 | NERVE_ACTIONS_MAKE_STRUCT(KeyMoveFollowTarget, Wait, Move, Stop) |
| 20 | } // namespace |
| 21 | |
| 22 | namespace al { |
| 23 | |
| 24 | KeyMoveFollowTarget::KeyMoveFollowTarget(const char* name) : LiveActor(name) {} |
| 25 | |
| 26 | void KeyMoveFollowTarget::initKeyMoveFollowTarget(const ActorInitInfo& info, |
| 27 | const char* archiveName, const char* suffix) { |
| 28 | initNerveAction(actor: this, actionName: "Wait" , collector: &NrvKeyMoveFollowTarget.collector, maxStates: 0); |
| 29 | initActorWithArchiveName(actor: this, initInfo: info, archiveName, suffix); |
| 30 | |
| 31 | mKeyPoseKeeper = createKeyPoseKeeper(info); |
| 32 | |
| 33 | makeActorAlive(); |
| 34 | } |
| 35 | |
| 36 | void KeyMoveFollowTarget::exeWait() { |
| 37 | if (isFirstStep(user: this)) { |
| 38 | s32 timer = calcKeyMoveWaitTime(keyPoseKeeper: mKeyPoseKeeper); |
| 39 | if (timer > -1) |
| 40 | mMoveWaitTime = timer; |
| 41 | } |
| 42 | |
| 43 | if (isGreaterEqualStep(user: this, step: mMoveWaitTime)) { |
| 44 | if (isRestart(keyPoseKeeper: mKeyPoseKeeper)) { |
| 45 | restartKeyPose(keyPoseKeeper: mKeyPoseKeeper, pos: getTransPtr(actor: this), orientation: getQuatPtr(actor: this)); |
| 46 | resetPosition(actor: this); |
| 47 | startNerveAction(actor: this, actionName: "Wait" ); |
| 48 | |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | startNerveAction(actor: this, actionName: "Move" ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | void KeyMoveFollowTarget::exeMove() { |
| 57 | if (isFirstStep(user: this)) |
| 58 | mTimer = calcKeyMoveMoveTime(keyPoseKeeper: mKeyPoseKeeper); |
| 59 | |
| 60 | f32 rate = calcNerveRate(user: this, max: mTimer); |
| 61 | calcLerpKeyTrans(out: getTransPtr(actor: this), keyPoseKeeper: mKeyPoseKeeper, rate); |
| 62 | calcSlerpKeyQuat(out: getQuatPtr(actor: this), keyPoseKeeper: mKeyPoseKeeper, rate); |
| 63 | |
| 64 | if (isGreaterEqualStep(user: this, step: mTimer)) { |
| 65 | nextKeyPose(keyPoseKeeper: mKeyPoseKeeper); |
| 66 | |
| 67 | if (!isStop(keyPoseKeeper: mKeyPoseKeeper)) { |
| 68 | startHitReaction(actor: this, name: "移動終了" ); |
| 69 | startNerveAction(actor: this, actionName: "Wait" ); |
| 70 | |
| 71 | return; |
| 72 | } |
| 73 | |
| 74 | startNerveAction(actor: this, actionName: "Stop" ); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void KeyMoveFollowTarget::exeStop() { |
| 79 | if (isFirstStep(user: this) && isInvalidClipping(this)) |
| 80 | validateClipping(actor: this); |
| 81 | } |
| 82 | } // namespace al |
| 83 | |