public static int EstimatedTicksToArrive(int from, int to, WorldPath path, float nextTileCostLeft, int caravanTicksPerMove, 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)Caravan_PathFollower.CostToMove(caravanTicksPerMove, start, num2, yearPercent); } 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); }
public static int LeftRestTicksAt(int tile) { return(CaravanRestUtility.LeftRestTicksAt(tile, GenTicks.TicksAbs)); }
public static void EstimatedTicksToArriveToEvery(int from, int to, WorldPath path, float nextTileCostLeft, int caravanTicksPerMove, int curTicksAbs, List <Pair <int, int> > outTicksToArrive) { outTicksToArrive.Clear(); outTicksToArrive.Add(new Pair <int, int>(from, 0)); if (from == to) { outTicksToArrive.Add(new Pair <int, int>(to, 0)); } else { 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 num9; if (CaravanRestUtility.WouldBeRestingAt(from, (long)curTicksAbs)) { if (Caravan_PathFollower.IsValidFinalPushDestination(to) && (path.Peek(0) == to || (nextTileCostLeft <= 0f && path.NodesLeftCount >= 2 && path.Peek(1) == to))) { float costToMove = CaravanArrivalTimeEstimator.GetCostToMove(nextTileCostLeft, path.Peek(0) == to, curTicksAbs, num, caravanTicksPerMove, from, to); int num8 = Mathf.CeilToInt(costToMove / 1f); if (num8 <= 10000) { num += num8; outTicksToArrive.Add(new Pair <int, int>(to, num)); return; } } num += CaravanRestUtility.LeftRestTicksAt(from, (long)curTicksAbs); num9 = num5; } else { num9 = CaravanRestUtility.LeftNonRestTicksAt(from, (long)curTicksAbs); } for (;;) { num7++; if (num7 >= 10000) { break; } if (num6 <= 0) { if (num2 == to) { goto Block_10; } bool firstInPath = num3 == 0; int num10 = num2; num2 = path.Peek(num3); num3++; outTicksToArrive.Add(new Pair <int, int>(num10, num)); float costToMove2 = CaravanArrivalTimeEstimator.GetCostToMove(nextTileCostLeft, firstInPath, curTicksAbs, num, caravanTicksPerMove, num10, num2); num6 = Mathf.CeilToInt(costToMove2 / 1f); } if (num9 < num6) { num += num9; num6 -= num9; if (num2 == to && num6 <= 10000 && Caravan_PathFollower.IsValidFinalPushDestination(to)) { goto Block_14; } num += num4; num9 = num5; } else { num += num6; num9 -= num6; num6 = 0; } } Log.ErrorOnce("Could not calculate estimated ticks to arrive. Too many iterations.", 1837451324, false); outTicksToArrive.Add(new Pair <int, int>(to, num)); return; Block_10: outTicksToArrive.Add(new Pair <int, int>(to, num)); return; Block_14: num += num6; outTicksToArrive.Add(new Pair <int, int>(to, num)); } }