Go to the documentation of this file.00001 #ifndef __NYTRO_World_H
00002 #define __NYTRO_World_H
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "system/nyCommon.h"
00012 #include "system/nyResource.h"
00013 #include "system/nyXml.h"
00014 #include "game/nyEntity.h"
00015
00016 namespace Nytro
00017 {
00018 namespace Game
00019 {
00021 class NYTRO_API WorldObserver : IObserver
00022 {
00023 public:
00024
00026 virtual void onWorldLoadProgress( int8 aProgress, const char* pMessage ){};
00028 virtual void onWorldSaveProgress( int8 aProgress, const char* pMessage ){};
00029 };
00030
00032 class NYTRO_API World : public Resource, public Observable<WorldObserver>
00033 {
00034 public:
00035
00036 NYTRO_CLASS_NAME( World );
00037
00038 World();
00039 virtual ~World();
00040
00042 EResult load( const char* pFilename = NULL, bool bSkipFileProvider = false );
00044 EResult unload();
00046 EResult save( const char* pFilename = NULL );
00048 Entity* findEntityByName( const char* pName );
00050 EResult removeEntity( Entity* pEntity );
00052 EResult removeEntities( vector<Entity*>& rEntities );
00054 void processEntitySlots();
00056 EntityGroup* createEntityGroup();
00058 EntityGroup* findEntityGroupByName( const char* pGroupName );
00060 void deleteEntityGroupByName( const char* pGroupName );
00062 void deleteEntityGroup( EntityGroup* pGroup );
00064 vector<Entity*>& getEntities();
00066 const vector<EntityGroup*>& getEntityGroups() const;
00068 const vector<EntityLayer*>& getEntityLayers() const;
00070 EntityLayer* createEntityLayer();
00072 EntityLayer* getEntityLayerByName( const char* pName );
00074 void deleteEntityLayer( EntityLayer* pLayer, bool bDeleteEntitiesAlso = false );
00076 void updateEntitiesFromLayers();
00077 EResult loadFromStream( Stream* pStream );
00078 EResult saveToStream( Stream* pStream );
00079
00080 protected:
00081
00083 bool addNewEntityFromXML( XmlElement* pEntityElem, int8 aProgress = 0 );
00084
00086 vector<Entity*> m_entities;
00088 vector<EntityGroup*> m_entityGroups;
00090 string m_description;
00092 vector<EntityLayer*> m_entityLayers;
00093 };
00094 };
00095 };
00096
00097 #endif