| 1 | #include "MapObj/CapBomb.h" |
| 2 | |
| 3 | #include "Library/Layout/LayoutActor.h" |
| 4 | #include "Library/Layout/LayoutInitInfo.h" |
| 5 | #include "Library/LiveActor/ActorActionFunction.h" |
| 6 | #include "Library/LiveActor/ActorFlagFunction.h" |
| 7 | #include "Library/LiveActor/ActorInitUtil.h" |
| 8 | #include "Library/LiveActor/ActorModelFunction.h" |
| 9 | #include "Library/LiveActor/ActorMovementFunction.h" |
| 10 | #include "Library/LiveActor/ActorSensorUtil.h" |
| 11 | #include "Library/Nerve/NerveSetupUtil.h" |
| 12 | #include "Library/Nerve/NerveUtil.h" |
| 13 | |
| 14 | #include "Util/SensorMsgFunction.h" |
| 15 | |
| 16 | namespace { |
| 17 | NERVE_IMPL(CapBomb, Wait); |
| 18 | NERVE_IMPL(CapBomb, Explosion); |
| 19 | |
| 20 | NERVES_MAKE_STRUCT(CapBomb, Wait, Explosion); |
| 21 | } // namespace |
| 22 | |
| 23 | CapBomb::CapBomb(const char* name) : al::LiveActor(name) {} |
| 24 | |
| 25 | void CapBomb::init(const al::ActorInitInfo& info) { |
| 26 | al::initActorWithArchiveName(actor: this, initInfo: info, archiveName: "Bomb" , suffix: nullptr); |
| 27 | al::initNerve(actor: this, nerve: &NrvCapBomb.Wait, maxStates: 0); |
| 28 | al::invalidateHitSensors(this); |
| 29 | al::validateHitSensor(this, "Body" ); |
| 30 | al::hideSilhouetteModel(actor: this); |
| 31 | makeActorAlive(); |
| 32 | |
| 33 | mTestLayout = new al::LayoutActor("テストレイアウト" ); |
| 34 | al::initLayoutActor(mTestLayout, al::getLayoutInitInfo(initInfo: info), "TestSugawaraLayout" , nullptr); |
| 35 | |
| 36 | mTestLayoutParts = new al::LayoutActor("テストパーツ" ); |
| 37 | al::initLayoutPartsActor(mTestLayoutParts, mTestLayout, al::getLayoutInitInfo(initInfo: info), "Par_00" , |
| 38 | nullptr); |
| 39 | mTestLayout->kill(); |
| 40 | } |
| 41 | |
| 42 | void CapBomb::appear() { |
| 43 | al::showModelIfHide(actor: this); |
| 44 | al::setVelocityZero(this); |
| 45 | al::onCollide(actor: this); |
| 46 | al::invalidateHitSensors(this); |
| 47 | al::validateHitSensor(this, "Body" ); |
| 48 | |
| 49 | al::setNerve(user: this, nerve: &NrvCapBomb.Wait); |
| 50 | |
| 51 | al::LiveActor::appear(); |
| 52 | } |
| 53 | |
| 54 | bool CapBomb::receiveMsg(const al::SensorMsg* message, al::HitSensor* other, al::HitSensor* self) { |
| 55 | if (al::isNerve(user: this, nerve: &NrvCapBomb.Wait) && |
| 56 | (al::isMsgPlayerObjTouch(msg: message) || rs::isMsgItemGetByWeapon(message) || |
| 57 | al::isMsgExplosion(msg: message))) { |
| 58 | al::setNerve(user: this, nerve: &NrvCapBomb.Explosion); |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | void CapBomb::attackSensor(al::HitSensor* self, al::HitSensor* other) { |
| 66 | if (al::isNerve(user: this, nerve: &NrvCapBomb.Explosion)) |
| 67 | al::sendMsgExplosion(receiver: other, sender: self, comboCounter: nullptr); |
| 68 | } |
| 69 | |
| 70 | void CapBomb::exeWait() {} |
| 71 | |
| 72 | void CapBomb::exeExplosion() { |
| 73 | if (al::isFirstStep(user: this)) { |
| 74 | al::hideModelIfShow(actor: this); |
| 75 | al::setVelocityZero(this); |
| 76 | al::offCollide(actor: this); |
| 77 | al::startHitReaction(actor: this, name: "爆発" ); |
| 78 | al::validateHitSensor(this, "ExplosionPlayer" ); |
| 79 | } else |
| 80 | kill(); |
| 81 | } |
| 82 | |