public virtual void Repair(Building_RepairStation repairStation) { List <Hediff_Injury> allInjuries = health.hediffSet.GetHediffs <Hediff_Injury>().ToList(); List <Hediff_MissingPart> allMissingParts = health.hediffSet.GetHediffs <Hediff_MissingPart>().ToList(); float num = Rand.Value; if ((allInjuries.Count == 0 || num > 0.6) && allMissingParts.Count > 0 && repairStation != null && repairStation.HasEnoughOf(repairStation.Def.repairThingDef, repairStation.Def.repairCostAmount)) { Hediff_MissingPart hediff = allMissingParts.RandomElement(); if (repairStation.TakeSomeOf(repairStation.Def.repairThingDef, repairStation.Def.repairCostAmount)) { health.hediffSet.RestorePart(hediff.Part.HighestMissingPart(this)); } } else if (allInjuries.Count > 0) { Hediff_Injury hediff = allInjuries.RandomElement(); if (hediff.def.injuryProps.fullyHealableOnlyByTreatment) { HediffComp_Treatable treatable = hediff.TryGetComp <HediffComp_Treatable>(); if (treatable != null && !treatable.treatedWithMedicine) { treatable.NewlyTreated(1f, ThingDefOf.Medicine); } } hediff.DirectHeal(repairStation.Def.repairAmount); } }