mirror of
https://gitgud.io/c0ffeeeeeeee/coffees-rjw-ideology-addons.git
synced 2024-08-14 23:57:38 +00:00
filters and vanilla cooking expanded
This commit is contained in:
parent
266356123e
commit
40a681a685
6 changed files with 80 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue