public static bool ShouldBeTendedNowUrgent(Pawn pawn) { if (!HealthAIUtility.ShouldBeTendedNow(pawn)) { return(false); } return(HealthUtility.TicksUntilDeathDueToBloodLoss(pawn) < 15000); }
protected override IEnumerable <Toil> MakeNewToils() { _003CMakeNewToils_003Ec__Iterator0 _003CMakeNewToils_003Ec__Iterator = (_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0052: stateMachine*/; this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOn(delegate { if (!WorkGiver_Tend.GoodLayingStatusForTend(_003CMakeNewToils_003Ec__Iterator._0024this.Deliveree, _003CMakeNewToils_003Ec__Iterator._0024this.pawn)) { return(true); } if (_003CMakeNewToils_003Ec__Iterator._0024this.MedicineUsed != null) { if (_003CMakeNewToils_003Ec__Iterator._0024this.Deliveree.playerSettings == null) { return(true); } if (!_003CMakeNewToils_003Ec__Iterator._0024this.Deliveree.playerSettings.medCare.AllowsMedicine(_003CMakeNewToils_003Ec__Iterator._0024this.MedicineUsed.def)) { return(true); } } if (_003CMakeNewToils_003Ec__Iterator._0024this.pawn == _003CMakeNewToils_003Ec__Iterator._0024this.Deliveree && (_003CMakeNewToils_003Ec__Iterator._0024this.pawn.playerSettings == null || !_003CMakeNewToils_003Ec__Iterator._0024this.pawn.playerSettings.selfTend)) { return(true); } return(false); }); base.AddEndCondition(delegate { if (HealthAIUtility.ShouldBeTendedNow(_003CMakeNewToils_003Ec__Iterator._0024this.Deliveree)) { return(JobCondition.Ongoing); } return(JobCondition.Succeeded); }); this.FailOnAggroMentalState(TargetIndex.A); Toil reserveMedicine = null; if (this.usesMedicine) { reserveMedicine = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null).FailOnDespawnedNullOrForbidden(TargetIndex.B); yield return(reserveMedicine); /*Error: Unable to find new state assignment for yield return*/; } PathEndMode interactionCell = (PathEndMode)((this.Deliveree == base.pawn) ? 1 : 4); Toil gotoToil = Toils_Goto.GotoThing(TargetIndex.A, interactionCell); yield return(gotoToil); /*Error: Unable to find new state assignment for yield return*/; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOn(delegate { if (!WorkGiver_Tend.GoodLayingStatusForTend(this.$this.Deliveree, this.$this.pawn)) { return(true); } if (this.$this.MedicineUsed != null) { if (this.$this.Deliveree.playerSettings == null) { return(true); } if (!this.$this.Deliveree.playerSettings.medCare.AllowsMedicine(this.$this.MedicineUsed.def)) { return(true); } } return(this.$this.pawn == this.$this.Deliveree && (this.$this.pawn.playerSettings == null || !this.$this.pawn.playerSettings.selfTend)); }); base.AddEndCondition(delegate { if (HealthAIUtility.ShouldBeTendedNow(this.$this.Deliveree)) { return(JobCondition.Ongoing); } return(JobCondition.Succeeded); }); this.FailOnAggroMentalState(TargetIndex.A); Toil reserveMedicine = null; if (this.usesMedicine) { reserveMedicine = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null).FailOnDespawnedNullOrForbidden(TargetIndex.B); yield return(reserveMedicine); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B)); yield return(Toils_Tend.PickupMedicine(TargetIndex.B, this.Deliveree).FailOnDestroyedOrNull(TargetIndex.B)); yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveMedicine, TargetIndex.B, TargetIndex.None, true, null)); } PathEndMode interactionCell = (this.Deliveree != this.pawn) ? PathEndMode.InteractionCell : PathEndMode.OnCell; Toil gotoToil = Toils_Goto.GotoThing(TargetIndex.A, interactionCell); yield return(gotoToil); int duration = (int)(1f / this.pawn.GetStatValue(StatDefOf.MedicalTendSpeed, true) * 600f); yield return(Toils_General.Wait(duration).FailOnCannotTouch(TargetIndex.A, interactionCell).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f).PlaySustainerOrSound(SoundDefOf.Interact_Tend)); yield return(Toils_Tend.FinalizeTend(this.Deliveree)); if (this.usesMedicine) { yield return(new Toil { initAction = delegate { if (this.$this.MedicineUsed.DestroyedOrNull() && Medicine.GetMedicineCountToFullyHeal(this.$this.Deliveree) > 0) { Thing thing = HealthAIUtility.FindBestMedicine(this.$this.pawn, this.$this.Deliveree); if (thing != null) { this.$this.job.targetB = thing; this.$this.JumpToToil(reserveMedicine); } } } }); } yield return(Toils_Jump.Jump(gotoToil)); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Pawn pawn2 = t as Pawn; if (pawn2 != null && (!this.def.tendToHumanlikesOnly || pawn2.RaceProps.Humanlike) && (!this.def.tendToAnimalsOnly || pawn2.RaceProps.Animal) && WorkGiver_Tend.GoodLayingStatusForTend(pawn2, pawn) && HealthAIUtility.ShouldBeTendedNow(pawn2)) { LocalTargetInfo target = pawn2; if (pawn.CanReserve(target, 1, -1, null, forced)) { return(true); } } return(false); }
public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams) { if (!HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(ThinkResult.NoJob); } if (RestUtility.TimetablePreventsLayDown(pawn) && !HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn) && !HealthAIUtility.ShouldBeTendedNow(pawn)) { return(ThinkResult.NoJob); } if (RestUtility.DisturbancePreventsLyingDown(pawn)) { return(ThinkResult.NoJob); } Thing thing = RestUtility.FindPatientBedFor(pawn); if (thing == null) { return(ThinkResult.NoJob); } Job job = new Job(JobDefOf.LayDown, thing); return(new ThinkResult(job, this, null, false)); }