1#include "MapObj/ChurchDoor.h"
2
3#include "Library/Base/StringUtil.h"
4#include "Library/Bgm/BgmLineFunction.h"
5#include "Library/LiveActor/ActorActionFunction.h"
6#include "Library/LiveActor/ActorCollisionFunction.h"
7#include "Library/LiveActor/ActorInitUtil.h"
8#include "Library/LiveActor/ActorSensorUtil.h"
9#include "Library/Nerve/NerveSetupUtil.h"
10#include "Library/Nerve/NerveUtil.h"
11
12#include "System/GameDataFunction.h"
13#include "System/GameDataUtil.h"
14#include "Util/SensorMsgFunction.h"
15
16namespace {
17NERVE_IMPL(ChurchDoor, DemoEnterChurch);
18NERVE_IMPL(ChurchDoor, CloseWait1);
19NERVE_IMPL(ChurchDoor, OpenWait);
20NERVE_IMPL(ChurchDoor, Open1);
21NERVE_IMPL(ChurchDoor, Open2);
22NERVE_IMPL(ChurchDoor, CloseWait2);
23NERVE_IMPL(ChurchDoor, CloseWait3);
24NERVE_IMPL(ChurchDoor, Open3);
25
26NERVES_MAKE_NOSTRUCT(ChurchDoor, DemoEnterChurch, CloseWait1, OpenWait, Open1, Open2, CloseWait2,
27 CloseWait3, Open3);
28} // namespace
29
30inline bool isCurrentStageMoonWeddingRoom(const al::LiveActor* actor) {
31 return al::isEqualString(str1: "MoonWorldWeddingRoomStage",
32 str2: GameDataFunction::getCurrentStageName(accessor: actor));
33}
34
35ChurchDoor::ChurchDoor(const char* name) : al::LiveActor(name) {}
36
37void ChurchDoor::init(const al::ActorInitInfo& info) {
38 al::initActor(actor: this, initInfo: info);
39 al::initNerve(actor: this, nerve: &CloseWait1, maxStates: 0);
40
41 if (isCurrentStageMoonWeddingRoom(actor: this)) {
42 mSaveObjInfo = rs::createSaveObjInfoWriteSaveData(actorInitInfo: info);
43 if (rs::isOnSaveObjInfo(saveObjInfo: mSaveObjInfo)) {
44 al::invalidateCollisionParts(this);
45 al::setNerve(user: this, nerve: &OpenWait);
46 makeActorAlive();
47 return;
48 }
49 }
50
51 al::startBgmSituation(this, "CloseChurchDoor", true, true);
52 makeActorAlive();
53}
54
55bool ChurchDoor::receiveMsg(const al::SensorMsg* msg, al::HitSensor* other, al::HitSensor* self) {
56 if (rs::isMsgPlayerDisregardTargetMarker(msg))
57 return true;
58
59 if (rs::isMsgCapTouchWall(msg)) {
60 if ((al::isNerve(user: this, nerve: &Open1) || al::isNerve(user: this, nerve: &Open2)) &&
61 al::isLessEqualStep(user: this, step: 10))
62 return true;
63
64 rs::requestHitReactionToAttacker(msg, other, al::getSensorPos(other));
65
66 if (al::isNerve(user: this, nerve: &CloseWait1)) {
67 al::startHitReaction(actor: this, name: "ヒット1回目");
68 al::setNerve(user: this, nerve: &Open1);
69 } else if (al::isNerve(user: this, nerve: &CloseWait2) || al::isNerve(user: this, nerve: &Open1)) {
70 al::startHitReaction(actor: this, name: "ヒット2回目");
71 al::setNerve(user: this, nerve: &Open2);
72 } else if (al::isNerve(user: this, nerve: &CloseWait3) || al::isNerve(user: this, nerve: &Open2)) {
73 al::startHitReaction(actor: this, name: "ヒット3回目");
74 al::setNerve(user: this, nerve: &Open3);
75 }
76 return true;
77 }
78
79 return false;
80}
81
82bool ChurchDoor::isOpenWait() const {
83 return al::isNerve(user: this, nerve: &OpenWait);
84}
85
86bool ChurchDoor::isDemoEnterChurch() const {
87 return al::isNerve(user: this, nerve: &DemoEnterChurch);
88}
89
90void ChurchDoor::startDemoEnterChurch() {
91 al::setNerve(user: this, nerve: &DemoEnterChurch);
92}
93
94void ChurchDoor::endDemoEnterChurch() {
95 al::setNerve(user: this, nerve: &OpenWait);
96}
97
98void ChurchDoor::exeCloseWait1() {
99 if (al::isFirstStep(user: this))
100 al::startAction(actor: this, actionName: "CloseWait1");
101}
102
103void ChurchDoor::exeOpen1() {
104 if (al::isFirstStep(user: this))
105 al::startAction(actor: this, actionName: "Open1");
106
107 al::setNerveAtActionEnd(actor: this, nerve: &CloseWait2);
108}
109
110void ChurchDoor::exeCloseWait2() {
111 if (al::isFirstStep(user: this))
112 al::startAction(actor: this, actionName: "CloseWait2");
113}
114
115void ChurchDoor::exeOpen2() {
116 if (al::isFirstStep(user: this))
117 al::startAction(actor: this, actionName: "Open2");
118
119 al::setNerveAtActionEnd(actor: this, nerve: &CloseWait3);
120}
121
122void ChurchDoor::exeCloseWait3() {
123 if (al::isFirstStep(user: this))
124 al::startAction(actor: this, actionName: "CloseWait3");
125}
126
127void ChurchDoor::exeOpen3() {
128 if (al::isFirstStep(user: this)) {
129 al::startAction(actor: this, actionName: "Open3");
130 al::invalidateCollisionParts(this);
131 }
132
133 al::setNerveAtActionEnd(actor: this, nerve: &OpenWait);
134}
135
136void ChurchDoor::exeOpenWait() {
137 if (al::isFirstStep(user: this)) {
138 al::startAction(actor: this, actionName: "OpenWait");
139
140 if (isCurrentStageMoonWeddingRoom(actor: this))
141 rs::onSaveObjInfo(saveObjInfo: mSaveObjInfo);
142 }
143}
144
145void ChurchDoor::exeDemoEnterChurch() {
146 if (al::isFirstStep(user: this)) {
147 }
148}
149