コード例 #1
0
        public static float ApproxTilesPerDay(List <ThingCount> thingCounts, float massUsage, float massCapacity, int tile, int nextTile, StringBuilder explanation = null)
        {
            TilesPerDayCalculator.tmpPawns.Clear();
            for (int i = 0; i < thingCounts.Count; i++)
            {
                if (thingCounts[i].Count > 0)
                {
                    Pawn pawn = thingCounts[i].Thing as Pawn;
                    if (pawn != null)
                    {
                        TilesPerDayCalculator.tmpPawns.Add(pawn);
                    }
                }
            }
            if (!TilesPerDayCalculator.tmpPawns.Any <Pawn>())
            {
                return(0f);
            }
            StringBuilder stringBuilder = (explanation == null) ? null : new StringBuilder();
            int           ticksPerMove  = CaravanTicksPerMoveUtility.GetTicksPerMove(TilesPerDayCalculator.tmpPawns, massUsage, massCapacity, stringBuilder);
            float         result        = TilesPerDayCalculator.ApproxTilesPerDay(ticksPerMove, tile, nextTile, explanation, (stringBuilder == null) ? null : stringBuilder.ToString());

            TilesPerDayCalculator.tmpPawns.Clear();
            return(result);
        }
コード例 #2
0
        public static float ApproxTilesPerDayLeftAfterTransfer(List <TransferableOneWay> transferables, float massUsageLeftAfterTransfer, float massCapacityLeftAfterTransfer, int tile, int nextTile, StringBuilder explanation = null)
        {
            TilesPerDayCalculator.tmpPawns.Clear();
            for (int i = 0; i < transferables.Count; i++)
            {
                TransferableOneWay transferableOneWay = transferables[i];
                if (transferableOneWay.HasAnyThing && transferableOneWay.AnyThing is Pawn)
                {
                    for (int j = transferableOneWay.things.Count - 1; j >= transferableOneWay.CountToTransfer; j--)
                    {
                        TilesPerDayCalculator.tmpPawns.Add((Pawn)transferableOneWay.things[j]);
                    }
                }
            }
            if (!TilesPerDayCalculator.tmpPawns.Any <Pawn>())
            {
                return(0f);
            }
            StringBuilder stringBuilder = (explanation == null) ? null : new StringBuilder();
            int           ticksPerMove  = CaravanTicksPerMoveUtility.GetTicksPerMove(TilesPerDayCalculator.tmpPawns, massUsageLeftAfterTransfer, massCapacityLeftAfterTransfer, stringBuilder);
            float         result        = TilesPerDayCalculator.ApproxTilesPerDay(ticksPerMove, tile, nextTile, explanation, (stringBuilder == null) ? null : stringBuilder.ToString());

            TilesPerDayCalculator.tmpPawns.Clear();
            return(result);
        }
コード例 #3
0
        public static float ApproxTilesPerDay(List <TransferableOneWay> transferables, float massUsage, float massCapacity, int tile, int nextTile, StringBuilder explanation = null)
        {
            tmpPawns.Clear();
            for (int i = 0; i < transferables.Count; i++)
            {
                TransferableOneWay transferableOneWay = transferables[i];
                if (transferableOneWay.HasAnyThing && transferableOneWay.AnyThing is Pawn)
                {
                    for (int j = 0; j < transferableOneWay.CountToTransfer; j++)
                    {
                        tmpPawns.Add((Pawn)transferableOneWay.things[j]);
                    }
                }
            }
            if (!tmpPawns.Any())
            {
                return(0f);
            }
            StringBuilder stringBuilder = (explanation == null) ? null : new StringBuilder();
            int           ticksPerMove  = CaravanTicksPerMoveUtility.GetTicksPerMove(tmpPawns, massUsage, massCapacity, stringBuilder);
            float         result        = ApproxTilesPerDay(ticksPerMove, tile, nextTile, explanation, stringBuilder?.ToString());

            tmpPawns.Clear();
            return(result);
        }
コード例 #4
0
 public static int GetTicksPerMove(Caravan caravan)
 {
     if (caravan == null)
     {
         return(2500);
     }
     return(CaravanTicksPerMoveUtility.GetTicksPerMove(caravan.PawnsListForReading));
 }
コード例 #5
0
 public static int GetTicksPerMove(Caravan caravan, StringBuilder explanation = null)
 {
     if (caravan == null)
     {
         if (explanation != null)
         {
             CaravanTicksPerMoveUtility.AppendUsingDefaultTicksPerMoveInfo(explanation);
         }
         return(3300);
     }
     return(CaravanTicksPerMoveUtility.GetTicksPerMove(new CaravanTicksPerMoveUtility.CaravanInfo(caravan), explanation));
 }
コード例 #6
0
        public static int GetTicksPerMove(Caravan caravan, StringBuilder explanation = null)
        {
            int result;

            if (caravan == null)
            {
                if (explanation != null)
                {
                    CaravanTicksPerMoveUtility.AppendUsingDefaultTicksPerMoveInfo(explanation);
                }
                result = 3500;
            }
            else
            {
                result = CaravanTicksPerMoveUtility.GetTicksPerMove(new CaravanTicksPerMoveUtility.CaravanInfo(caravan), explanation);
            }
            return(result);
        }
コード例 #7
0
        public static float ApproxTilesPerDay(List <ThingCount> thingCounts, float massUsage, float massCapacity, int tile, int nextTile, StringBuilder explanation = null)
        {
            tmpPawns.Clear();
            for (int i = 0; i < thingCounts.Count; i++)
            {
                if (thingCounts[i].Count > 0)
                {
                    Pawn pawn = thingCounts[i].Thing as Pawn;
                    if (pawn != null)
                    {
                        tmpPawns.Add(pawn);
                    }
                }
            }
            if (!tmpPawns.Any())
            {
                return(0f);
            }
            StringBuilder stringBuilder = ((explanation != null) ? new StringBuilder() : null);
            float         result        = ApproxTilesPerDay(CaravanTicksPerMoveUtility.GetTicksPerMove(tmpPawns, massUsage, massCapacity, stringBuilder), tile, nextTile, explanation, stringBuilder?.ToString());

            tmpPawns.Clear();
            return(result);
        }
コード例 #8
0
        public static float ApproxTilesPerDayLeftAfterTransfer(List <TransferableOneWay> transferables, float massUsageLeftAfterTransfer, float massCapacityLeftAfterTransfer, int tile, int nextTile, StringBuilder explanation = null)
        {
            tmpPawns.Clear();
            for (int i = 0; i < transferables.Count; i++)
            {
                TransferableOneWay transferableOneWay = transferables[i];
                if (transferableOneWay.HasAnyThing && transferableOneWay.AnyThing is Pawn)
                {
                    for (int num = transferableOneWay.things.Count - 1; num >= transferableOneWay.CountToTransfer; num--)
                    {
                        tmpPawns.Add((Pawn)transferableOneWay.things[num]);
                    }
                }
            }
            if (!tmpPawns.Any())
            {
                return(0f);
            }
            StringBuilder stringBuilder = ((explanation != null) ? new StringBuilder() : null);
            float         result        = ApproxTilesPerDay(CaravanTicksPerMoveUtility.GetTicksPerMove(tmpPawns, massUsageLeftAfterTransfer, massCapacityLeftAfterTransfer, stringBuilder), tile, nextTile, explanation, stringBuilder?.ToString());

            tmpPawns.Clear();
            return(result);
        }
コード例 #9
0
 public static int GetTicksPerMove(CaravanTicksPerMoveUtility.CaravanInfo caravanInfo, StringBuilder explanation = null)
 {
     return(CaravanTicksPerMoveUtility.GetTicksPerMove(caravanInfo.pawns, caravanInfo.massUsage, caravanInfo.massCapacity, explanation));
 }
コード例 #10
0
        public static int EstimatedTicksToArrive(int from, int to, Caravan caravan)
        {
            int result;

            using (WorldPath worldPath = Find.WorldPathFinder.FindPath(from, to, caravan, null))
            {
                if (worldPath == WorldPath.NotFound)
                {
                    result = 0;
                }
                else
                {
                    result = CaravanArrivalTimeEstimator.EstimatedTicksToArrive(from, to, worldPath, 0f, CaravanTicksPerMoveUtility.GetTicksPerMove(caravan), Find.TickManager.TicksAbs);
                }
            }
            return(result);
        }