/// <summary>
        /// Returns a clone of the node of this state.
        /// </summary>
        /// <returns>The cloned node.</returns>
        public override INode CloneNode()
        {
            INode NewNode = null;

            NodeTreeHelperOptional.GetChildNode(Optional, out bool IsAssigned, out INode ChildNode);
            if (ChildNode != null)
            {
                // Create a clone, initially empty and full of null references.
                NewNode = NodeHelper.CreateEmptyNode(ChildNode.GetType());

                // Clone and assign reference to all nodes, optional or not, list and block lists.
                foreach (KeyValuePair <string, IReadOnlyInner> Entry in InnerTable)
                {
                    string         PropertyName = Entry.Key;
                    IReadOnlyInner Inner        = Entry.Value;
                    ((IReadOnlyInner <IReadOnlyBrowsingChildIndex>)Inner).CloneChildren(NewNode);
                }

                // Copy other properties.
                foreach (KeyValuePair <string, ValuePropertyType> Entry in ValuePropertyTypeTable)
                {
                    string            PropertyName = Entry.Key;
                    ValuePropertyType Type         = Entry.Value;
                    bool IsHandled = false;

                    switch (Type)
                    {
                    case ValuePropertyType.Boolean:
                        NodeTreeHelper.CopyBooleanProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;

                    case ValuePropertyType.Enum:
                        NodeTreeHelper.CopyEnumProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;

                    case ValuePropertyType.String:
                        NodeTreeHelper.CopyStringProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;

                    case ValuePropertyType.Guid:
                        NodeTreeHelper.CopyGuidProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;
                    }

                    Debug.Assert(IsHandled);
                }

                // Also copy comments.
                NodeTreeHelper.CopyDocumentation(Node, NewNode, cloneCommentGuid: true);
            }

            return(NewNode);
        }
Ejemplo n.º 2
0
 public void ChildDone(ChildNode _child, bool _bChildResult)
 {
     AIBehaviour.s_strDebugBehaviourRun += "\n" + _child.GetType().ToString() + ":" + _bChildResult + "->";
     for (int i = 0; i < m_listChildren.Count; i++)
     {
         m_listChildren[i].Deactivate();
     }
     m_parent.ChildDone(this, _bChildResult);
 }
Ejemplo n.º 3
0
        public override string?Render()
        {
            if (!IsChildAllowed(ChildNode?.GetType()))
            {
                throw new InvalidOperationException($"Child of type {ChildNode?.GetType()} is not allowed");
            }

            Content = ChildNode?.Render();
            Content = Content != null ? $"<html{GetAttributes()}>{Content}</html>" : $"<html{GetAttributes()}></html>";

            return(Content);
        }
Ejemplo n.º 4
0
        public void ChildDone(ChildNode _child, bool _bChildResult)
        {
            AIBehaviour.s_strDebugBehaviourRun += "\n" + _child.GetType().ToString() + ":" + _bChildResult + "->";
            //if child returns true activate it again
            if (_bChildResult)
            {
                _child.Activate();
            }

            //else return true
            else
            {
                m_parent.ChildDone(this, true);
            }
        }
Ejemplo n.º 5
0
        public override string?Render()
        {
            if (!IsChildAllowed(ChildNode?.GetType()))
            {
                throw new InvalidOperationException($"Child of type {ChildNode?.GetType()} is not allowed");
            }

            if (!IsSiblingAllowed(SiblingNode?.GetType()))
            {
                throw new InvalidOperationException($"Sibling of type {SiblingNode?.GetType()} is not allowed");
            }

            Content = ChildNode?.Render();
            Content = Content != null ? $"<body>{Content}</body>" : "<body></body>";

            return(Content);
        }
Ejemplo n.º 6
0
        public void ChildDone(ChildNode _child, bool _bChildResult)
        {
            AIBehaviour.s_strDebugBehaviourRun += "\n" + _child.GetType().ToString() + ":" + _bChildResult + "->";
            //if child returns true check if all children have now returned true
            //if so, return true
            if (_bChildResult)
            {
                int index = m_listChildren.IndexOf(_child);
                m_listbReturns[index] = true;

                //check if all children are true
                bool bAllTrue = true;
                for (int i = 0; i < m_listbReturns.Count; ++i)
                {
                    if (m_listbReturns[i] == false)
                    {
                        bAllTrue = false;
                    }
                }
                if (bAllTrue)
                {
                    for (int i = 0; i < m_listChildren.Count; ++i)
                    {
                        m_listChildren[i].Deactivate();
                    }
                    m_parentnode.ChildDone(this, true);
                }
            }
            //if child returns false return false yourself
            else
            {
                for (int i = 0; i < m_listChildren.Count; ++i)
                {
                    m_listChildren[i].Deactivate();
                }
                m_parentnode.ChildDone(this, false);
            }
        }
Ejemplo n.º 7
0
        public void ChildDone(ChildNode _child, bool _bChildResult)
        {
            AIBehaviour.s_strDebugBehaviourRun += "\n" + _child.GetType().ToString() + ":" + _bChildResult + "->";
            //if child returns true, return true yourself
            if (_bChildResult)
            {
                m_parent.ChildDone(this, true);
            }

            //else try the next child if there is no next child return false
            else
            {
                m_iCurrentChildIndex++;
                if (m_iCurrentChildIndex < m_listChildren.Count)
                {
                    m_listChildren[m_iCurrentChildIndex].Activate();
                }
                else
                {
                    m_parent.ChildDone(this, false);
                }
            }
        }
Ejemplo n.º 8
0
 //Callback from your ChildNode
 public void ChildDone(ChildNode _child, bool _bChildResult)
 {
     s_strDebugBehaviourRun += "\n" + _child.GetType().ToString() + ":" + _bChildResult + "|";
     //Debug.Log(s_strDebugBehaviourRun); //This would print the debugString to the console;
     m_bIsRunning = false;
 }
Ejemplo n.º 9
0
 public void ChildDone(ChildNode _child, bool _bChildResult)
 {
     AIBehaviour.s_strDebugBehaviourRun += "\n" + _child.GetType().ToString() + ":" + _bChildResult + "->";
     m_parent.ChildDone(this, !_bChildResult);
 }