| 1 | #include "Npc/TiaraEyes.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorActionFunction.h" |
| 4 | #include "Library/LiveActor/ActorFlagFunction.h" |
| 5 | #include "Library/LiveActor/ActorInitUtil.h" |
| 6 | #include "Library/LiveActor/ActorModelFunction.h" |
| 7 | #include "Library/LiveActor/LiveActor.h" |
| 8 | #include "Library/Nerve/NerveSetupUtil.h" |
| 9 | #include "Library/Nerve/NerveUtil.h" |
| 10 | |
| 11 | namespace { |
| 12 | NERVE_IMPL(TiaraEyes, Appear); |
| 13 | NERVE_IMPL_(TiaraEyes, WaitPanicL, Controlled); |
| 14 | NERVE_IMPL_(TiaraEyes, WaitPanicR, Controlled); |
| 15 | NERVE_IMPL_(TiaraEyes, MovePanicL, Controlled); |
| 16 | NERVE_IMPL_(TiaraEyes, MovePanicR, Controlled); |
| 17 | NERVE_IMPL_(TiaraEyes, Reaction, Controlled); |
| 18 | NERVE_IMPL_(TiaraEyes, ReactionCap, Controlled); |
| 19 | NERVE_IMPL(TiaraEyes, Wait); |
| 20 | NERVE_IMPL(TiaraEyes, Disappear); |
| 21 | NERVE_END_IMPL(TiaraEyes, Hide); |
| 22 | |
| 23 | NERVES_MAKE_NOSTRUCT(TiaraEyes, Appear, WaitPanicL, WaitPanicR, MovePanicL, MovePanicR, Reaction, |
| 24 | ReactionCap, Wait, Disappear, Hide); |
| 25 | } // namespace |
| 26 | |
| 27 | TiaraEyes::TiaraEyes(const char* name) : al::PartsModel(name) {} |
| 28 | |
| 29 | void TiaraEyes::init(const al::ActorInitInfo& info) { |
| 30 | al::initNerve(actor: this, nerve: &Appear, maxStates: 0); |
| 31 | makeActorDead(); |
| 32 | } |
| 33 | |
| 34 | void TiaraEyes::appear() { |
| 35 | al::LiveActor::appear(); |
| 36 | al::setNerve(user: this, nerve: &Appear); |
| 37 | } |
| 38 | |
| 39 | void TiaraEyes::startWaitPanicL(f32 frame) { |
| 40 | if (al::isDead(actor: this)) |
| 41 | appear(); |
| 42 | |
| 43 | al::startAction(actor: this, actionName: "WaitPanicL" ); |
| 44 | al::setActionFrame(actor: this, frame: sead::Mathf::min(a: al::getActionFrameMax(actor: this, actionName: "WaitPanicL" ), b: frame)); |
| 45 | al::setNerve(user: this, nerve: &WaitPanicL); |
| 46 | } |
| 47 | |
| 48 | void TiaraEyes::startWaitPanicR(f32 frame) { |
| 49 | if (al::isDead(actor: this)) |
| 50 | appear(); |
| 51 | |
| 52 | al::startAction(actor: this, actionName: "WaitPanicR" ); |
| 53 | al::setActionFrame(actor: this, frame: sead::Mathf::min(a: al::getActionFrameMax(actor: this, actionName: "WaitPanicR" ), b: frame)); |
| 54 | al::setNerve(user: this, nerve: &WaitPanicR); |
| 55 | } |
| 56 | |
| 57 | void TiaraEyes::startMovePanicL(f32 frame) { |
| 58 | if (al::isDead(actor: this)) |
| 59 | appear(); |
| 60 | |
| 61 | al::startAction(actor: this, actionName: "MovePanicL" ); |
| 62 | al::setActionFrame(actor: this, frame: sead::Mathf::min(a: al::getActionFrameMax(actor: this, actionName: "MovePanicL" ), b: frame)); |
| 63 | al::setNerve(user: this, nerve: &MovePanicL); |
| 64 | } |
| 65 | |
| 66 | void TiaraEyes::startMovePanicR(f32 frame) { |
| 67 | if (al::isDead(actor: this)) |
| 68 | appear(); |
| 69 | |
| 70 | al::startAction(actor: this, actionName: "MovePanicR" ); |
| 71 | al::setActionFrame(actor: this, frame: sead::Mathf::min(a: al::getActionFrameMax(actor: this, actionName: "MovePanicR" ), b: frame)); |
| 72 | al::setNerve(user: this, nerve: &MovePanicR); |
| 73 | } |
| 74 | |
| 75 | void TiaraEyes::startReaction() { |
| 76 | if (al::isDead(actor: this)) |
| 77 | appear(); |
| 78 | |
| 79 | al::startAction(actor: this, actionName: "Reaction" ); |
| 80 | al::setActionFrame(actor: this, frame: sead::Mathf::min(a: al::getActionFrameMax(actor: this, actionName: "Reaction" ), b: 0.0f)); |
| 81 | al::setNerve(user: this, nerve: &Reaction); |
| 82 | } |
| 83 | |
| 84 | void TiaraEyes::startReactionCap() { |
| 85 | if (al::isDead(actor: this)) |
| 86 | appear(); |
| 87 | |
| 88 | al::startAction(actor: this, actionName: "ReactionCap" ); |
| 89 | al::setActionFrame(actor: this, frame: sead::Mathf::min(a: al::getActionFrameMax(actor: this, actionName: "ReactionCap" ), b: 0.0f)); |
| 90 | al::setNerve(user: this, nerve: &ReactionCap); |
| 91 | } |
| 92 | |
| 93 | void TiaraEyes::exeAppear() { |
| 94 | if (al::isFirstStep(user: this)) |
| 95 | al::startAction(actor: this, actionName: "Appear" ); |
| 96 | |
| 97 | al::setNerveAtActionEnd(actor: this, nerve: &Wait); |
| 98 | } |
| 99 | |
| 100 | void TiaraEyes::exeWait() { |
| 101 | if (al::isFirstStep(user: this)) |
| 102 | al::startAction(actor: this, actionName: "Wait" ); |
| 103 | |
| 104 | if (!mIsActive) |
| 105 | al::setNerve(user: this, nerve: &Disappear); |
| 106 | } |
| 107 | |
| 108 | void TiaraEyes::exeDisappear() { |
| 109 | if (al::isFirstStep(user: this)) |
| 110 | al::startAction(actor: this, actionName: "Disappear" ); |
| 111 | |
| 112 | if (al::isActionEnd(actor: this)) { |
| 113 | al::hideModelIfShow(actor: this); |
| 114 | al::setNerve(user: this, nerve: &Hide); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | void TiaraEyes::exeHide() { |
| 119 | if (al::isFirstStep(user: this)) |
| 120 | mHideTimer = 0; |
| 121 | |
| 122 | mHideTimer += mIsActive ? 1 : -mHideTimer; |
| 123 | |
| 124 | if (mHideTimer >= 60) |
| 125 | al::setNerve(user: this, nerve: &Appear); |
| 126 | } |
| 127 | |
| 128 | void TiaraEyes::endHide() { |
| 129 | al::showModelIfHide(actor: this); |
| 130 | } |
| 131 | |
| 132 | void TiaraEyes::exeControlled() {} |
| 133 | |