Example #1
0
 public static bool WillEat(this Pawn p, ThingDef food, Pawn getter = null)
 {
     if (!p.RaceProps.CanEverEat(food))
     {
         return(false);
     }
     if (p.foodRestriction != null)
     {
         FoodRestriction currentRespectedRestriction = p.foodRestriction.GetCurrentRespectedRestriction(getter);
         if (currentRespectedRestriction != null && !currentRespectedRestriction.Allows(food) && food.IsWithinCategory(currentRespectedRestriction.filter.DisplayRootCategory.catDef))
         {
             return(false);
         }
     }
     return(true);
 }
Example #2
0
 public static bool WillEat(this Pawn p, Thing food, Pawn getter = null)
 {
     if (!p.RaceProps.CanEverEat(food))
     {
         return(false);
     }
     if (p.foodRestriction != null)
     {
         FoodRestriction currentRespectedRestriction = p.foodRestriction.GetCurrentRespectedRestriction(getter);
         if (currentRespectedRestriction != null && !currentRespectedRestriction.Allows(food) && (food.def.IsWithinCategory(ThingCategoryDefOf.Foods) || food.def.IsWithinCategory(ThingCategoryDefOf.Corpses)))
         {
             return(false);
         }
     }
     return(true);
 }
Example #3
0
 public static bool WillEat(this Pawn p, ThingDef food, Pawn getter = null, bool careIfNotAcceptableForTitle = true)
 {
     if (!p.RaceProps.CanEverEat(food))
     {
         return(false);
     }
     if (p.foodRestriction != null)
     {
         FoodRestriction currentRespectedRestriction = p.foodRestriction.GetCurrentRespectedRestriction(getter);
         if (currentRespectedRestriction != null && !currentRespectedRestriction.Allows(food) && food.IsWithinCategory(currentRespectedRestriction.filter.DisplayRootCategory.catDef))
         {
             return(false);
         }
     }
     if (careIfNotAcceptableForTitle && InappropriateForTitle(food, p, allowIfStarving: true))
     {
         return(false);
     }
     return(true);
 }
Example #4
0
 public static bool WillEat(this Pawn p, Thing food, Pawn getter = null, bool careIfNotAcceptableForTitle = true)
 {
     if (!p.RaceProps.CanEverEat(food))
     {
         return(false);
     }
     if (p.foodRestriction != null)
     {
         FoodRestriction currentRespectedRestriction = p.foodRestriction.GetCurrentRespectedRestriction(getter);
         if (currentRespectedRestriction != null && !currentRespectedRestriction.Allows(food) && (food.def.IsWithinCategory(ThingCategoryDefOf.Foods) || food.def.IsWithinCategory(ThingCategoryDefOf.Corpses)))
         {
             return(false);
         }
     }
     if (careIfNotAcceptableForTitle && InappropriateForTitle(food.def, p, allowIfStarving: true))
     {
         return(false);
     }
     return(true);
 }