public void AdvancePath(bool trigger_advance = true)
    {
        int  num = Grid.PosToCell(this);
        int  num2;
        bool flag;

        if ((UnityEngine.Object)target == (UnityEngine.Object)null)
        {
            Trigger(-766531887, null);
            Stop(false);
        }
        else
        {
            if (num != reservedCell || CurrentNavType == NavType.Tube)
            {
                flag = false;
                num2 = Grid.PosToCell(target);
                if (reservedCell == NavigationReservations.InvalidReservation)
                {
                    flag = true;
                }
                else if (!CanReach(reservedCell))
                {
                    flag = true;
                }
                else if (!Grid.IsCellOffsetOf(reservedCell, num2, targetOffsets))
                {
                    flag = true;
                }
                else if (path.IsValid())
                {
                    int num3 = num;
                    PathFinder.Path.Node node = path.nodes[0];
                    if (num3 == node.cell)
                    {
                        NavType currentNavType     = CurrentNavType;
                        PathFinder.Path.Node node2 = path.nodes[0];
                        if (currentNavType == node2.navType)
                        {
                            flag = !ValidatePath(ref path);
                            goto IL_018c;
                        }
                    }
                    int num4 = num;
                    PathFinder.Path.Node node3 = path.nodes[1];
                    if (num4 == node3.cell)
                    {
                        NavType currentNavType2    = CurrentNavType;
                        PathFinder.Path.Node node4 = path.nodes[1];
                        if (currentNavType2 == node4.navType)
                        {
                            path.nodes.RemoveAt(0);
                            flag = !ValidatePath(ref path);
                            goto IL_018c;
                        }
                    }
                    flag = true;
                }
                else
                {
                    flag = true;
                }
                goto IL_018c;
            }
            Stop(true);
        }
        goto IL_02b5;
IL_018c:
        if (flag)
        {
            int cellPreferences = tactic.GetCellPreferences(num2, targetOffsets, this);
            SetReservedCell(cellPreferences);
            if (reservedCell != NavigationReservations.InvalidReservation)
            {
                PathFinder.UpdatePath(potential_path: new PathFinder.PotentialPath(num, CurrentNavType, flags), nav_grid: NavGrid, abilities: GetCurrentAbilities(), query: PathFinderQueries.cellQuery.Reset(reservedCell), path: ref path);
            }
            else
            {
                Stop(false);
            }
        }
        if (path.IsValid())
        {
            NavGrid.Transition[] transitions = NavGrid.transitions;
            PathFinder.Path.Node node5       = path.nodes[1];
            BeginTransition(transitions[node5.transitionId]);
            distanceTravelledByNavType[CurrentNavType] = Mathf.Max(distanceTravelledByNavType[CurrentNavType] + 1, distanceTravelledByNavType[CurrentNavType]);
        }
        else if (path.HasArrived())
        {
            Stop(true);
        }
        else
        {
            ClearReservedCell();
            Stop(false);
        }
        goto IL_02b5;
IL_02b5:
        if (trigger_advance)
        {
            Trigger(1347184327, null);
        }
    }