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