filters and vanilla cooking expanded

This commit is contained in:
c0ffee 2022-08-11 09:14:57 -07:00
parent 266356123e
commit 40a681a685
6 changed files with 80 additions and 1 deletions

View file

@ -92,6 +92,9 @@
<Compile Include="Source\RoleRequirements\RoleRequirement_Lactating.cs" />
<Compile Include="Source\StatDefOf\StatDefOf_Lactation.cs" />
<Compile Include="Source\ThingDefOf\ThingDefOf_Milk.cs" />
<Compile Include="Source\ThingFilters\SpecialThingFilterWorker_Milk.cs" />
<Compile Include="Source\ThingFilters\SpecialThingFilterWorker_MilkBase.cs" />
<Compile Include="Source\ThingFilters\SpecialThingFilterWorker_NoMilk.cs" />
<Compile Include="Source\Thoughts\ThoughtWorker_Precept_Lactating_Essential.cs" />
<Compile Include="Source\Thoughts\ThoughtWorker_Precept_Lactating_Essential_Social.cs" />
<Compile Include="Source\Thoughts\ThoughtWorker_Precept_NoRecentHumanMilk.cs" />

View file

@ -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);
}

View file

@ -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);
}
}
}

View file

@ -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<CompIngredients>();
if (compIngredients == null)
return false;
foreach (ThingDef ingredient in compIngredients.ingredients)
{
if (IsHumanMilk(ingredient))
return true;
}
return false;
}
}
}

View file

@ -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));
}
}
}