mirror of
https://gitee.com/dlmu-cone/Arborflow
synced 2026-10-24 10:12:19 +08:00
fix: support multi-tree BehaviorTree XML imports
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
Zap,
|
||||
type LucideIcon,
|
||||
} from 'lucide-react'
|
||||
import type { BehaviorNode, NodeCategory, NodeType } from '../types'
|
||||
import type { BehaviorNode, CustomNodeModel, NodeCategory, NodeType } from '../types'
|
||||
|
||||
export interface NodeDefinition {
|
||||
type: NodeType
|
||||
@@ -70,6 +70,19 @@ export function createNode(type: NodeType, position = { x: 80, y: 80 }): Behavio
|
||||
}
|
||||
}
|
||||
|
||||
export function createNodeFromModel(model: CustomNodeModel, position = { x: 80, y: 80 }): BehaviorNode {
|
||||
const node = createNode(model.nodeType, position)
|
||||
node.data = {
|
||||
...node.data,
|
||||
label: model.id,
|
||||
category: model.category,
|
||||
registrationName: model.id,
|
||||
xmlTag: model.id,
|
||||
ports: Object.fromEntries(model.ports.map((port) => [port.name, port.defaultValue || ''])),
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
export function canHaveChildren(type: NodeType) {
|
||||
return !['Action', 'Condition', 'SubTree', 'AlwaysSuccess', 'AlwaysFailure'].includes(type)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user