added tracker for when pawn last ingested human milk

This commit is contained in:
c0ffee 2021-11-17 09:59:06 -08:00
parent 994a525cb7
commit e1a817c55f
5 changed files with 58 additions and 2 deletions

View File

@ -76,6 +76,7 @@
<Compile Include="Source\Comps\CompInduceLactation.cs" />
<Compile Include="Source\HarmonyPatches\HarmonyPatch_FoodUtility.cs" />
<Compile Include="Source\HarmonyPatches\HarmonyPatch_Ideo.cs" />
<Compile Include="Source\HarmonyPatches\HarmonyPatch_Thing.cs" />
<Compile Include="Source\HarmonyPatches\Harmony_PatchAll.cs" />
<Compile Include="Source\HarmonyPatches\RJW\HarmonyPatch_Milk_HumanCompHasGatherableBodyResource.cs" />
<Compile Include="Source\HediffDefOf\HediffDefOf_Milk.cs" />
@ -93,6 +94,7 @@
<Compile Include="Source\ThingDefOf\ThingDefOf_Milk.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" />
<Compile Include="Source\WorkGivers\WorkGiver_MassageBreasts.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -16,9 +16,12 @@ namespace CRIALactation
private int TicksSinceLastMassage = -60000;
private float InductionCompletionPercent = 0f;
public bool isActive = false;
public bool CanMassage = true;
public int lastHumanLactationIngestedTick = 0;
public override void CompTick()
{
base.CompTick();
@ -107,6 +110,7 @@ namespace CRIALactation
base.PostExposeData();
Scribe_Values.Look<float>(ref this.InductionCompletionPercent, "InductionCompletionPercent", 0f);
Scribe_Values.Look<int>(ref this.TicksSinceLastMassage, "TicksSinceLastMassage", -60000);
Scribe_Values.Look<int>(ref this.lastHumanLactationIngestedTick, "lastHumanLactationIngestedTick", 0);
Scribe_Values.Look<bool>(ref this.isActive, "IsActive", false);
Scribe_Values.Look<bool>(ref this.CanMassage, "CanMassage", false);

View File

@ -53,11 +53,9 @@ namespace CRIALactation
AddThoughtsFromIdeo_Patch(HistoryEventDefOf_Milk.DrankMilkMeal, ingester, ingredient, meatSourceCategory);
}
}
}
}
}

View File

@ -0,0 +1,25 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
namespace CRIALactation
{
[HarmonyPatch(typeof(Thing), "Ingested")]
public static class HarmonyPatch_Thing
{
public static void Prefix(Thing __instance, Pawn ingester)
{
if(__instance.def == ThingDefOf_Milk.HumanMilk || __instance.def == ThingDefOf_Milk.HumanoidMilk)
{
ingester.TryGetComp<CompInduceLactation>().lastHumanLactationIngestedTick = Find.TickManager.TicksGame;
}
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using UnityEngine;
namespace CRIALactation
{
public class ThoughtWorker_Precept_NoRecentHumanMilk : ThoughtWorker_Precept, IPreceptCompDescriptionArgs
{
public IEnumerable<NamedArgument> GetDescriptionArgs()
{
yield return MinDaysSinceLastHumanMeatForThought.Named("HUMANMILKREQUIREDINTERVAL");
}
protected override ThoughtState ShouldHaveThought(Pawn p)
{
int num = Mathf.Max(0, p.TryGetComp<CompInduceLactation>().lastHumanLactationIngestedTick);
return Find.TickManager.TicksGame - num > 480000;
}
public const int MinDaysSinceLastHumanMeatForThought = 8;
}
}