23 if (!
j.is_object())
return false;
26 if (!
j.contains(
"blueprintType"))
return false;
27 if (!
j[
"blueprintType"].
is_string())
return false;
31 if (
j.contains(
"schema_version") &&
j[
"schema_version"].is_number())
33 int ver =
j[
"schema_version"].get<
int>();
34 if (
ver > 2)
return false;
46 if (nodeName ==
"Repeater" || nodeName.substr(0, 6) ==
"Repeat")
return true;
47 if (nodeName ==
"Inverter" || nodeName.substr(0, 6) ==
"Invert")
return true;
48 if (nodeName ==
"Cooldown" || nodeName.substr(0, 8) ==
"Cooldown")
return true;
49 if (nodeName ==
"Timeout" || nodeName.substr(0, 7) ==
"Timeout")
return true;
84 outErrors.push_back(
"BTtoVSMigrator: node missing 'id' field");
89 if (
btNode.contains(
"name") &&
btNode[
"name"].is_string())
96 if (
btNode.contains(
"type") &&
btNode[
"type"].is_string())
109 if (
btNode.contains(
"children") &&
btNode[
"children"].is_array())
127 if (
btNode.contains(
"actionType") &&
btNode[
"actionType"].is_string())
129 std::string
at =
btNode[
"actionType"].get<std::string>();
136 btNode.contains(
"parameters") &&
btNode[
"parameters"].is_object())
139 if (
params.contains(
"taskType") &&
params[
"taskType"].is_string())
149 if (
btNode.contains(
"parameters") &&
btNode[
"parameters"].is_object())
154 if (
it.value().is_string())
165 if (
btNode.contains(
"position") &&
btNode[
"position"].is_object())
168 float px =
pos.contains(
"x") &&
pos[
"x"].is_number() ?
pos[
"x"].get<
float>() : 0.0f;
169 float py =
pos.contains(
"y") &&
pos[
"y"].is_number() ?
pos[
"y"].get<
float>() : 0.0f;
189 std::vector<std::string>& )
191 std::vector<ExecPinConnection>
conns;
196 if (!
btNode.is_object())
continue;
203 if (!
btNode.contains(
"children") || !
btNode[
"children"].is_array())
continue;
217 ec.SourcePinName =
"Out";
219 ec.TargetPinName =
"In";
233 std::vector<std::string>& )
244 if (
d1.contains(
"blackboard") &&
d1[
"blackboard"].is_array())
246 else if (
d1.contains(
"data") &&
d1[
"data"].is_object())
248 const auto&
d2 =
d1[
"data"];
249 if (
d2.contains(
"blackboard") &&
d2[
"blackboard"].is_array())
258 if (!
entry.is_object())
continue;
261 if (
entry.contains(
"key") &&
entry[
"key"].is_string())
265 if (
entry.contains(
"type") &&
entry[
"type"].is_string())
267 std::string
t =
entry[
"type"].get<std::string>();
293 result.
Name =
"MigratedGraph";
312 if (
data1->contains(
"nodes") && (*data1)[
"nodes"].is_array())
315 if (
data1->contains(
"rootNodeId") && (*data1)[
"rootNodeId"].is_number())
318 else if (
data1->contains(
"data") && (*data1)[
"data"].is_object())
320 data2 = &(*data1)[
"data"];
321 if (
data2->contains(
"nodes") && (*data2)[
"nodes"].is_array())
324 if (
data2->contains(
"rootNodeId") && (*data2)[
"rootNodeId"].is_number())
332 outErrors.push_back(
"BTtoVSMigrator: could not find 'nodes' array in BT v2 JSON");
344 if (
btNode.contains(
"type") &&
btNode[
"type"].is_string())
358 result.
Nodes.push_back(def);
Converts legacy BT v2 JSON graphs to ATS VS v4 JSON format (Phase 6).
ComponentTypeID GetComponentTypeID_Static()
static TaskGraphTemplate Convert(const nlohmann::json &btV2Json, std::vector< std::string > &outErrors)
Converts a BT v2 JSON document to a TaskGraphTemplate.
static TaskNodeDefinition ConvertNode(const nlohmann::json &btNode, std::vector< std::string > &outErrors)
Converts one BT node JSON object to a TaskNodeDefinition.
static void ConvertBlackboard(const nlohmann::json &btV2Json, TaskGraphTemplate &vsGraph, std::vector< std::string > &outErrors)
Copies blackboard entries from the BT JSON to the VS template.
static TaskNodeType MapNodeType(const std::string &btType)
Maps a BT node type string to the closest TaskNodeType equivalent.
static bool IsDecoratorName(const std::string &nodeName)
Returns true if nodeName indicates a BT Decorator node.
static bool IsBTv2(const nlohmann::json &j)
Returns true if j looks like a BT v2 document.
static std::vector< ExecPinConnection > ConvertConnections(const nlohmann::json &nodesArray, std::vector< std::string > &outErrors)
Builds exec connections from the BT "children" tree structure.
Immutable, shareable task graph asset.
std::vector< TaskNodeDefinition > Nodes
All graph nodes.
std::vector< ExecPinConnection > ExecConnections
Explicit exec connections (ATS VS only)
std::string Name
Friendly name of this template (e.g. "PatrolBehaviour")
int32_t RootNodeID
ID of the root node (must exist in Nodes)
void BuildLookupCache()
Rebuilds the internal ID-to-node lookup map from the Nodes vector.
int32_t EntryPointID
ID of the EntryPoint node (for VS graphs)
std::string GraphType
Graph type: "BehaviorTree" (legacy) or "VisualScript" (ATS VS)
C++14-compliant type-safe value container for task parameters.
< Provides AssetID and INVALID_ASSET_ID
@ Int
32-bit signed integer
@ Float
Single-precision float.
@ None
Uninitialized / empty value.
@ Literal
Value is embedded directly in the template.
TaskNodeType
Identifies the role of a node in the task graph.
@ AtomicTask
Leaf node that executes a single atomic task.
@ Sequence
Executes children in order; stops on first failure.
@ Decorator
Wraps a single child and modifies its behaviour.
@ EntryPoint
Unique entry node for VS graphs (replaces Root)
@ Branch
If/Else conditional (Then / Else exec outputs)
constexpr int32_t NODE_INDEX_NONE
Sentinel value for "no node" in node index / ID fields.
Single entry in the graph's declared blackboard schema (local or global).
Explicit connection between a named exec-out pin of a source node and the exec-in pin of a target nod...
Describes how a single parameter value is supplied to a task node.
ParameterBindingType Type
Binding mode.
Full description of a single node in the task graph.
std::vector< int32_t > ChildrenIDs
Child node IDs (control-flow nodes only; empty for AtomicTask/Decorator leaf)
std::string AtomicTaskID
Atomic task type identifier (used when Type == AtomicTask)
TaskNodeType Type
Node role.
std::string NodeName
Human-readable name.
std::unordered_map< std::string, ParameterBinding > Parameters
Named parameter bindings passed to the atomic task.
int32_t NodeID
Unique ID within this template.