mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 03:47:43 +00:00
Various CStateManager additions and camera stubs
This commit is contained in:
66
Runtime/CObjectList.cpp
Normal file
66
Runtime/CObjectList.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "CObjectList.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CObjectList::CObjectList(EGameObjectList listEnum)
|
||||
: m_listEnum(listEnum)
|
||||
{}
|
||||
|
||||
void CObjectList::AddObject(CEntity& entity)
|
||||
{
|
||||
if (IsQualified())
|
||||
{
|
||||
if (m_lastId != -1)
|
||||
m_list[m_lastId].next = entity.GetUniqueId() & 0x3ff;
|
||||
TUniqueId prevLast = m_lastId;
|
||||
m_lastId = entity.GetUniqueId() & 0x3ff;
|
||||
SObjectListEntry& newEnt = m_list[m_lastId];
|
||||
newEnt.entity = &entity;
|
||||
newEnt.prev = prevLast;
|
||||
newEnt.next = -1;
|
||||
++m_count;
|
||||
}
|
||||
}
|
||||
|
||||
void CObjectList::RemoveObject(TUniqueId uid)
|
||||
{
|
||||
uid = uid & 0x3ff;
|
||||
SObjectListEntry& ent = m_list[uid];
|
||||
if (!ent.entity || ent.entity->GetUniqueId() != uid)
|
||||
return;
|
||||
if (uid == m_lastId)
|
||||
{
|
||||
m_lastId = ent.prev;
|
||||
if (ent.prev != -1)
|
||||
m_list[ent.prev].next = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ent.prev != -1)
|
||||
m_list[ent.prev].next = -1;
|
||||
m_list[ent.next].prev = -1;
|
||||
}
|
||||
ent.entity = nullptr;
|
||||
ent.prev = -1;
|
||||
ent.next = -1;
|
||||
--m_count;
|
||||
}
|
||||
|
||||
const CEntity* CObjectList::GetObjectById(TUniqueId uid) const
|
||||
{
|
||||
if (!uid)
|
||||
return nullptr;
|
||||
return m_list[uid & 0x3ff].entity;
|
||||
}
|
||||
|
||||
CEntity* CObjectList::GetObjectById(TUniqueId uid)
|
||||
{
|
||||
if (!uid)
|
||||
return nullptr;
|
||||
return m_list[uid & 0x3ff].entity;
|
||||
}
|
||||
|
||||
bool CObjectList::IsQualified() {return true;}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user