mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Consolidate the three HashSet fillers into one function
This commit is contained in:
parent
4a41bb69f4
commit
cf6fd77ea8
1 changed files with 19 additions and 45 deletions
|
@ -1,5 +1,6 @@
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using rjw;
|
using rjw;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Verse;
|
using Verse;
|
||||||
|
@ -74,26 +75,27 @@ namespace RJW_Menstruation
|
||||||
return allkinds;
|
return allkinds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static HashSet<HediffDef> GetCompHashSet(Type type)
|
||||||
|
{
|
||||||
|
HashSet<HediffDef> set = new HashSet<HediffDef>();
|
||||||
|
foreach (HediffDef hediffDef in DefDatabase<HediffDef>.AllDefsListForReading)
|
||||||
|
{
|
||||||
|
if (hediffDef.comps.NullOrEmpty()) continue;
|
||||||
|
foreach (HediffCompProperties comp in hediffDef.comps)
|
||||||
|
if (comp.compClass == type || (comp.compClass?.IsSubclassOf(type) ?? false))
|
||||||
|
{
|
||||||
|
set.Add(hediffDef);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
public static HashSet<HediffDef> AllVaginas
|
public static HashSet<HediffDef> AllVaginas
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (allvaginas != null) return allvaginas;
|
if (allvaginas != null) return allvaginas;
|
||||||
allvaginas = new HashSet<HediffDef>();
|
allvaginas = GetCompHashSet(typeof(HediffComp_Menstruation));
|
||||||
|
|
||||||
foreach(HediffDef hediffDef in DefDatabase<HediffDef>.AllDefsListForReading)
|
|
||||||
{
|
|
||||||
if (hediffDef.comps.NullOrEmpty()) continue;
|
|
||||||
foreach (HediffCompProperties comp in hediffDef.comps)
|
|
||||||
{
|
|
||||||
if (comp.compClass == typeof(HediffComp_Menstruation) || (comp.compClass?.IsSubclassOf(typeof(HediffComp_Menstruation)) ?? false))
|
|
||||||
{
|
|
||||||
allvaginas.Add(hediffDef);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return allvaginas;
|
return allvaginas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,21 +104,7 @@ namespace RJW_Menstruation
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (allanuses != null) return allanuses;
|
if (allanuses != null) return allanuses;
|
||||||
allanuses = new HashSet<HediffDef>();
|
allanuses = GetCompHashSet(typeof(HediffComp_Anus));
|
||||||
|
|
||||||
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;
|
return allanuses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,21 +113,7 @@ namespace RJW_Menstruation
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (allbreasts != null) return allbreasts;
|
if (allbreasts != null) return allbreasts;
|
||||||
allbreasts = new HashSet<HediffDef>();
|
allbreasts = GetCompHashSet(typeof(HediffComp_Breast));
|
||||||
|
|
||||||
foreach(HediffDef hediffDef in DefDatabase<HediffDef>.AllDefsListForReading)
|
|
||||||
{
|
|
||||||
if (hediffDef.comps.NullOrEmpty()) continue;
|
|
||||||
foreach(HediffCompProperties comp in hediffDef.comps)
|
|
||||||
{
|
|
||||||
if (comp.compClass == typeof(HediffComp_Breast) || (comp.compClass?.IsSubclassOf(typeof(HediffComp_Breast)) ?? false))
|
|
||||||
{
|
|
||||||
allbreasts.Add(hediffDef);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return allbreasts;
|
return allbreasts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue