metaforce/Runtime/World/CScriptPlayerStateChange.cpp

43 lines
2.2 KiB
C++
Raw Permalink Normal View History

#include "Runtime/World/CScriptPlayerStateChange.hpp"
#include "Runtime/CPlayerState.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/Input/ControlMapper.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
2017-07-30 04:00:30 -07:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
2017-11-12 22:19:18 -08:00
CScriptPlayerStateChange::CScriptPlayerStateChange(TUniqueId uid, std::string_view name, const CEntityInfo& info,
2017-07-30 04:00:30 -07:00
bool active, u32 itemType, u32 itemCount, u32 itemCapacity,
EControl control, EControlCommandOption controlCmdOpt)
: CEntity(uid, info, active, name)
, x34_itemType(itemType)
, x38_itemCount(itemCount)
, x3c_itemCapacity(itemCapacity)
, x40_ctrl(control)
2018-12-07 21:30:43 -08:00
, x44_ctrlCmdOpt(controlCmdOpt) {}
2017-07-30 04:00:30 -07:00
2018-12-07 21:30:43 -08:00
void CScriptPlayerStateChange::Accept(IVisitor& visitor) { visitor.Visit(this); }
2017-07-30 04:00:30 -07:00
2018-12-07 21:30:43 -08:00
void CScriptPlayerStateChange::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
if (GetActive() && msg == EScriptObjectMessage::SetToZero) {
stateMgr.GetPlayerState()->AddPowerUp(CPlayerState::EItemType(x34_itemType), x3c_itemCapacity);
2018-12-07 21:30:43 -08:00
stateMgr.GetPlayerState()->IncrPickup(CPlayerState::EItemType(x34_itemType), x38_itemCount);
2017-07-30 04:00:30 -07:00
2018-12-07 21:30:43 -08:00
if (x44_ctrlCmdOpt == EControlCommandOption::Filtered && x40_ctrl == EControl::Filtered) {
bool filtered = x44_ctrlCmdOpt != EControlCommandOption::Unfiltered;
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitClose, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitConfirm, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitDown, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitFar, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitLeft, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitObject, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitRight, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitSelect, filtered);
ControlMapper::SetCommandFiltered(ControlMapper::ECommands::OrbitUp, filtered);
2017-07-30 04:00:30 -07:00
}
2018-12-07 21:30:43 -08:00
}
2017-07-30 04:00:30 -07:00
2018-12-07 21:30:43 -08:00
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
2017-07-30 04:00:30 -07:00
}
2021-04-10 01:42:06 -07:00
} // namespace metaforce