示例#1
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);
 }