public void PatherTick()
 {
     if (moving && arrivalAction != null && !arrivalAction.StillValid(caravan, Destination))
     {
         string failMessage = arrivalAction.StillValid(caravan, Destination).FailMessage;
         Messages.Message("MessageCaravanArrivalActionNoLongerValid".Translate(caravan.Name).CapitalizeFirst() + ((failMessage != null) ? (" " + failMessage) : ""), caravan, MessageTypeDefOf.NegativeEvent, true);
         StopDead();
     }
     if (caravan.CantMove || paused)
     {
         return;
     }
     if (nextTileCostLeft > 0f)
     {
         nextTileCostLeft -= CostToPayThisTick();
         return;
     }
     if (moving)
     {
         TryEnterNextPathTile();
     }
 }
 public bool StartPath(int destTile, CaravanArrivalAction arrivalAction, bool repathImmediately = false, bool resetPauseStatus = true)
 {
     caravan.autoJoinable = false;
     if (resetPauseStatus)
     {
         paused = false;
     }
     if (arrivalAction != null && !arrivalAction.StillValid(caravan, destTile))
     {
         return(false);
     }
     if (!IsPassable(caravan.Tile) && !TryRecoverFromUnwalkablePosition())
     {
         return(false);
     }
     if (moving && curPath != null && this.destTile == destTile)
     {
         this.arrivalAction = arrivalAction;
         return(true);
     }
     if (!WorldVehicleReachability.Instance.CanReach(caravan, destTile))
     {
         PatherFailed();
         return(false);
     }
     this.destTile      = destTile;
     this.arrivalAction = arrivalAction;
     caravan.Notify_DestinationOrPauseStatusChanged();
     if (nextTile < 0 || !IsNextTilePassable())
     {
         nextTile         = caravan.Tile;
         nextTileCostLeft = 0f;
         previousTileForDrawingIfInDoubt = -1;
     }
     if (AtDestinationPosition())
     {
         PatherArrived();
         return(true);
     }
     if (curPath != null)
     {
         curPath.ReleaseToPool();
     }
     curPath = null;
     moving  = true;
     if (repathImmediately && TrySetNewPath() && nextTileCostLeft <= 0f && moving)
     {
         TryEnterNextPathTile();
     }
     return(true);
 }
        private void PatherArrived()
        {
            CaravanArrivalAction caravanArrivalAction = arrivalAction;

            StopDead();
            if (caravanArrivalAction != null && caravanArrivalAction.StillValid(caravan, caravan.Tile))
            {
                caravanArrivalAction.Arrived(caravan);
                return;
            }
            if (caravan.IsPlayerControlled && !caravan.VisibleToCameraNow())
            {
                Messages.Message("MessageCaravanArrivedAtDestination".Translate(caravan.Label), caravan, MessageTypeDefOf.TaskCompletion, true);
            }
        }