private float CalculateForDirectChildren(HediffSet diffSet, BodyPartRecord part, BodyPartTagDef partTag, List <PawnCapacityUtility.CapacityImpactor> impactors) { float value = 0; int partCount = 0; foreach (BodyPartRecord partWithTag in part.parts.Where(t => t.def.tags.Contains(partTag))) { value += PawnCapacityUtility.CalculateImmediatePartEfficiencyAndRecord(diffSet, partWithTag, impactors); partCount++; } if (partCount == 0) { return(0f); } return(value / partCount); }
private float CalculateForLimbs(HediffSet diffSet, BodyPartTagDef limbCore, List <PawnCapacityUtility.CapacityImpactor> impactors) { BodyDef body = diffSet.pawn.RaceProps.body; float totalValue = 0; int partCount = 0; foreach (BodyPartRecord limb in body.GetPartsWithTag(limbCore)) { var conduitParts = limb.GetChildParts(GethCoolingTags.GethCoolantConduit); if (!conduitParts.Any()) { continue; } float value = 1; foreach (BodyPartRecord conduitPart in conduitParts) { value *= PawnCapacityUtility.CalculateImmediatePartEfficiencyAndRecord(diffSet, conduitPart, impactors); } float heatExchangerValue = 0; int heatExchangerCount = 0; foreach (BodyPartRecord heatExchangerPart in limb.GetChildParts(GethCoolingTags.GethHeatExchanger)) { heatExchangerValue += PawnCapacityUtility.CalculateImmediatePartEfficiencyAndRecord(diffSet, heatExchangerPart, impactors); heatExchangerCount++; } totalValue += value * (heatExchangerValue / heatExchangerCount); partCount++; } if (partCount == 0) { return(0f); } return(totalValue / partCount); }