27 return blueprint.contains(
"schema_version") &&
28 blueprint[
"schema_version"].get<
int>() == 2;
33 auto now = std::chrono::system_clock::now();
34 auto time = std::chrono::system_clock::to_time_t(
now);
42 ss << std::put_time(&
timeInfo,
"%Y-%m-%dT%H:%M:%S");
51 return "EntityPrefab";
61 return "BehaviorTree";
81 v2[
"schema_version"] = 2;
83 v2[
"name"] =
v1Blueprint.value<std::string>(
"name",
"Unnamed");
84 v2[
"description"] =
"";
87 v2[
"metadata"][
"author"] =
"Atlasbruce";
90 v2[
"metadata"][
"tags"] = json::array();
93 v2[
"editorState"][
"zoom"] = 1.0;
94 v2[
"editorState"][
"scrollOffset"] = json::object();
95 v2[
"editorState"][
"scrollOffset"][
"x"] = 0;
96 v2[
"editorState"][
"scrollOffset"][
"y"] = 0;
99 v2[
"data"] = json::object();
120 v2Data[
"rootNodeId"] =
v1.value<
int>(
"rootNodeId", 1);
121 v2Data[
"nodes"] = json::array();
123 if (!
v1.contains(
"nodes") || !
v1[
"nodes"].is_array())
130 for (
size_t i = 0;
i <
v1[
"nodes"].size(); ++
i)
133 int id =
node.value<
int>(
"id", 0);
134 if (
node.contains(
"children") &&
node[
"children"].is_array())
136 std::vector<int> children;
137 for (
size_t j = 0;
j <
node[
"children"].size(); ++
j)
149 int rootId =
v1.value<
int>(
"rootNodeId", 1);
153 for (
size_t i = 0;
i <
v1[
"nodes"].size(); ++
i)
157 int nodeId =
v1Node.value<
int>(
"id", 0);
160 v2Node[
"name"] =
v1Node.value<std::string>(
"name",
"Unnamed");
161 v2Node[
"type"] =
v1Node.value<std::string>(
"type",
"Unknown");
172 v2Node[
"position"][
"x"] = 400.0;
173 v2Node[
"position"][
"y"] = 300.0;
177 if (
v1Node.contains(
"children"))
183 if (
v1Node.contains(
"actionType"))
187 if (
v1Node.contains(
"conditionType"))
191 if (
v1Node.contains(
"decoratorType"))
206 v2Data[
"initialState"] =
v1.value<std::string>(
"initialState",
"");
207 v2Data[
"states"] = json::array();
209 if (
v1.contains(
"states") &&
v1[
"states"].is_array())
211 for (
size_t i = 0;
i <
v1[
"states"].size(); ++
i)
213 const json& state =
v1[
"states"][
i];
216 if (!
v2State.contains(
"position"))
218 v2State[
"position"][
"x"] = 400.0;
219 v2State[
"position"][
"y"] = 300.0;
225 if (
v1.contains(
"transitions"))
227 v2Data[
"transitions"] =
v1[
"transitions"];
234 v2Data[
"prefabName"] =
v1.value<std::string>(
"name",
"Unnamed");
236 if (
v1.contains(
"components"))
238 v2Data[
"components"] =
v1[
"components"];
242 v2Data[
"components"] = json::array();
248 v2Node[
"parameters"] = json::object();
251 if (
v1Node.contains(
"param"))
255 if (
v1Node.contains(
"param1"))
259 if (
v1Node.contains(
"param2"))
267 const std::map<
int, std::vector<int>>&
childrenMap,
270 std::map<int, NodeLayout>
layouts;
273 std::queue<std::tuple<int, int, int>>
queue;
278 while (!
queue.empty())
280 std::tuple<int, int, int>
front =
queue.front();
283 int nodeId = std::get<0>(
front);
284 int depth = std::get<1>(
front);
285 int siblingIndex = std::get<2>(
front);
304 queue.push(std::make_tuple(childId, depth + 1, childIndex++));
ComponentTypeID GetComponentTypeID_Static()
std::string GetCurrentTimestamp()
static constexpr float HORIZONTAL_SPACING
nlohmann::json MigrateToV2(const nlohmann::json &v1Blueprint)
static constexpr float VERTICAL_SPACING
static constexpr float START_Y
std::string DetectBlueprintType(const nlohmann::json &blueprint)
void MigrateEntityPrefab(const nlohmann::json &v1, nlohmann::json &v2Data)
std::map< int, NodeLayout > CalculateHierarchicalLayout(const nlohmann::json &nodes, const std::map< int, std::vector< int > > &childrenMap, int rootId)
void MigrateHFSM(const nlohmann::json &v1, nlohmann::json &v2Data)
void MigrateBehaviorTree(const nlohmann::json &v1, nlohmann::json &v2Data)
static constexpr float START_X
void MigrateParameters(const nlohmann::json &v1Node, nlohmann::json &v2Node)
bool IsV2(const nlohmann::json &blueprint) const