coffees-rjw-ideology-addons/CRIALactation/Source/ThingFilters/SpecialThingFilterWorker_Mi...

43 lines
1006 B
C#
Raw Normal View History

2022-08-11 16:14:57 +00:00
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
{
2023-02-06 03:05:01 +00:00
protected bool IsHumanMilk(ThingDef t) => t == ThingDefOf_Milk.HumanMilk || t == ThingDefOf_Milk.HumanoidMilk || t == ThingDefOf_Milk.HumanoidMilkBulk || t == ThingDefOf_Milk.HumanMilkBulk;
2022-08-11 16:14:57 +00:00
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<CompIngredients>();
if (compIngredients == null)
return false;
foreach (ThingDef ingredient in compIngredients.ingredients)
{
if (IsHumanMilk(ingredient))
return true;
}
return false;
}
}
}