Exemple #1
0
        // RimWorld.Planet.CaravanInventoryUtility
        public static bool TryGetBestFood(Pawn vehicle, Pawn forPawn, out Thing food, out Pawn owner)
        {
            List <Thing> list  = vehicle?.inventory?.innerContainer?.InnerListForReading;
            Thing        thing = null;
            float        num   = 0f;

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing2 = list[i];
                if (CompVehicleUtility.CanNowEatForNutrition(thing2, forPawn))
                {
                    float foodScore = CaravanPawnsNeedsUtility.GetFoodScore(thing2, forPawn);
                    if (thing == null || foodScore > num)
                    {
                        thing = thing2;
                        num   = foodScore;
                    }
                }
            }
            if (thing != null)
            {
                food  = thing;
                owner = forPawn; //CaravanInventoryUtility.GetOwnerOf(caravan, thing);
                return(true);
            }
            food  = null;
            owner = null;
            return(false);
        }
Exemple #2
0
 // RimWorld.Planet.CaravanPawnsNeedsUtility
 public static bool CanNowEatForNutrition(Thing food, Pawn pawn)
 {
     return(food.IngestibleNow && CompVehicleUtility.CanNowEatForNutrition(food.def, pawn));
 }