Made eating human milk raw + in meals a requirement

This commit is contained in:
c0ffee 2021-11-17 11:36:41 -08:00
parent e1a817c55f
commit 40c79dd0cd
5 changed files with 81 additions and 25 deletions

View file

@ -23,10 +23,14 @@ namespace CRIALactation
[HarmonyPatch(typeof(FoodUtility), "ThoughtsFromIngesting")]
public static void Postfix(ref List<FoodUtility.ThoughtFromIngesting> __result, ref List<FoodUtility.ThoughtFromIngesting> ___ingestThoughts, Pawn ingester, Thing foodSource, ThingDef foodDef)
{
/**
* checks if food has milk or not
*/
if (ingester.Ideo != null)
{
CompIngredients ingredients = foodSource.TryGetComp<CompIngredients>();
if (foodDef == ThingDefOf_Milk.HumanMilk || foodDef == ThingDefOf_Milk.HumanoidMilk)
{
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkRaw, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef));
@ -34,6 +38,11 @@ namespace CRIALactation
__result = ___ingestThoughts;
}
else if (ingredients == null
|| !(ingredients.ingredients.Contains(ThingDefOf_Milk.HumanMilk) || (ingredients.ingredients.Contains(ThingDefOf_Milk.HumanoidMilk)))) {
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankNonMilkMeal, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef));
__result = ___ingestThoughts;
}
}
@ -57,5 +66,17 @@ namespace CRIALactation
}
[HarmonyPatch(typeof(FoodUtility), "GenerateGoodIngredients")]
public static void Postfix(Thing meal, Ideo ideo)
{
CompIngredients compIngredients = meal.TryGetComp<CompIngredients>();
if(ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_Essential))
{
compIngredients.ingredients.Add(ThingDefOf_Milk.HumanMilk);
compIngredients.ingredients.Add(ThingDefOf_Milk.HumanoidMilk);
}
}
}
}

View file

@ -18,5 +18,7 @@ namespace CRIALactation
public static HistoryEventDef DrankMilkRaw;
public static HistoryEventDef DrankMilkMeal;
public static HistoryEventDef DrankNonMilkMeal;
}
}