public static void DoTend(Pawn doctor, Pawn patient, Medicine medicine) { if (!patient.health.HasHediffsNeedingTend(false)) { return; } if (medicine != null && medicine.Destroyed) { Log.Warning("Tried to use destroyed medicine.", false); medicine = null; } float quality = TendUtility.CalculateBaseTendQuality(doctor, patient, (medicine == null) ? null : medicine.def); TendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medicine != null, TendUtility.tmpHediffsToTend, null); for (int i = 0; i < TendUtility.tmpHediffsToTend.Count; i++) { TendUtility.tmpHediffsToTend[i].Tended(quality, i); } if (doctor != null && doctor.Faction == Faction.OfPlayer && patient.Faction != doctor.Faction && !patient.IsPrisoner && patient.Faction != null) { patient.mindState.timesGuestTendedToByPlayer++; } if (doctor != null && doctor.IsColonistPlayerControlled) { patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer); } if (doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal && RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f) && doctor.Faction != null && doctor.Faction != patient.Faction) { InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false); } patient.records.Increment(RecordDefOf.TimesTendedTo); if (doctor != null) { doctor.records.Increment(RecordDefOf.TimesTendedOther); } if (doctor == patient && !doctor.Dead) { doctor.mindState.Notify_SelfTended(); } if (medicine != null) { if ((patient.Spawned || (doctor != null && doctor.Spawned)) && medicine != null && medicine.GetStatValue(StatDefOf.MedicalPotency, true) > ThingDefOf.MedicineIndustrial.GetStatValueAbstract(StatDefOf.MedicalPotency, null)) { SoundDefOf.TechMedicineUsed.PlayOneShot(new TargetInfo(patient.Position, patient.Map, false)); } if (medicine.stackCount > 1) { medicine.stackCount--; } else if (!medicine.Destroyed) { medicine.Destroy(DestroyMode.Vanish); } } }
public static void DoTend(Pawn doctor, Pawn patient, Medicine medicine) { if (patient.health.HasHediffsNeedingTend(false)) { if (medicine != null && medicine.Destroyed) { Log.Warning("Tried to use destroyed medicine."); medicine = null; } float num = (float)((medicine == null) ? 0.30000001192092896 : medicine.def.GetStatValueAbstract(StatDefOf.MedicalPotency, null)); float num2 = (float)((doctor == null) ? 0.75 : doctor.GetStatValue(StatDefOf.MedicalTendQuality, true)); num2 *= num; Building_Bed building_Bed = patient.CurrentBed(); if (building_Bed != null) { num2 += building_Bed.GetStatValue(StatDefOf.MedicalTendQualityOffset, true); } if (doctor == patient) { num2 = (float)(num2 * 0.699999988079071); } num2 = Mathf.Clamp01(num2); TendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medicine != null, TendUtility.tmpHediffsToTend, null); for (int i = 0; i < TendUtility.tmpHediffsToTend.Count; i++) { TendUtility.tmpHediffsToTend[i].Tended(num2, i); } if (doctor != null && doctor.Faction != null && patient.HostFaction == null && patient.Faction != null && patient.Faction != doctor.Faction) { patient.Faction.AffectGoodwillWith(doctor.Faction, 0.3f); } if (doctor != null && doctor.IsColonistPlayerControlled) { patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer); } if (doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal && RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f) && doctor.Faction != null && doctor.Faction != patient.Faction) { InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false); } patient.records.Increment(RecordDefOf.TimesTendedTo); if (doctor != null) { doctor.records.Increment(RecordDefOf.TimesTendedOther); } if (medicine != null) { if ((patient.Spawned || (doctor != null && doctor.Spawned)) && num > ThingDefOf.Medicine.GetStatValueAbstract(StatDefOf.MedicalPotency, null)) { SoundDefOf.TechMedicineUsed.PlayOneShot(new TargetInfo(patient.Position, patient.Map, false)); } if (medicine.stackCount > 1) { medicine.stackCount--; } else if (!medicine.Destroyed) { medicine.Destroy(DestroyMode.Vanish); } } } }