1
0
forked from 0ad/0ad
0ad/source/graphics/ObjectManager.h
Ykkrosh 22dd4dd67b Entities: Removed Tag attribute; it is taken from the filename instead. Made entity XML files be loaded on demand. Probably stopped crash when maps contain non-existent entities. Fixed a few bugs in entity definitions.
Maps: Stored non-entity objects in XML instead of PMP, for easier manual
editing. Updated existing maps to newest format, so that they can still
work. Added undocumented _rewriteMaps() JS function. Also renamed _mem
to vmem, and reclassified its undocumentedness as unintentional, since
it's reasonably useful.
Loader: added NonprogressiveLoad function, for ScEd/_rewriteMaps/etc
which don't care about progressiveness.
main.cpp: re-enabled vfs_display, since it doesn't crash now
Vector3D: stopped warning

This was SVN commit r2078.
2005-03-29 20:50:04 +00:00

68 lines
1.5 KiB
C++
Executable File

#ifndef _OBJECTMANAGER_H
#define _OBJECTMANAGER_H
#include <vector>
#include <map>
#include "Singleton.h"
#include "CStr.h"
#include "ObjectBase.h"
class CObjectBase;
class CObjectEntry;
class CBaseEntity;
// access to sole CObjectManager object
#define g_ObjMan CObjectManager::GetSingleton()
///////////////////////////////////////////////////////////////////////////////////////////
// CObjectManager: manager class for all possible actor types
class CObjectManager : public Singleton<CObjectManager>
{
public:
struct ObjectKey
{
ObjectKey(CStr& name, CObjectBase::variation_key& var)
: ActorName(name), ActorVariation(var) {}
CStr ActorName;
CObjectBase::variation_key ActorVariation;
};
struct SObjectType
{
// name of this object type (derived from directory name)
CStr m_Name;
// index in parent array
int m_Index;
// list of objects of this type (found from the objects directory)
std::map<ObjectKey, CObjectEntry*> m_Objects;
std::map<CStr, CObjectBase*> m_ObjectBases;
};
public:
// constructor, destructor
CObjectManager();
~CObjectManager();
void LoadObjects();
void AddObjectType(const char* name);
CObjectEntry* FindObject(const char* objname);
void AddObject(ObjectKey& key, CObjectEntry* entry, int type);
void DeleteObject(CObjectEntry* entry);
CObjectBase* FindObjectBase(const char* objname);
CBaseEntity* m_SelectedEntity;
std::vector<SObjectType> m_ObjectTypes;
};
// Global comparison operator
bool operator< (const CObjectManager::ObjectKey& a, const CObjectManager::ObjectKey& b);
#endif