Peoplemon  0.1.0
Peoplemon 3 game source documentation
Scripts.cpp
Go to the documentation of this file.
2 
5 
6 namespace core
7 {
8 namespace system
9 {
11 : owner(s) {}
12 
13 void Scripts::init() { bl::event::Dispatcher::subscribe(this); }
14 
15 const bl::script::Value* Scripts::getEntry(const std::string& name) const {
16  const auto it = entries.find(name);
17  return it != entries.end() ? &it->second : nullptr;
18 }
19 
20 void Scripts::setEntry(const std::string& name, const bl::script::Value& val) {
21  entries.emplace(name, val);
22 }
23 
24 void Scripts::observe(const event::GameSaveInitializing& save) {
25  save.gameSave.scripts.entries = &entries;
26 }
27 
28 } // namespace system
29 } // namespace core
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
file::GameSave & gameSave
Game save being initialized.
Definition: GameSave.hpp:24
struct core::file::GameSave::ScriptDataPointers scripts
std::unordered_map< std::string, bl::script::Value > * entries
Definition: GameSave.hpp:63
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