/// <summary> /// Removes the child from this behaviour. /// </summary> /// <param name="parent"></param> /// <param name="child"></param> private void removeChild(Core.BehaviourNode child) { if (behaviour && child) { behaviour.RemoveChild(child); } }
/// <summary> /// Attempts to parent the child. /// </summary> /// <param name="parent"></param> /// <param name="child"></param> private void addChild(Core.BehaviourNode child) { if (behaviour && child) { behaviour.AddChild(child); } }
/// <summary> /// Remove the child from its parent. /// </summary> /// <param name="parent"></param> /// <param name="child"></param> private void unparent(Core.BehaviourNode child) { if (child && child.Parent) { child.Parent.RemoveChild(child); Input.outputConnection.RemoveInputConnection(Input); } }
private bool canAddChild(Core.BehaviourNode child) { if (behaviour && child) { return(behaviour.CanAddChild(child)); } return(false); }
/// <summary> /// Create a node from an existing behaviour. /// </summary> /// <param name="behaviour"></param> /// <returns></returns> internal BonsaiNode CreateNode(Core.BehaviourNode behaviour) { var node = createEditorNode(behaviour.GetType()); node.behaviour = behaviour; // Setup the style with the updated properties such as name and texture. node.SetupStyle(); return(node); }
/// <summary> /// Highlights nodes that are being re-evaluated, like abort nodes. /// </summary> /// <param name="node"></param> private bool IsNodeObserving(BonsaiNode node) { Core.BehaviourNode behaviour = node.Behaviour; Core.BehaviourIterator itr = behaviour.Iterator; if (itr != null && itr.IsRunning) { var aborter = behaviour as Core.ConditionalAbort; return(aborter && aborter.IsObserving); } return(false); }
/// <summary> /// Highlights nodes that are being re-evaluated, like abort nodes. /// </summary> /// <param name="node"></param> private bool IsNodeEvaluating(BonsaiNode node) { if (!EditorApplication.isPlaying) { return(false); } Core.BehaviourIterator itr = node.Behaviour.Iterator; if (itr != null && itr.IsRunning) { var aborter = node.Behaviour as Core.ConditionalAbort; int index = itr.CurrentIndex; if (index != -1) { Core.BehaviourNode currentNode = Canvas.Tree.GetNode(index); // The current running node can be aborted by it. return(aborter && Core.ConditionalAbort.IsAbortable(aborter, currentNode)); } } return(false); }
private bool containsChild(Core.BehaviourNode child) { return(child.Parent == behaviour); }