public static bool FianceReadyToStartCeremony(Pawn pawn, Pawn otherPawn) { if (!FianceCanContinueCeremony(pawn, otherPawn)) { return(false); } if (pawn.health.hediffSet.BleedRateTotal > 0f) { return(false); } if (HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn)) { return(false); } if (PawnUtility.WillSoonHaveBasicNeed(pawn)) { return(false); } if (IsCurrentlyMarryingSomeone(pawn)) { return(false); } if (pawn.GetLord() != null) { return(false); } return(!pawn.Drafted && !pawn.InMentalState && pawn.Awake() && !pawn.IsBurning() && !pawn.InBed()); }
protected override bool Satisfied(Pawn pawn) { if (pawn.CurJob != null && pawn.jobs.curDriver.layingDown != 0) { if (!pawn.Downed) { if (RestUtility.DisturbancePreventsLyingDown(pawn)) { return(false); } if (!pawn.CurJob.restUntilHealed || !HealthAIUtility.ShouldSeekMedicalRest(pawn)) { if (!pawn.jobs.curDriver.asleep) { return(false); } if (!pawn.CurJob.playerForced && RestUtility.TimetablePreventsLayDown(pawn)) { return(false); } } } return(true); } return(false); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { _003CGetFloatMenuOptions_003Ec__Iterator2 _003CGetFloatMenuOptions_003Ec__Iterator = (_003CGetFloatMenuOptions_003Ec__Iterator2) /*Error near IL_0036: stateMachine*/; if (myPawn.RaceProps.Humanlike && !ForPrisoners && Medical && !myPawn.Drafted && base.Faction == Faction.OfPlayer && RestUtility.CanUseBedEver(myPawn, def)) { if (!HealthAIUtility.ShouldSeekMedicalRest(myPawn) && !HealthAIUtility.ShouldSeekMedicalRestUrgent(myPawn)) { yield return(new FloatMenuOption("UseMedicalBed".Translate() + " (" + "NotInjured".Translate() + ")", null)); /*Error: Unable to find new state assignment for yield return*/; } yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(action: delegate { if (!_003CGetFloatMenuOptions_003Ec__Iterator._0024this.ForPrisoners && _003CGetFloatMenuOptions_003Ec__Iterator._0024this.Medical && myPawn.CanReserveAndReach(_003CGetFloatMenuOptions_003Ec__Iterator._0024this, PathEndMode.ClosestTouch, Danger.Deadly, _003CGetFloatMenuOptions_003Ec__Iterator._0024this.SleepingSlotsCount, -1, null, ignoreOtherReservations: true)) { if (myPawn.CurJobDef == JobDefOf.LayDown && myPawn.CurJob.GetTarget(TargetIndex.A).Thing == _003CGetFloatMenuOptions_003Ec__Iterator._0024this) { myPawn.CurJob.restUntilHealed = true; } else { Job job = new Job(JobDefOf.LayDown, _003CGetFloatMenuOptions_003Ec__Iterator._0024this) { restUntilHealed = true }; myPawn.jobs.TryTakeOrderedJob(job); } myPawn.mindState.ResetLastDisturbanceTick(); } }, label: "UseMedicalBed".Translate()), myPawn, this, (!AnyUnoccupiedSleepingSlot) ? "SomeoneElseSleeping" : "ReservedBy")); /*Error: Unable to find new state assignment for yield return*/; } }
protected override bool Satisfied(Pawn pawn) { bool result; if (pawn.CurJob == null || !pawn.GetPosture().Laying()) { result = false; } else { if (!pawn.Downed) { if (RestUtility.DisturbancePreventsLyingDown(pawn)) { return(false); } if (!pawn.CurJob.restUntilHealed || !HealthAIUtility.ShouldSeekMedicalRest(pawn)) { if (!pawn.jobs.curDriver.asleep) { return(false); } if (!pawn.CurJob.playerForced) { if (RestUtility.TimetablePreventsLayDown(pawn)) { return(false); } } } } result = true; } return(result); }
private static bool AboutToRecover(Pawn pawn) { if (pawn.Downed) { return(false); } if (!HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) && !HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(true); } if (pawn.health.hediffSet.HasTendedImmunizableNotImmuneHediff()) { return(false); } float num = 0f; List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { Hediff_Injury hediff_Injury = hediffs[i] as Hediff_Injury; if (hediff_Injury != null && (hediff_Injury.CanHealFromTending() || hediff_Injury.CanHealNaturally() || hediff_Injury.Bleeding)) { num += hediff_Injury.Severity; } } return(num < 8.0 * pawn.RaceProps.baseHealthScale); }
public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams) { ThinkResult result; if (!HealthAIUtility.ShouldSeekMedicalRest(pawn)) { result = ThinkResult.NoJob; } else if (this.respectTimetable && RestUtility.TimetablePreventsLayDown(pawn) && !HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn) && !HealthAIUtility.ShouldBeTendedNowByPlayer(pawn)) { result = ThinkResult.NoJob; } else if (RestUtility.DisturbancePreventsLyingDown(pawn)) { result = ThinkResult.NoJob; } else { Thing thing = RestUtility.FindPatientBedFor(pawn); if (thing == null) { result = ThinkResult.NoJob; } else { Job job = new Job(JobDefOf.LayDown, thing); result = new ThinkResult(job, this, null, false); } } return(result); }
private Job TakeDownedToBedJob(Pawn prisoner, Pawn warden) { Job result; if (!prisoner.Downed || !HealthAIUtility.ShouldSeekMedicalRestUrgent(prisoner) || prisoner.InBed() || !warden.CanReserve(prisoner, 1, -1, null, false)) { result = null; } else { Building_Bed building_Bed = RestUtility.FindBedFor(prisoner, warden, true, true, false); if (building_Bed != null) { result = new Job(JobDefOf.TakeWoundedPrisonerToBed, prisoner, building_Bed) { count = 1 }; } else { result = null; } } return(result); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { if (!myPawn.RaceProps.Humanlike || ForPrisoners || !Medical || myPawn.Drafted || base.Faction != Faction.OfPlayer || !RestUtility.CanUseBedEver(myPawn, def)) { yield break; } if (!HealthAIUtility.ShouldSeekMedicalRest(myPawn) && !HealthAIUtility.ShouldSeekMedicalRestUrgent(myPawn)) { yield return(new FloatMenuOption("UseMedicalBed".Translate() + " (" + "NotInjured".Translate() + ")", null)); yield break; } Action action = delegate { if (!ForPrisoners && Medical && myPawn.CanReserveAndReach(this, PathEndMode.ClosestTouch, Danger.Deadly, SleepingSlotsCount, -1, null, ignoreOtherReservations: true)) { if (myPawn.CurJobDef == JobDefOf.LayDown && myPawn.CurJob.GetTarget(TargetIndex.A).Thing == this) { myPawn.CurJob.restUntilHealed = true; } else { Job job = JobMaker.MakeJob(JobDefOf.LayDown, this); job.restUntilHealed = true; myPawn.jobs.TryTakeOrderedJob(job); } myPawn.mindState.ResetLastDisturbanceTick(); } }; yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("UseMedicalBed".Translate(), action), myPawn, this, (AnyUnoccupiedSleepingSlot ? "ReservedBy" : "SomeoneElseSleeping").CapitalizeFirst())); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { if (myPawn.RaceProps.Humanlike && !this.ForPrisoners && this.Medical && !myPawn.Drafted && base.Faction == Faction.OfPlayer && RestUtility.CanUseBedEver(myPawn, this.def)) { if (!HealthAIUtility.ShouldSeekMedicalRest(myPawn) && !HealthAIUtility.ShouldSeekMedicalRestUrgent(myPawn)) { yield return(new FloatMenuOption("UseMedicalBed".Translate() + " (" + "NotInjured".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action sleep = delegate { if (!this.$this.ForPrisoners && this.$this.Medical && myPawn.CanReserveAndReach(this.$this, PathEndMode.ClosestTouch, Danger.Deadly, this.$this.SleepingSlotsCount, -1, null, true)) { Job job = new Job(JobDefOf.LayDown, this.$this); job.restUntilHealed = true; myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); myPawn.mindState.ResetLastDisturbanceTick(); } }; if (this.AnyUnoccupiedSleepingSlot) { yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("UseMedicalBed".Translate(), sleep, MenuOptionPriority.Default, null, null, 0f, null, null), myPawn, this, "ReservedBy")); } else { yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("UseMedicalBed".Translate(), sleep, MenuOptionPriority.Default, null, null, 0f, null, null), myPawn, this, "SomeoneElseSleeping")); } } } }
public override Job NonScanJob(Pawn pawn) { if (!HealthAIUtility.ShouldBeTendedNowUrgent(pawn)) { return(null); } return(base.NonScanJob(pawn)); }
public static bool ShouldBeTendedNowUrgent(Pawn pawn) { if (!HealthAIUtility.ShouldBeTendedNow(pawn)) { return(false); } return(HealthUtility.TicksUntilDeathDueToBloodLoss(pawn) < 15000); }
public override bool ShouldMeasureTimeNow(Pawn pawn) { if (!pawn.InBed()) { return(false); } return(HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) || (HealthAIUtility.ShouldSeekMedicalRest(pawn) && (pawn.needs.rest.CurLevel >= 1f || pawn.CurJob.restUntilHealed))); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { if (base.HasJobOnThing(pawn, t, forced)) { return(HealthAIUtility.ShouldBeTendedNowByPlayerUrgent((Pawn)t)); } return(false); }
static bool IsAwaiting(Pawn p) { if (HealthAIUtility.ShouldHaveSurgeryDoneNow(p)) { return(p.InBed()); } return(false); }
public static Building_Bed FindBedFor(Pawn sleeper, Pawn traveler, bool sleeperWillBePrisoner, bool checkSocialProperness, bool ignoreOtherReservations = false) { if (HealthAIUtility.ShouldSeekMedicalRest(sleeper)) { if (sleeper.InBed() && sleeper.CurrentBed().Medical&& IsValidBedFor(sleeper.CurrentBed(), sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations)) { return(sleeper.CurrentBed()); } for (int i = 0; i < bedDefsBestToWorst_Medical.Count; i++) { ThingDef thingDef = bedDefsBestToWorst_Medical[i]; if (!CanUseBedEver(sleeper, thingDef)) { continue; } for (int j = 0; j < 2; j++) { Danger maxDanger2 = ((j == 0) ? Danger.None : Danger.Deadly); Building_Bed building_Bed = (Building_Bed)GenClosest.ClosestThingReachable(sleeper.Position, sleeper.Map, ThingRequest.ForDef(thingDef), PathEndMode.OnCell, TraverseParms.For(traveler), 9999f, (Thing b) => ((Building_Bed)b).Medical && (int)b.Position.GetDangerFor(sleeper, sleeper.Map) <= (int)maxDanger2 && IsValidBedFor(b, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations)); if (building_Bed != null) { return(building_Bed); } } } } if (sleeper.ownership != null && sleeper.ownership.OwnedBed != null && IsValidBedFor(sleeper.ownership.OwnedBed, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations)) { return(sleeper.ownership.OwnedBed); } DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(sleeper, allowDead: false); if (directPawnRelation != null) { Building_Bed ownedBed = directPawnRelation.otherPawn.ownership.OwnedBed; if (ownedBed != null && IsValidBedFor(ownedBed, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations)) { return(ownedBed); } } for (int k = 0; k < 2; k++) { Danger maxDanger = ((k == 0) ? Danger.None : Danger.Deadly); for (int l = 0; l < bedDefsBestToWorst_RestEffectiveness.Count; l++) { ThingDef thingDef2 = bedDefsBestToWorst_RestEffectiveness[l]; if (CanUseBedEver(sleeper, thingDef2)) { Building_Bed building_Bed2 = (Building_Bed)GenClosest.ClosestThingReachable(sleeper.Position, sleeper.Map, ThingRequest.ForDef(thingDef2), PathEndMode.OnCell, TraverseParms.For(traveler), 9999f, (Thing b) => !((Building_Bed)b).Medical && (int)b.Position.GetDangerFor(sleeper, sleeper.Map) <= (int)maxDanger && IsValidBedFor(b, sleeper, traveler, sleeperWillBePrisoner, checkSocialProperness, allowMedBedEvenIfSetToNoCare: false, ignoreOtherReservations)); if (building_Bed2 != null) { return(building_Bed2); } } } } return(null); }
public static void FailOnBedNoLongerUsable(this Toil toil, TargetIndex bedIndex) { toil.FailOnDespawnedOrNull(bedIndex); toil.FailOn(() => ((Building_Bed)toil.actor.CurJob.GetTarget(bedIndex).Thing).IsBurning()); toil.FailOn(() => ((Building_Bed)toil.actor.CurJob.GetTarget(bedIndex).Thing).ForPrisoners != toil.actor.IsPrisoner); toil.FailOnNonMedicalBedNotOwned(bedIndex, TargetIndex.None); toil.FailOn(() => !HealthAIUtility.ShouldSeekMedicalRest(toil.actor) && !HealthAIUtility.ShouldSeekMedicalRestUrgent(toil.actor) && ((Building_Bed)toil.actor.CurJob.GetTarget(bedIndex).Thing).Medical); toil.FailOn(() => toil.actor.IsColonist && !toil.actor.CurJob.ignoreForbidden && !toil.actor.Downed && toil.actor.CurJob.GetTarget(bedIndex).Thing.IsForbidden(toil.actor)); }
public static bool ShouldBeFed(Pawn p) { bool result; if (p.GetPosture() == PawnPosture.Standing) { result = false; } else { if (p.NonHumanlikeOrWildMan()) { Building_Bed building_Bed = p.CurrentBed(); if (building_Bed == null || building_Bed.Faction != Faction.OfPlayer) { return(false); } } else { if (p.Faction != Faction.OfPlayer && p.HostFaction != Faction.OfPlayer) { return(false); } if (!p.InBed()) { return(false); } } if (!p.RaceProps.EatsFood) { result = false; } else if (!HealthAIUtility.ShouldSeekMedicalRest(p)) { result = false; } else { if (p.HostFaction != null) { if (p.HostFaction != Faction.OfPlayer) { return(false); } if (p.guest != null && !p.guest.CanBeBroughtFood) { return(false); } } result = true; } } return(result); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { _003CGetFloatMenuOptions_003Ec__Iterator2 _003CGetFloatMenuOptions_003Ec__Iterator = (_003CGetFloatMenuOptions_003Ec__Iterator2) /*Error near IL_003a: stateMachine*/; if (!myPawn.RaceProps.Humanlike) { yield break; } if (this.ForPrisoners) { yield break; } if (!this.Medical) { yield break; } if (myPawn.Drafted) { yield break; } if (base.Faction != Faction.OfPlayer) { yield break; } if (!RestUtility.CanUseBedEver(myPawn, base.def)) { yield break; } if (!HealthAIUtility.ShouldSeekMedicalRest(myPawn) && !HealthAIUtility.ShouldSeekMedicalRestUrgent(myPawn)) { yield return(new FloatMenuOption("UseMedicalBed".Translate() + " (" + "NotInjured".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); /*Error: Unable to find new state assignment for yield return*/; } Action sleep = delegate { if (!_003CGetFloatMenuOptions_003Ec__Iterator._0024this.ForPrisoners && _003CGetFloatMenuOptions_003Ec__Iterator._0024this.Medical && myPawn.CanReserveAndReach(_003CGetFloatMenuOptions_003Ec__Iterator._0024this, PathEndMode.ClosestTouch, Danger.Deadly, _003CGetFloatMenuOptions_003Ec__Iterator._0024this.SleepingSlotsCount, -1, null, true)) { Job job = new Job(JobDefOf.LayDown, _003CGetFloatMenuOptions_003Ec__Iterator._0024this); job.restUntilHealed = true; myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); myPawn.mindState.ResetLastDisturbanceTick(); } }; if (this.AnyUnoccupiedSleepingSlot) { yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("UseMedicalBed".Translate(), sleep, MenuOptionPriority.Default, null, null, 0f, null, null), myPawn, this, "ReservedBy")); /*Error: Unable to find new state assignment for yield return*/; } yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("UseMedicalBed".Translate(), sleep, MenuOptionPriority.Default, null, null, 0f, null, null), myPawn, this, "SomeoneElseSleeping")); /*Error: Unable to find new state assignment for yield return*/; }
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { Pawn pawn2 = t as Pawn; Thing thing = HealthAIUtility.FindBestMedicine(pawn, pawn2); if (thing != null) { return(new Job(JobDefOf.TendPatient, pawn2, thing)); } return(new Job(JobDefOf.TendPatient, pawn2)); }
protected override Job TryGiveJob(Pawn pawn) { if (!this.CanDoDuringMedicalRest && pawn.InBed() && HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(null); } List <JoyGiverDef> allDefsListForReading = DefDatabase <JoyGiverDef> .AllDefsListForReading; JoyToleranceSet tolerances = pawn.needs.joy.tolerances; for (int i = 0; i < allDefsListForReading.Count; i++) { JoyGiverDef joyGiverDef = allDefsListForReading[i]; this.joyGiverChances[joyGiverDef] = 0f; if (this.JoyGiverAllowed(joyGiverDef)) { if (!pawn.needs.joy.tolerances.BoredOf(joyGiverDef.joyKind)) { if (joyGiverDef.Worker.MissingRequiredCapacity(pawn) == null) { if (joyGiverDef.pctPawnsEverDo < 1f) { Rand.PushState(pawn.thingIDNumber ^ 63216713); if (Rand.Value >= joyGiverDef.pctPawnsEverDo) { Rand.PopState(); goto IL_131; } Rand.PopState(); } float num = tolerances[joyGiverDef.joyKind]; float num2 = Mathf.Pow(1f - num, 5f); num2 = Mathf.Max(0.001f, num2); this.joyGiverChances[joyGiverDef] = joyGiverDef.Worker.GetChance(pawn) * num2; } } } IL_131 :; } for (int j = 0; j < this.joyGiverChances.Count; j++) { JoyGiverDef def; if (!allDefsListForReading.TryRandomElementByWeight((JoyGiverDef d) => this.joyGiverChances[d], out def)) { break; } Job job = this.TryGiveJobFromJoyGiverDefDirect(def, pawn); if (job != null) { return(job); } this.joyGiverChances[def] = 0f; } return(null); }
public override Job NonScanJob(Pawn pawn) { if (!HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn)) { return(null); } if (!AnyAvailableDoctorFor(pawn)) { return(null); } return(base.NonScanJob(pawn)); }
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*/; }
public static bool ShouldBeTendedNow(Pawn pawn) { if (pawn.playerSettings == null) { return(false); } if (!HealthAIUtility.ShouldEverReceiveMedicalCare(pawn)) { return(false); } return(pawn.health.HasHediffsNeedingTendByColony(false)); }
public override bool ShouldSkip(Pawn pawn, bool forced = false) { List <Pawn> allPawnsSpawned = pawn.Map.mapPawns.AllPawnsSpawned; for (int i = 0; i < allPawnsSpawned.Count; i++) { if (HealthAIUtility.ShouldHaveSurgeryDoneNow(allPawnsSpawned[i])) { return(false); } } return(true); }
public static bool ShouldBeFed(Pawn p) { if (p.GetPosture() == PawnPosture.Standing) { return(false); } if (p.NonHumanlikeOrWildMan()) { Building_Bed building_Bed = p.CurrentBed(); if (building_Bed == null || building_Bed.Faction != Faction.OfPlayer) { return(false); } } else { if (p.Faction != Faction.OfPlayer && p.HostFaction != Faction.OfPlayer) { return(false); } if (!p.InBed()) { return(false); } } if (!p.RaceProps.EatsFood) { return(false); } if (p.Spawned && p.Map.designationManager.DesignationOn(p, DesignationDefOf.Slaughter) != null) { return(false); } if (!HealthAIUtility.ShouldSeekMedicalRest(p)) { return(false); } if (p.HostFaction != null) { if (p.HostFaction != Faction.OfPlayer) { return(false); } if (p.guest != null && !p.guest.CanBeBroughtFood) { return(false); } } return(true); }
public override Job NonScanJob(Pawn pawn) { if (!HasJobOnThing(pawn, pawn) || !HealthAIUtility.ShouldBeTendedNowByPlayerUrgent(pawn)) { return(null); } ThinkResult thinkResult = jgp.TryIssueJobPackage(pawn, default(JobIssueParams)); if (thinkResult.IsValid) { return(thinkResult.Job); } return(null); }
public override Job NonScanJob(Pawn pawn) { Job result; if (!HealthAIUtility.ShouldBeTendedNowByPlayerUrgent(pawn)) { result = null; } else { result = base.NonScanJob(pawn); } return(result); }
private Job TakeDownedToBedJob(Pawn prisoner, Pawn warden) { if (prisoner.Downed && HealthAIUtility.ShouldSeekMedicalRestUrgent(prisoner) && !prisoner.InBed() && warden.CanReserve(prisoner, 1, -1, null, false)) { Building_Bed building_Bed = RestUtility.FindBedFor(prisoner, warden, true, true, false); if (building_Bed != null) { Job job = new Job(JobDefOf.TakeWoundedPrisonerToBed, prisoner, building_Bed); job.count = 1; return(job); } return(null); } return(null); }
private Job TakeDownedToBedJob(Pawn prisoner, Pawn warden) { if (!prisoner.Downed || !HealthAIUtility.ShouldSeekMedicalRestUrgent(prisoner) || prisoner.InBed() || !warden.CanReserve(prisoner)) { return(null); } Building_Bed building_Bed = RestUtility.FindBedFor(prisoner, warden, sleeperWillBePrisoner: true, checkSocialProperness: true); if (building_Bed != null) { Job job = JobMaker.MakeJob(JobDefOf.TakeWoundedPrisonerToBed, prisoner, building_Bed); job.count = 1; return(job); } return(null); }
protected override Job TryGiveJob(Pawn pawn) { if (!CanDoDuringMedicalRest && pawn.InBed() && HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(null); } List <JoyGiverDef> allDefsListForReading = DefDatabase <JoyGiverDef> .AllDefsListForReading; JoyToleranceSet tolerances = pawn.needs.joy.tolerances; for (int i = 0; i < allDefsListForReading.Count; i++) { JoyGiverDef joyGiverDef = allDefsListForReading[i]; joyGiverChances[joyGiverDef] = 0f; if (!JoyGiverAllowed(joyGiverDef) || pawn.needs.joy.tolerances.BoredOf(joyGiverDef.joyKind) || !joyGiverDef.Worker.CanBeGivenTo(pawn)) { continue; } if (joyGiverDef.pctPawnsEverDo < 1f) { Rand.PushState(pawn.thingIDNumber ^ 0x3C49C49); if (Rand.Value >= joyGiverDef.pctPawnsEverDo) { Rand.PopState(); continue; } Rand.PopState(); } float num = tolerances[joyGiverDef.joyKind]; float b = Mathf.Pow(1f - num, 5f); b = Mathf.Max(0.001f, b); joyGiverChances[joyGiverDef] = joyGiverDef.Worker.GetChance(pawn) * b; } for (int j = 0; j < joyGiverChances.Count; j++) { if (!allDefsListForReading.TryRandomElementByWeight((JoyGiverDef d) => joyGiverChances[d], out JoyGiverDef result)) { break; } Job job = TryGiveJobFromJoyGiverDefDirect(result, pawn); if (job != null) { return(job); } joyGiverChances[result] = 0f; } return(null); }