/// <summary> /// Add a new child to the Selector, creating a PriorityNode. /// </summary> /// <param name='child'>Child.</param> /// <param name="prio">The assigned priority</param> /// <returns>A reference to the PriorityNode.</returns> public void AddChild(Node child, double prio = 1.0) { if (prio <= 0) throw new ArgumentException("prio must be positive: " + prio); PriorityNode pn = new PriorityNode(child,prio); children_.Add(pn); prioTotal += pn.Prio; }
/// <summary> /// Construct a priority node with the given prio. /// </summary> /// <param name='n'> /// N. /// </param> /// <param name='prio'> /// Prio. /// </param> public PriorityNode(Node n, double prio) { node = n; priority = prio; }
/// <summary> /// Construct a priority node with prio 1. /// </summary> /// <param name='n'> /// N. /// </param> public PriorityNode(Node n) { node = n; priority = 1; }
/// <summary>Removes the specified child.</summary> /// <param name='child'>Node to remove.</param> /// <returns>The removed child Node.</returns> public Node RemoveChild(Node child) { PriorityNode n = children_.First(x => x.Child == child); children_.Remove(n); return n.Child; }
/// <summary> /// Add a new child to the Selector, creating a PriorityNode. /// Take care to always save the return value as that is the only way to change its priority! /// </summary> /// <param name='child'>Child.</param> /// <param name="prio">The assigned priority</param> /// <returns>A reference to the PriorityNode.</returns> public PriorityNode AddChild(Node child, double prio = 1.0) { PriorityNode pn = new PriorityNode(child,prio); children_.Add(pn); return pn; }
/// <summary> /// Construct a ConditionDecorator with the given Child and condition. /// </summary> /// <param name='child'> /// Child. /// </param> /// <param name='condition'> /// Condition on which to execute Child. /// </param> public ConditionDecorator(Node child, Func<bool> condition) : base(child) { this.condition = condition; }
public void SetChild(Node n) { child_ = n; }
/// <summary> /// Construct a Decorator with the given child Node. /// </summary> /// <param name='child'> /// Child. /// </param> public Decorator(Node child) : base() { child_ = child; }
/// <summary>Removes the specified child.</summary> /// <param name='child'>Node to remove.</param> /// <returns>The removed child Node.</returns> public Node RemoveChild(Node child) { Node n = children_.Find(x => x == child); children_.Remove(child); return n; }
/// <summary>Add a new child to the Selector.</summary> /// <param name='child'>Child.</param> public void AddChild(Node child) { children_.Add(child); }