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;
|
|
|
|
TUniqueId next = -1;
|
2016-08-14 21:11:44 +00:00
|
|
|
TUniqueId prev = -1;
|
2015-08-19 05:48:57 +00:00
|
|
|
};
|
|
|
|
SObjectListEntry m_list[1024];
|
|
|
|
EGameObjectList m_listEnum;
|
2016-08-15 20:58:07 +00:00
|
|
|
TUniqueId m_firstId = kInvalidUniqueId;
|
2015-08-19 05:48:57 +00:00
|
|
|
u16 m_count = 0;
|
2016-08-07 00:20:02 +00:00
|
|
|
int m_areaIdx = 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;
|
|
|
|
TUniqueId m_id;
|
|
|
|
iterator(CObjectList& list, TUniqueId 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.GetObjectById(m_id); }
|
|
|
|
};
|
|
|
|
iterator begin() { return iterator(*this, m_firstId); }
|
|
|
|
iterator end() { return iterator(*this, kInvalidUniqueId); }
|
|
|
|
|
2016-04-16 21:49:47 +00:00
|
|
|
CObjectList(EGameObjectList listEnum);
|
2015-08-19 05:48:57 +00:00
|
|
|
|
2016-04-16 21:49:47 +00:00
|
|
|
void AddObject(CEntity& entity);
|
|
|
|
void RemoveObject(TUniqueId uid);
|
|
|
|
const CEntity* GetObjectById(TUniqueId uid) const;
|
|
|
|
CEntity* GetObjectById(TUniqueId uid);
|
2016-08-14 21:11:44 +00:00
|
|
|
TUniqueId GetFirstObjectIndex() const { return m_firstId; }
|
|
|
|
TUniqueId GetNextObjectIndex(TUniqueId prev) const { return m_list[prev].next; }
|
2016-10-01 19:00:16 +00:00
|
|
|
virtual bool IsQualified(const CEntity&);
|
2015-08-19 05:48:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_COBJECTLIST_HPP__
|