rjw_menstruation/1.3/source/RJW_Menstruation/SexperienceModule/Patch/RJW_Patch.cs
2022-07-11 11:52:27 -07:00

46 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
using Verse.AI;
using rjw;
using RJW_Menstruation;
using HarmonyLib;
using RJWSexperience;
namespace RJW_Menstruation.Sexperience
{
[HarmonyPatch(typeof(WorkGiver_CleanSelf))]
public static class RJW_Patch_WorkGiver_CleanSelf
{
[HarmonyPrefix]
[HarmonyPatch("HasJobOnThing")]
public static bool HasJobOnThing(Pawn pawn, ref bool __result)
{
if (pawn.GetMenstruationComps().Any(comp => comp.DoCleanWomb && comp.TotalCumPercent > 0.001f) && pawn.Map.listerBuildings.ColonistsHaveBuilding(VariousDefOf.CumBucket))
{
__result = true;
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch("JobOnThing")]
public static void JobOnThing(Pawn pawn, ref Job __result)
{
if (pawn.GetMenstruationComps().Any(comp => comp.DoCleanWomb && comp.TotalCumPercent > 0.001f))
{
Building_CumBucket bucket = pawn.FindClosestBucket();
if (bucket != null)
{
__result = JobMaker.MakeJob(VariousDefOf.VaginaWashingwithBucket, null, bucket, bucket.Position);
}
}
}
}
}