Terminus
world.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <list>
4 #include <memory>
5 #include <unordered_map>
6 
7 #include <QObject>
8 
9 #include <bullet/btBulletDynamicsCommon.h>
10 
11 #include <util/actionscheduler.h>
12 #include <util/timer.h>
13 #include <world/camera.h>
14 #include <world/level.h>
15 #include <world/lightmanager.h>
17 
18 class QOpenGLFunctions;
19 class QOpenGLShaderProgram;
20 class QTime;
21 
22 class btCollisionObject;
23 class btDiscreteDynamicsWorld;
24 
25 namespace terminus
26 {
27 class AbstractGraphicsObject;
28 class AbstractPhysicsObject;
29 class AbstractPlayer;
30 class AIPlayer;
31 class Game;
32 class LocalPlayer;
33 class NetworkManager;
34 class SkyBox;
35 class Terrain;
36 class Train;
37 
46 class World : public QObject
47 {
48  Q_OBJECT
49 public:
57  World(Game & game, bool isNetworkGame, bool isPlayerOne, unsigned int terrainSeed);
58 
62  World(const World & other) = delete;
63 
67  World & operator=(const World & other) = delete;
68 
69  ~World();
70 
71  void update();
72  void render(QOpenGLFunctions & gl) const;
73 
76 
79 
80  Level & level();
81  Timer & timer();
82 
84 
86 
88 
89  void addObject(AbstractGraphicsObject * node);
90  void deleteObject(AbstractGraphicsObject * object);
91 
99  std::shared_ptr<BulletWorld> bulletWorld();
100 
101 protected:
103 
105 
107 
108  std::shared_ptr<BulletWorld> m_bulletWorld;
109 
110  std::unique_ptr<SkyBox> m_skybox;
111  std::unique_ptr<Terrain> m_terrain;
112  std::shared_ptr<Train> m_rightTrain;
113  std::shared_ptr<Train> m_leftTrain;
114 
115  std::unique_ptr<LocalPlayer> m_localPlayer;
116  std::unique_ptr<AbstractPlayer> m_enemyPlayer;
117 
118  std::list<std::unique_ptr<AbstractGraphicsObject>> m_dynamicObjects;
119 };
120 
121 }
void render(QOpenGLFunctions &gl) const
Definition: world.cpp:139
std::unique_ptr< LocalPlayer > m_localPlayer
Definition: world.h:115
Train & localPlayerTrain()
Definition: world.cpp:181
void deleteObject(AbstractGraphicsObject *object)
Definition: world.cpp:103
Train & enemyPlayerTrain()
Definition: world.cpp:186
std::shared_ptr< BulletWorld > bulletWorld()
Returns a shared pointer to the corresponding BulletWorld.
Definition: world.cpp:206
The Timer class implements a set of pauseable duration counters (subsequently called timers) and mech...
Definition: timer.h:18
Level m_level
Definition: world.h:104
The Game class is the main entry point. It subclasses QQuickItem and handles all communication betwee...
Definition: game.h:36
void scheduleAction(ActionScheduler::Action event)
Definition: world.cpp:211
The Level class is a generator for level data such as terrain geometry and track courses.
Definition: level.h:26
Game & m_game
Definition: world.h:102
std::shared_ptr< Train > m_rightTrain
Definition: world.h:112
LightManager m_lightManager
Definition: world.h:106
LightManager & lightManager()
Definition: world.cpp:201
The AbstractGraphicsObject class is the root of a class hierarchy of objects that contain independen ...
Definition: abstractgraphicsobject.h:27
Timer & timer()
Definition: world.cpp:196
std::shared_ptr< Train > m_leftTrain
Definition: world.h:113
std::function< bool(void)> Action
functions that can be stored as actions can not have parameters and must return a bool whether they s...
Definition: actionscheduler.h:23
World & operator=(const World &other)=delete
Delete assignment operator.
The NetworkManager implements the basic functionality for the multiplayer mode of this game...
Definition: networkmanager.h:28
The LightManager class manages slots that can be filled with Light instances and is able to set those...
Definition: lightmanager.h:21
AbstractPlayer & enemyPlayer()
Definition: world.cpp:176
World(Game &game, bool isNetworkGame, bool isPlayerOne, unsigned int terrainSeed)
Construct a world for a local or multiplayer game.
Definition: world.cpp:31
std::list< std::unique_ptr< AbstractGraphicsObject > > m_dynamicObjects
Definition: world.h:118
std::unique_ptr< SkyBox > m_skybox
Definition: world.h:110
The World class represents a running game instance and contains all graphical (3D) elements of the sc...
Definition: world.h:46
The LocalPlayer class represents a local player that interacts with the World and their Train...
Definition: localplayer.h:17
NetworkManager & networkManager()
Definition: world.cpp:216
std::unique_ptr< Terrain > m_terrain
Definition: world.h:111
std::unique_ptr< AbstractPlayer > m_enemyPlayer
Definition: world.h:116
std::shared_ptr< BulletWorld > m_bulletWorld
Definition: world.h:108
Definition: eventhandler.cpp:18
LocalPlayer & localPlayer()
Definition: world.cpp:171
void addObject(AbstractGraphicsObject *node)
Definition: world.cpp:98
Level & level()
Definition: world.cpp:191
The AbstractPlayer class is the base class for interacting with a train and a camera.
Definition: abstractplayer.h:21
~World()
Definition: world.cpp:93
void update()
Definition: world.cpp:112
The Train class works as a logical container for all wagons one train consists of.
Definition: train.h:25