HatchitGame
ht_scene.h
1 
15 #pragma once
16 
17 #include <ht_platform.h>
18 #include <ht_noncopy.h>
19 #include <ht_guid.h>
20 #include <ht_scene_resource.h>
21 
22 #include <json.hpp>
23 
24 #include <vector>
25 #include <unordered_set>
26 #include <unordered_map>
27 
28 #ifdef HT_SYS_LINUX
29  #include <cstdlib>
30 #endif
31 
32 namespace Hatchit {
33 
34  namespace Game {
35 
36  using JSON = Core::JSON;
37 
38  class GameObject;
39  class Transform;
40 
44  class HT_API Scene : public Core::INonCopy
45  {
46  friend class SceneManager;
47  public:
48 
49  Scene(const Scene& rhs) = default;
50  Scene& operator=(const Scene& rhs) = default;
51  Scene(Scene&& rhs);
52  Scene& operator=(Scene&& rhs);
53 
57  static GameObject* CreateGameObject();
58 
62  static GameObject* CreateGameObject(GameObject& prefab);
63 
67  std::string Name() const;
68 
74  const Core::Guid& GUID() const;
75 
82  bool LoadFromHandle(Resource::SceneHandle sceneHandle);
83 
87  void Render(void);
88 
92  void Update(void);
93 
97  void Unload(void);
98 
99  private:
100 
101  static Scene* instance;
102 
103  Scene(void) = default;
104  virtual ~Scene(void) = default;
105 
109  void Init(void);
110 
117  bool ParseScene(const JSON& obj);
118 
126  bool ParseGameObject(const JSON& obj, GameObject*& out);
127 
135  void ParseChildGameObjects(const Core::Guid& id, std::unordered_map<Core::Guid, GameObject*>& guid_to_obj, std::unordered_map<Core::Guid, JSON>& guid_to_json);
136 
146  Transform ParseTransform(const JSON& obj);
147 
157  bool ParseComponent(const JSON& obj, GameObject& out);
158 
159  std::string m_name;
160  Core::Guid m_guid;
161  std::vector<GameObject*> m_gameObjects;
162  std::vector<GameObject*> m_prefabs;
163  };
164  }
165 }
Definition: ht_transform.h:25
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_glfwkeyboard.h:21
Defines the singleton scene manager.
Definition: ht_scenemanager_singleton.h:32
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_gameobject.h:48
Defines a scene.
Definition: ht_scene.h:44