コード例 #1
0
        private WorldPath GenerateNewPath()
        {
            int num = (!moving || nextTile < 0 || !IsNextTilePassable()) ? warObject.Tile : nextTile;

            lastPathedTargetTile = destTile;
            WorldPath worldPath = Verse.Find.WorldPathFinder.FindPath(num, destTile, null); //caravan=null

            if (worldPath.Found && num != warObject.Tile)
            {
                if (worldPath.NodesLeftCount >= 2 && worldPath.Peek(1) == warObject.Tile)
                {
                    worldPath.ConsumeNextNode();
                    if (moving)
                    {
                        previousTileForDrawingIfInDoubt = nextTile;
                        nextTile         = warObject.Tile;
                        nextTileCostLeft = nextTileCostTotal - nextTileCostLeft;
                    }
                }
                else
                {
                    worldPath.AddNodeAtStart(warObject.Tile);
                }
            }
            return(worldPath);
        }
コード例 #2
0
        private WorldPath GenerateNewPath()
        {
            int num = (moving && nextTile >= 0 && IsNextTilePassable()) ? nextTile : caravan.Tile;

            lastPathedTargetTile = destTile;
            WorldPath worldPath = WorldVehiclePathfinder.Instance.FindPath(num, destTile, caravan, null);

            if (worldPath.Found && num != caravan.Tile)
            {
                if (worldPath.NodesLeftCount >= 2 && worldPath.Peek(1) == caravan.Tile)
                {
                    worldPath.ConsumeNextNode();
                    if (moving)
                    {
                        previousTileForDrawingIfInDoubt = nextTile;
                        nextTile         = caravan.Tile;
                        nextTileCostLeft = nextTileCostTotal - nextTileCostLeft;
                    }
                }
                else
                {
                    worldPath.AddNodeAtStart(caravan.Tile);
                }
            }
            return(worldPath);
        }
コード例 #3
0
 private bool NeedNewPath()
 {
     if (!moving)
     {
         return(false);
     }
     if (curPath == null || !curPath.Found || curPath.NodesLeftCount == 0)
     {
         return(true);
     }
     for (int i = 0; i < 20 && i < curPath.NodesLeftCount; i++)
     {
         int tileID = curPath.Peek(i);
         if (Verse.Find.World.Impassable(tileID))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #4
0
        private bool NeedNewPath()
        {
            if (!moving)
            {
                return(false);
            }
            if (curPath == null || !curPath.Found || curPath.NodesLeftCount == 0)
            {
                return(true);
            }
            int num = 0;

            while (num < MaxCheckAheadNodes && num < curPath.NodesLeftCount)
            {
                int tileID = curPath.Peek(num);
                if (!IsPassable(tileID))
                {
                    return(true);
                }
                num++;
            }
            return(false);
        }
コード例 #5
0
        public static int EstimatedTicksToArrive(int from, int to, WorldPath path, float nextTileCostLeft, List <Pawn> pawns, int curTicksAbs)
        {
            int num  = 0;
            int num2 = from;
            int num3 = 0;
            int num4 = Mathf.CeilToInt(20000f) - 1;
            int num5 = 60000 - num4;
            int num6 = 0;
            int num7 = 0;
            int num8;

            if (CaravanRestUtility.WouldBeRestingAt(from, (long)curTicksAbs))
            {
                num += CaravanRestUtility.LeftRestTicksAt(from, (long)curTicksAbs);
                num8 = num5;
            }
            else
            {
                num8 = CaravanRestUtility.LeftNonRestTicksAt(from, (long)curTicksAbs);
            }
            while (true)
            {
                num7++;
                if (num7 >= 10000)
                {
                    break;
                }
                if (num6 <= 0)
                {
                    if (num2 == to)
                    {
                        return(num);
                    }
                    bool flag  = num3 == 0;
                    int  start = num2;
                    num2 = path.Peek(num3);
                    num3++;
                    float num9;
                    if (flag)
                    {
                        num9 = nextTileCostLeft;
                    }
                    else
                    {
                        int   num10       = curTicksAbs + num;
                        float yearPercent = (float)GenDate.DayOfYear((long)num10, 0f) / 60f;
                        num9 = (float)Utilities.CaravanUtility.CostToMove(pawns, start, num2, yearPercent); //replaced caravanTicksPerMove with caravan here.
                    }
                    num6 = Mathf.CeilToInt(num9 / 1f);
                }
                if (num8 < num6)
                {
                    num  += num8;
                    num6 -= num8;
                    num  += num4;
                    num8  = num5;
                }
                else
                {
                    num  += num6;
                    num8 -= num6;
                    num6  = 0;
                }
            }
            Log.ErrorOnce("Could not calculate estimated ticks to arrive. Too many iterations.", 1837451324);
            return(num);
        }