public void StartPath(int destTile, CaravanArrivalAction arrivalAction, bool repathImmediately = false, bool resetPauseStatus = true)
 {
     this.caravan.autoJoinable = false;
     if (resetPauseStatus)
     {
         this.paused = false;
     }
     if (arrivalAction == null || arrivalAction.StillValid(this.caravan, destTile))
     {
         if (!this.IsPassable(this.caravan.Tile))
         {
             if (!this.TryRecoverFromUnwalkablePosition())
             {
                 return;
             }
         }
         if (this.moving && this.curPath != null && this.destTile == destTile)
         {
             this.arrivalAction = arrivalAction;
         }
         else if (!this.caravan.CanReach(destTile))
         {
             this.PatherFailed();
         }
         else
         {
             this.destTile      = destTile;
             this.arrivalAction = arrivalAction;
             this.caravan.Notify_DestinationOrPauseStatusChanged();
             if (this.nextTile < 0 || !this.IsNextTilePassable())
             {
                 this.nextTile         = this.caravan.Tile;
                 this.nextTileCostLeft = 0f;
                 this.previousTileForDrawingIfInDoubt = -1;
             }
             if (this.AtDestinationPosition())
             {
                 this.PatherArrived();
             }
             else
             {
                 if (this.curPath != null)
                 {
                     this.curPath.ReleaseToPool();
                 }
                 this.curPath = null;
                 this.moving  = true;
                 if (repathImmediately)
                 {
                     bool flag = this.TrySetNewPath();
                     if (flag && this.nextTileCostLeft <= 0f && this.moving)
                     {
                         this.TryEnterNextPathTile();
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
 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);
         StopDead();
     }
     if (!caravan.CantMove && !paused)
     {
         if (nextTileCostLeft > 0f)
         {
             nextTileCostLeft -= CostToPayThisTick();
         }
         else if (moving)
         {
             TryEnterNextPathTile();
         }
     }
 }
Exemple #3
0
 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 (!caravan.CanReach(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);
 }
Exemple #4
0
        private void PatherArrived()
        {
            CaravanArrivalAction caravanArrivalAction = arrivalAction;

            StopDead();
            if (caravanArrivalAction != null && (bool)caravanArrivalAction.StillValid(caravan, caravan.Tile))
            {
                caravanArrivalAction.Arrived(caravan);
            }
            else if (caravan.IsPlayerControlled && !caravan.VisibleToCameraNow())
            {
                Messages.Message("MessageCaravanArrivedAtDestination".Translate(caravan.Label), caravan, MessageTypeDefOf.TaskCompletion);
            }
        }
        private void PatherArrived()
        {
            CaravanArrivalAction caravanArrivalAction = this.arrivalAction;

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