예제 #1
0
 public void RemoveChildNode(NodeDesigner childNodeDesigner)
 {
     if (!this.isEntryDisplay)
     {
         ParentTask parentTask = this.mTask as ParentTask;
         parentTask.Children.Remove(childNodeDesigner.Task);
     }
     for (int i = 0; i < this.outgoingNodeConnections.Count; i++)
     {
         NodeConnection nodeConnection = this.outgoingNodeConnections[i];
         if (nodeConnection.DestinationNodeDesigner.Equals(childNodeDesigner) || nodeConnection.OriginatingNodeDesigner.Equals(childNodeDesigner))
         {
             this.outgoingNodeConnections.RemoveAt(i);
             break;
         }
     }
     childNodeDesigner.ParentNodeDesigner = null;
     this.mConnectionIsDirty = true;
 }
예제 #2
0
 public void AddChildNode(NodeDesigner childNodeDesigner, NodeConnection nodeConnection, bool adjustOffset, bool replaceNode, int replaceNodeIndex)
 {
     if (replaceNode)
     {
         ParentTask parentTask = this.mTask as ParentTask;
         parentTask.Children[replaceNodeIndex] = childNodeDesigner.Task;
     }
     else
     {
         if (!this.isEntryDisplay)
         {
             ParentTask parentTask2 = this.mTask as ParentTask;
             int        i           = 0;
             if (parentTask2.Children != null)
             {
                 for (i = 0; i < parentTask2.Children.Count; i++)
                 {
                     if (childNodeDesigner.GetAbsolutePosition().x < (parentTask2.Children[i].NodeData.NodeDesigner as NodeDesigner).GetAbsolutePosition().x)
                     {
                         break;
                     }
                 }
             }
             parentTask2.AddChild(childNodeDesigner.Task, i);
         }
         if (adjustOffset)
         {
             childNodeDesigner.Task.NodeData.Offset -= this.GetAbsolutePosition();
         }
     }
     childNodeDesigner.ParentNodeDesigner   = this;
     nodeConnection.DestinationNodeDesigner = childNodeDesigner;
     nodeConnection.NodeConnectionType      = NodeConnectionType.Fixed;
     if (!nodeConnection.OriginatingNodeDesigner.Equals(this))
     {
         nodeConnection.OriginatingNodeDesigner = this;
     }
     this.outgoingNodeConnections.Add(nodeConnection);
     this.mConnectionIsDirty = true;
 }
예제 #3
0
        public void LoadTask(Task task, Behavior owner, ref int id)
        {
            if (task == null)
            {
                return;
            }
            mTask       = task;
            mTask.Owner = owner;
            mTask.ID    = id++;
            mTask.NodeData.NodeDesigner = this;
            mTask.NodeData.InitWatchedFields(mTask);
            if (!mTask.NodeData.FriendlyName.Equals(string.Empty))
            {
                mTask.FriendlyName          = mTask.NodeData.FriendlyName;
                mTask.NodeData.FriendlyName = string.Empty;
            }
            LoadTaskIcon();
            Init();
            RequiredComponentAttribute[] array;
            if (mTask.Owner != null && (array = (mTask.GetType().GetCustomAttributes(typeof(RequiredComponentAttribute), true) as RequiredComponentAttribute[])).Length > 0)
            {
                Type componentType = array[0].ComponentType;
                if (typeof(Component).IsAssignableFrom(componentType) && mTask.Owner.gameObject.GetComponent(componentType) == null)
                {
                    mTask.Owner.gameObject.AddComponent(componentType);
                }
            }
            List <Type>  baseClasses = FieldInspector.GetBaseClasses(mTask.GetType());
            BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            for (int i = baseClasses.Count - 1; i > -1; i--)
            {
                FieldInfo[] fields = baseClasses[i].GetFields(bindingAttr);
                for (int j = 0; j < fields.Length; j++)
                {
                    if (typeof(SharedVariable).IsAssignableFrom(fields[j].FieldType) && !fields[j].FieldType.IsAbstract)
                    {
                        SharedVariable sharedVariable = fields[j].GetValue(mTask) as SharedVariable;
                        if (sharedVariable == null)
                        {
                            sharedVariable = (Activator.CreateInstance(fields[j].FieldType) as SharedVariable);
                        }
                        if (TaskUtility.HasAttribute(fields[j], typeof(RequiredFieldAttribute)) || TaskUtility.HasAttribute(fields[j], typeof(SharedRequiredAttribute)))
                        {
                            sharedVariable.IsShared = true;
                        }
                        fields[j].SetValue(mTask, sharedVariable);
                    }
                }
            }
            if (isParent)
            {
                ParentTask parentTask = this.mTask as ParentTask;
                if (parentTask.Children != null)
                {
                    for (int k = 0; k < parentTask.Children.Count; k++)
                    {
                        NodeDesigner nodeDesigner = CreateInstance <NodeDesigner>();
                        nodeDesigner.LoadTask(parentTask.Children[k], owner, ref id);
                        NodeConnection nodeConnection = CreateInstance <NodeConnection>();
                        nodeConnection.LoadConnection(this, NodeConnectionType.Fixed);
                        AddChildNode(nodeDesigner, nodeConnection, true, true, k);
                    }
                }
                mConnectionIsDirty = true;
            }
        }
예제 #4
0
 public void AddChildNode(NodeDesigner childNodeDesigner, NodeConnection nodeConnection, bool adjustOffset, bool replaceNode)
 {
     AddChildNode(childNodeDesigner, nodeConnection, adjustOffset, replaceNode, -1);
 }