SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
FlashingCtrl.cpp
1#include "Game/LiveActor/FlashingCtrl.hpp"
2#include "Game/Util.hpp"
3
4FlashingCtrl::FlashingCtrl(LiveActor *pActor, bool toggleDraw) : NameObj("点滅") {
5 mActor = pActor;
6 mToggleDraw = toggleDraw;
7 mIsEnded = true;
8 mOverrideInterval = 0;
9 mTimer = 0;
10 mFlashStartTime = 0;
11 MR::connectToScene(this, 0x22, -1, -1, -1);
12}
13
14void FlashingCtrl::movement() {
15 if (!mIsEnded) {
16 s32 curTimer = mTimer;
17 mTimer = curTimer -1;
18 if (curTimer - 1 <= 0 || MR::isClipped(mActor) || MR::isDead(mActor)) {
19 end();
20 }
21 else if (MR::isDemoActive()) {
22 if (mToggleDraw && MR::isNoEntryDrawBuffer(mActor)) {
23 MR::onEntryDrawBuffer(mActor);
24 }
25 }
26 else if (isNowFlashing()) {
27 updateFlashing();
28 }
29 }
30}
31
32void FlashingCtrl::start(int timer) {
33 mIsEnded = false;
34 mTimer = timer;
35 mFlashStartTime = 180;
36 mOverrideInterval = 0;
37}
38
39void FlashingCtrl::end() {
40 mTimer = 0;
41 mIsEnded = true;
42
43 if (mToggleDraw && !MR::isDead(mActor) && !MR::isClipped(mActor) && MR::isNoEntryDrawBuffer(mActor)) {
44 MR::onEntryDrawBuffer(mActor);
45 }
46}
47
48s32 FlashingCtrl::getCurrentInterval() const {
49 if (mOverrideInterval) {
50 return 8;
51 }
52 s32 curTimer = mTimer;
53 s32 ret = 10;
54
55 if (curTimer < 90) {
56 ret = 5;
57 }
58 return ret;
59}
60
61bool FlashingCtrl::isNowFlashing() const {
62 return mTimer <= mFlashStartTime;
63}
64
65bool FlashingCtrl::isNowOn() const {
66 return !((mTimer / getCurrentInterval()) & 1);
67}
68
69void FlashingCtrl::updateFlashing() {
70 if (mToggleDraw) {
71 if (isNowOn()) {
72 MR::offEntryDrawBuffer(mActor);
73 }
74 else {
75 MR::onEntryDrawBuffer(mActor);
76 }
77 }
78}
79
80FlashingCtrl::~FlashingCtrl() {
81}
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24
The most basic form of an object.
Definition NameObj.hpp:11