2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_COBJECTLIST_HPP__
|
|
|
|
#define __URDE_COBJECTLIST_HPP__
|
2015-08-19 05:48:57 +00:00
|
|
|
|
2016-04-16 23:48:29 +00:00
|
|
|
#include "World/CEntity.hpp"
|
2015-08-19 05:48:57 +00:00
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-19 05:48:57 +00:00
|
|
|
{
|
|
|
|
|
2015-11-21 01:16:07 +00:00
|
|
|
enum class EGameObjectList
|
2015-08-19 05:48:57 +00:00
|
|
|
{
|
2016-08-07 00:20:02 +00:00
|
|
|
Invalid = -1,
|
2015-11-21 01:16:07 +00:00
|
|
|
All,
|
|
|
|
Actor,
|
|
|
|
PhysicsActor,
|
|
|
|
GameCamera,
|
|
|
|
GameLight,
|
|
|
|
ListeningAi,
|
|
|
|
AiWaypoint,
|
|
|
|
PlatformAndDoor,
|
2015-08-19 05:48:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CObjectList
|
|
|
|
{
|
2016-08-07 00:20:02 +00:00
|
|
|
friend class CGameArea;
|
|
|
|
|
2015-08-19 05:48:57 +00:00
|
|
|
struct SObjectListEntry
|
|
|
|
{
|
|
|
|
CEntity* entity = nullptr;
|
2017-08-10 13:40:07 +00:00
|
|
|
s16 next = -1;
|
|
|
|
s16 prev = -1;
|
2015-08-19 05:48:57 +00:00
|
|
|
};
|
2017-02-21 03:29:28 +00:00
|
|
|
SObjectListEntry x0_list[1024]; // was an rstl::prereserved_vector
|
2017-01-15 03:59:37 +00:00
|
|
|
EGameObjectList x2004_listEnum;
|
2017-08-10 13:40:07 +00:00
|
|
|
s16 x2008_firstId = -1;
|
2017-01-15 03:59:37 +00:00
|
|
|
u16 x200a_count = 0;
|
2015-08-19 05:48:57 +00:00
|
|
|
public:
|
2016-08-15 20:58:07 +00:00
|
|
|
class iterator
|
|
|
|
{
|
|
|
|
friend class CObjectList;
|
|
|
|
CObjectList& m_list;
|
2017-08-10 13:40:07 +00:00
|
|
|
s16 m_id;
|
|
|
|
iterator(CObjectList& list, s16 id) : m_list(list), m_id(id) {}
|
2016-08-15 20:58:07 +00:00
|
|
|
public:
|
|
|
|
iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; }
|
|
|
|
bool operator!=(const iterator& other) const { return m_id != other.m_id; }
|
2017-08-10 13:40:07 +00:00
|
|
|
CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
|
2016-08-15 20:58:07 +00:00
|
|
|
};
|
2017-01-15 03:59:37 +00:00
|
|
|
iterator begin() { return iterator(*this, x2008_firstId); }
|
2017-08-10 13:40:07 +00:00
|
|
|
iterator end() { return iterator(*this, -1); }
|
2016-08-15 20:58:07 +00:00
|
|
|
|
2017-08-08 22:12:14 +00:00
|
|
|
class const_iterator
|
|
|
|
{
|
|
|
|
friend class CObjectList;
|
|
|
|
const CObjectList& m_list;
|
2017-08-10 13:40:07 +00:00
|
|
|
s16 m_id;
|
|
|
|
const_iterator(const CObjectList& list, s16 id) : m_list(list), m_id(id) {}
|
2017-08-08 22:12:14 +00:00
|
|
|
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; }
|
2017-08-10 13:40:07 +00:00
|
|
|
const CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
|
2017-08-08 22:12:14 +00:00
|
|
|
};
|
|
|
|
const_iterator cbegin() const { return const_iterator(*this, x2008_firstId); }
|
2017-08-10 13:40:07 +00:00
|
|
|
const_iterator cend() const { return const_iterator(*this, -1); }
|
2017-08-08 22:12:14 +00:00
|
|
|
|
2016-04-16 21:49:47 +00:00
|
|
|
CObjectList(EGameObjectList listEnum);
|
2018-05-25 06:39:38 +00:00
|
|
|
virtual ~CObjectList() = default;
|
2015-08-19 05:48:57 +00:00
|
|
|
|
2016-04-16 21:49:47 +00:00
|
|
|
void AddObject(CEntity& entity);
|
|
|
|
void RemoveObject(TUniqueId uid);
|
2017-02-14 04:27:20 +00:00
|
|
|
const CEntity* operator[](size_t i) const;
|
|
|
|
CEntity* operator[](size_t i);
|
2016-04-16 21:49:47 +00:00
|
|
|
const CEntity* GetObjectById(TUniqueId uid) const;
|
2017-08-10 13:40:07 +00:00
|
|
|
const CEntity* GetObjectByIndex(s16 index) const { return x0_list[index].entity; }
|
|
|
|
CEntity* GetObjectByIndex(s16 index) { return x0_list[index].entity; }
|
2016-04-16 21:49:47 +00:00
|
|
|
CEntity* GetObjectById(TUniqueId uid);
|
2017-03-26 05:53:04 +00:00
|
|
|
const CEntity* GetValidObjectById(TUniqueId uid) const;
|
|
|
|
CEntity* GetValidObjectById(TUniqueId uid);
|
2017-08-10 13:40:07 +00:00
|
|
|
s16 GetFirstObjectIndex() const { return x2008_firstId; }
|
|
|
|
s16 GetNextObjectIndex(s16 prev) const { return x0_list[prev].next; }
|
2016-10-01 19:00:16 +00:00
|
|
|
virtual bool IsQualified(const CEntity&);
|
2017-03-03 07:18:12 +00:00
|
|
|
u16 size() const { return x200a_count; }
|
2015-08-19 05:48:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_COBJECTLIST_HPP__
|