2021-11-17 05:37:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using RimWorld;
|
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace CRIALactation
|
|
|
|
|
{
|
|
|
|
|
[HarmonyPatch]
|
|
|
|
|
public static class HarmonyPatch_FoodUtility
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[HarmonyReversePatch(HarmonyReversePatchType.Snapshot)]
|
|
|
|
|
[HarmonyPatch(typeof(FoodUtility), "AddThoughtsFromIdeo")]
|
|
|
|
|
public static void AddThoughtsFromIdeo_Patch(HistoryEventDef eventDef, Pawn ingester, ThingDef foodDef, MeatSourceCategory meatSourceCategory)
|
|
|
|
|
{
|
2021-11-28 23:02:51 +00:00
|
|
|
|
//throw new NotImplementedException("thoughts from ideo wasn't implemented!");
|
2021-11-17 05:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(FoodUtility), "ThoughtsFromIngesting")]
|
2021-11-17 06:28:13 +00:00
|
|
|
|
public static void Postfix(ref List<FoodUtility.ThoughtFromIngesting> __result, ref List<FoodUtility.ThoughtFromIngesting> ___ingestThoughts, Pawn ingester, Thing foodSource, ThingDef foodDef)
|
2021-11-17 05:37:17 +00:00
|
|
|
|
{
|
2021-11-17 19:36:41 +00:00
|
|
|
|
/**
|
|
|
|
|
* checks if food has milk or not
|
|
|
|
|
*/
|
2021-11-17 05:37:17 +00:00
|
|
|
|
|
|
|
|
|
if (ingester.Ideo != null)
|
|
|
|
|
{
|
2021-11-17 19:36:41 +00:00
|
|
|
|
|
|
|
|
|
CompIngredients ingredients = foodSource.TryGetComp<CompIngredients>();
|
2021-11-17 05:37:17 +00:00
|
|
|
|
if (foodDef == ThingDefOf_Milk.HumanMilk || foodDef == ThingDefOf_Milk.HumanoidMilk)
|
|
|
|
|
{
|
|
|
|
|
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkRaw, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef));
|
2021-11-17 06:28:13 +00:00
|
|
|
|
|
|
|
|
|
__result = ___ingestThoughts;
|
|
|
|
|
|
2021-11-17 05:37:17 +00:00
|
|
|
|
}
|
2021-11-17 19:36:41 +00:00
|
|
|
|
else if (ingredients == null
|
2022-08-06 05:04:35 +00:00
|
|
|
|
|| !(ingredients.ingredients.Contains(ThingDefOf_Milk.HumanMilk) || (ingredients.ingredients.Contains(ThingDefOf_Milk.HumanoidMilk)))
|
|
|
|
|
&& !LactationUtility.IsHucow(ingester)) {
|
2021-11-17 19:36:41 +00:00
|
|
|
|
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankNonMilkMeal, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef));
|
|
|
|
|
__result = ___ingestThoughts;
|
|
|
|
|
}
|
2021-11-17 05:37:17 +00:00
|
|
|
|
|
2021-11-17 05:39:06 +00:00
|
|
|
|
|
2021-11-17 05:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(FoodUtility), "AddIngestThoughtsFromIngredient")]
|
|
|
|
|
public static void Postfix(ThingDef ingredient, Pawn ingester) {
|
|
|
|
|
|
|
|
|
|
MeatSourceCategory meatSourceCategory = FoodUtility.GetMeatSourceCategory(ingredient);
|
|
|
|
|
|
2021-11-17 06:13:27 +00:00
|
|
|
|
if (ingester.Ideo != null)
|
2021-11-17 05:37:17 +00:00
|
|
|
|
{
|
2021-11-17 06:13:27 +00:00
|
|
|
|
|
2022-08-11 16:14:57 +00:00
|
|
|
|
if (ingredient == ThingDefOf_Milk.HumanoidMilk || ingredient == ThingDefOf_Milk.HumanMilk || ingredient.defName == "VCE_HumanoidCheese")
|
2021-11-17 06:13:27 +00:00
|
|
|
|
{
|
|
|
|
|
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkMeal, ingester, ingredient, meatSourceCategory);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 05:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 19:36:41 +00:00
|
|
|
|
[HarmonyPatch(typeof(FoodUtility), "GenerateGoodIngredients")]
|
|
|
|
|
public static void Postfix(Thing meal, Ideo ideo)
|
|
|
|
|
{
|
|
|
|
|
CompIngredients compIngredients = meal.TryGetComp<CompIngredients>();
|
|
|
|
|
|
2022-08-09 21:56:13 +00:00
|
|
|
|
if(ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_Essential) ||
|
|
|
|
|
ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_MandatoryHucow))
|
2021-11-17 19:36:41 +00:00
|
|
|
|
{
|
|
|
|
|
compIngredients.ingredients.Add(ThingDefOf_Milk.HumanMilk);
|
|
|
|
|
compIngredients.ingredients.Add(ThingDefOf_Milk.HumanoidMilk);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 05:37:17 +00:00
|
|
|
|
}
|
2022-08-11 02:13:43 +00:00
|
|
|
|
}
|