While I'm at it, add an allanuses hashset.

This commit is contained in:
lutepickle 2022-09-27 16:36:29 -07:00
parent 6b585afa86
commit e9671624c0
3 changed files with 26 additions and 2 deletions

View File

@ -273,7 +273,7 @@ namespace RJW_Menstruation
public static Texture2D GetAnalIcon(this Pawn pawn, bool drawOrigin = false)
{
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("anus"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def));
if (hediff == null) return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true);
string icon;

View File

@ -331,7 +331,7 @@ namespace RJW_Menstruation
}
public static string GetAnusLabel(this Pawn pawn)
{
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault((Hediff h) => h.def.defName.ToLower().Contains("anus"));
Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def));
if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
else return "";
}

View File

@ -50,6 +50,7 @@ namespace RJW_Menstruation
private static List<ThingDef> allraces = null;
private static List<PawnKindDef> allkinds = null;
private static HashSet<HediffDef> allvaginas = null;
private static HashSet<HediffDef> allanuses = null;
private static HashSet<HediffDef> allbreasts = null;
public static List<ThingDef> AllRaces
@ -97,6 +98,29 @@ namespace RJW_Menstruation
return allvaginas;
}
}
public static HashSet<HediffDef> AllAnuses
{
get
{
if (allanuses != null) return allanuses;
allanuses = new HashSet<HediffDef>();
foreach (HediffDef hediffDef in DefDatabase<HediffDef>.AllDefsListForReading)
{
if (hediffDef.comps.NullOrEmpty()) continue;
foreach (HediffCompProperties comp in hediffDef.comps)
{
if (comp.compClass == typeof(HediffComp_Anus) || (comp.compClass?.IsSubclassOf(typeof(HediffComp_Anus)) ?? false))
{
allanuses.Add(hediffDef);
break;
}
}
}
return allanuses;
}
}
public static HashSet<HediffDef> AllBreasts
{
get