mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 23:47:42 +00:00
New code style refactor
This commit is contained in:
@@ -3,83 +3,85 @@
|
||||
#include "World/CEntity.hpp"
|
||||
#include "RetroTypes.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace urde {
|
||||
|
||||
enum class EGameObjectList
|
||||
{
|
||||
Invalid = -1,
|
||||
All,
|
||||
Actor,
|
||||
PhysicsActor,
|
||||
GameCamera,
|
||||
GameLight,
|
||||
ListeningAi,
|
||||
AiWaypoint,
|
||||
PlatformAndDoor,
|
||||
enum class EGameObjectList {
|
||||
Invalid = -1,
|
||||
All,
|
||||
Actor,
|
||||
PhysicsActor,
|
||||
GameCamera,
|
||||
GameLight,
|
||||
ListeningAi,
|
||||
AiWaypoint,
|
||||
PlatformAndDoor,
|
||||
};
|
||||
|
||||
class CObjectList
|
||||
{
|
||||
friend class CGameArea;
|
||||
class CObjectList {
|
||||
friend class CGameArea;
|
||||
|
||||
struct SObjectListEntry {
|
||||
CEntity* entity = nullptr;
|
||||
s16 next = -1;
|
||||
s16 prev = -1;
|
||||
};
|
||||
SObjectListEntry x0_list[1024]; // was an rstl::prereserved_vector
|
||||
EGameObjectList x2004_listEnum;
|
||||
s16 x2008_firstId = -1;
|
||||
u16 x200a_count = 0;
|
||||
|
||||
struct SObjectListEntry
|
||||
{
|
||||
CEntity* entity = nullptr;
|
||||
s16 next = -1;
|
||||
s16 prev = -1;
|
||||
};
|
||||
SObjectListEntry x0_list[1024]; // was an rstl::prereserved_vector
|
||||
EGameObjectList x2004_listEnum;
|
||||
s16 x2008_firstId = -1;
|
||||
u16 x200a_count = 0;
|
||||
public:
|
||||
class iterator
|
||||
{
|
||||
friend class CObjectList;
|
||||
CObjectList& m_list;
|
||||
s16 m_id;
|
||||
iterator(CObjectList& list, s16 id) : m_list(list), m_id(id) {}
|
||||
public:
|
||||
iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; }
|
||||
bool operator!=(const iterator& other) const { return m_id != other.m_id; }
|
||||
CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
|
||||
};
|
||||
iterator begin() { return iterator(*this, x2008_firstId); }
|
||||
iterator end() { return iterator(*this, -1); }
|
||||
class iterator {
|
||||
friend class CObjectList;
|
||||
CObjectList& m_list;
|
||||
s16 m_id;
|
||||
iterator(CObjectList& list, s16 id) : m_list(list), m_id(id) {}
|
||||
|
||||
class const_iterator
|
||||
{
|
||||
friend class CObjectList;
|
||||
const CObjectList& m_list;
|
||||
s16 m_id;
|
||||
const_iterator(const CObjectList& list, s16 id) : m_list(list), m_id(id) {}
|
||||
public:
|
||||
const_iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; }
|
||||
bool operator!=(const iterator& other) const { return m_id != other.m_id; }
|
||||
const CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
|
||||
};
|
||||
const_iterator cbegin() const { return const_iterator(*this, x2008_firstId); }
|
||||
const_iterator cend() const { return const_iterator(*this, -1); }
|
||||
public:
|
||||
iterator& operator++() {
|
||||
m_id = m_list.GetNextObjectIndex(m_id);
|
||||
return *this;
|
||||
}
|
||||
bool operator!=(const iterator& other) const { return m_id != other.m_id; }
|
||||
CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
|
||||
};
|
||||
iterator begin() { return iterator(*this, x2008_firstId); }
|
||||
iterator end() { return iterator(*this, -1); }
|
||||
|
||||
CObjectList(EGameObjectList listEnum);
|
||||
virtual ~CObjectList() = default;
|
||||
class const_iterator {
|
||||
friend class CObjectList;
|
||||
const CObjectList& m_list;
|
||||
s16 m_id;
|
||||
const_iterator(const CObjectList& list, s16 id) : m_list(list), m_id(id) {}
|
||||
|
||||
void AddObject(CEntity& entity);
|
||||
void RemoveObject(TUniqueId uid);
|
||||
const CEntity* operator[](size_t i) const;
|
||||
CEntity* operator[](size_t i);
|
||||
const CEntity* GetObjectById(TUniqueId uid) const;
|
||||
const CEntity* GetObjectByIndex(s16 index) const { return x0_list[index].entity; }
|
||||
CEntity* GetObjectByIndex(s16 index) { return x0_list[index].entity; }
|
||||
CEntity* GetObjectById(TUniqueId uid);
|
||||
const CEntity* GetValidObjectById(TUniqueId uid) const;
|
||||
CEntity* GetValidObjectById(TUniqueId uid);
|
||||
s16 GetFirstObjectIndex() const { return x2008_firstId; }
|
||||
s16 GetNextObjectIndex(s16 prev) const { return x0_list[prev].next; }
|
||||
virtual bool IsQualified(const CEntity&);
|
||||
u16 size() const { return x200a_count; }
|
||||
public:
|
||||
const_iterator& operator++() {
|
||||
m_id = m_list.GetNextObjectIndex(m_id);
|
||||
return *this;
|
||||
}
|
||||
bool operator!=(const iterator& other) const { return m_id != other.m_id; }
|
||||
const CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
|
||||
};
|
||||
const_iterator cbegin() const { return const_iterator(*this, x2008_firstId); }
|
||||
const_iterator cend() const { return const_iterator(*this, -1); }
|
||||
|
||||
CObjectList(EGameObjectList listEnum);
|
||||
virtual ~CObjectList() = default;
|
||||
|
||||
void AddObject(CEntity& entity);
|
||||
void RemoveObject(TUniqueId uid);
|
||||
const CEntity* operator[](size_t i) const;
|
||||
CEntity* operator[](size_t i);
|
||||
const CEntity* GetObjectById(TUniqueId uid) const;
|
||||
const CEntity* GetObjectByIndex(s16 index) const { return x0_list[index].entity; }
|
||||
CEntity* GetObjectByIndex(s16 index) { return x0_list[index].entity; }
|
||||
CEntity* GetObjectById(TUniqueId uid);
|
||||
const CEntity* GetValidObjectById(TUniqueId uid) const;
|
||||
CEntity* GetValidObjectById(TUniqueId uid);
|
||||
s16 GetFirstObjectIndex() const { return x2008_firstId; }
|
||||
s16 GetNextObjectIndex(s16 prev) const { return x0_list[prev].next; }
|
||||
virtual bool IsQualified(const CEntity&);
|
||||
u16 size() const { return x200a_count; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
||||
Reference in New Issue
Block a user