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) { //throw new NotImplementedException("thoughts from ideo wasn't implemented!"); } [HarmonyPatch(typeof(FoodUtility), "ThoughtsFromIngesting")] public static void Postfix(ref List __result, ref List ___ingestThoughts, Pawn ingester, Thing foodSource, ThingDef foodDef) { /** * checks if food has milk or not */ if (ingester.Ideo != null) { CompIngredients ingredients = foodSource.TryGetComp(); if (foodDef == ThingDefOf_Milk.HumanMilk || foodDef == ThingDefOf_Milk.HumanoidMilk) { AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkRaw, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef)); __result = ___ingestThoughts; } else if (ingredients == null || !(ingredients.ingredients.Contains(ThingDefOf_Milk.HumanMilk) || (ingredients.ingredients.Contains(ThingDefOf_Milk.HumanoidMilk))) && !LactationUtility.IsHucow(ingester)) { AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankNonMilkMeal, ingester, foodDef, FoodUtility.GetMeatSourceCategory(foodDef)); __result = ___ingestThoughts; } } } [HarmonyPatch(typeof(FoodUtility), "AddIngestThoughtsFromIngredient")] public static void Postfix(ThingDef ingredient, Pawn ingester) { MeatSourceCategory meatSourceCategory = FoodUtility.GetMeatSourceCategory(ingredient); if (ingester.Ideo != null) { if (ingredient == ThingDefOf_Milk.HumanoidMilk || ingredient == ThingDefOf_Milk.HumanMilk || ingredient.defName == "VCE_HumanoidCheese") { AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkMeal, ingester, ingredient, meatSourceCategory); } } } [HarmonyPatch(typeof(FoodUtility), "GenerateGoodIngredients")] public static void Postfix(Thing meal, Ideo ideo) { CompIngredients compIngredients = meal.TryGetComp(); if(ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_Essential) || ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_MandatoryHucow)) { compIngredients.ingredients.Add(ThingDefOf_Milk.HumanMilk); compIngredients.ingredients.Add(ThingDefOf_Milk.HumanoidMilk); } } } }