#include "game/scenes/scene_registry.hpp"

namespace Scenes {

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

    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
