mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 09:47:43 +00:00
various implementation
This commit is contained in:
50
Runtime/CEntity.cpp
Normal file
50
Runtime/CEntity.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "CEntity.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
CEntity::CEntity(TUniqueId uniqueId, const CEntityInfo& info, bool active)
|
||||
: m_uid(uniqueId), m_info(info), m_active(active) {}
|
||||
|
||||
void CEntity::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case MsgActivate:
|
||||
if (!GetActive())
|
||||
{
|
||||
SetActive(true);
|
||||
SendScriptMsgs(StActive, stateMgr, MsgNone);
|
||||
}
|
||||
break;
|
||||
case MsgDeactivate:
|
||||
if (GetActive())
|
||||
{
|
||||
SetActive(false);
|
||||
SendScriptMsgs(StInactive, stateMgr, MsgNone);
|
||||
}
|
||||
break;
|
||||
case MsgToggleActive:
|
||||
if (GetActive())
|
||||
{
|
||||
SetActive(false);
|
||||
SendScriptMsgs(StInactive, stateMgr, MsgNone);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetActive(true);
|
||||
SendScriptMsgs(StActive, stateMgr, MsgNone);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::SendScriptMsgs(EScriptObjectState state, CStateManager& stateMgr, EScriptObjectMessage skipMsg)
|
||||
{
|
||||
for (const SConnection& conn : m_info.m_conns)
|
||||
if (conn.state == state && conn.msg != skipMsg)
|
||||
stateMgr.SendScriptMsg(m_uid, conn.objId, conn.msg, state);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user