metaforce/Runtime/World/CScriptControllerAction.cpp

45 lines
1.6 KiB
C++
Raw Normal View History

#include "Runtime/World/CScriptControllerAction.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/Input/ControlMapper.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
2018-12-08 05:30:43 +00:00
namespace urde {
2018-12-08 05:30:43 +00:00
CScriptControllerAction::CScriptControllerAction(TUniqueId uid, std::string_view name, const CEntityInfo& info,
bool active, ControlMapper::ECommands command, bool mapScreenResponse,
u32 w1, bool deactivateOnClose)
: CEntity(uid, info, active, name)
, x34_command(command)
, x38_mapScreenSubaction(w1)
, x3c_24_mapScreenResponse(mapScreenResponse)
, x3c_25_deactivateOnClose(deactivateOnClose)
, x3c_26_pressed(false) {}
2018-12-08 05:30:43 +00:00
void CScriptControllerAction::Accept(IVisitor& visitor) { visitor.Visit(this); }
2018-12-08 05:30:43 +00:00
void CScriptControllerAction::Think(float, CStateManager& stateMgr) {
bool oldPressed = x3c_26_pressed;
if (x3c_24_mapScreenResponse) {
if (x38_mapScreenSubaction == 0)
x3c_26_pressed = stateMgr.GetInMapScreen();
} else {
x3c_26_pressed = ControlMapper::GetDigitalInput(x34_command, stateMgr.GetFinalInput());
}
2018-12-08 05:30:43 +00:00
if (GetActive() && x3c_26_pressed != oldPressed) {
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);
}
}
2018-12-08 05:30:43 +00:00
}
}
2018-12-08 05:30:43 +00:00
} // namespace urde