prime/include/MetroidPrime/CObjectList.hpp

65 lines
1.4 KiB
C++
Raw Normal View History

#ifndef _COBJECTLIST
#define _COBJECTLIST
2022-08-05 10:23:49 +00:00
2022-08-13 01:26:00 +00:00
#include "types.h"
#include "MetroidPrime/TGameTypes.hpp"
2022-08-05 10:23:49 +00:00
#define kMaxObjects 1024
2022-08-13 01:26:00 +00:00
2022-08-05 10:23:49 +00:00
enum EGameObjectList {
kOL_Invalid = -1,
kOL_All,
kOL_Actor,
kOL_PhysicsActor,
kOL_GameCamera,
kOL_GameLight,
kOL_ListeningAi,
kOL_AiWaypoint,
kOL_PlatformAndDoor,
2022-08-05 10:23:49 +00:00
};
class CEntity;
class CObjectList {
struct SObjectListEntry {
CEntity* mEnt;
short mNext;
short mPrev;
2022-10-14 04:50:56 +00:00
SObjectListEntry() : mEnt(nullptr), mNext(-1), mPrev(-1) {}
2022-08-05 10:23:49 +00:00
};
public:
CObjectList(EGameObjectList list);
2022-10-14 04:50:56 +00:00
virtual bool IsQualified(const CEntity& ent);
2022-08-05 10:23:49 +00:00
void AddObject(CEntity& ent);
void RemoveObject(TUniqueId uid);
2022-10-14 04:50:56 +00:00
CEntity* GetObjectById(TUniqueId uid);
const CEntity* GetObjectById(TUniqueId uid) const;
2022-08-05 10:23:49 +00:00
CEntity* GetValidObjectById(TUniqueId uid);
const CEntity* GetValidObjectById(TUniqueId uid) const;
CEntity* operator[](int idx);
const CEntity* operator[](int idx) const;
2022-10-14 04:50:56 +00:00
const CEntity* GetObjectByIndex(int idx) const;
int size() const { return mCount; }
2022-08-13 01:26:00 +00:00
int GetFirstObjectIndex() const { return mFirstId; }
int GetNextObjectIndex(int idx) const {
if (idx != -1) {
return mObjects[idx].mNext;
} else {
return -1;
}
}
2022-08-05 10:23:49 +00:00
private:
SObjectListEntry mObjects[1024];
EGameObjectList mListType;
short mFirstId;
short mCount;
2022-08-13 01:26:00 +00:00
};
CHECK_SIZEOF(CObjectList, 0x200c)
2022-08-05 10:23:49 +00:00
#endif // _COBJECTLIST