コード例 #1
0
 private void DrawDaysUntilRot(Rect rect, TransferableOneWay trad)
 {
     if (!trad.HasAnyThing || !trad.ThingDef.IsNutritionGivingIngestible)
     {
         return;
     }
     if (!cachedTicksUntilRot.TryGetValue(trad, out var value))
     {
         value = int.MaxValue;
         for (int i = 0; i < trad.things.Count; i++)
         {
             CompRottable compRottable = trad.things[i].TryGetComp <CompRottable>();
             if (compRottable != null)
             {
                 value = Mathf.Min(value, DaysUntilRotCalculator.ApproxTicksUntilRot_AssumeTimePassesBy(compRottable, tile));
             }
         }
         cachedTicksUntilRot.Add(trad, value);
     }
     if (value < 36000000 && !((float)value >= 3.6E+07f))
     {
         Widgets.DrawHighlightIfMouseover(rect);
         float num = (float)value / 60000f;
         GUI.color = Color.yellow;
         Widgets.Label(rect, num.ToString("0.#"));
         GUI.color = Color.white;
         TooltipHandler.TipRegionByKey(rect, "DaysUntilRotTip");
     }
 }
コード例 #2
0
        private void DrawDaysUntilRot(Rect rect, TransferableOneWay trad)
        {
            if (!trad.HasAnyThing)
            {
                return;
            }
            if (!trad.ThingDef.IsNutritionGivingIngestible)
            {
                return;
            }
            int num = int.MaxValue;

            for (int i = 0; i < trad.things.Count; i++)
            {
                CompRottable compRottable = trad.things[i].TryGetComp <CompRottable>();
                if (compRottable != null)
                {
                    num = Mathf.Min(num, DaysUntilRotCalculator.ApproxTicksUntilRot_AssumeTimePassesBy(compRottable, this.tile, null));
                }
            }
            if (num >= 36000000)
            {
                return;
            }
            Widgets.DrawHighlightIfMouseover(rect);
            float num2 = (float)num / 60000f;

            GUI.color = Color.yellow;
            Widgets.Label(rect, num2.ToString("0.#"));
            GUI.color = Color.white;
            TooltipHandler.TipRegion(rect, "DaysUntilRotTip".Translate());
        }
コード例 #3
0
        private float GetFoodScore(Pawn pawn, Thing food, List <Pair <int, int> > ticksToArrive)
        {
            if (!CaravanPawnsNeedsUtility.CanEatForNutritionEver(food.def, pawn) || !food.def.ingestible.canAutoSelectAsFoodForCaravan)
            {
                return(0f);
            }
            float        num          = CaravanPawnsNeedsUtility.GetFoodScore(food.def, pawn, food.GetStatValue(StatDefOf.Nutrition));
            CompRottable compRottable = food.TryGetComp <CompRottable>();

            if (compRottable != null && compRottable.Active && DaysUntilRotCalculator.ApproxTicksUntilRot_AssumeTimePassesBy(compRottable, CurrentTile, ticksToArrive) < ticksToArrive.Last().Second)
            {
                num *= 0.1f;
            }
            return(num);
        }