mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
124 lines
4.2 KiB
C#
124 lines
4.2 KiB
C#
using HarmonyLib;
|
|
using RimWorld;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace RJW_Menstruation
|
|
{
|
|
|
|
[HarmonyPatch(typeof(Pawn), nameof(Pawn.SpawnSetup))]
|
|
public class Pawn_Patch
|
|
{
|
|
public static void Postfix(Pawn __instance)
|
|
{
|
|
//Log.Message("Initialize on spawnsetup");
|
|
foreach (HediffComp_Menstruation comp in __instance.GetMenstruationComps())
|
|
{
|
|
comp.Initialize();
|
|
}
|
|
|
|
__instance.GetBreastComp()?.Initialize();
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(FloatMenuMakerMap), "AddHumanlikeOrders")]
|
|
public class HumanlikeOrder_Patch
|
|
{
|
|
public static void Postfix(Vector3 clickPos, Pawn pawn, List<FloatMenuOption> opts)
|
|
{
|
|
IEnumerable<LocalTargetInfo> selftargets = GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn));
|
|
|
|
foreach (LocalTargetInfo t in selftargets)
|
|
{
|
|
if (t.Pawn == pawn && pawn.HasMenstruationComp()) opts.AddDistinct(MakeSelfMenu(pawn, t));
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public static FloatMenuOption MakeSelfMenu(Pawn pawn, LocalTargetInfo target)
|
|
{
|
|
FloatMenuOption option = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(Translations.FloatMenu_CleanSelf, delegate ()
|
|
{
|
|
pawn.jobs.TryTakeOrderedJob(new Verse.AI.Job(VariousDefOf.VaginaWashing, null, null, target.Cell));
|
|
}, MenuOptionPriority.Low), pawn, target);
|
|
|
|
return option;
|
|
}
|
|
}
|
|
|
|
//[HarmonyPatch(typeof(HealthCardUtility), "DrawHediffListing")]
|
|
//public class DrawHediffListing_Patch
|
|
//{
|
|
// public const float buttonWidth = 80f;
|
|
// public const float buttonHeight = 20f;
|
|
//
|
|
// public static void Postfix(Rect rect, Pawn pawn, bool showBloodLoss)
|
|
// {
|
|
// if (Configurations.EnableButtonInHT && pawn.HasMenstruationComp())
|
|
// {
|
|
// Rect buttonrect = new Rect(rect.xMax - buttonWidth, rect.yMax - buttonHeight, buttonWidth, buttonHeight);
|
|
// if (Widgets.ButtonText(buttonrect, "Status"))
|
|
// {
|
|
// Dialog_WombStatus.ToggleWindow(pawn,pawn.GetMenstruationComp());
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
//}
|
|
|
|
[HarmonyPatch(typeof(HealthCardUtility), "DrawHediffRow")]
|
|
public class DrawHediffRow_Patch
|
|
{
|
|
public const float buttonWidth = 50f;
|
|
public const float buttonHeight = 20f;
|
|
|
|
private static HediffComp_Menstruation GetFirstMenstruation(IEnumerable<Hediff> diffs)
|
|
{
|
|
foreach (Hediff diff in diffs)
|
|
{
|
|
HediffComp_Menstruation comp = diff.GetMenstruationCompFromVagina();
|
|
if (comp != null) return comp;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void Prefix(Rect rect, Pawn pawn, IEnumerable<Hediff> diffs, ref float curY)
|
|
{
|
|
if (Configurations.EnableButtonInHT && pawn.ShowStatus())
|
|
{
|
|
HediffComp_Menstruation comp = GetFirstMenstruation(diffs);
|
|
if (comp != null)
|
|
{
|
|
Rect buttonrect = new Rect((rect.xMax) / 2 - 5f, curY + 2f, buttonWidth, buttonHeight);
|
|
if (Widgets.ButtonText(buttonrect, Translations.Button_HealthTab))
|
|
{
|
|
Dialog_WombStatus.ToggleWindow(pawn, comp);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[HarmonyPatch(typeof(CompBiosculpterPod), nameof(CompBiosculpterPod.CannotUseNowPawnCycleReason), new Type[] { typeof(Pawn), typeof(Pawn), typeof(CompBiosculpterPod_Cycle), typeof(bool) })]
|
|
public class CannotUseNowPawnCycleReason_Patch
|
|
{
|
|
private const string eggRestorationKey = "eggRestoration";
|
|
public static void Postfix(ref string __result, Pawn biosculptee, CompBiosculpterPod_Cycle cycle)
|
|
{
|
|
if (__result != null) return;
|
|
if (cycle.Props.key == eggRestorationKey && !biosculptee.GetMenstruationComps().Any())
|
|
__result = Translations.CannotNoWomb;
|
|
}
|
|
}
|
|
}
|