コード例 #1
0
 public static float ApproxDaysUntilRot(List <ThingCount> potentiallyFood, int tile, WorldPath path = null, float nextTileCostLeft = 0f, int caravanTicksPerMove = 3300)
 {
     DaysUntilRotCalculator.tmpTicksToArrive.Clear();
     if (path != null && path.Found)
     {
         CaravanArrivalTimeEstimator.EstimatedTicksToArriveToEvery(tile, path.LastNode, path, nextTileCostLeft, caravanTicksPerMove, Find.TickManager.TicksAbs, DaysUntilRotCalculator.tmpTicksToArrive);
     }
     DaysUntilRotCalculator.tmpNutritions.Clear();
     for (int i = 0; i < potentiallyFood.Count; i++)
     {
         ThingCount thingCount = potentiallyFood[i];
         if (thingCount.Count > 0 && thingCount.Thing.def.IsNutritionGivingIngestible)
         {
             CompRottable compRottable = thingCount.Thing.TryGetComp <CompRottable>();
             float        first;
             if (compRottable != null && compRottable.Active)
             {
                 first = (float)DaysUntilRotCalculator.ApproxTicksUntilRot_AssumeTimePassesBy(compRottable, tile, DaysUntilRotCalculator.tmpTicksToArrive) / 60000f;
             }
             else
             {
                 first = 600f;
             }
             float second = thingCount.Thing.GetStatValue(StatDefOf.Nutrition, true) * (float)thingCount.Count;
             DaysUntilRotCalculator.tmpNutritions.Add(new Pair <float, float>(first, second));
         }
     }
     return(GenMath.WeightedMedian(DaysUntilRotCalculator.tmpNutritions, 600f, 0.5f));
 }
コード例 #2
0
        public static float ApproxDaysUntilRotLeftAfterTradeableTransfer(List <Thing> allCurrentThings, List <Tradeable> tradeables, int tile, IgnorePawnsInventoryMode ignoreInventory)
        {
            DaysUntilRotCalculator.tmpThingCountsFromTradeables.Clear();
            TransferableUtility.SimulateTradeableTransfer(allCurrentThings, tradeables, DaysUntilRotCalculator.tmpThingCountsFromTradeables);
            DaysUntilRotCalculator.tmpThingCounts.Clear();
            for (int i = DaysUntilRotCalculator.tmpThingCountsFromTradeables.Count - 1; i >= 0; i--)
            {
                if (DaysUntilRotCalculator.tmpThingCountsFromTradeables[i].Count > 0)
                {
                    Pawn pawn = DaysUntilRotCalculator.tmpThingCountsFromTradeables[i].Thing as Pawn;
                    if (pawn != null)
                    {
                        if (!InventoryCalculatorsUtility.ShouldIgnoreInventoryOf(pawn, ignoreInventory))
                        {
                            ThingOwner <Thing> innerContainer = pawn.inventory.innerContainer;
                            for (int j = 0; j < innerContainer.Count; j++)
                            {
                                DaysUntilRotCalculator.tmpThingCounts.Add(new ThingCount(innerContainer[j], innerContainer[j].stackCount));
                            }
                        }
                    }
                    else
                    {
                        DaysUntilRotCalculator.tmpThingCounts.Add(DaysUntilRotCalculator.tmpThingCountsFromTradeables[i]);
                    }
                }
            }
            DaysUntilRotCalculator.tmpThingCountsFromTradeables.Clear();
            float result = DaysUntilRotCalculator.ApproxDaysUntilRot(DaysUntilRotCalculator.tmpThingCounts, tile, null, 0f, 3300);

            DaysUntilRotCalculator.tmpThingCounts.Clear();
            return(result);
        }
コード例 #3
0
        public static float ApproxDaysUntilRotLeftAfterTransfer(List <TransferableOneWay> transferables, int assumingTile, IgnorePawnsInventoryMode ignoreInventory)
        {
            DaysUntilRotCalculator.tmpThings.Clear();
            for (int i = 0; i < transferables.Count; i++)
            {
                TransferableOneWay transferableOneWay = transferables[i];
                if (transferableOneWay.HasAnyThing)
                {
                    if (transferableOneWay.AnyThing is Pawn)
                    {
                        for (int j = transferableOneWay.things.Count - 1; j >= transferableOneWay.CountToTransfer; j--)
                        {
                            Pawn pawn = (Pawn)transferableOneWay.things[j];
                            if (!InventoryCalculatorsUtility.ShouldIgnoreInventoryOf(pawn, ignoreInventory))
                            {
                                ThingOwner <Thing> innerContainer = pawn.inventory.innerContainer;
                                for (int k = 0; k < innerContainer.Count; k++)
                                {
                                    DaysUntilRotCalculator.tmpThings.Add(innerContainer[k]);
                                }
                            }
                        }
                    }
                    else if (transferableOneWay.MaxCount - transferableOneWay.CountToTransfer > 0)
                    {
                        DaysUntilRotCalculator.tmpThings.AddRange(transferableOneWay.things);
                    }
                }
            }
            float result = DaysUntilRotCalculator.ApproxDaysUntilRot(DaysUntilRotCalculator.tmpThings, assumingTile);

            DaysUntilRotCalculator.tmpThings.Clear();
            return(result);
        }
コード例 #4
0
        public static float ApproxDaysUntilRotLeftAfterTradeableTransfer(List <Thing> allCurrentThings, List <Tradeable> tradeables, int assumingTile, IgnorePawnsInventoryMode ignoreInventory)
        {
            TransferableUtility.SimulateTradeableTransfer(allCurrentThings, tradeables, DaysUntilRotCalculator.tmpThingStackParts);
            DaysUntilRotCalculator.tmpThings.Clear();
            for (int num = DaysUntilRotCalculator.tmpThingStackParts.Count - 1; num >= 0; num--)
            {
                if (DaysUntilRotCalculator.tmpThingStackParts[num].Count > 0)
                {
                    Pawn pawn = DaysUntilRotCalculator.tmpThingStackParts[num].Thing as Pawn;
                    if (pawn != null)
                    {
                        if (!InventoryCalculatorsUtility.ShouldIgnoreInventoryOf(pawn, ignoreInventory))
                        {
                            ThingOwner <Thing> innerContainer = pawn.inventory.innerContainer;
                            for (int i = 0; i < innerContainer.Count; i++)
                            {
                                DaysUntilRotCalculator.tmpThings.Add(innerContainer[i]);
                            }
                        }
                    }
                    else
                    {
                        DaysUntilRotCalculator.tmpThings.Add(DaysUntilRotCalculator.tmpThingStackParts[num].Thing);
                    }
                }
            }
            DaysUntilRotCalculator.tmpThingStackParts.Clear();
            float result = DaysUntilRotCalculator.ApproxDaysUntilRot(DaysUntilRotCalculator.tmpThings, assumingTile);

            DaysUntilRotCalculator.tmpThings.Clear();
            return(result);
        }
コード例 #5
0
        public static float ApproxDaysUntilRot(List <Thing> potentiallyFood, int tile, WorldPath path = null, float nextTileCostLeft = 0f, int caravanTicksPerMove = 3300)
        {
            DaysUntilRotCalculator.tmpThingCounts.Clear();
            for (int i = 0; i < potentiallyFood.Count; i++)
            {
                DaysUntilRotCalculator.tmpThingCounts.Add(new ThingCount(potentiallyFood[i], potentiallyFood[i].stackCount));
            }
            float result = DaysUntilRotCalculator.ApproxDaysUntilRot(DaysUntilRotCalculator.tmpThingCounts, tile, path, nextTileCostLeft, caravanTicksPerMove);

            DaysUntilRotCalculator.tmpThingCounts.Clear();
            return(result);
        }
コード例 #6
0
        public static float ApproxDaysUntilRotLeftAfterTransfer(List <TransferableOneWay> transferables, int tile, IgnorePawnsInventoryMode ignoreInventory, WorldPath path = null, float nextTileCostLeft = 0f, int caravanTicksPerMove = 3300)
        {
            DaysUntilRotCalculator.tmpThingCounts.Clear();
            for (int i = 0; i < transferables.Count; i++)
            {
                TransferableOneWay transferableOneWay = transferables[i];
                if (transferableOneWay.HasAnyThing)
                {
                    if (transferableOneWay.AnyThing is Pawn)
                    {
                        for (int j = transferableOneWay.things.Count - 1; j >= transferableOneWay.CountToTransfer; j--)
                        {
                            Pawn pawn = (Pawn)transferableOneWay.things[j];
                            if (!InventoryCalculatorsUtility.ShouldIgnoreInventoryOf(pawn, ignoreInventory))
                            {
                                ThingOwner <Thing> innerContainer = pawn.inventory.innerContainer;
                                for (int k = 0; k < innerContainer.Count; k++)
                                {
                                    DaysUntilRotCalculator.tmpThingCounts.Add(new ThingCount(innerContainer[k], innerContainer[k].stackCount));
                                }
                            }
                        }
                    }
                    else if (transferableOneWay.MaxCount - transferableOneWay.CountToTransfer > 0)
                    {
                        DaysUntilRotCalculator.thingsInReverse.Clear();
                        DaysUntilRotCalculator.thingsInReverse.AddRange(transferableOneWay.things);
                        DaysUntilRotCalculator.thingsInReverse.Reverse();
                        TransferableUtility.TransferNoSplit(DaysUntilRotCalculator.thingsInReverse, transferableOneWay.MaxCount - transferableOneWay.CountToTransfer, delegate(Thing thing, int count)
                        {
                            DaysUntilRotCalculator.tmpThingCounts.Add(new ThingCount(thing, count));
                        }, false, false);
                    }
                }
            }
            DaysUntilRotCalculator.thingsInReverse.Clear();
            float result = DaysUntilRotCalculator.ApproxDaysUntilRot(DaysUntilRotCalculator.tmpThingCounts, tile, path, nextTileCostLeft, caravanTicksPerMove);

            DaysUntilRotCalculator.tmpThingCounts.Clear();
            return(result);
        }
コード例 #7
0
 public static float ApproxDaysUntilRot(Caravan caravan)
 {
     return(DaysUntilRotCalculator.ApproxDaysUntilRot(CaravanInventoryUtility.AllInventoryItems(caravan), caravan.Tile, caravan.pather.curPath, caravan.pather.nextTileCostLeft, caravan.TicksPerMove));
 }
コード例 #8
0
 public static float ApproxDaysUntilRot(Caravan caravan)
 {
     return(DaysUntilRotCalculator.ApproxDaysUntilRot(CaravanInventoryUtility.AllInventoryItems(caravan), caravan.Tile));
 }