mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 13:53:57 -07:00
- Made some classes not be singletons, since there's no reason why they should be. - Made them non-global too (because globals have unclear lifetimes, and make it harder to test things, etc). They're now owned by CGameView and CWorld, and mostly accessed via g_Game or arguments (vaguely trying to avoid the graphics code calling into the game code). - Moved CGameView implementation into pimpl, so the header file isn't so heavy. - Changed a few pointers into references, to indicate that they're never NULL. This was SVN commit r4756.
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#ifndef _OBJECTMANAGER_H
|
|
#define _OBJECTMANAGER_H
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
#include "ps/CStr.h"
|
|
#include "ObjectBase.h"
|
|
|
|
class CObjectEntry;
|
|
class CEntityTemplate;
|
|
class CMatrix3D;
|
|
class CMeshManager;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
// CObjectManager: manager class for all possible actor types
|
|
class CObjectManager
|
|
{
|
|
public:
|
|
struct ObjectKey
|
|
{
|
|
ObjectKey(const CStr& name, const std::vector<u8>& var)
|
|
: ActorName(name), ActorVariation(var) {}
|
|
|
|
CStr ActorName;
|
|
std::vector<u8> ActorVariation;
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
// constructor, destructor
|
|
CObjectManager(CMeshManager& meshManager);
|
|
~CObjectManager();
|
|
|
|
CMeshManager& GetMeshManager() const { return m_MeshManager; }
|
|
|
|
void UnloadObjects();
|
|
|
|
CObjectEntry* FindObject(const char* objname);
|
|
void DeleteObject(CObjectEntry* entry);
|
|
|
|
CObjectBase* FindObjectBase(const char* objname);
|
|
|
|
CObjectEntry* FindObjectVariation(const char* objname, const std::vector<std::set<CStr> >& selections);
|
|
CObjectEntry* FindObjectVariation(CObjectBase* base, const std::vector<std::set<CStr> >& selections);
|
|
|
|
// Get all names, quite slowly. (Intended only for Atlas.)
|
|
static void GetAllObjectNames(std::vector<CStr>& names);
|
|
static void GetPropObjectNames(std::vector<CStr>& names);
|
|
|
|
private:
|
|
CMeshManager& m_MeshManager;
|
|
|
|
std::map<ObjectKey, CObjectEntry*> m_Objects;
|
|
std::map<CStr, CObjectBase*> m_ObjectBases;
|
|
|
|
NO_COPY_CTOR(CObjectManager);
|
|
};
|
|
|
|
|
|
// Global comparison operator
|
|
bool operator< (const CObjectManager::ObjectKey& a, const CObjectManager::ObjectKey& b);
|
|
|
|
#endif
|