scenes: infraestructura de la capa scenes:: (scene, timeline, sprite mover, frame animator, palette fade, surface handle, registry)
This commit is contained in:
20
source/scenes/scene_registry.cpp
Normal file
20
source/scenes/scene_registry.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "scenes/scene_registry.hpp"
|
||||
|
||||
namespace scenes {
|
||||
|
||||
SceneRegistry& SceneRegistry::instance() {
|
||||
static SceneRegistry inst;
|
||||
return inst;
|
||||
}
|
||||
|
||||
void SceneRegistry::registerScene(int state_key, Factory factory) {
|
||||
factories_[state_key] = std::move(factory);
|
||||
}
|
||||
|
||||
std::unique_ptr<Scene> SceneRegistry::tryCreate(int state_key) const {
|
||||
const auto it = factories_.find(state_key);
|
||||
if (it == factories_.end()) return nullptr;
|
||||
return it->second();
|
||||
}
|
||||
|
||||
} // namespace scenes
|
||||
Reference in New Issue
Block a user