示例#1
0
        public static void DeleteNode(Node node, BehaviorTree bt)
        {
            if (node.parentNode != null)
            {
                node.parentNode.childNodes = ArrayUtility.Remove <Node>(node.parentNode.childNodes, node);
            }

            foreach (Node child in node.childNodes)
            {
                child.parentNode = null;
            }

            if (node.decorators.Length > 0)
            {
                foreach (Decorator decorator in node.decorators)
                {
                    BehaviorTreeEditorUtility.DeleteDecorator(decorator);
                }
            }
            if (node is Composite && (node as Composite).services.Length > 0)
            {
                foreach (Service service in (node as Composite).services)
                {
                    BehaviorTreeEditorUtility.DeleteService(service);
                }
            }
            bt.nodes = ArrayUtility.Remove <Node>(bt.nodes, node);
            BehaviorTreeEditorUtility.DestroyImmediate(node);
        }
示例#2
0
 public static void DeleteService(Service service)
 {
     service.parent.services = ArrayUtility.Remove <Service>(service.parent.services, service);
     BehaviorTreeEditorUtility.DestroyImmediate(service);
 }
示例#3
0
 public static void DeleteDecorator(Decorator decorator)
 {
     decorator.parent.decorators = ArrayUtility.Remove <Decorator>(decorator.parent.decorators, decorator);
     BehaviorTreeEditorUtility.DestroyImmediate(decorator);
 }