2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 09:47:43 +00:00

various implementation

This commit is contained in:
Jack Andersen
2015-08-18 19:48:57 -10:00
parent b9c3c8138e
commit e1d45fd01c
14 changed files with 300 additions and 10 deletions

50
Runtime/CEntity.cpp Normal file
View 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);
}
}