public AStarRecord(GridmapCell c, AStarRecord p, float cost)
                {
                    if (c == null) throw new UnityException("Cannot create an AStarRecord with a null node.");

                    cell = c;
                    parent = p;
                    linkCost = cost;

                    totalCost = (parent != null) ? parent.totalCost + linkCost : linkCost;
                    estimatedFinalCost = totalCost + (finalTarget - cell.center).magnitude;
                }
                public void Reparent(AStarRecord newP, float cost)
                {
                    parent = newP;
                    linkCost = cost;

                    totalCost = (parent != null) ? parent.totalCost + linkCost : linkCost;
                    estimatedFinalCost = totalCost + (finalTarget - cell.center).magnitude;
                }
            private static bool PlaceInCorrectList(GridmapCell cell, AStarRecord parent, float cost)
            {
                if (cell == null) return false;
                if (!cell.Valid && checkValiditiy) return false;

                AStarRecord olinstance = openList.FirstOrDefault(r => r.cell.Equals(cell));
                if (olinstance != null)  // it's on the open list.
                {
                    if (olinstance.totalCost > parent.totalCost + cost)  // this new path is shorter
                        olinstance.Reparent(parent, cost);
                    return true;
                }

                AStarRecord clinstance = closedList.FirstOrDefault(r => r.cell.Equals(cell));
                if (clinstance != null) // it's in the closed list
                {
                    return true;
                }

                // add it to the open list
                openList.Add(new AStarRecord(cell, parent, cost));
                return true;
            }