Ejemplo n.º 1
0
        public void RefreshVariableRefs()
        {
            VariableReferences.Clear();

            Type t = DotaAction.GetType();

            //Loop through all of this action's properties and add node elements for each property type
            PropertyInfo[] properties = t.GetProperties();

            foreach (PropertyInfo prop in properties)
            {
                //Skip DotaDataObject's properties as they don't go into the node
                if (prop.Name == "ClassName")
                {
                    continue;
                }
                if (prop.Name == "KeyValue")
                {
                    continue;
                }
                if (prop.Name == "ObjectInfo")
                {
                    continue;
                }
                if (prop.Name == "Target")
                {
                    continue;                        //Skip target because we handled it already
                }
                if (prop.PropertyType == typeof(NumberValue))
                {
                    NumberValue nv = prop.GetMethod.Invoke(DotaAction, new object[] { }) as NumberValue;

                    if (nv.IsVariable)
                    {
                        //Check to see if we have a variable reference in our list
                        VariableRefInfo varRef = VariableReferences.FirstOrDefault(x => x.VariableName == nv.Value);
                        if (varRef != null) //varRef is not null, so we can just add this pin to the reference list
                        {
                            //Get the pin for this property
                            NodeItem pin = this.Items.FirstOrDefault(x => (string)x.Tag == prop.Name);

                            List <NodeItem> pins = new List <NodeItem>(varRef.InputPins);
                            pins.Add(pin);
                            varRef.InputPins = pins.ToArray();
                        }
                        else //We don't have a reference entry fo this one.  Lets add it
                        {
                            varRef = new VariableRefInfo();
                            varRef.VariableName = nv.Value;

                            //Get the pin for this property
                            NodeItem pin = this.Items.FirstOrDefault(x => (string)x.Tag == prop.Name);

                            varRef.InputPins = new NodeItem[] { pin };

                            VariableReferences.Add(varRef);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void RefreshVariableRefs()
        {
            VariableReferences.Clear();

            Type t = DotaAction.GetType();

            //Loop through all of this action's properties and add node elements for each property type
            PropertyInfo[] properties = t.GetProperties();

            foreach (PropertyInfo prop in properties)
            {
                //Skip DotaDataObject's properties as they don't go into the node
                if (prop.Name == "ClassName") continue;
                if (prop.Name == "KeyValue") continue;
                if (prop.Name == "ObjectInfo") continue;
                if (prop.Name == "Target") continue; //Skip target because we handled it already


                if (prop.PropertyType == typeof(NumberValue))
                {
                    NumberValue nv = prop.GetMethod.Invoke(DotaAction, new object[] { }) as NumberValue;

                    if(nv.IsVariable)
                    {
                        //Check to see if we have a variable reference in our list
                        VariableRefInfo varRef = VariableReferences.FirstOrDefault(x => x.VariableName == nv.Value);
                        if (varRef != null) //varRef is not null, so we can just add this pin to the reference list
                        {
                            //Get the pin for this property
                            NodeItem pin = this.Items.FirstOrDefault(x => (string)x.Tag == prop.Name);

                            List<NodeItem> pins = new List<NodeItem>(varRef.InputPins);
                            pins.Add(pin);
                            varRef.InputPins = pins.ToArray();                            
                        }
                        else //We don't have a reference entry fo this one.  Lets add it
                        {
                            varRef = new VariableRefInfo();
                            varRef.VariableName = nv.Value;

                            //Get the pin for this property
                            NodeItem pin = this.Items.FirstOrDefault(x => (string)x.Tag == prop.Name);

                            varRef.InputPins = new NodeItem[] { pin };

                            VariableReferences.Add(varRef);
                        }

                    }

                }
            }
            
        }