metaforce/Runtime/World/CScriptDockAreaChange.cpp

44 lines
1.3 KiB
C++
Raw Normal View History

2016-12-22 02:48:22 +00:00
#include "CScriptDockAreaChange.hpp"
#include "CStateManager.hpp"
#include "World/CScriptDock.hpp"
2017-01-15 03:07:01 +00:00
#include "TCastTo.hpp"
2016-12-22 02:48:22 +00:00
namespace urde
{
2017-11-13 06:19:18 +00:00
CScriptDockAreaChange::CScriptDockAreaChange(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 w1,
2016-12-22 02:48:22 +00:00
bool active)
: CEntity(uid, info, active, name), x34_dockReference(w1)
{
}
2017-01-15 03:07:01 +00:00
void CScriptDockAreaChange::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
2016-12-22 02:48:22 +00:00
void CScriptDockAreaChange::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{
if (msg == EScriptObjectMessage::Action && GetActive())
{
for (SConnection conn : x20_conns)
{
if (conn.x0_state != EScriptObjectState::Play)
continue;
auto search = stateMgr.GetIdListForScript(conn.x8_objId);
for (auto it = search.first ; it != search.second ; ++it)
{
TUniqueId id = it->second;
2017-01-15 03:59:37 +00:00
TCastToPtr<CScriptDock> dock(stateMgr.ObjectById(id));
2016-12-22 02:48:22 +00:00
if (dock)
dock->SetDockReference(stateMgr, x34_dockReference);
2016-12-22 02:48:22 +00:00
}
}
SendScriptMsgs(EScriptObjectState::Play, stateMgr, EScriptObjectMessage::None);
}
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
}
}