Refactor DamagePants

This commit is contained in:
lutepickle 2024-05-14 20:51:18 -07:00
parent 9a495ad32b
commit 2516ed1439

View file

@ -441,21 +441,10 @@ namespace RJW_Menstruation
public static float DamagePants(this Pawn pawn, float fluidAmount) public static float DamagePants(this Pawn pawn, float fluidAmount)
{ {
if (pawn.apparel == null) return 0; if (pawn.apparel == null) return 0;
Apparel pants = null; if (!pawn.apparel.WornApparel.
foreach(Apparel apparel in pawn.apparel.WornApparel.Where(app => app.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs))) Where(apparel => apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs)).
{ TryMinBy(apparel => apparel.def.apparel.LastLayer.drawOrder, out Apparel pants))
if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.OnSkin) return 0;
{
pants = apparel;
break;
}
else if (pants == null || apparel.def.apparel.LastLayer == ApparelLayerDefOf.Middle)
// Either grab whatever's available or reassign the pants from shell to a middle
pants = apparel;
// Pants are middle and this is a shell
else continue;
}
if (pants == null) return 0;
const float HPPerMl = 0.5f; const float HPPerMl = 0.5f;