mirror of
https://github.com/encounter/Petari.git
synced 2026-03-30 11:34:15 -07:00
36 lines
805 B
C++
36 lines
805 B
C++
#include "Game/Map/TimerSwitch.hpp"
|
|
|
|
TimerSwitch::TimerSwitch(const char *pName) : LiveActor(pName) {
|
|
mTimerLength = -1;
|
|
mCurrentTime = -1;
|
|
}
|
|
|
|
void TimerSwitch::init(const JMapInfoIter &rIter) {
|
|
MR::connectToSceneMapObjMovement(this);
|
|
MR::getJMapInfoArg0NoInit(rIter, &mTimerLength);
|
|
MR::needStageSwitchWriteA(this, rIter);
|
|
MR::needStageSwitchReadB(this, rIter);
|
|
MR::invalidateClipping(this);
|
|
makeActorAppeared();
|
|
}
|
|
|
|
void TimerSwitch::control() {
|
|
if (mCurrentTime < 0 && MR::isOnSwitchB(this)) {
|
|
mCurrentTime = mTimerLength;
|
|
}
|
|
|
|
s32 current = mCurrentTime;
|
|
if (current > 0) {
|
|
mCurrentTime = current - 1;
|
|
|
|
if (current - 1 <= 0) {
|
|
MR::onSwitchA(this);
|
|
kill();
|
|
}
|
|
}
|
|
}
|
|
|
|
TimerSwitch::~TimerSwitch() {
|
|
|
|
}
|