diff --git a/CRIALactation/1.3/Assemblies/CRIALactation.dll b/CRIALactation/1.3/Assemblies/CRIALactation.dll index 72bb0ff..07e2c1d 100644 Binary files a/CRIALactation/1.3/Assemblies/CRIALactation.dll and b/CRIALactation/1.3/Assemblies/CRIALactation.dll differ diff --git a/CRIALactation/CRIALactation.csproj b/CRIALactation/CRIALactation.csproj index 4105640..084d84b 100644 --- a/CRIALactation/CRIALactation.csproj +++ b/CRIALactation/CRIALactation.csproj @@ -92,6 +92,9 @@ + + + diff --git a/CRIALactation/Source/HarmonyPatches/HarmonyPatch_FoodUtility.cs b/CRIALactation/Source/HarmonyPatches/HarmonyPatch_FoodUtility.cs index dbcc083..ed1fc1c 100644 --- a/CRIALactation/Source/HarmonyPatches/HarmonyPatch_FoodUtility.cs +++ b/CRIALactation/Source/HarmonyPatches/HarmonyPatch_FoodUtility.cs @@ -58,7 +58,7 @@ namespace CRIALactation if (ingester.Ideo != null) { - if (ingredient == ThingDefOf_Milk.HumanoidMilk || ingredient == ThingDefOf_Milk.HumanMilk) + if (ingredient == ThingDefOf_Milk.HumanoidMilk || ingredient == ThingDefOf_Milk.HumanMilk || ingredient.defName == "VCE_HumanoidCheese") { AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkMeal, ingester, ingredient, meatSourceCategory); } diff --git a/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_Milk.cs b/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_Milk.cs new file mode 100644 index 0000000..3e7260c --- /dev/null +++ b/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_Milk.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace CRIALactation.Source.ThingFilters +{ + class SpecialThingFilterWorker_Milk : SpecialThingFilterWorker_MilkBase + { + public override bool Matches(Thing t) + { + return IsHumanMilk(t) || IsFoodWithMilk(t); + } + } +} diff --git a/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_MilkBase.cs b/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_MilkBase.cs new file mode 100644 index 0000000..958688d --- /dev/null +++ b/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_MilkBase.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RimWorld; +using Verse; +using Milk; + +namespace CRIALactation +{ + public abstract class SpecialThingFilterWorker_MilkBase : SpecialThingFilterWorker + { + + protected bool IsHumanMilk(ThingDef t) => t == ThingDefOf_Milk.HumanMilk || t == ThingDefOf_Milk.HumanoidMilk; + + protected bool IsHumanMilk(Thing t) => IsHumanMilk(t.def); + + public override bool CanEverMatch(ThingDef def) + { + return def.IsIngestible && def.IsProcessedFood; + } + + protected bool IsFoodWithMilk(Thing food) + { + CompIngredients compIngredients = food.TryGetComp(); + + if (compIngredients == null) + return false; + + foreach (ThingDef ingredient in compIngredients.ingredients) + { + if (IsHumanMilk(ingredient)) + return true; + } + + return false; + } + + + } +} diff --git a/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_NoMilk.cs b/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_NoMilk.cs new file mode 100644 index 0000000..637a20a --- /dev/null +++ b/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_NoMilk.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace CRIALactation +{ + class SpecialThingFilterWorker_NoMilk : SpecialThingFilterWorker_MilkBase + { + public override bool Matches(Thing t) + { + return !(IsHumanMilk(t) || IsFoodWithMilk(t)); + } + } +}