2006-07-12 20:29:33 -07:00
|
|
|
// EntityTemplateCollection.h
|
2004-05-21 17:57:54 -07:00
|
|
|
//
|
2004-07-20 12:30:35 -07:00
|
|
|
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
2004-05-21 17:57:54 -07:00
|
|
|
//
|
|
|
|
|
// Keeps tabs on the various types of entity that roam the world.
|
|
|
|
|
//
|
|
|
|
|
// General note: Template, Base Entity, and Entity Class are used more-or-less interchangably.
|
|
|
|
|
//
|
2006-07-17 15:18:37 -07:00
|
|
|
// Usage: g_EntityTemplateCollection.loadTemplates(): loads all templates
|
|
|
|
|
// g_EntityTemplateCollection.getTemplate(name): get a template by name
|
|
|
|
|
//
|
|
|
|
|
// EntityTemplateCollection will look at all subdirectiroes of entities/, but each template's
|
|
|
|
|
// name will only be its filename; thus, no two templates should have the same filename,
|
|
|
|
|
// but subdirectories can be created in entities/ to organize the files nicely.
|
2004-05-21 16:46:16 -07:00
|
|
|
|
2006-07-17 15:18:37 -07:00
|
|
|
#ifndef ENTITY_TEMPLATE_COLLECTION_INCLUDED
|
|
|
|
|
#define ENTITY_TEMPLATE_COLLECTION_INCLUDED
|
2004-05-21 16:46:16 -07:00
|
|
|
|
|
|
|
|
#include <vector>
|
2006-04-27 21:53:23 -07:00
|
|
|
#include <map>
|
2006-06-01 19:10:27 -07:00
|
|
|
#include "ps/CStr.h"
|
|
|
|
|
#include "ps/Singleton.h"
|
|
|
|
|
#include "graphics/ObjectEntry.h"
|
2006-07-12 20:29:33 -07:00
|
|
|
#include "EntityTemplate.h"
|
2006-06-01 19:10:27 -07:00
|
|
|
#include "ps/Game.h"
|
2004-05-21 16:46:16 -07:00
|
|
|
|
2006-07-12 20:29:33 -07:00
|
|
|
#define g_EntityTemplateCollection CEntityTemplateCollection::GetSingleton()
|
2006-05-13 15:11:46 -07:00
|
|
|
|
|
|
|
|
class CPlayer;
|
2004-05-21 16:46:16 -07:00
|
|
|
|
2006-07-12 20:29:33 -07:00
|
|
|
class CEntityTemplateCollection : public Singleton<CEntityTemplateCollection>
|
2004-05-21 16:46:16 -07:00
|
|
|
{
|
2006-07-17 21:17:46 -07:00
|
|
|
static const uint NULL_PLAYER = (PS_MAX_PLAYERS+1);
|
|
|
|
|
|
|
|
|
|
typedef STL_HASH_MAP<CStrW, CEntityTemplate*, CStrW_hash_compare> TemplateMap;
|
|
|
|
|
typedef STL_HASH_MAP<CStrW, CStr, CStrW_hash_compare> TemplateFilenameMap;
|
2006-05-13 15:11:46 -07:00
|
|
|
|
2006-07-17 21:17:46 -07:00
|
|
|
TemplateMap m_templates[PS_MAX_PLAYERS + 2];
|
|
|
|
|
TemplateFilenameMap m_templateFilenames;
|
2004-05-21 16:46:16 -07:00
|
|
|
public:
|
2006-07-12 20:29:33 -07:00
|
|
|
~CEntityTemplateCollection();
|
2006-07-20 07:37:58 -07:00
|
|
|
CEntityTemplate* getTemplate( const CStrW& entityType, CPlayer* player = 0 );
|
2006-07-17 21:17:46 -07:00
|
|
|
|
|
|
|
|
// Load list of template filenames
|
2005-05-03 14:36:57 -07:00
|
|
|
int loadTemplates();
|
2005-03-26 17:44:41 -08:00
|
|
|
void LoadFile( const char* path );
|
2005-03-22 15:31:30 -08:00
|
|
|
|
2005-03-29 18:06:00 -08:00
|
|
|
// Create a list of the names of all base entities, excluding template_*,
|
|
|
|
|
// for display in ScEd's entity-selection box.
|
2006-07-12 20:29:33 -07:00
|
|
|
void getEntityTemplateNames( std::vector<CStrW>& names );
|
2006-07-17 21:17:46 -07:00
|
|
|
|
|
|
|
|
// Get all the templates owned by a specific player, which is useful for techs
|
|
|
|
|
void getPlayerTemplates( CPlayer* player, std::vector<CEntityTemplate*>& dest );
|
2004-05-21 16:46:16 -07:00
|
|
|
};
|
|
|
|
|
|
2004-06-02 09:11:32 -07:00
|
|
|
#endif
|