2022-05-10 06:47:51 +00:00
|
|
|
|
using HarmonyLib;
|
2022-06-13 05:51:09 +00:00
|
|
|
|
using RJWSexperience.SexHistory;
|
2022-05-10 06:47:51 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace RJWSexperience
|
|
|
|
|
{
|
2023-03-24 15:56:21 +00:00
|
|
|
|
[HarmonyPatch(typeof(Pawn), nameof(Pawn.GetGizmos))]
|
2022-05-10 06:47:51 +00:00
|
|
|
|
public static class Pawn_GetGizmos
|
|
|
|
|
{
|
2023-03-24 15:22:54 +00:00
|
|
|
|
private static Configurations Settings => SexperienceMod.Settings;
|
2022-06-11 12:32:15 +00:00
|
|
|
|
|
2023-03-24 15:56:21 +00:00
|
|
|
|
public static bool Prepare() => Settings.EnableSexHistory;
|
2022-06-07 03:46:19 +00:00
|
|
|
|
|
2022-05-10 06:47:51 +00:00
|
|
|
|
public static void Postfix(ref IEnumerable<Gizmo> __result, Pawn __instance)
|
|
|
|
|
{
|
2022-06-11 12:32:15 +00:00
|
|
|
|
if (Settings.HideGizmoWhenDrafted && __instance.Drafted)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-05-10 06:47:51 +00:00
|
|
|
|
if (Find.Selector.NumSelected > 1)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-06-11 12:32:15 +00:00
|
|
|
|
if (Settings.HideGizmoWithRJW && !rjw.RJWSettings.show_RJW_designation_box)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-06-04 08:40:40 +00:00
|
|
|
|
SexHistoryComp history = __instance.TryGetComp<SexHistoryComp>();
|
|
|
|
|
if (history == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-06-11 12:32:15 +00:00
|
|
|
|
__result = AddHistoryGizmo(history.Gizmo, __result);
|
2022-05-10 06:47:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 12:32:15 +00:00
|
|
|
|
private static IEnumerable<Gizmo> AddHistoryGizmo(Gizmo historyGizmo, IEnumerable<Gizmo> gizmos)
|
2022-05-10 06:47:51 +00:00
|
|
|
|
{
|
|
|
|
|
foreach (Gizmo gizmo in gizmos)
|
|
|
|
|
yield return gizmo;
|
|
|
|
|
|
2022-06-11 12:32:15 +00:00
|
|
|
|
yield return historyGizmo;
|
2022-05-10 06:47:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|