2016-12-19 18:27:58 +00:00
|
|
|
#include "CScriptSwitch.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
2017-01-15 03:07:01 +00:00
|
|
|
#include "TCastTo.hpp"
|
2016-12-19 18:27:58 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
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)
|
|
|
|
: CEntity(uid, info, active, name), x34_opened(opened), x35_closeOnOpened(closeOnOpened)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-15 03:07:01 +00:00
|
|
|
void CScriptSwitch::Accept(IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
2016-12-19 19:20:30 +00:00
|
|
|
void CScriptSwitch::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr)
|
2016-12-19 18:27:58 +00:00
|
|
|
{
|
|
|
|
if (GetActive())
|
|
|
|
{
|
|
|
|
if (msg == EScriptObjectMessage::Open)
|
|
|
|
x34_opened = true;
|
|
|
|
else if (msg == EScriptObjectMessage::Close)
|
|
|
|
x34_opened = false;
|
|
|
|
else if (msg == EScriptObjectMessage::SetToZero)
|
|
|
|
{
|
|
|
|
if (x34_opened)
|
|
|
|
{
|
|
|
|
SendScriptMsgs(EScriptObjectState::Open, mgr, EScriptObjectMessage::None);
|
|
|
|
if (x35_closeOnOpened)
|
|
|
|
x34_opened = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CEntity::AcceptScriptMsg(msg, objId, mgr);
|
|
|
|
}
|
|
|
|
}
|