rimworld-animations-patch_m.../Source/Scripts/Patches/HarmonyPatch_DrawGUIOverlay.cs

49 lines
1.2 KiB
C#
Raw Normal View History

2022-09-10 01:22:08 +00:00
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;
}
}
}