public void PopulateNodesFromRoot(RootNode Root)
 {
     this.UIDCurrentRoot = Root.tech.UID;
     this.SubNodes.Clear();
     int Rows = 1;
     int Cols = CalculateTreeDemensionsFromRoot(Root.tech.UID, ref Rows, 0, 0);
     if (Rows < 9)
         this.RowOffset = (MainMenu.Menu.Height - 40) / Rows;
     else
         this.RowOffset = (MainMenu.Menu.Height - 40) / 9;
     if (Cols > 0 && Cols < 9)
         this.ColumnOffset = (MainMenu.Menu.Width - 350) / Cols + 1;
     else
         this.ColumnOffset = 165;
     foreach (KeyValuePair<string, Node> node in this.TechTree)
     {
         (node.Value as RootNode).nodeState = NodeState.Normal;
     }
     Root.nodeState = NodeState.Press;
     this.ClaimedSpots.Clear();
     this.Cursor = new Vector2(1f, 1f);
     bool first = true;
     for (int i = 0; i < ResourceManager.TechTree[Root.tech.UID].LeadsTo.Count; i++)
     {
         if (!ResourceManager.TechTree[ResourceManager.TechTree[Root.tech.UID].LeadsTo[i].UID].Secret || EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetTDict()[ResourceManager.TechTree[Root.tech.UID].LeadsTo[i].UID].Discovered)
         {
             if (!first)
             {
                 this.Cursor.Y = (float)(this.FindDeepestYSubNodes() + 1);
             }
             else
             {
                 this.Cursor.Y = (float)this.FindDeepestYSubNodes();
                 first = false;
             }
             this.Cursor.X = Root.NodePosition.X + 1f;
             TechEntry te = EmpireManager.GetEmpireByName(this.empireUI.screen.PlayerLoyalty).GetTDict()[ResourceManager.TechTree[Root.tech.UID].LeadsTo[i].UID];
             TreeNode newNode = new TreeNode(this.MainMenuOffset + new Vector2((float)(this.ColumnOffset * (int)this.Cursor.X), (float)(this.RowOffset * (int)this.Cursor.Y)), te, this)
             {
                 NodePosition = this.Cursor
             };
             if (EmpireManager.GetEmpireByName(this.empireUI.screen.PlayerLoyalty).GetTDict()[te.UID].Unlocked)
             {
                 newNode.complete = true;
             }
             this.SubNodes.Add(newNode.tech.UID, newNode);
             this.PopulateNodesFromSubNode(newNode);
         }
     }
 }
 private void SetNode(TechEntry tech)
 {
     Vector2 Position = new Vector2(this.Cursor.X, this.Cursor.Y);
     bool SeatTaken = false;
     foreach (Vector2 v in this.ClaimedSpots)
     {
         if (v.X != Position.X || v.Y != Position.Y)
         {
             continue;
         }
         SeatTaken = true;
     }
     if (SeatTaken)
     {
         this.Cursor.Y = this.Cursor.Y + 1f;
     }
     else
     {
         this.ClaimedSpots.Add(Position);
     }
     RootNode newNode = new RootNode(this.MainMenuOffset + new Vector2((float)(this.ColumnOffset * (int)this.Cursor.X), (float)(this.RowOffset * ((int)this.Cursor.Y - 1))), tech)
     {
         NodePosition = this.Cursor
     };
     if (EmpireManager.GetEmpireByName(this.empireUI.screen.PlayerLoyalty).GetTDict()[tech.UID].Unlocked)
     {
         newNode.isResearched = true;
     }
     this.TechTree.Add(tech.UID, newNode);
 }
 public void PopulateAllTechsFromRoot(RootNode Root)
 {
     foreach (KeyValuePair<string, Node> node in this.TechTree)
     {
         (node.Value as RootNode).nodeState = NodeState.Normal;
     }
     Root.nodeState = NodeState.Press;
     this.Cursor = new Vector2(1f, 1f);
     for (int i = 0; i < ResourceManager.TechTree[Root.tech.UID].LeadsTo.Count; i++)
     {
         if (!ResourceManager.TechTree[ResourceManager.TechTree[Root.tech.UID].LeadsTo[i].UID].Secret || EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetTDict()[ResourceManager.TechTree[Root.tech.UID].LeadsTo[i].UID].Discovered)
         {
             TechEntry te = EmpireManager.GetEmpireByName(this.empireUI.screen.PlayerLoyalty).GetTDict()[ResourceManager.TechTree[Root.tech.UID].LeadsTo[i].UID];
             TreeNode newNode = new TreeNode(this.MainMenuOffset + new Vector2((float)(this.ColumnOffset * (int)this.Cursor.X), (float)(this.RowOffset * (int)this.Cursor.Y)), te, this)
             {
                 NodePosition = this.Cursor
             };
             if (EmpireManager.GetEmpireByName(this.empireUI.screen.PlayerLoyalty).GetTDict()[te.UID].Unlocked)
             {
                 newNode.complete = true;
             }
             this.CompleteSubNodeTree.Add(newNode.tech.UID, newNode);
             this.PopulateAllTechs(newNode);
         }
     }
 }