| 1 | #include "Library/Action/ActorActionKeeper.h" |
| 2 | |
| 3 | #include "Library/Base/HashCodeUtil.h" |
| 4 | #include "Library/Base/StringUtil.h" |
| 5 | #include "Library/LiveActor/ActorActionFunction.h" |
| 6 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 7 | #include "Library/LiveActor/LiveActor.h" |
| 8 | #include "Library/Nerve/NerveExecutor.h" |
| 9 | #include "Library/Nerve/NerveKeeper.h" |
| 10 | #include "Library/Nerve/NerveUtil.h" |
| 11 | #include "Project/Action/ActionAnimCtrl.h" |
| 12 | #include "Project/Action/ActionBgmCtrl.h" |
| 13 | #include "Project/Action/ActionEffectCtrl.h" |
| 14 | #include "Project/Action/ActionFlagCtrl.h" |
| 15 | #include "Project/Action/ActionPadAndCameraCtrl.h" |
| 16 | #include "Project/Action/ActionScreenEffectCtrl.h" |
| 17 | #include "Project/Action/ActionSeCtrl.h" |
| 18 | |
| 19 | namespace al { |
| 20 | ActorActionKeeper::ActorActionKeeper(LiveActor* parentActor, const char* actorName, |
| 21 | ActionAnimCtrl* animCtrl, NerveActionCtrl* nrvActionCtrl, |
| 22 | ActionFlagCtrl* flagCtrl, ActionEffectCtrl* effectCtrl, |
| 23 | ActionSeCtrl* seCtrl, ActionBgmCtrl* bgmCtrl, |
| 24 | ActionPadAndCameraCtrl* padAndCamCtrl, |
| 25 | ActionScreenEffectCtrl* screenEffectCtrl) |
| 26 | : mParentActor(parentActor), mActorName(actorName), mAnimCtrl(animCtrl), |
| 27 | mNerveActionCtrl(nrvActionCtrl), mFlagCtrl(flagCtrl), mEffectCtrl(effectCtrl), |
| 28 | mSeCtrl(seCtrl), mBgmCtrl(bgmCtrl), mPadAndCameraCtrl(padAndCamCtrl), |
| 29 | mScreenEffectCtrl(screenEffectCtrl) {} |
| 30 | |
| 31 | ActorActionKeeper* ActorActionKeeper::tryCreate(LiveActor* actor, const ActorResource* actorRes, |
| 32 | const char* string0, const char* string1) { |
| 33 | if (!actor->getModelKeeper()) { |
| 34 | if (!actor->getNerveKeeper()) |
| 35 | return nullptr; |
| 36 | if (!actor->getNerveKeeper()->getActionCtrl()) |
| 37 | return nullptr; |
| 38 | } |
| 39 | |
| 40 | const char* name = createStringIfInStack(str: getBaseName(name: string0)); |
| 41 | |
| 42 | ActionAnimCtrl* newAnimCtrl; |
| 43 | NerveActionCtrl* newNerveCtrl; |
| 44 | ActionFlagCtrl* newFlagCtrl; |
| 45 | ActionEffectCtrl* newEffectCtrl; |
| 46 | ActionSeCtrl* newSeCtrl; |
| 47 | ActionBgmCtrl* newBgmCtrl; |
| 48 | ActionPadAndCameraCtrl* newPadAndCameraCtrl; |
| 49 | ActionScreenEffectCtrl* newScreenEffectCtrl; |
| 50 | |
| 51 | newAnimCtrl = ActionAnimCtrl::tryCreate(actor, actorRes, name, string1); |
| 52 | newNerveCtrl = actor->getNerveKeeper() ? actor->getNerveKeeper()->getActionCtrl() : nullptr; |
| 53 | newFlagCtrl = ActionFlagCtrl::tryCreate(actor, string1); |
| 54 | newEffectCtrl = ActionEffectCtrl::tryCreate(actor); |
| 55 | newSeCtrl = ActionSeCtrl::tryCreate(actor->getAudioKeeper()); |
| 56 | newBgmCtrl = ActionBgmCtrl::tryCreate(actor->getAudioKeeper()); |
| 57 | newPadAndCameraCtrl = |
| 58 | ActionPadAndCameraCtrl::tryCreate(actor, actorRes, getTransPtr(actor), string1); |
| 59 | newScreenEffectCtrl = ActionScreenEffectCtrl::tryCreate(actor, string1); |
| 60 | |
| 61 | if (newAnimCtrl || newFlagCtrl || newEffectCtrl || newSeCtrl || newBgmCtrl || |
| 62 | newPadAndCameraCtrl || newScreenEffectCtrl) { |
| 63 | return new ActorActionKeeper(actor, name, newAnimCtrl, newNerveCtrl, newFlagCtrl, |
| 64 | newEffectCtrl, newSeCtrl, newBgmCtrl, newPadAndCameraCtrl, |
| 65 | newScreenEffectCtrl); |
| 66 | } else { |
| 67 | return nullptr; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | void ActorActionKeeper::init() { |
| 72 | if (mFlagCtrl) |
| 73 | mFlagCtrl->initPost(); |
| 74 | } |
| 75 | |
| 76 | bool ActorActionKeeper::startAction(const char* name) { |
| 77 | mIsActionRunning = true; |
| 78 | if (!mNerveActionCtrl) |
| 79 | tryStartActionNoAnim(actionName: name); |
| 80 | |
| 81 | return mAnimCtrl && mAnimCtrl->start(name); |
| 82 | } |
| 83 | |
| 84 | void ActorActionKeeper::tryStartActionNoAnim(const char* string) { |
| 85 | if (mFlagCtrl) |
| 86 | mFlagCtrl->start(string); |
| 87 | if (mEffectCtrl) |
| 88 | mEffectCtrl->startAction(string); |
| 89 | if (mSeCtrl) |
| 90 | mSeCtrl->startAction(string); |
| 91 | if (mBgmCtrl) |
| 92 | mBgmCtrl->startAction(string); |
| 93 | if (mPadAndCameraCtrl) |
| 94 | mPadAndCameraCtrl->startAction(string); |
| 95 | if (mScreenEffectCtrl) |
| 96 | mScreenEffectCtrl->startAction(string); |
| 97 | } |
| 98 | |
| 99 | void ActorActionKeeper::updatePrev() {} |
| 100 | } // namespace al |
| 101 | |