| 1 | #include "Library/Obj/EffectObjFollowCamera.h" |
| 2 | |
| 3 | #include "Library/Camera/CameraUtil.h" |
| 4 | #include "Library/Effect/EffectKeeper.h" |
| 5 | #include "Library/Effect/EffectSystemInfo.h" |
| 6 | #include "Library/LiveActor/ActorClippingFunction.h" |
| 7 | #include "Library/LiveActor/ActorFlagFunction.h" |
| 8 | #include "Library/LiveActor/ActorInitUtil.h" |
| 9 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 10 | #include "Library/Nerve/NerveSetupUtil.h" |
| 11 | #include "Library/Nerve/NerveUtil.h" |
| 12 | #include "Library/Obj/EffectObjFunction.h" |
| 13 | #include "Library/Se/SeFunction.h" |
| 14 | #include "Library/Stage/StageSwitchUtil.h" |
| 15 | #include "Library/Thread/FunctorV0M.h" |
| 16 | |
| 17 | namespace al { |
| 18 | namespace { |
| 19 | NERVE_IMPL(EffectObjFollowCamera, Wait) |
| 20 | NERVE_IMPL(EffectObjFollowCamera, Disappear) |
| 21 | |
| 22 | NERVES_MAKE_NOSTRUCT(EffectObjFollowCamera, Wait, Disappear) |
| 23 | } // namespace |
| 24 | |
| 25 | EffectObjFollowCamera::EffectObjFollowCamera(const char* name) : LiveActor(name) {} |
| 26 | |
| 27 | void EffectObjFollowCamera::init(const ActorInitInfo& info) { |
| 28 | using EffectObjFollowCameraFunctor = |
| 29 | FunctorV0M<EffectObjFollowCamera*, void (EffectObjFollowCamera::*)()>; |
| 30 | |
| 31 | EffectObjFunction::initActorEffectObj(actor: this, info); |
| 32 | invalidateClipping(actor: this); |
| 33 | setEffectNamedMtxPtr(this, "Wait" , &mBaseMtx); |
| 34 | initNerve(actor: this, nerve: &Wait, maxStates: 0); |
| 35 | |
| 36 | listenStageSwitchOnOffAppear( |
| 37 | user: this, actionOn: EffectObjFollowCameraFunctor(this, &EffectObjFollowCamera::startAppear), |
| 38 | actionOff: EffectObjFollowCameraFunctor(this, &EffectObjFollowCamera::startDisappear)) ? |
| 39 | makeActorDead() : |
| 40 | makeActorAlive(); |
| 41 | |
| 42 | listenStageSwitchOnKill( |
| 43 | user: this, action: EffectObjFollowCameraFunctor(this, &EffectObjFollowCamera::startDisappear)); |
| 44 | } |
| 45 | |
| 46 | void EffectObjFollowCamera::startAppear() { |
| 47 | if (isDead(actor: this)) |
| 48 | appear(); |
| 49 | |
| 50 | setNerve(user: this, nerve: &Wait); |
| 51 | } |
| 52 | |
| 53 | void EffectObjFollowCamera::startDisappear() { |
| 54 | setNerve(user: this, nerve: &Disappear); |
| 55 | } |
| 56 | |
| 57 | void EffectObjFollowCamera::control() { |
| 58 | mBaseMtx.setInverse(getViewMtx(user: this, viewIdx: 0)); |
| 59 | } |
| 60 | |
| 61 | void EffectObjFollowCamera::exeWait() { |
| 62 | if (isFirstStep(user: this)) { |
| 63 | tryEmitEffect(this, "Wait" , nullptr); |
| 64 | tryStartSe(this, "Wait" ); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void EffectObjFollowCamera::exeDisappear() { |
| 69 | if (isFirstStep(user: this)) |
| 70 | deleteEffect(this, "Wait" ); |
| 71 | |
| 72 | if (isStep(user: this, step: 180)) |
| 73 | kill(); |
| 74 | } |
| 75 | } // namespace al |
| 76 | |