Peoplemon  0.1.0
Peoplemon 3 game source documentation
Scripts.hpp
Go to the documentation of this file.
1 #ifndef CORE_SYSTEMS_SCRIPTS_HPP
2 #define CORE_SYSTEMS_SCRIPTS_HPP
3 
4 #include <BLIB/Events.hpp>
5 #include <BLIB/Scripts.hpp>
6 #include <BLIB/Serialization/JSON.hpp>
8 #include <unordered_map>
9 
10 namespace core
11 {
12 namespace system
13 {
14 class Systems;
15 
22 class Scripts : public bl::event::Listener<event::GameSaveInitializing> {
23 public:
29  Scripts(Systems& owner);
30 
35  void init();
36 
43  const bl::script::Value* getEntry(const std::string& name) const;
44 
51  void setEntry(const std::string& name, const bl::script::Value& val);
52 
53 private:
54  Systems& owner;
55  std::unordered_map<std::string, bl::script::Value> entries;
56 
57  virtual void observe(const event::GameSaveInitializing& save) override;
58 
59  friend struct bl::serial::SerializableObject<Scripts>;
60 };
61 
62 } // namespace system
63 } // namespace core
64 
65 #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
System that stores and handles saving/loading of save entries for scripts.
Definition: Scripts.hpp:22
const bl::script::Value * getEntry(const std::string &name) const
Returns the save entry with the given name. May be null if not found.
Definition: Scripts.cpp:15
void setEntry(const std::string &name, const bl::script::Value &val)
Sets a save entry.
Definition: Scripts.cpp:20
void init()
Subscribes to the game event bus.
Definition: Scripts.cpp:13
Scripts(Systems &owner)
Initializes the scripting system.
Definition: Scripts.cpp:10
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47