diff options
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 c609ae9520..d2ef70d82b 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() { |