1#include "Layout/CoinCollectLayout.h"
2
3#include "Library/Layout/LayoutActionFunction.h"
4#include "Library/Layout/LayoutActorUtil.h"
5#include "Library/Layout/LayoutInitInfo.h"
6#include "Library/LiveActor/ActorPoseUtil.h"
7#include "Library/LiveActor/LiveActor.h"
8#include "Library/Nerve/NerveSetupUtil.h"
9#include "Library/Nerve/NerveUtil.h"
10#include "Library/Screen/ScreenFunction.h"
11
12namespace {
13NERVE_IMPL(CoinCollectLayout, Start);
14NERVE_IMPL(CoinCollectLayout, Wait);
15NERVE_IMPL(CoinCollectLayout, End);
16
17NERVES_MAKE_NOSTRUCT(CoinCollectLayout, Start, Wait, End);
18} // namespace
19
20CoinCollectLayout::CoinCollectLayout(const al::LayoutInitInfo& info)
21 : al::LayoutActor("コレクトコインレイアウト") {
22 al::initLayoutActor(this, info, "PopUpCollectCoin", nullptr);
23 initNerve(&Start, 0);
24}
25
26void CoinCollectLayout::appearCounter(s32 maxCoins, s32 currentCoins,
27 const al::LiveActor* coinActor) {
28 mCoinActor = coinActor;
29 al::setPaneStringFormat(this, "TxtCollectCoin", "%d/%d", currentCoins, maxCoins);
30 al::setNerve(user: this, nerve: &Start);
31
32 // regswap when using updatePos() directly because coinActor is used instead of mCoinActor
33 sead::Vector2f layoutPos = sead::Vector2f::zero;
34 sead::Vector3f coinPos = al::getTrans(actor: coinActor);
35 al::calcLayoutPosFromWorldPos(output: &layoutPos, coinActor, coinPos);
36 al::setLocalTrans(this, layoutPos);
37
38 appear();
39}
40
41void CoinCollectLayout::exeStart() {
42 if (al::isFirstStep(user: this))
43 al::startAction(layout: this, actionName: "Appear", paneName: nullptr);
44 if (al::isActionEnd(layout: this, paneName: nullptr))
45 al::setNerve(user: this, nerve: &Wait);
46 updatePos();
47}
48
49void CoinCollectLayout::updatePos() {
50 sead::Vector2f layoutPos = sead::Vector2f::zero;
51 sead::Vector3f coinPos = al::getTrans(actor: mCoinActor);
52 al::calcLayoutPosFromWorldPos(output: &layoutPos, mCoinActor, coinPos);
53 al::setLocalTrans(this, layoutPos);
54}
55
56void CoinCollectLayout::exeWait() {
57 if (al::isFirstStep(user: this))
58 al::startAction(layout: this, actionName: "Wait", paneName: nullptr);
59 if (al::isGreaterEqualStep(user: this, step: 120)) {
60 al::setNerve(user: this, nerve: &End);
61 return;
62 }
63 updatePos();
64}
65
66void CoinCollectLayout::exeEnd() {
67 if (al::isFirstStep(user: this))
68 al::startAction(layout: this, actionName: "End", paneName: nullptr);
69 if (al::isActionEnd(layout: this, paneName: nullptr)) {
70 kill();
71 return;
72 }
73 updatePos();
74}
75