| 1 | #include "Boss/Mofumofu/MofumofuScrap.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorActionFunction.h" |
| 4 | #include "Library/LiveActor/ActorInitUtil.h" |
| 5 | #include "Library/LiveActor/ActorSensorUtil.h" |
| 6 | #include "Library/Nerve/NerveSetupUtil.h" |
| 7 | #include "Library/Nerve/NerveUtil.h" |
| 8 | #include "Library/Obj/CollisionObj.h" |
| 9 | #include "Library/Obj/PartsFunction.h" |
| 10 | #include "Library/Stage/StageSwitchUtil.h" |
| 11 | |
| 12 | #include "Util/SensorMsgFunction.h" |
| 13 | |
| 14 | namespace { |
| 15 | NERVE_IMPL(MofumofuScrap, Wait) |
| 16 | NERVE_IMPL(MofumofuScrap, ReactionCap) |
| 17 | NERVE_IMPL(MofumofuScrap, Reaction) |
| 18 | |
| 19 | NERVES_MAKE_NOSTRUCT(MofumofuScrap, Wait) |
| 20 | NERVES_MAKE_STRUCT(MofumofuScrap, ReactionCap, Reaction) |
| 21 | } // namespace |
| 22 | |
| 23 | MofumofuScrap::MofumofuScrap(const char* name) : al::LiveActor(name) {} |
| 24 | |
| 25 | void MofumofuScrap::init(const al::ActorInitInfo& info) { |
| 26 | al::initActor(actor: this, initInfo: info); |
| 27 | al::initNerve(actor: this, nerve: &Wait, maxStates: 0); |
| 28 | al::startAction(actor: this, actionName: "Wait" ); |
| 29 | |
| 30 | al::CollisionObj* collision = |
| 31 | al::createCollisionObj(parent: this, info, collisionFileName: "Leg" , hitSensor: al::getHitSensor(this, "Leg" ), joinMtxName: nullptr, suffix: nullptr); |
| 32 | collision->makeActorAlive(); |
| 33 | |
| 34 | al::trySyncStageSwitchAppearAndKill(actor: this); |
| 35 | } |
| 36 | |
| 37 | bool MofumofuScrap::receiveMsg(const al::SensorMsg* message, al::HitSensor* other, |
| 38 | al::HitSensor* self) { |
| 39 | if (rs::isMsgNpcCapReactionAll(message) || rs::isMsgCapTouchWall(message) || |
| 40 | rs::isMsgPlayerRollingWallHitDown(message)) { |
| 41 | al::setNerve(user: this, nerve: &NrvMofumofuScrap.ReactionCap); |
| 42 | return true; |
| 43 | } |
| 44 | if (rs::isMsgPlayerAndCapHipDropAll(message) && !al::isSensorName(self, "Leg" )) { |
| 45 | al::tryOnStageSwitch(user: this, linkName: "SwitchHipDropOn" ); |
| 46 | al::setNerve(user: this, nerve: &NrvMofumofuScrap.Reaction); |
| 47 | } |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | void MofumofuScrap::exeWait() { |
| 52 | if (al::isFirstStep(user: this)) |
| 53 | al::tryStartActionIfNotPlaying(actor: this, actionName: "Wait" ); |
| 54 | } |
| 55 | |
| 56 | void MofumofuScrap::exeReaction() { |
| 57 | if (al::isFirstStep(user: this)) |
| 58 | al::startAction(actor: this, actionName: "Reaction" ); |
| 59 | al::setNerveAtActionEnd(actor: this, nerve: &Wait); |
| 60 | } |
| 61 | |
| 62 | void MofumofuScrap::exeReactionCap() { |
| 63 | if (al::isFirstStep(user: this)) |
| 64 | al::startAction(actor: this, actionName: "ReactionCap" ); |
| 65 | al::setNerveAtActionEnd(actor: this, nerve: &Wait); |
| 66 | } |
| 67 | |