Switch deadeggs to a HashSet

This commit is contained in:
lutepickle 2023-03-19 22:48:04 -07:00
parent 310c03a193
commit f7e3d6c1c4
1 changed files with 4 additions and 12 deletions

View File

@ -1364,7 +1364,7 @@ namespace RJW_Menstruation
{ {
if (eggs.NullOrEmpty()) return false; if (eggs.NullOrEmpty()) return false;
List<Egg> deadeggs = new List<Egg>(); HashSet<Egg> deadeggs = new HashSet<Egg>();
bool pregnant = false; bool pregnant = false;
foreach (Egg egg in eggs) foreach (Egg egg in eggs)
{ {
@ -1474,12 +1474,7 @@ namespace RJW_Menstruation
return true; return true;
} }
else else
{ eggs.RemoveAll(egg => deadeggs.Contains(egg));
foreach (Egg egg in deadeggs)
{
eggs.Remove(egg);
}
}
return pregnant; return pregnant;
} }
@ -1549,7 +1544,7 @@ namespace RJW_Menstruation
protected void EggDecay() protected void EggDecay()
{ {
List<Egg> deadeggs = new List<Egg>(); HashSet<Egg> deadeggs = new HashSet<Egg>();
foreach (Egg egg in eggs) foreach (Egg egg in eggs)
{ {
egg.position += Configurations.CycleAcceleration; egg.position += Configurations.CycleAcceleration;
@ -1560,10 +1555,7 @@ namespace RJW_Menstruation
if (egg.lifespanhrs < 0) deadeggs.Add(egg); if (egg.lifespanhrs < 0) deadeggs.Add(egg);
} }
} }
foreach (Egg egg in deadeggs) eggs.RemoveAll(egg => deadeggs.Contains(egg));
{
eggs.Remove(egg);
}
} }
protected void AddCrampPain() protected void AddCrampPain()