2017-03-18 05:12:27 +00:00
|
|
|
#include "CScriptControllerAction.hpp"
|
|
|
|
#include "TCastTo.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "Input/ControlMapper.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
CScriptControllerAction::CScriptControllerAction(TUniqueId uid, const std::string& name,
|
|
|
|
const CEntityInfo& info, bool active,
|
2017-07-07 12:23:20 +00:00
|
|
|
ControlMapper::ECommands command, bool mapScreenResponse, u32 w1, bool deactivateOnClose)
|
2017-03-18 05:12:27 +00:00
|
|
|
: CEntity(uid, info, active, name), x34_command(command), x38_mapScreenSubaction(w1)
|
|
|
|
{
|
2017-07-07 12:23:20 +00:00
|
|
|
x3c_24_mapScreenResponse = mapScreenResponse;
|
|
|
|
x3c_25_deactivateOnClose = deactivateOnClose;
|
2017-03-18 05:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptControllerAction::Accept(IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptControllerAction::Think(float dt, CStateManager& stateMgr)
|
|
|
|
{
|
2017-07-07 12:23:20 +00:00
|
|
|
bool oldPressed = x3c_26_pressed;
|
2017-03-18 05:12:27 +00:00
|
|
|
if (x3c_24_mapScreenResponse)
|
|
|
|
{
|
|
|
|
if (x38_mapScreenSubaction == 0)
|
|
|
|
x3c_26_pressed = stateMgr.GetInMapScreen();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x3c_26_pressed = ControlMapper::GetDigitalInput(x34_command, stateMgr.GetFinalInput());
|
|
|
|
}
|
|
|
|
|
2017-07-07 12:23:20 +00:00
|
|
|
if (GetActive() && x3c_26_pressed != oldPressed)
|
2017-03-18 05:12:27 +00:00
|
|
|
{
|
|
|
|
if (x3c_26_pressed)
|
|
|
|
{
|
|
|
|
SendScriptMsgs(EScriptObjectState::Open, stateMgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, stateMgr, EScriptObjectMessage::None);
|
|
|
|
if (x3c_25_deactivateOnClose)
|
|
|
|
{
|
|
|
|
SetActive(false);
|
|
|
|
SendScriptMsgs(EScriptObjectState::Inactive, stateMgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|