| 1 | #include "Library/MapObj/RotateMapParts.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorActionFunction.h" |
| 4 | #include "Library/LiveActor/ActorAreaFunction.h" |
| 5 | #include "Library/LiveActor/ActorInitUtil.h" |
| 6 | #include "Library/LiveActor/ActorModelFunction.h" |
| 7 | #include "Library/LiveActor/ActorMovementFunction.h" |
| 8 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 9 | #include "Library/LiveActor/ActorSensorUtil.h" |
| 10 | #include "Library/MapObj/ChildStep.h" |
| 11 | #include "Library/Nerve/NerveSetupUtil.h" |
| 12 | #include "Library/Nerve/NerveUtil.h" |
| 13 | #include "Library/Placement/PlacementFunction.h" |
| 14 | #include "Library/Se/SeFunction.h" |
| 15 | #include "Library/Stage/StageSwitchUtil.h" |
| 16 | #include "Library/Thread/FunctorV0M.h" |
| 17 | |
| 18 | namespace al { |
| 19 | namespace { |
| 20 | NERVE_ACTION_IMPL(RotateMapParts, StandBy) |
| 21 | NERVE_ACTION_IMPL(RotateMapParts, Rotate) |
| 22 | NERVE_ACTION_IMPL(RotateMapParts, AssistStop) |
| 23 | |
| 24 | NERVE_ACTIONS_MAKE_STRUCT(RotateMapParts, StandBy, Rotate, AssistStop) |
| 25 | } // namespace |
| 26 | |
| 27 | RotateMapParts::RotateMapParts(const char* name) : LiveActor(name) {} |
| 28 | |
| 29 | void RotateMapParts::init(const ActorInitInfo& info) { |
| 30 | using RotateMapPartsFunctor = FunctorV0M<RotateMapParts*, void (RotateMapParts::*)()>; |
| 31 | |
| 32 | tryInitSubActorKeeperChildStep(actor: this, info); |
| 33 | initNerveAction(actor: this, actionName: "Rotate" , collector: &NrvRotateMapParts.collector, maxStates: 0); |
| 34 | initMapPartsActor(actor: this, initInfo: info, suffix: nullptr); |
| 35 | tryGetQuatPtr(actor: this); |
| 36 | registerAreaHostMtx(actor: this, initInfo: info); |
| 37 | |
| 38 | mQuat.set(getQuat(actor: this)); |
| 39 | tryGetArg(arg: (s32*)&mRotateAxis, initInfo: info, key: "RotateAxis" ); |
| 40 | tryGetArg(arg: &mRotateSpeed, initInfo: info, key: "RotateSpeed" ); |
| 41 | |
| 42 | createChildStep(info, parent: this, isSyncClipping: true); |
| 43 | initMaterialCode(actor: this, initInfo: info); |
| 44 | |
| 45 | if (listenStageSwitchOnStart(user: this, action: RotateMapPartsFunctor(this, &RotateMapParts::start))) |
| 46 | startNerveAction(actor: this, actionName: "StandBy" ); |
| 47 | |
| 48 | trySyncStageSwitchAppear(actor: this); |
| 49 | } |
| 50 | |
| 51 | void RotateMapParts::start() { |
| 52 | if (isNerve(user: this, nerve: NrvRotateMapParts.StandBy.data())) |
| 53 | startNerveAction(actor: this, actionName: "Rotate" ); |
| 54 | } |
| 55 | |
| 56 | bool RotateMapParts::receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) { |
| 57 | if (isMsgTouchAssist(msg: message)) { |
| 58 | mAssistTimer = 45; |
| 59 | |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | if (isMsgShowModel(msg: message)) { |
| 64 | showModelIfHide(actor: this); |
| 65 | |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | if (isMsgHideModel(msg: message)) { |
| 70 | hideModelIfShow(actor: this); |
| 71 | |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | if (isMsgRestart(msg: message)) { |
| 76 | appearAndSetStart(); |
| 77 | |
| 78 | return true; |
| 79 | } |
| 80 | |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | void RotateMapParts::appearAndSetStart() { |
| 85 | mAssistTimer = 0; |
| 86 | setQuat(actor: this, quat: mQuat); |
| 87 | |
| 88 | makeActorAlive(); |
| 89 | } |
| 90 | |
| 91 | void RotateMapParts::exeStandBy() {} |
| 92 | |
| 93 | void RotateMapParts::exeRotate() { |
| 94 | rotateQuatLocalDirDegree(actor: this, axis: (s32)mRotateAxis, deg: mRotateSpeed / 100.0f); |
| 95 | if (mAssistTimer > 0) |
| 96 | startNerveAction(actor: this, actionName: "AssistStop" ); |
| 97 | |
| 98 | tryHoldSeWithParam(this, "RotateWithSpeed" , mRotateSpeed, "" ); |
| 99 | } |
| 100 | |
| 101 | void RotateMapParts::exeAssistStop() { |
| 102 | mAssistTimer--; |
| 103 | if (mAssistTimer <= 0) { |
| 104 | mAssistTimer = 0; |
| 105 | startNerveAction(actor: this, actionName: "Rotate" ); |
| 106 | } |
| 107 | } |
| 108 | } // namespace al |
| 109 | |