| 1 | #include "MapObj/FireDrum2D.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 | |
| 9 | #include "Util/ActorDimensionKeeper.h" |
| 10 | #include "Util/SensorMsgFunction.h" |
| 11 | |
| 12 | namespace { |
| 13 | NERVE_IMPL(FireDrum2D, Wait); |
| 14 | NERVE_IMPL(FireDrum2D, Burn); |
| 15 | |
| 16 | NERVES_MAKE_NOSTRUCT(FireDrum2D, Wait, Burn); |
| 17 | } // namespace |
| 18 | |
| 19 | FireDrum2D::FireDrum2D(const char* name) : LiveActor(name) {} |
| 20 | |
| 21 | void FireDrum2D::init(const al::ActorInitInfo& info) { |
| 22 | al::initActor(actor: this, initInfo: info); |
| 23 | al::initNerve(actor: this, nerve: &Wait, maxStates: 0); |
| 24 | mDimensionKeeper = rs::createDimensionKeeper(actor: this); |
| 25 | rs::updateDimensionKeeper(keeper: mDimensionKeeper); |
| 26 | |
| 27 | if (rs::isIn2DArea(dimension: this)) { |
| 28 | rs::snap2D(actor: this, dimension: this, unk_distance: 500.0f); |
| 29 | makeActorAlive(); |
| 30 | } else { |
| 31 | makeActorDead(); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | void FireDrum2D::exeWait() { |
| 36 | if (al::isFirstStep(user: this)) |
| 37 | al::startAction(actor: this, actionName: "Burn" ); |
| 38 | } |
| 39 | |
| 40 | void FireDrum2D::exeBurn() { |
| 41 | if (al::isFirstStep(user: this)) |
| 42 | al::startAction(actor: this, actionName: "Wait" ); |
| 43 | if (al::isActionEnd(actor: this)) |
| 44 | al::setNerve(user: this, nerve: &Wait); |
| 45 | } |
| 46 | |
| 47 | void FireDrum2D::attackSensor(al::HitSensor* self, al::HitSensor* other) { |
| 48 | if (rs::sendMsgTouchFireDrum2D(source: other, target: self) || rs::sendMsgEnemyAttack2D(source: other, target: self)) |
| 49 | al::setNerve(user: this, nerve: &Burn); |
| 50 | } |
| 51 | |
| 52 | bool FireDrum2D::receiveMsg(const al::SensorMsg* message, al::HitSensor* other, |
| 53 | al::HitSensor* self) { |
| 54 | return al::isMsgPlayerDisregard(msg: message); |
| 55 | } |
| 56 | |