Meteor2D  dev internal
Meteor is a lightweight 2D game engine.
Loading...
Searching...
No Matches
scene.h
1#pragma once
2#include<vector>
3#include<entities/spatial.h>
4#include<pugixml/pugixml.hpp>
5
6namespace meteor {
10 class MScene : public MEntity {
11 friend class Spatial;
12 public:
13
19 ~MScene();
23 void startScene();
27 void update(float deltaTime);
31 void onClose();
32
40 inline size_t getRootSize() { return rootEntities == NULL ? 0 : rootEntities->size(); }
44 inline std::vector<MSpatialEntity*>* getRootEntities() { return rootEntities; };
48 bool tryParse(pugi::xml_document* doc);
49
53 inline bool isClosing() { return sceneClosing; }
54
58 template<typename T>
59 T* find(std::string name) {
60 if (rootEntities->size() <= 0)
61 return NULL;
62
63 for (auto rootEntity : *rootEntities) {
64 auto res = rootEntity->find<T>(name);
65 if (res != NULL)
66 return res;
67 }
68
69 return NULL;
70 }
71
72 private:
73 std::vector<MSpatialEntity*>* rootEntities;
74 void recursivelyLoadEntity(pugi::xml_node* currNode, MSpatialEntity* parent);
75 bool sceneClosing = false;
76 public:
77 static const std::string VALID_SCENE_FILE_XML_TAG;
78 };
79}
An Entity is the base class for all data and behaviour oriented objects in meteor....
Definition entity.h:9
A scene holds a collection of spatial entity for a specific level.
Definition scene.h:10
bool tryParse(pugi::xml_document *doc)
Tries to parse and load a scene state.
void addToRoot(MSpatialEntity *entity)
Adds a SpatialEntity to the scene root.
T * find(std::string name)
Finds a Spatial Entity within this scene.
Definition scene.h:59
size_t getRootSize()
Returns size of root.
Definition scene.h:40
void onClose()
Invoked during scene unload.
std::vector< MSpatialEntity * > * getRootEntities()
Return a list of root entities.
Definition scene.h:44
void update(float deltaTime)
Invoked once per frame.
void startScene()
Invoked when scene loads.
MScene()
Constructor.
bool isClosing()
Definition scene.h:53
Spatial Entity is the base entity for all types present in scene. This entity keeps track of spatial ...
Definition spatial.h:15