1#include "Library/Play/Layout/WipeCloseAppearWaitEnd.h"
2
3#include "Library/Layout/LayoutActionFunction.h"
4#include "Library/Layout/LayoutInitInfo.h"
5#include "Library/Nerve/NerveSetupUtil.h"
6#include "Library/Nerve/NerveUtil.h"
7
8namespace {
9using namespace al;
10
11NERVE_HOST_TYPE_IMPL(WipeCloseAppearWaitEnd, CloseStart)
12NERVE_HOST_TYPE_IMPL(WipeCloseAppearWaitEnd, CloseEnd)
13NERVE_HOST_TYPE_IMPL(WipeCloseAppearWaitEnd, Open)
14NERVE_HOST_TYPE_IMPL(WipeCloseAppearWaitEnd, Wait)
15NERVE_HOST_TYPE_IMPL(WipeCloseAppearWaitEnd, CloseWait)
16
17NERVES_MAKE_NOSTRUCT(HostType, CloseStart, CloseEnd, Open, Wait, CloseWait)
18} // namespace
19
20namespace al {
21WipeCloseAppearWaitEnd::WipeCloseAppearWaitEnd(const char* name, const char* archiveName,
22 const LayoutInitInfo& info, const char* suffix,
23 bool isLocalized)
24 : LayoutActor(name) {
25 if (isLocalized)
26 initLayoutActorLocalized(this, info, archiveName, suffix);
27 else
28 initLayoutActor(this, info, archiveName, suffix);
29
30 initNerve(&CloseStart, 0);
31}
32
33void WipeCloseAppearWaitEnd::startClose(s32 frames) {
34 mFrames = frames;
35
36 startAction(layout: this, actionName: "CloseStart", paneName: nullptr);
37 LayoutActor::appear();
38
39 f32 rate = 1.0f;
40 if (mFrames <= 0)
41 asm("");
42 else
43 rate = getActionFrameMax(layout: this, actionName: "CloseStart", paneName: nullptr) / (f32)mFrames;
44
45 setActionFrameRate(layout: this, frameRate: rate, paneName: nullptr);
46 setNerve(user: this, nerve: &CloseStart);
47}
48
49void WipeCloseAppearWaitEnd::startCloseEnd() {
50 startFreezeActionEnd(layout: this, actionName: "CloseEnd", paneName: nullptr);
51 LayoutActor::appear();
52 setNerve(user: this, nerve: &CloseEnd);
53}
54
55void WipeCloseAppearWaitEnd::startOpen(s32 frames) {
56 mFrames = frames;
57
58 startAction(layout: this, actionName: "End", paneName: nullptr);
59 setNerve(user: this, nerve: &Open);
60}
61
62bool WipeCloseAppearWaitEnd::isCloseEnd() const {
63 return isNerve(user: this, nerve: &Wait) && isGreaterEqualStep(user: this, step: 2);
64}
65
66void WipeCloseAppearWaitEnd::exeCloseStart() {
67 if (isActionEnd(layout: this, paneName: nullptr))
68 setNerve(user: this, nerve: &CloseWait);
69}
70
71void WipeCloseAppearWaitEnd::exeCloseWait() {
72 if (isFirstStep(user: this))
73 startAction(layout: this, actionName: "CloseWait", paneName: nullptr);
74
75 if (mWaitDelay >= 0 && isGreaterEqualStep(user: this, step: mWaitDelay))
76 setNerve(user: this, nerve: &CloseEnd);
77}
78
79void WipeCloseAppearWaitEnd::exeCloseEnd() {
80 if (isFirstStep(user: this))
81 startAction(layout: this, actionName: "CloseEnd", paneName: nullptr);
82
83 if (isActionEnd(layout: this, paneName: nullptr))
84 setNerve(user: this, nerve: &Wait);
85}
86
87void WipeCloseAppearWaitEnd::exeWait() {
88 if (isFirstStep(user: this))
89 startAction(layout: this, actionName: "Wait", paneName: nullptr);
90}
91
92void WipeCloseAppearWaitEnd::exeOpen() {
93 if (isActionEnd(layout: this, paneName: nullptr))
94 kill();
95}
96} // namespace al
97