SetNodeParent() публичный Метод

public SetNodeParent ( TreeNode n, TreeNode parent ) : void
n TreeNode
parent TreeNode
Результат void
Пример #1
0
 public void UpdateFrequency(TreeData owner)
 {
     if (this.distributionFrequency < 1)
     {
         this.distributionFrequency = 1;
     }
     if (this.parentGroup == null)
     {
         this.distributionFrequency = 1;
         if (this.nodes.Count < 1)
         {
             owner.AddNode(this, null, false);
         }
     }
     else if ((this.lockFlags == 0) && (this.parentGroup != null))
     {
         int num = 0;
         for (int j = 0; j < this.parentGroup.nodes.Count; j++)
         {
             int num3 = Mathf.RoundToInt(this.distributionFrequency * this.parentGroup.nodes[j].GetScale());
             if (num3 < 1)
             {
                 num3 = 1;
             }
             for (int k = 0; k < num3; k++)
             {
                 if (num < this.nodes.Count)
                 {
                     owner.SetNodeParent(this.nodes[num], this.parentGroup.nodes[j]);
                 }
                 else
                 {
                     owner.AddNode(this, this.parentGroup.nodes[j], false);
                 }
                 num++;
             }
         }
         if (num < this.nodes.Count)
         {
             List <TreeNode> list = new List <TreeNode>();
             for (int m = num; m < this.nodes.Count; m++)
             {
                 list.Add(this.nodes[m]);
             }
             for (int n = 0; n < list.Count; n++)
             {
                 owner.DeleteNode(list[n], false);
             }
         }
         this.UpdateSeed();
         this.UpdateDistribution(true, false);
     }
     for (int i = 0; i < this.childGroups.Count; i++)
     {
         this.childGroups[i].UpdateFrequency(owner);
     }
 }
Пример #2
0
        //
        // Controls generation of nodes based on frequency
        //
        public void UpdateFrequency(TreeData owner)
        {
            Profiler.BeginSample("UpdateFrequency");

            // Must have at least 1
            if (distributionFrequency < 1)
            {
                distributionFrequency = 1;
            }

            if (parentGroup == null)
            {
                // Only root can have no parent..

                // Must have 1 as distribution frequency
                distributionFrequency = 1;
                if (nodes.Count < 1)
                {
                    owner.AddNode(this, null, false);
                }
            }
            else if ((lockFlags == 0) && (parentGroup != null))
            {
                // Exact count depends on parent
                int newTotalCount = 0;
                for (int n = 0; n < parentGroup.nodes.Count; n++)
                {
                    int tempFrequency = Mathf.RoundToInt(distributionFrequency * parentGroup.nodes[n].GetScale());

                    // make sure there is at least one node..
                    if (tempFrequency < 1)
                    {
                        tempFrequency = 1;
                    }
                    for (int i = 0; i < tempFrequency; i++)
                    {
                        if (newTotalCount < nodes.Count)
                        {
                            owner.SetNodeParent(nodes[newTotalCount], parentGroup.nodes[n]);
                        }
                        else
                        {
                            owner.AddNode(this, parentGroup.nodes[n], false);
                        }

                        newTotalCount++;
                    }
                }

                // remove excess nodes
                if (newTotalCount < nodes.Count)
                {
                    List <TreeNode> killNodes = new List <TreeNode>();
                    for (int i = newTotalCount; i < nodes.Count; i++)
                    {
                        killNodes.Add(nodes[i]);
                    }
                    for (int i = 0; i < killNodes.Count; i++)
                    {
                        owner.DeleteNode(killNodes[i], false);
                    }
                    //owner.ValidateReferences();
                }

                UpdateSeed();
                UpdateDistribution(true, false);
            }

            // Update child groups..
            for (int i = 0; i < childGroups.Count; i++)
            {
                childGroups[i].UpdateFrequency(owner);
            }

            Profiler.EndSample(); // UpdateFrequency
        }
Пример #3
0
 public void UpdateFrequency(TreeData owner)
 {
     if (this.distributionFrequency < 1)
     {
         this.distributionFrequency = 1;
     }
     if (this.parentGroup == null)
     {
         this.distributionFrequency = 1;
         if (this.nodes.Count < 1)
         {
             owner.AddNode(this, null, false);
         }
     }
     else if ((this.lockFlags == 0) && (this.parentGroup != null))
     {
         int num = 0;
         for (int j = 0; j < this.parentGroup.nodes.Count; j++)
         {
             int num3 = Mathf.RoundToInt(this.distributionFrequency * this.parentGroup.nodes[j].GetScale());
             if (num3 < 1)
             {
                 num3 = 1;
             }
             for (int k = 0; k < num3; k++)
             {
                 if (num < this.nodes.Count)
                 {
                     owner.SetNodeParent(this.nodes[num], this.parentGroup.nodes[j]);
                 }
                 else
                 {
                     owner.AddNode(this, this.parentGroup.nodes[j], false);
                 }
                 num++;
             }
         }
         if (num < this.nodes.Count)
         {
             List<TreeNode> list = new List<TreeNode>();
             for (int m = num; m < this.nodes.Count; m++)
             {
                 list.Add(this.nodes[m]);
             }
             for (int n = 0; n < list.Count; n++)
             {
                 owner.DeleteNode(list[n], false);
             }
         }
         this.UpdateSeed();
         this.UpdateDistribution(true, false);
     }
     for (int i = 0; i < this.childGroups.Count; i++)
     {
         this.childGroups[i].UpdateFrequency(owner);
     }
 }
Пример #4
0
 public void UpdateFrequency(TreeData owner)
 {
     Profiler.BeginSample("UpdateFrequency");
     if (this.distributionFrequency < 1)
     {
         this.distributionFrequency = 1;
     }
     if (this.parentGroup == null)
     {
         this.distributionFrequency = 1;
         if (this.nodes.Count < 1)
         {
             owner.AddNode(this, null, false);
         }
     }
     else
     {
         if (this.lockFlags == 0 && this.parentGroup != null)
         {
             int num = 0;
             for (int i = 0; i < this.parentGroup.nodes.Count; i++)
             {
                 int num2 = Mathf.RoundToInt((float)this.distributionFrequency * this.parentGroup.nodes[i].GetScale());
                 if (num2 < 1)
                 {
                     num2 = 1;
                 }
                 for (int j = 0; j < num2; j++)
                 {
                     if (num < this.nodes.Count)
                     {
                         owner.SetNodeParent(this.nodes[num], this.parentGroup.nodes[i]);
                     }
                     else
                     {
                         owner.AddNode(this, this.parentGroup.nodes[i], false);
                     }
                     num++;
                 }
             }
             if (num < this.nodes.Count)
             {
                 List <TreeNode> list = new List <TreeNode>();
                 for (int k = num; k < this.nodes.Count; k++)
                 {
                     list.Add(this.nodes[k]);
                 }
                 for (int l = 0; l < list.Count; l++)
                 {
                     owner.DeleteNode(list[l], false);
                 }
             }
             this.UpdateSeed();
             this.UpdateDistribution(true, false);
         }
     }
     for (int m = 0; m < this.childGroups.Count; m++)
     {
         this.childGroups[m].UpdateFrequency(owner);
     }
     Profiler.EndSample();
 }
Пример #5
0
		public void UpdateFrequency(TreeData owner)
		{
			Profiler.BeginSample("UpdateFrequency");
			if (this.distributionFrequency < 1)
			{
				this.distributionFrequency = 1;
			}
			if (this.parentGroup == null)
			{
				this.distributionFrequency = 1;
				if (this.nodes.Count < 1)
				{
					owner.AddNode(this, null, false);
				}
			}
			else
			{
				if (this.lockFlags == 0 && this.parentGroup != null)
				{
					int num = 0;
					for (int i = 0; i < this.parentGroup.nodes.Count; i++)
					{
						int num2 = Mathf.RoundToInt((float)this.distributionFrequency * this.parentGroup.nodes[i].GetScale());
						if (num2 < 1)
						{
							num2 = 1;
						}
						for (int j = 0; j < num2; j++)
						{
							if (num < this.nodes.Count)
							{
								owner.SetNodeParent(this.nodes[num], this.parentGroup.nodes[i]);
							}
							else
							{
								owner.AddNode(this, this.parentGroup.nodes[i], false);
							}
							num++;
						}
					}
					if (num < this.nodes.Count)
					{
						List<TreeNode> list = new List<TreeNode>();
						for (int k = num; k < this.nodes.Count; k++)
						{
							list.Add(this.nodes[k]);
						}
						for (int l = 0; l < list.Count; l++)
						{
							owner.DeleteNode(list[l], false);
						}
					}
					this.UpdateSeed();
					this.UpdateDistribution(true, false);
				}
			}
			for (int m = 0; m < this.childGroups.Count; m++)
			{
				this.childGroups[m].UpdateFrequency(owner);
			}
			Profiler.EndSample();
		}