diff options
| author | Leon Krause | 2017-11-13 21:46:57 +0100 |
|---|---|---|
| committer | Leon Krause | 2017-11-14 15:15:13 +0100 |
| commit | 9b7b46143d2df7d4f2efcb89ceb5034c7a57e79c (patch) | |
| tree | 8ceadc6a5891c5f3205b0e23d5b7dd6ef3d40e1f /core/engine.cpp | |
| parent | 3732b2318e8a4942e8202f1797527220a5ae01a0 (diff) | |
| download | godot-9b7b46143d2df7d4f2efcb89ceb5034c7a57e79c.tar.gz godot-9b7b46143d2df7d4f2efcb89ceb5034c7a57e79c.tar.zst godot-9b7b46143d2df7d4f2efcb89ceb5034c7a57e79c.zip | |
Diffstat (limited to 'core/engine.cpp')
| -rw-r--r-- | core/engine.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/engine.cpp b/core/engine.cpp index c609ae952..d2ef70d82 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -100,6 +100,32 @@ Dictionary Engine::get_version_info() const { return dict; } +void Engine::add_singleton(const Singleton &p_singleton) { + + singletons.push_back(p_singleton); + singleton_ptrs[p_singleton.name] = p_singleton.ptr; +} + +Object *Engine::get_singleton_object(const String &p_name) const { + + const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name); + if (!E) + return NULL; + else + return E->get(); +}; + +bool Engine::has_singleton(const String &p_name) const { + + return get_singleton_object(p_name) != NULL; +}; + +void Engine::get_singletons(List<Singleton> *p_singletons) { + + for (List<Singleton>::Element *E = singletons.front(); E; E = E->next()) + p_singletons->push_back(E->get()); +} + Engine *Engine::singleton = NULL; Engine *Engine::get_singleton() { |
