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; if (Pawn.HasIUD()) antisperm = 0.70f + asafactor;
else antisperm = 0.0f + 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) if (absorber != null)
{ {
absorber.WearEffect(TickInterval); absorber.WearEffect(TickInterval);

View file

@ -43,14 +43,14 @@ namespace RJW_Menstruation
switch (parent) switch (parent)
{ {
case Hediff_Pregnant hediff_Pregnant: 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>(); HediffComp_PregeneratedBabies laborcomp = labor?.TryGetComp<HediffComp_PregeneratedBabies>();
if (laborcomp == null) return; if (laborcomp == null) return;
laborcomp.babies = this.babies; laborcomp.babies = this.babies;
laborcomp.enzygoticSiblings = this.enzygoticSiblings; laborcomp.enzygoticSiblings = this.enzygoticSiblings;
break; break;
case Hediff_Labor hediff_Labor: 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>(); HediffComp_PregeneratedBabies pushingcomp = pushing?.TryGetComp<HediffComp_PregeneratedBabies>();
if (pushingcomp == null) return; if (pushingcomp == null) return;
pushingcomp.babies = this.babies; pushingcomp.babies = this.babies;