#include "game/scenes/scene_registry.hpp"

namespace scenes {

    auto SceneRegistry::instance() -> SceneRegistry& {
        static SceneRegistry inst;
        return inst;
    }

    void SceneRegistry::registerScene(int state_key, Factory factory) {
        factories_[state_key] = std::move(factory);
    }

    auto SceneRegistry::tryCreate(int state_key) const -> std::unique_ptr<Scene> {
        const auto it = factories_.find(state_key);
        if (it == factories_.end()) {
            return nullptr;
        }
        return it->second();
    }

}  // namespace scenes
