Use OfType in places where it'd be useful

This commit is contained in:
lutepickle 2024-05-10 21:23:46 -07:00
parent 7f6309466a
commit 3cd1220283
2 changed files with 3 additions and 3 deletions

View File

@ -971,7 +971,7 @@ namespace RJW_Menstruation
if (Pawn.HasIUD()) antisperm = 0.70f + asafactor;
else antisperm = 0.0f + asafactor;
absorber = (Absorber)Pawn.apparel?.WornApparel.Find(x => x is Absorber);
absorber = Pawn.apparel?.WornApparel.OfType<Absorber>().FirstOrDefault();
if (absorber != null)
{
absorber.WearEffect(TickInterval);

View File

@ -43,14 +43,14 @@ namespace RJW_Menstruation
switch (parent)
{
case Hediff_Pregnant hediff_Pregnant:
Hediff_Labor labor = (Hediff_Labor)Pawn.health.hediffSet.hediffs.Where(hediff => hediff is Hediff_Labor).MaxByWithFallback(hediff => hediff.loadID);
Hediff_Labor labor = Pawn.health.hediffSet.hediffs.OfType<Hediff_Labor>().MaxByWithFallback(hediff => hediff.loadID);
HediffComp_PregeneratedBabies laborcomp = labor?.TryGetComp<HediffComp_PregeneratedBabies>();
if (laborcomp == null) return;
laborcomp.babies = this.babies;
laborcomp.enzygoticSiblings = this.enzygoticSiblings;
break;
case Hediff_Labor hediff_Labor:
Hediff_LaborPushing pushing = (Hediff_LaborPushing)Pawn.health.hediffSet.hediffs.Where(hediff => hediff is Hediff_LaborPushing).MaxByWithFallback(hediff => hediff.loadID);
Hediff_LaborPushing pushing = Pawn.health.hediffSet.hediffs.OfType<Hediff_LaborPushing>().MaxByWithFallback(hediff => hediff.loadID);
HediffComp_PregeneratedBabies pushingcomp = pushing?.TryGetComp<HediffComp_PregeneratedBabies>();
if (pushingcomp == null) return;
pushingcomp.babies = this.babies;