GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
World.hpp
Go to the documentation of this file.
1 #ifndef RADIX_WORLD_HPP
2 #define RADIX_WORLD_HPP
3 
4 #include <algorithm>
5 #include <condition_variable>
6 #include <functional>
7 #include <map>
8 #include <mutex>
9 #include <set>
10 #include <stack>
11 #include <stdexcept>
12 #include <string>
13 #include <queue>
14 #include <thread>
15 #include <utility>
16 #include <vector>
17 
18 #include <radix/Camera.hpp>
19 #include <radix/EntityManager.hpp>
24 #include <radix/SystemManager.hpp>
26 #include <radix/env/Config.hpp>
27 
28 namespace radix {
29 
30 typedef std::pair<Entity*, Entity*> EntityPair;
31 
32 class World {
33 private:
35 protected:
37 
38 public:
40  World(InputSource &input);
41  void setConfig(radix::Config &config);
43  ~World();
44  void create();
45  void destroy();
46 
47  inline double getTime() const {
48  return gameTime;
49  }
50  void update(TDelta dtime);
51 
52  Entity& getPlayer();
53 
55  std::map<int, Material> materials;
56 
58 
60 
62 
63  // Convenience
64  std::map<std::string, Entity*> entityAliases;
65  std::map<std::string, std::vector<Entity*>> entityGroups;
66  std::map<std::string, std::vector<EntityPair>> entityPairs;
67 
68  // Game States
69  std::stack<HandleGameFunction> stateFunctionStack;
70 
76  return entities.getById(id);
77  }
78 
83  inline Entity& getEntityByName(const std::string &name) {
84  return entities.getByName(name);
85  }
86 
87 private:
88  double gameTime;
89  uint32_t lastUpdateTime;
90 };
91 
92 } /* namespace glPortal */
93 
94 #endif /* RADIX_WORLD_HPP */
radix::Config & getConfig()
Definition: World.cpp:41
EventDispatcher event
Definition: World.hpp:57
Definition: GameController.hpp:7
InputSource & input
Definition: World.hpp:39
double gameTime
Definition: World.hpp:88
Definition: InputSource.hpp:16
Entity & getEntityByName(const std::string &name)
Gets the reference to the entity with specified name.
Definition: World.hpp:83
ECS entity, Component container It is created like this:
Definition: Entity.hpp:23
std::map< std::string, std::vector< EntityPair > > entityPairs
Definition: World.hpp:66
double getTime() const
Definition: World.hpp:47
EntityManager entities
Definition: World.hpp:61
Configuration class.
Definition: Config.hpp:19
SystemManager systems
Definition: World.hpp:59
Definition: EventDispatcher.hpp:13
Definition: TimeDelta.hpp:8
std::map< std::string, std::vector< Entity * > > entityGroups
Definition: World.hpp:65
void create()
Definition: World.cpp:47
Camera camera
Definition: World.hpp:54
Entity & getEntityById(EntityId id)
Gets the reference to the entity with specified ID.
Definition: World.hpp:75
std::map< std::string, Entity * > entityAliases
Definition: World.hpp:64
radix::Config config
Definition: World.hpp:34
Entity & getPlayer()
Definition: World.cpp:136
Definition: Camera.hpp:11
uint32_t EntityId
Definition: Entity.hpp:16
Manager and container of entities.
Definition: EntityManager.hpp:16
Entity * player
Definition: World.hpp:36
~World()
Definition: World.cpp:33
void setConfig(radix::Config &config)
Definition: World.cpp:37
std::map< int, Material > materials
Definition: World.hpp:55
void destroy()
Definition: World.cpp:51
uint32_t lastUpdateTime
Definition: World.hpp:89
std::pair< Entity *, Entity * > EntityPair
Definition: World.hpp:30
std::stack< HandleGameFunction > stateFunctionStack
Definition: World.hpp:69
Entity & getById(EntityId id)
Gets the reference to the entity with specified ID.
Definition: EntityManager.cpp:28
Entity & getByName(const std::string &name)
Gets the reference to the entity with specified name.
Definition: EntityManager.cpp:37
World(InputSource &input)
Definition: World.cpp:16
Definition: World.hpp:32
Definition: SystemManager.hpp:22
void update(TDelta dtime)
Definition: World.cpp:54