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 && _003CMakeNewToils_003Ec__Iterator._0024this.pawn.Faction == Faction.OfPlayer) { 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.Faction == Faction.OfPlayer && !_003CMakeNewToils_003Ec__Iterator._0024this.pawn.playerSettings.selfTend) { return(true); } return(false); }); AddEndCondition(delegate { if (_003CMakeNewToils_003Ec__Iterator._0024this.pawn.Faction == Faction.OfPlayer && HealthAIUtility.ShouldBeTendedNowByPlayer(_003CMakeNewToils_003Ec__Iterator._0024this.Deliveree)) { return(JobCondition.Ongoing); } if (_003CMakeNewToils_003Ec__Iterator._0024this.pawn.Faction != Faction.OfPlayer && _003CMakeNewToils_003Ec__Iterator._0024this.Deliveree.health.HasHediffsNeedingTend()) { return(JobCondition.Ongoing); } return(JobCondition.Succeeded); }); this.FailOnAggroMentalState(TargetIndex.A); Toil reserveMedicine = null; if (!usesMedicine) { PathEndMode interactionCell = (Deliveree == pawn) ? PathEndMode.OnCell : PathEndMode.InteractionCell; Toil gotoToil = Toils_Goto.GotoThing(TargetIndex.A, interactionCell); yield return(gotoToil); /*Error: Unable to find new state assignment for yield return*/; } reserveMedicine = Toils_Tend.ReserveMedicine(TargetIndex.B, Deliveree).FailOnDespawnedNullOrForbidden(TargetIndex.B); yield return(reserveMedicine); /*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); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOn(delegate { if (!WorkGiver_Tend.GoodLayingStatusForTend(Deliveree, pawn)) { return(true); } if (MedicineUsed != null && pawn.Faction == Faction.OfPlayer) { if (Deliveree.playerSettings == null) { return(true); } if (!Deliveree.playerSettings.medCare.AllowsMedicine(MedicineUsed.def)) { return(true); } } return((pawn == Deliveree && pawn.Faction == Faction.OfPlayer && !pawn.playerSettings.selfTend) ? true : false); }); AddEndCondition(delegate { if (pawn.Faction == Faction.OfPlayer && HealthAIUtility.ShouldBeTendedNowByPlayer(Deliveree)) { return(JobCondition.Ongoing); } return((pawn.Faction != Faction.OfPlayer && Deliveree.health.HasHediffsNeedingTend()) ? JobCondition.Ongoing : JobCondition.Succeeded); }); this.FailOnAggroMentalState(TargetIndex.A); Toil reserveMedicine = null; if (usesMedicine) { reserveMedicine = Toils_Tend.ReserveMedicine(TargetIndex.B, Deliveree).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, Deliveree).FailOnDestroyedOrNull(TargetIndex.B)); yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveMedicine, TargetIndex.B, TargetIndex.None, takeFromValidStorage: true)); } PathEndMode interactionCell = ((Deliveree == pawn) ? PathEndMode.OnCell : PathEndMode.InteractionCell); Toil gotoToil = Toils_Goto.GotoThing(TargetIndex.A, interactionCell); yield return(gotoToil); Toil toil = Toils_General.Wait((int)(1f / pawn.GetStatValue(StatDefOf.MedicalTendSpeed) * 600f)).FailOnCannotTouch(TargetIndex.A, interactionCell).WithProgressBarToilDelay(TargetIndex.A) .PlaySustainerOrSound(SoundDefOf.Interact_Tend); toil.activeSkill = () => SkillDefOf.Medicine; if (pawn == Deliveree && pawn.Faction != Faction.OfPlayer) { toil.tickAction = delegate { if (pawn.IsHashIntervalTick(100) && !pawn.Position.Fogged(pawn.Map)) { MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_HealingCross); } }; } yield return(toil); yield return(Toils_Tend.FinalizeTend(Deliveree)); if (usesMedicine) { Toil toil2 = new Toil(); toil2.initAction = delegate { if (MedicineUsed.DestroyedOrNull()) { Thing thing = HealthAIUtility.FindBestMedicine(pawn, Deliveree); if (thing != null) { job.targetB = thing; JumpToToil(reserveMedicine); } } }; yield return(toil2); } yield return(Toils_Jump.Jump(gotoToil)); }