UPDATE: VERSION-20260313

This commit is contained in:
libertyspy
2026-03-13 10:42:39 +08:00
parent 27f8810401
commit 5a7b57d603
2 changed files with 26 additions and 3 deletions

View File

@@ -87,9 +87,12 @@ public class BehaviortreeProcessor {
// 插入节点 treenodeinstance // 插入节点 treenodeinstance
Map<String, Treenodeinstance> instanceKeyMap = new HashMap<>(); Map<String, Treenodeinstance> instanceKeyMap = new HashMap<>();
Map<String, Long> nodeKeyIndexMap = new HashMap<>(); Map<String, Long> nodeKeyIndexMap = new HashMap<>();
Map<String,GraphNode> nodesMap = new HashMap<>();
if (graph.hasNodes()) { if (graph.hasNodes()) {
Long index = 0L; Long index = 0L;
for (GraphNode node : graph.getNodes()) { for (GraphNode node : graph.getNodes()) {
nodesMap.put(node.getKey(), node);
Treenodeinstance instance = createNodeInstance(behaviortree, node); Treenodeinstance instance = createNodeInstance(behaviortree, node);
treenodeinstanceService.insertTreenodeinstance(instance); treenodeinstanceService.insertTreenodeinstance(instance);
instanceKeyMap.put(node.getKey(), instance); instanceKeyMap.put(node.getKey(), instance);
@@ -110,16 +113,18 @@ public class BehaviortreeProcessor {
// 插入连线 nodeconnection // 插入连线 nodeconnection
if (graph.hasEdges()) { if (graph.hasEdges()) {
for (GraphEdge edge : graph.getEdges()) { for (GraphEdge edge : graph.getEdges()) {
Nodeconnection connection = createConnection(behaviortree, edge, instanceKeyMap, nodeKeyIndexMap); Nodeconnection connection = createConnection(behaviortree, edge, nodesMap, instanceKeyMap, nodeKeyIndexMap);
nodeconnectionService.insertNodeconnection(connection); nodeconnectionService.insertNodeconnection(connection);
} }
} }
} }
private Nodeconnection createConnection(Behaviortree behaviortree, GraphEdge edge, private Nodeconnection createConnection(Behaviortree behaviortree, GraphEdge edge,
Map<String,GraphNode> nodesMap,
Map<String, Treenodeinstance> instanceKeyMap, Map<String, Treenodeinstance> instanceKeyMap,
Map<String, Long> nodeKeyIndexMap) { Map<String, Long> nodeKeyIndexMap) {
Nodeconnection connection = new Nodeconnection(); Nodeconnection connection = new Nodeconnection();
Long orderIndex = 0L;
connection.setTreeId(behaviortree.getId()); connection.setTreeId(behaviortree.getId());
if (null != instanceKeyMap.get(edge.getSource().getCell())) { if (null != instanceKeyMap.get(edge.getSource().getCell())) {
Treenodeinstance parent = instanceKeyMap.get(edge.getSource().getCell()); Treenodeinstance parent = instanceKeyMap.get(edge.getSource().getCell());
@@ -129,9 +134,17 @@ public class BehaviortreeProcessor {
Treenodeinstance children = instanceKeyMap.get(edge.getTarget().getCell()); Treenodeinstance children = instanceKeyMap.get(edge.getTarget().getCell());
connection.setChildNodeId(children.getId()); connection.setChildNodeId(children.getId());
} }
if (null != nodeKeyIndexMap.get(edge.getSource().getCell())) {
connection.setOrderIndex(nodeKeyIndexMap.get(edge.getSource().getCell())); if (null != nodesMap.get(edge.getTarget().getCell())) {
orderIndex = nodesMap.get(edge.getTarget().getCell()).getOrder();
} }
if(null == orderIndex){
orderIndex = 0L;
}
// if (null != nodeKeyIndexMap.get(edge.getSource().getCell())) {
// connection.setOrderIndex(nodeKeyIndexMap.get(edge.getSource().getCell()));
// }
connection.setOrderIndex(orderIndex);
return connection; return connection;
} }

View File

@@ -23,6 +23,8 @@ public class GraphNode implements Serializable {
private String type; private String type;
private Long order;
private String key; private String key;
private String name; private String name;
@@ -139,4 +141,12 @@ public class GraphNode implements Serializable {
this.variables = variables; this.variables = variables;
} }
public Long getOrder() {
return order;
}
public void setOrder(Long order) {
this.order = order;
}
} }