Inheritance: UnityEngine.ScriptableObject
Exemplo n.º 1
0
 /// <summary>
 /// Removes node from this AiTree. Also removes all connections between other nodes, so it doesn't have to be done manually.
 /// </summary>
 /// <param name="node">A node to remove from this AiTree.</param>
 /// <returns>True if removing node was succeed. Otherwise false.</returns>
 public bool RemoveNode(ANode node)
 {
     if (_nodes.Remove(node))
     {
         if (Root == node)
         {
             Root = null;
         }
         //remove connections to removed node
         for (int i = 0; i < _nodes.Count; ++i)
         {
             var n = _nodes[i] as AFlowNode;
             if (n != null)
             {
                 for (int j = 0; j < n.NodeCount; ++j)
                 {
                     if (n.GetNode(j) == node)
                     {
                         n.RemoveNode(node);
                     }
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Removes child node.
 /// </summary>
 /// <param name="node">Child node to be removed.</param>
 /// <returns>True if provided node to remove is the current child node. Otherwise false.</returns>
 public override bool RemoveNode(ANode node)
 {
     if (_node == node) {
         _node = null;
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds new node to this AiTree.
 /// </summary>
 /// <param name="node">A node to add to this AiTree.</param>
 /// <returns>True if adding node was succeed. Otherwise false.</returns>
 public bool AddNode(ANode node)
 {
     if (_nodes.Contains(node)) {
         return false;
     }
     _nodes.Add(node);
     return true;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds new node to this AiTree.
 /// </summary>
 /// <param name="node">A node to add to this AiTree.</param>
 /// <returns>True if adding node was succeed. Otherwise false.</returns>
 public bool AddNode(ANode node)
 {
     if (_nodes.Contains(node))
     {
         return(false);
     }
     _nodes.Add(node);
     return(true);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Removes child node.
 /// </summary>
 /// <param name="node">Child node to be removed.</param>
 /// <returns>True if provided node to remove is the current child node. Otherwise false.</returns>
 public override bool RemoveNode(ANode node)
 {
     if (_node == node)
     {
         _node = null;
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates connection between one node to another. The connection is one one-way and tries to prevent circular to prevent infinity loops.
 /// </summary>
 /// <param name="from">A node that is higher in hierarchy.</param>
 /// <param name="to">A node that is lower in hierarchy.</param>
 /// <returns>True if connection succeed. Otherwise false.</returns>
 public bool ConnectNodes(AFlowNode from, ANode to)
 {
     if (_nodes.Contains(from) && _nodes.Contains(to) && to != Root) {
         var n = to as AFlowNode;
         if (n != null) {
             //check nodes recursive to prevent circular trees
             if (IsConnected(from, n)) {
                 return false;
             }
         }
         return from.AddNode(to);
     }
     return false;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates connection between one node to another. The connection is one one-way and tries to prevent circular to prevent infinity loops.
 /// </summary>
 /// <param name="from">A node that is higher in hierarchy.</param>
 /// <param name="to">A node that is lower in hierarchy.</param>
 /// <returns>True if connection succeed. Otherwise false.</returns>
 public bool ConnectNodes(AFlowNode from, ANode to)
 {
     if (_nodes.Contains(from) && _nodes.Contains(to) && to != Root)
     {
         var n = to as AFlowNode;
         if (n != null)
         {
             //check nodes recursive to prevent circular trees
             if (IsConnected(from, n))
             {
                 return(false);
             }
         }
         return(from.AddNode(to));
     }
     return(false);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Adds new node as child. There can be only one child for SucceederNode, so child will be overriden.
 /// </summary>
 /// <param name="node">Node to be added as a child.</param>
 /// <returns>Always returns true.</returns>
 public override bool AddNode(ANode node)
 {
     _node = node;
     return true;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds new node as child. There can be only one child for RepeaterNode, so child will be overriden.
 /// </summary>
 /// <param name="node">Node to be added as a child.</param>
 /// <returns>Always returns true.</returns>
 public override bool AddNode(ANode node)
 {
     _node = node;
     return(true);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Removes node from this AiTree. Also removes all connections between other nodes, so it doesn't have to be done manually.
 /// </summary>
 /// <param name="node">A node to remove from this AiTree.</param>
 /// <returns>True if removing node was succeed. Otherwise false.</returns>
 public bool RemoveNode(ANode node)
 {
     if (_nodes.Remove(node)) {
         if (Root == node) {
             Root = null;
         }
         //remove connections to removed node
         for (int i = 0; i < _nodes.Count; ++i) {
             var n = _nodes[i] as AFlowNode;
             if (n != null) {
                 for (int j = 0; j < n.NodeCount; ++j) {
                     if (n.GetNode(j) == node) {
                         n.RemoveNode(node);
                     }
                 }
             }
         }
         return true;
     }
     return false;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Removes child node.
 /// </summary>
 /// <param name="node">Child node to remove.</param>
 /// <returns>True if removing succeed. Otherwise false.</returns>
 public override bool RemoveNode(ANode node)
 {
     return(_nodes.Remove(node));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Removes child node.
 /// </summary>
 /// <param name="node">Child node to remove.</param>
 /// <returns>True if removing succeed. Otherwise false.</returns>
 public override bool RemoveNode(ANode node)
 {
     return _nodes.Remove(node);
 }