rimworld-animations-patch_m.../Source/Scripts/Patches/HarmonyPatch_DrawGUIOverlay.cs
AbstractConcept 8e6918ae70 First commit
2022-09-09 20:22:08 -05:00

49 lines
No EOL
1.2 KiB
C#

using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using UnityEngine;
using RimWorld;
using Verse;
using AlienRace;
namespace Rimworld_Animations_Patch
{
[StaticConstructorOnStartup]
[HarmonyPatch(typeof(Building_Bed), "DrawGUIOverlay")]
public static class HarmonyPatch_Building_Bed_DrawGUIOverlay
{
// Patches beds so sleeping spot names are hidden when the owner is having sex on it
public static bool Prefix(Building_Bed __instance)
{
foreach (Pawn pawn in __instance.OwnersForReading)
{
if (pawn.GetAnimationData() != null && pawn.IsInBed(out Building bed) && bed == __instance)
{ return false; }
}
return true;
}
}
[StaticConstructorOnStartup]
[HarmonyPatch(typeof(PawnUIOverlay), "DrawPawnGUIOverlay")]
public static class HarmonyPatch_PawnUIOverlay_DrawPawnGUIOverlay
{
// Patches pawns so their name is hidden when having sex
public static bool Prefix(PawnUIOverlay __instance)
{
if (BasicSettings.hideNamesForSex)
{
Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnUIOverlay), "pawn").GetValue(__instance);
if (pawn.GetAnimationData() != null)
{ return false; }
}
return true;
}
}
}