1#include "Layout/AimingCursor.h"
2
3#include "Library/Layout/LayoutActionFunction.h"
4#include "Library/Layout/LayoutActorUtil.h"
5#include "Library/Layout/LayoutInitInfo.h"
6#include "Library/Nerve/NerveSetupUtil.h"
7#include "Library/Nerve/NerveUtil.h"
8
9namespace {
10NERVE_IMPL(AimingCursor, Appear);
11NERVE_IMPL(AimingCursor, End);
12NERVE_IMPL(AimingCursor, Wait);
13
14NERVES_MAKE_NOSTRUCT(AimingCursor, Appear, End, Wait);
15} // namespace
16
17AimingCursor::AimingCursor(const char* name, const al::LayoutInitInfo& info)
18 : al::LayoutActor(name) {
19 al::initLayoutActor(this, info, "Aiming", nullptr);
20 initNerve(&Appear, 0);
21 kill();
22}
23
24void AimingCursor::startAppear() {
25 appear();
26 al::setNerve(user: this, nerve: &Appear);
27}
28
29void AimingCursor::end() {
30 al::setNerve(user: this, nerve: &End);
31}
32
33void AimingCursor::setTrans(const sead::Vector2f& pos) {
34 sead::Vector2f t = al::getLocalTrans(this);
35 al::setLocalTrans(this, (t + pos) * 0.5f);
36}
37
38void AimingCursor::setScale(f32 scale) {
39 al::setLocalScale(this, (al::getLocalScale(this) + scale) * 0.5f);
40}
41
42bool AimingCursor::tryLookOn() {
43 if (mIsLookOn)
44 return false;
45 mIsLookOn = true;
46 al::startAction(layout: this, actionName: "On", paneName: "State");
47 return true;
48}
49
50bool AimingCursor::tryLookOff() {
51 if (!mIsLookOn)
52 return false;
53 mIsLookOn = false;
54 al::startAction(layout: this, actionName: "Off", paneName: "State");
55 return true;
56}
57
58void AimingCursor::exeAppear() {
59 if (al::isFirstStep(user: this))
60 al::startAction(layout: this, actionName: "Appear", paneName: nullptr);
61 if (al::isActionEnd(layout: this, paneName: nullptr))
62 al::setNerve(user: this, nerve: &Wait);
63}
64
65void AimingCursor::exeWait() {
66 if (al::isFirstStep(user: this))
67 al::startAction(layout: this, actionName: "Wait", paneName: nullptr);
68}
69
70void AimingCursor::exeEnd() {
71 if (al::isFirstStep(user: this))
72 al::startAction(layout: this, actionName: "End", paneName: nullptr);
73 if (al::isActionEnd(layout: this, paneName: nullptr))
74 kill();
75}
76