mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-08-18 16:11:31 +00:00
37 lines
982 B
C++
37 lines
982 B
C++
#include "MetroidPrime/ScriptObjects/CScriptSwitch.hpp"
|
|
|
|
CScriptSwitch::CScriptSwitch(TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
|
|
bool active, bool opened, bool closeOnOpened)
|
|
: CEntity(uid, info, active, name) {
|
|
mOpened = opened;
|
|
mCloseOnOpened = closeOnOpened;
|
|
}
|
|
|
|
void CScriptSwitch::Accept(IVisitor& visitor) { visitor.Visit(*this); }
|
|
|
|
void CScriptSwitch::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) {
|
|
if (GetActive()) {
|
|
switch (msg) {
|
|
case kSM_Open:
|
|
mOpened = true;
|
|
break;
|
|
case kSM_Close:
|
|
mOpened = false;
|
|
break;
|
|
case kSM_SetToZero: {
|
|
if (mOpened) {
|
|
SendScriptMsgs(kSS_Open, mgr, kSM_None);
|
|
if (mCloseOnOpened)
|
|
mOpened = false;
|
|
} else {
|
|
SendScriptMsgs(kSS_Closed, mgr, kSM_None);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
CEntity::AcceptScriptMsg(msg, objId, mgr);
|
|
}
|
|
|
|
CScriptSwitch::~CScriptSwitch() {}
|