rjw_menstruation/1.2/source/RJW_Menstruation/RJW_Menstruation/HARCompatibility.cs

32 lines
809 B
C#

using System.Linq;
using Verse;
namespace RJW_Menstruation
{
public static class HARCompatibility
{
public static bool IsHAR(this Pawn pawn)
{
return pawn.def.GetType().ToString().StartsWith("AlienRace");
}
public static ThingComp GetHARComp(this Pawn pawn)
{
return pawn?.GetComps<ThingComp>()?.First(x => x.GetType().Namespace.EqualsIgnoreCase("AlienRace") && x.GetType().Name.EndsWith("AlienComp"));
}
public static string GetHARCrown(this Pawn pawn)
{
return (string)pawn.GetHARComp().GetMemberValue("crownType");
}
public static void SetHARCrown(this Pawn pawn, string crown)
{
pawn.GetHARComp().SetMemberValue("crownType", crown);
}
}
}