3#include "../AI/BehaviorTree.h"
4#include "../AI/BTGraphLayoutEngine.h"
5#include "../third_party/nlohmann/json.hpp"
10 namespace NodeGraphShared
18 json j = json::object();
20 j[
"schema_version"] = 2;
21 j[
"type"] =
"BehaviorTree";
22 j[
"blueprintType"] =
"BehaviorTree";
23 j[
"name"] =
tree.name;
24 j[
"description"] =
"";
26 json metadata = json::object();
27 metadata[
"author"] =
"BT Editor";
38 metadata[
"created"] = std::string(
buffer);
39 metadata[
"lastModified"] = std::string(
buffer);
41 json tags = json::array();
43 tags.push_back(
"BehaviorTree");
44 metadata[
"tags"] = tags;
46 j[
"metadata"] = metadata;
48 json editorState = json::object();
49 editorState[
"zoom"] = 1.0;
50 json scrollOffset = json::object();
51 scrollOffset[
"x"] = 0.0;
52 scrollOffset[
"y"] = 0.0;
53 editorState[
"scrollOffset"] = scrollOffset;
54 j[
"editorState"] = editorState;
56 json data = json::object();
57 data[
"rootNodeId"] =
static_cast<int>(
tree.rootNodeId);
81 if (
node.editorPosX != 0.0f ||
node.editorPosY != 0.0f)
98 pos[
"y"] = 100.0f *
static_cast<float>(
node.id);
104 pos[
"y"] = 100.0f *
static_cast<float>(
node.id);
110 json children = json::array();
112 children.push_back(
static_cast<int>(
cid));
118 if (
node.decoratorChildId != 0)
119 nodeJson[
"decoratorChildId"] =
static_cast<int>(
node.decoratorChildId);
127 switch (
node.actionType)
153 switch (
node.conditionType)
173 if (!
nodeJson.contains(
"parameters"))
174 nodeJson[
"parameters"] = json::object();
@ SetMoveGoalToTarget
Move towards current target.
@ SetMoveGoalToLastKnownTargetPos
Move to last seen target position.
@ WaitRandomTime
Initialize random timer (param1=min, param2=max)
@ MoveToGoal
Execute movement to goal.
@ ClearTarget
Clear current target.
@ PatrolPickNextPoint
Select next patrol point.
@ ChooseRandomNavigablePoint
Choose navigable point (param1=searchRadius, param2=maxAttempts)
@ AttackIfClose
Attack if in range.
@ SetMoveGoalToPatrolPoint
Move to next patrol waypoint.
@ RequestPathfinding
Request pathfinding to moveGoal via MoveIntent.
@ FollowPath
Follow the path (check progression)
@ Action
Leaf node - performs an action.
@ Selector
OR node - succeeds if any child succeeds.
@ Sequence
AND node - succeeds if all children succeed.
@ Inverter
Decorator - inverts child result.
@ Condition
Leaf node - checks a condition.
@ Repeater
Decorator - repeats child N times.
@ HasValidPath
Valid path calculated?
@ CanAttack
Attack is available.
@ IsWaitTimerExpired
Wait timer expired?
@ HeardNoise
Detected noise.
@ TargetVisible
Can see target entity.
@ HasMoveGoal
Movement goal is set.
@ HasNavigableDestination
Navigable destination chosen?
@ HealthBelow
Health below threshold.
@ HasReachedDestination
Reached destination?
@ TargetInRange
Target within specified range.
ComponentTypeID GetComponentTypeID_Static()
Computes clean hierarchical layouts for behavior trees.
json SerializeBehaviorTreeToJson(const BehaviorTreeAsset &tree, const BTGraphLayoutEngine *layoutEngine)
< Provides AssetID and INVALID_ASSET_ID
Layout information for a single behavior tree node.
Vector position
Final position (x, y)