Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Member Functions | List of all members
Olympe::BTtoVSMigrator Class Reference

Converts a BT v2 JSON object to a TaskGraphTemplate (VS v4). More...

#include <BTtoVSMigrator.h>

Static Public Member Functions

static TaskGraphTemplate Convert (const nlohmann::json &btV2Json, std::vector< std::string > &outErrors)
 Converts a BT v2 JSON document to a TaskGraphTemplate.
 
static bool IsBTv2 (const nlohmann::json &j)
 Returns true if j looks like a BT v2 document.
 
static bool IsDecoratorName (const std::string &nodeName)
 Returns true if nodeName indicates a BT Decorator node.
 

Static Private Member Functions

static TaskNodeDefinition ConvertNode (const nlohmann::json &btNode, std::vector< std::string > &outErrors)
 Converts one BT node JSON object to a TaskNodeDefinition.
 
static std::vector< ExecPinConnectionConvertConnections (const nlohmann::json &nodesArray, std::vector< std::string > &outErrors)
 Builds exec connections from the BT "children" tree structure.
 
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.
 

Detailed Description

Converts a BT v2 JSON object to a TaskGraphTemplate (VS v4).

All methods are static; the class is a pure utility with no instance state.

Definition at line 51 of file BTtoVSMigrator.h.

Member Function Documentation

◆ Convert()

TaskGraphTemplate Olympe::BTtoVSMigrator::Convert ( const nlohmann::json btV2Json,
std::vector< std::string > &  outErrors 
)
static

◆ ConvertBlackboard()

void Olympe::BTtoVSMigrator::ConvertBlackboard ( const nlohmann::json btV2Json,
TaskGraphTemplate vsGraph,
std::vector< std::string > &  outErrors 
)
staticprivate

Copies blackboard entries from the BT JSON to the VS template.

Definition at line 231 of file BTtoVSMigrator.cpp.

References Olympe::Bool, Olympe::Float, GetComponentTypeID_Static(), Olympe::Int, Olympe::BlackboardEntry::Key, Olympe::None, and Olympe::String.

Referenced by Convert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConvertConnections()

std::vector< ExecPinConnection > Olympe::BTtoVSMigrator::ConvertConnections ( const nlohmann::json nodesArray,
std::vector< std::string > &  outErrors 
)
staticprivate

Builds exec connections from the BT "children" tree structure.

Walks the node array and for each node that has a "children" array, emits an ExecPinConnection { nodeID, "Out", childID, "In" }.

Definition at line 187 of file BTtoVSMigrator.cpp.

References GetComponentTypeID_Static(), Olympe::NODE_INDEX_NONE, and Olympe::ExecPinConnection::SourceNodeID.

Referenced by Convert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConvertNode()

TaskNodeDefinition Olympe::BTtoVSMigrator::ConvertNode ( const nlohmann::json btNode,
std::vector< std::string > &  outErrors 
)
staticprivate

◆ IsBTv2()

bool Olympe::BTtoVSMigrator::IsBTv2 ( const nlohmann::json j)
static

Returns true if j looks like a BT v2 document.

Heuristic: document must contain "blueprintType" == "BehaviorTree" and either no schema_version or schema_version <= 2.

Definition at line 21 of file BTtoVSMigrator.cpp.

References GetComponentTypeID_Static().

Referenced by Olympe::TaskGraphLoader::LoadFromJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsDecoratorName()

bool Olympe::BTtoVSMigrator::IsDecoratorName ( const std::string &  nodeName)
static

Returns true if nodeName indicates a BT Decorator node.

Some BT v2 files encode Decorator nodes as type "Action" with a descriptive name (e.g. "Repeater", "Inverter", "Cooldown", "Timeout"). This helper centralises that heuristic so both the migrator and the loader can use it consistently.

Definition at line 43 of file BTtoVSMigrator.cpp.

Referenced by ConvertNode(), and Olympe::TaskGraphLoader::ParseNodeV4().

+ Here is the caller graph for this function:

◆ MapNodeType()

TaskNodeType Olympe::BTtoVSMigrator::MapNodeType ( const std::string &  btType)
staticprivate

Maps a BT node type string to the closest TaskNodeType equivalent.

Definition at line 57 of file BTtoVSMigrator.cpp.

References Olympe::AtomicTask, Olympe::Branch, Olympe::Decorator, Olympe::EntryPoint, GetComponentTypeID_Static(), and Olympe::Sequence.

Referenced by ConvertNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: