private void GenerateTree()
        {
            int        NodeGoal   = Mathf.CeilInt(Mathf.Pow(m_ItemSource.baseCap / 3f, 0.95) * 1.25f);
            List <int> IDS        = ItemNodeAtlas.GetAvailibleNodeList(m_ItemSource, false);
            int        yPos       = 0; //skilltree will allways goes down
            int        minbranche = MINBRANCH;

            minbranche = Mathf.Clamp(Mathf.FloorInt(MINBRANCH + m_ItemSource.GetCapLevel() * 0.02f), MINBRANCH, MAXBRANCH);
            int           brancheAmm = Mathf.RandomInt(minbranche, MAXBRANCH);
            List <Branch> Branches   = new List <Branch>
            {
                new Branch(),
                new Branch(),
                new Branch()
            };

            //branches placement :
            // 3 1 0 2 4
            int     brancheID  = 0;
            bool    emptyLevel = true;
            int     connectionBranch;
            Vector2 pos;

            for (int i = 0; i < NodeGoal; i++)
            {
                //20% chance to add a new branches
                if (Mathf.RandomInt(0, 5) >= 4 && Branches.Count < brancheAmm)
                {
                    Branches.Add(new Branch());
                }


                //Used to init the first node

                if (i == 0)
                {
                    Branches[0].Add(AddNewRandomNode(-1, new Vector2(0, 0), IDS, false));
                    yPos++;
                    emptyLevel = true;
                }
                else
                {
                    //if we reached all branches, then we goes to the layer
                    if (brancheID >= Branches.Count)
                    {
                        emptyLevel = true;
                        brancheID  = 0;
                        yPos++;
                    }
                    if (Mathf.RandomInt(0, 5) < 4 || (brancheID == Branches.Count - 1 && emptyLevel))
                    {
                        emptyLevel = false;

                        connectionBranch = brancheID;

                        if (Branches[brancheID].IsEmpty())
                        {
                            connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                        }
                        else if (Mathf.RandomInt(0, 5) >= 4)
                        {
                            connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                        }



                        pos = new Vector2(Branch.GetPosition(brancheID), yPos * 100);



                        int a = HaveNodeAtPos(pos);
                        if (a > 0)
                        {
                            m_nodeList[a].AddNeightboor(Branches[brancheID].GetLastandBefore());
                        }
                        else
                        {
                            Branches[brancheID].Add(AddNewRandomNode(Branches[connectionBranch].GetLastandBefore(), pos, IDS, false));
                        }

                        //add neightboor
                        if (Mathf.RandomInt(0, 5) >= 4)
                        {
                            connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                            int id = Branches[connectionBranch].GetLastandBefore();
                            if (!m_nodeList[Branches[brancheID].GetLast()].GetNeighboor.Contains(id))
                            {
                                m_nodeList[Branches[brancheID].GetLast()].AddNeightboor(id);
                            }
                        }
                    }
                    //Go through all the node one by one
                    brancheID += 1;
                }
            }
            BuildConnection();
            m_nodeList[0].UnlockStep(3);
        }
        public void ExtendTree(int Node)
        {
            //Init all value to continue building the tree
            int        yPos       = GetYPos();
            List <int> IDS        = ItemNodeAtlas.GetAvailibleNodeList(m_ItemSource);
            int        brancheAmm = Mathf.RandomInt(
                Mathf.Clamp(GetBranchesCount(), Mathf.RoundInt(MINBRANCH + m_ItemSource.GetCapLevel() * 0.02f), MAXBRANCH)
                , MAXBRANCH
                );

            List <Branch> Branches = new List <Branch>();

            for (int i = 0; i < brancheAmm; i++)
            {
                Branches.Add(GetEntireBranch(i));
            }

            bool emptyLevel = false;

            int brancheID = GetLowestBranch(Branches, yPos);

            if (brancheID == -1)
            {
                brancheID++;
                emptyLevel = true;
            }

            int     connectionBranch;
            Vector2 pos;

            AnotherRpgMod.Instance.Logger.Info(m_nodeList.Count);
            for (int i = 0; i < Node; i++)
            {
                //20% chance to add a new branches
                if (Mathf.RandomInt(0, 5) >= 4 && Branches.Count < brancheAmm)
                {
                    Branches.Add(new Branch());
                }

                //if we reached all branches, then we goes to the layer
                if (brancheID >= Branches.Count)
                {
                    emptyLevel = true;
                    brancheID  = 0;
                    yPos++;
                }
                if (Mathf.RandomInt(0, 5) < 4 || (brancheID == Branches.Count - 1 && emptyLevel))
                {
                    emptyLevel = false;

                    connectionBranch = brancheID;

                    if (Branches[brancheID].IsEmpty())
                    {
                        connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                    }
                    else if (Mathf.RandomInt(0, 5) >= 4)
                    {
                        connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                    }



                    pos = new Vector2(Branch.GetPosition(brancheID), yPos * 100);



                    int a = HaveNodeAtPos(pos);
                    if (a > 0)
                    {
                        m_nodeList[a].AddNeightboor(Branches[brancheID].GetLastandBefore());
                    }
                    else
                    {
                        Branches[brancheID].Add(AddNewRandomNode(Branches[connectionBranch].GetLastandBefore(), pos, IDS, false));
                    }

                    //add neightboor
                    if (Mathf.RandomInt(0, 5) >= 4)
                    {
                        connectionBranch = Branch.GetRandomNearbyBranches(brancheID, Branches.Count, Branches, true);
                        int id = Branches[connectionBranch].GetLastandBefore();
                        if (!m_nodeList[Branches[brancheID].GetLast()].GetNeighboor.Contains(id))
                        {
                            m_nodeList[Branches[brancheID].GetLast()].AddNeightboor(id);
                        }
                    }
                }
                brancheID += 1;
            }
            UpdateConnection();
        }