2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptSwitch.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptSwitch::CScriptSwitch(TUniqueId uid, std::string_view name, const CEntityInfo& info, bool active, bool opened,
|
2016-12-19 18:27:58 +00:00
|
|
|
bool closeOnOpened)
|
2018-12-08 05:30:43 +00:00
|
|
|
: CEntity(uid, info, active, name), x34_opened(opened), x35_closeOnOpened(closeOnOpened) {}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSwitch::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSwitch::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) {
|
|
|
|
if (GetActive()) {
|
2020-05-07 15:48:34 +00:00
|
|
|
if (msg == EScriptObjectMessage::Open) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x34_opened = true;
|
2020-05-07 15:48:34 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Close) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x34_opened = false;
|
2020-05-07 15:48:34 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::SetToZero) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x34_opened) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::Open, mgr, EScriptObjectMessage::None);
|
|
|
|
if (x35_closeOnOpened)
|
|
|
|
x34_opened = false;
|
2020-05-07 15:48:34 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
2020-05-07 15:48:34 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CEntity::AcceptScriptMsg(msg, objId, mgr);
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|