public static bool ErrorOnIgnoredPart(HediffSet __instance, Hediff hediff) { if (!(hediff is Hediff_MissingPart) && __instance.PartShouldBeIgnored(hediff.Part)) { Log.Error("Tried to add health diff to part that should be ignored. Canceling.", false); return(false); } return(true); }
public static bool PartShouldBeIgnored(this HediffSet set, BodyPartRecord bodyPart) { if (bodyPart != null && bodyPart.parent != null) { var modExt = set.GetHediffs <Hediff_AddedPart>() .FirstOrDefault(h => h.Part == bodyPart.parent)? // added part on parent bodypartrecord .def.GetModExtension <IgnoreSubParts>(); return ((modExt != null && modExt.ignoredSubParts.Contains(bodyPart.def)) || set.PartShouldBeIgnored(bodyPart.parent)); } return(false); }
public static bool Prefix(ref float __result, HediffSet diffSet, BodyPartRecord part, bool ignoreAddedParts, List <PawnCapacityUtility.CapacityImpactor> impactors) { if (diffSet.PartShouldBeIgnored(part)) { if (part.parent == null) { __result = 1f; } else { __result = PawnCapacityUtility.CalculatePartEfficiency(diffSet, part.parent, ignoreAddedParts, impactors); } return(false); } return(true); }