Peoplemon  0.1.0
Peoplemon 3 game source documentation
World.hpp
Go to the documentation of this file.
1 #ifndef CORE_SYSTEMS_WORLD_HPP
2 #define CORE_SYSTEMS_WORLD_HPP
3 
4 #include <BLIB/Engine/System.hpp>
5 #include <BLIB/Events.hpp>
6 #include <BLIB/Serialization/JSON.hpp>
8 #include <Core/Maps/Map.hpp>
9 
10 namespace core
11 {
12 namespace system
13 {
14 class Systems;
15 
21 class World
22 : public bl::engine::System
23 , public bl::event::Listener<event::GameSaveInitializing, event::GameSaveLoaded> {
24 public:
30  World(Systems& systems);
31 
35  virtual ~World() = default;
36 
44  bool switchMaps(const std::string& newMap, int spawnId);
45 
52  void whiteout(const std::string& newMap, int spawnId);
53 
58 
62  const map::Map& activeMap() const;
63 
67  virtual void observe(const event::GameSaveInitializing& save) override;
68 
72  virtual void observe(const event::GameSaveLoaded& load) override;
73 
79  void setWhiteoutMap(unsigned int spawn);
80 
81 private:
82  Systems& owner;
83  bl::resource::Ref<map::Map> currentMap;
84  bl::resource::Ref<map::Map> previousMap;
85 
86  std::string currentMapFile;
87  std::string prevMapFile;
88  bl::tmap::Position playerPos;
89  bl::tmap::Position prevPlayerPos;
90 
91  virtual void init(bl::engine::Engine&) override;
92  virtual void update(std::mutex&, float dt, float, float, float) override;
93  virtual void earlyCleanup() override;
94 };
95 
96 } // namespace system
97 } // namespace core
98 
99 #endif
Core classes and functionality for both the editor and game.
Fired when the game is saving or loading. Allows systems to hook in their data.
Definition: GameSave.hpp:22
Fired when a game save is loaded. Fired after the load is complete.
Definition: GameSave.hpp:46
The primary map class that represents a usable map in the game.
Definition: Map.hpp:49
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47
System for managing the current map and previous maps.
Definition: World.hpp:23
virtual ~World()=default
Destroys the system.
World(Systems &systems)
Creates the world system.
Definition: World.cpp:16
void setWhiteoutMap(unsigned int spawn)
Sets the respawn point to the given spawn in the current map.
Definition: World.cpp:79
void whiteout(const std::string &newMap, int spawnId)
Switches to the new map and resets the last map to empty.
Definition: World.cpp:72
bool switchMaps(const std::string &newMap, int spawnId)
Switches the current map to the map in the given file.
Definition: World.cpp:26
map::Map & activeMap()
Returns a reference to the active map.
Definition: World.cpp:84
virtual void observe(const event::GameSaveInitializing &save) override
Adds saved world data to the save file.
Definition: World.cpp:92