summaryrefslogtreecommitdiff
path: root/core/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/engine.cpp')
-rw-r--r--core/engine.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/engine.cpp b/core/engine.cpp
index c609ae9520..31abcd62ef 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -100,6 +100,31 @@ 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);
+ ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
+ ERR_FAIL_COND_V(!E, NULL);
+ return E->get();
+};
+
+bool Engine::has_singleton(const String &p_name) const {
+
+ return singleton_ptrs.has(p_name);
+};
+
+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() {