private static bool PartNeedsMaintenance(Hediff_AddedPart part) { if (part.TryGetComp <AddedPartMaintenance>()?.NeedsMaintenance ?? false) { return(true); } if (part.TryGetComp <AddedPartBreakdownable>()?.IsBrokenDown ?? false) { return(true); } if (part.TryGetComp <AddedPartDamageable>()?.NeedsRepair ?? false) { return(true); } return(false); }
private static void PartSystem(Hediff_AddedPart __instance, DamageInfo?dinfo) { HediffComp_PartSystem partSystem = __instance.TryGetComp <HediffComp_PartSystem>(); if (partSystem != null) { partSystem.SpecialPostAdd(dinfo); } }
private static bool ToggleAndCheckPart <T>( Hediff_AddedPart part, Func <bool> check, bool fallback = false ) where T : HediffComp, AddedPartEffectivenessModifier { var comp = part.TryGetComp <T>(); if (comp == null) { return(fallback); } var enabled = CheckFeature(comp, true, check); var disabled = CheckFeature(comp, false, check); CheckFeature(comp, null, () => true); return(enabled != disabled); }