8#include <entt/locator/locator.hpp>
9#include <nlohmann/json.hpp>
40 void Scene::add_system(
const std::string& system)
42 auto& sf = entt::locator<meta::SystemFactory>::value();
43 sf.create_system(system, m_systems);
52 entt::locator<sol::state>::value().collect_garbage();
60 for (
auto&& system : m_systems)
103 const std::string& Scene::name() const noexcept
119 nlohmann::json Scene::serialize()
139 nlohmann::json json =
"{}"_json;
140 json[
"name"] = m_name;
142 json[
"systems"] = nlohmann::json::object();
143 for (
auto i = 0; i < m_systems.size(); i++)
145 json[
"systems"][std::to_string(i)] = m_systems[i]->id();
151 void Scene::deserialize(
const nlohmann::json& json)
153 m_name = json.at(
"name");
155 const auto& systems = json.at(
"systems");
156 m_systems.reserve(systems.size());
157 for (
const auto& [index, name] : systems.items())
159 add_system(name.get<std::string>());
Wrapper around entt::registry to expand functionality.
Scene()=delete
Constructor.