public static bool WorkTime(Pawn pawn) { if (pawn.timetable == null) { return(true); } if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Work) { return(true); } if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Anything) { if (HealthAIUtility.ShouldSeekMedicalRest(pawn) || pawn.needs.food.CurCategory > HungerCategory.Hungry || pawn.needs.rest.CurCategory != RestCategory.Rested) { return(false); } else { return(true); } } return(false); }
public static bool PrisonLabor_WorkTimePrefix(Pawn pawn, ref bool __result) { if (pawn != null && pawn.IsAndroidTier()) { if (pawn.timetable == null) { __result = true; } else if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Work) { __result = true; } else if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Anything) { if (HealthAIUtility.ShouldSeekMedicalRest(pawn) || pawn.health.hediffSet.HasTemperatureInjury(TemperatureInjuryStage.Serious) || pawn.needs.food.CurCategory > HungerCategory.Hungry) { __result = false; } else { __result = true; } } else { __result = false; } return(false); } return(true); }
public static InjurySeverity GetTendSeverity(this Pawn patient) { if (!HealthAIUtility.ShouldBeTendedNowByPlayer(patient)) // .ShouldBeTendedNow( patient ) ) { return(InjurySeverity.Minor); } var hediffs = patient.health.hediffSet.hediffs; var ticksToDeathDueToBloodLoss = HealthUtility.TicksUntilDeathDueToBloodLoss(patient); // going to die in <6 hours, or any tendable is life threathening if (ticksToDeathDueToBloodLoss <= GenDate.TicksPerHour * 6 || hediffs.Any(h => h.CurStage?.lifeThreatening ?? false) || hediffs.Any(NearLethalDisease)) { return(InjurySeverity.LifeThreathening); } // going to die in <12 hours, or any immunity < severity and can be fatal, or death by a thousand cuts imminent if (ticksToDeathDueToBloodLoss <= GenDate.TicksPerHour * 12 || hediffs.Any(PotentiallyLethalDisease) || DeathByAThousandCuts(patient)) { return(InjurySeverity.Major); } // otherwise return(InjurySeverity.Minor); }
public static bool WorkTime(Pawn pawn) { /* if (pawn.needs == null || pawn.needs.food == null || pawn.needs.rest == null) * return false;*/ if (pawn.timetable == null) { return(true); } if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Work) { return(true); } if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Anything) { if (HealthAIUtility.ShouldSeekMedicalRest(pawn) || pawn.health.hediffSet.HasTemperatureInjury(TemperatureInjuryStage.Serious) || CheckFoodNeed(pawn) || CheckRestNeed(pawn)) { return(false); } else { return(true); } } return(false); }
public static void Postfix(Pawn sleeper, Thing bedThing, ref bool __result, bool sleeperWillBePrisoner) { if (!__result) { return; } switch (bedThing) { // guest bed case Building_GuestBed guestBed: if (!sleeper.IsGuest()) { __result = false; } break; // normal bed case Building_Bed bed: if (sleeper.IsGuest()) { __result = HealthAIUtility.ShouldSeekMedicalRest(sleeper) || sleeper.health.hediffSet.HasNaturallyHealingInjury() || sleeperWillBePrisoner; } break; } }
/* * public static Building_HackingTable HackingTable(this Pawn pawn) * { * List<Thing> thingList = pawn.Position.GetThingList(pawn.Map); * Building_HackingTable hackingTable = null; * for (int i = 0; i < thingList.Count; i++) * { * hackingTable = (thingList[i] as Building_HackingTable); * if (hackingTable != null) * { * break; * } * } * if (hackingTable == null) * { * return null; * } * if(hackingTable.GetCurOccupant(0) == pawn) * { * return hackingTable; * } * return null; * } */ /* * public static bool OnHackingTable(this Pawn pawn) * { * if(pawn.HackingTable() != null) * { * return true; * } * return false; * } */ public static void FailOnPlatformNoLongerUsable(this Toil toil, TargetIndex bedIndex) { toil.FailOnDespawnedOrNull(bedIndex); toil.FailOn(() => ((Building_Bed)toil.actor.CurJob.GetTarget(bedIndex).Thing).IsBurning()); 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)); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden <JobDriver_StabilizeHere>(TargetIndex.A); this.FailOnAggroMentalState <JobDriver_StabilizeHere>(TargetIndex.A); this.AddEndCondition(() => { if (HealthAIUtility.ShouldBeTendedNowByPlayer(this.Patient) || this.Patient.health.HasHediffsNeedingTend(false)) { return(JobCondition.Ongoing); } return(JobCondition.Succeeded); }); Toil toil1 = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); yield return(toil1); Toil toil2 = Toils_General.Wait((int)(1f / this.Doctor.GetStatValue(StatDefOf.MedicalTendSpeed, true) * 600f), TargetIndex.None).FailOnCannotTouch <Toil>(TargetIndex.A, PathEndMode.InteractionCell).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f).PlaySustainerOrSound(SoundDefOf.Interact_Tend); toil2.activeSkill = () => SkillDefOf.Medicine; yield return(toil2); yield return(Toils_Tend.FinalizeTend(this.Patient)); yield return(Toils_Jump.Jump(toil1)); }
// Token: 0x0600004F RID: 79 RVA: 0x000044B4 File Offset: 0x000026B4 public static bool CompatPatch_ShouldMeasureTimeNow(bool __result, ref Pawn pawn) { bool flag = pawn == null; bool result; if (flag) { result = true; } else { Pawn pawn2 = pawn; bool flag2 = ((pawn2 != null) ? pawn2.needs.TryGetNeed(NeedDefOf.Rest) : null) != null; bool flag3 = !flag2; if (flag3) { if (pawn.InBed()) { if (!HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn)) { bool flag4 = HealthAIUtility.ShouldSeekMedicalRest(pawn) && pawn.CurJob.restUntilHealed; } } result = false; } else { result = true; } } return(result); }
public static bool WorkTime(Pawn pawn) { if (pawn.needs == null || pawn.needs.food == null || pawn.needs.rest == null) { return(false); } if (pawn.timetable == null) { return(true); } if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Work) { return(true); } if (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Anything) { if (HealthAIUtility.ShouldSeekMedicalRest(pawn) || pawn.health.hediffSet.HasTemperatureInjury(TemperatureInjuryStage.Serious) || pawn.needs.food.CurCategory > HungerCategory.Hungry || pawn.needs.rest.CurCategory != RestCategory.Rested) { return(false); } else { return(true); } } return(false); }
protected override bool Satisfied(Pawn pawn) { if (pawn.CurJob == null || !pawn.GetPosture().Laying() || (pawn.def.defName == "M7Mech" && !pawn.IsSurrogateAndroid())) { return(false); } 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); }
// RimWorld.SickPawnVisitUtility private static bool AboutToRecover(Pawn pawn) { if (pawn.Downed) { return(false); } if (!HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) && !HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(true); } if (pawn.health.hediffSet.HasImmunizableNotImmuneHediff()) { 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 < 8f * pawn.RaceProps.baseHealthScale); }
public override float GetPriority(Pawn pawn) { if (pawn.health.hediffSet.HasNaturallyHealingInjury() || HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(6); } if (pawn.needs?.rest == null) { Log.Message(pawn.Name.ToStringShort + " needs no rest..."); return(0f); } float curLevel = pawn.needs.rest.CurLevel; int hourOfDay = GenLocalDate.HourOfDay(pawn); if (hourOfDay < 7 || hourOfDay > 21) { curLevel -= 0.2f; } if (curLevel < 0.35f) { return(6f); } if (curLevel > 0.4f) { return(0f); } return(1 - curLevel); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn != null && pawn.Map != null && pawn.health != null && pawn.health.hediffSet != null && pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_ChiHD) && !pawn.Drafted) { if (pawn.InBed() || HealthAIUtility.ShouldSeekMedicalRest(pawn) || !(pawn.GetPosture() == PawnPosture.Standing)) { return(null); } Need_Joy curJoy = pawn.needs.joy; if (curJoy == null) { return(null); } if (curJoy.CurLevel >= .8f) { return(null); } CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); if (comp != null) { MightPower mightPower = comp.MightData.MightPowersM.FirstOrDefault <MightPower>((MightPower x) => x.abilityDef == TorannMagicDefOf.TM_Meditate); if (mightPower == null) { return(null); } if (!mightPower.AutoCast) { return(null); } Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD); PawnAbility ability = pawn.GetComp <CompAbilityUserMight>().AbilityData.Powers.FirstOrDefault((PawnAbility x) => x.Def == TorannMagicDefOf.TM_Meditate); if (ability.CooldownTicksLeft > 0 || hediff.Severity >= 70) { return(null); } Building_Bed building_Bed = pawn.ownership.OwnedBed; if (building_Bed != null) { if (building_Bed.GetRoom() != null && !building_Bed.GetRoom().PsychologicallyOutdoors) { List <IntVec3> roomCells = building_Bed.GetRoom().Cells.ToList(); for (int i = 0; i < roomCells.Count; i++) { if (roomCells[i].IsValid && roomCells[i].Walkable(pawn.Map) && roomCells[i].GetFirstBuilding(pawn.Map) == null) { return(new Job(TorannMagicDefOf.JobDriver_TM_Meditate, roomCells[i])); } } } } return(new Job(TorannMagicDefOf.JobDriver_TM_Meditate, pawn.Position)); } } return(null); }
// Token: 0x06000026 RID: 38 RVA: 0x000026A3 File Offset: 0x000008A3 protected override IEnumerable <Toil> MakeNewToils() { base.AddEndCondition(delegate() { if (this.pawn.Faction == Faction.OfPlayer && HealthAIUtility.ShouldBeTendedNowByPlayer(this.pawn)) { return(JobCondition.Ongoing); } if (this.pawn.Faction != Faction.OfPlayer && this.pawn.health.HasHediffsNeedingTend(false)) { return(JobCondition.Ongoing); } return(JobCondition.Succeeded); }); int ticks = (int)(1f / StatExtension.GetStatValue(this.pawn, StatDefOf.MedicalTendSpeed, true) * 600f); yield return(ToilEffects.PlaySustainerOrSound(ToilEffects.WithProgressBarToilDelay(Toils_General.Wait(ticks, 0), (TargetIndex)1, false, -0.5f), SoundDefOf.Interact_Tend)); Toil toil = new Toil(); toil.initAction = delegate() { Pawn actor = toil.actor; Cloakgen medkit = actor.apparel.WornApparel.OfType <Cloakgen>().FirstOrDefault <Cloakgen>(); float num = (!actor.RaceProps.Animal) ? 500f : 175f; float num2 = (medkit != null) ? medkit.kitComp.Props.medicine.MedicineTendXpGainFactor : 0.5f; actor.skills.Learn(SkillDefOf.Medicine, num * num2, false); HealthShardTendUtility.DoTend(actor, actor, medkit); }; toil.defaultCompleteMode = (ToilCompleteMode)1; yield return(toil); yield break; }
protected override bool Satisfied(Pawn pawn) { return(Settings.UseGasp && Settings.ApplyAnimals && pawn.AnimalOrWildMan() && !pawn.IsWildMan() && pawn.Faction != null && pawn.Faction == Faction.OfPlayer && !pawn.Downed && !pawn.IsBurning() && pawn.Awake() && !pawn.InMentalState && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Moving) && !HealthAIUtility.ShouldSeekMedicalRest(pawn) && !BrrrGlobals.BrrrAnimalIsFollowing(pawn)); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn.AnimalOrWildMan()) { return(null); } if (!pawn.IsColonist) { return(null); } if (pawn.Drafted) { return(null); } if (pawn.Downed) { return(null); } if (HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(null); } CompMilkableHumanoid compMilk = pawn.TryGetComp <CompMilkableHumanoid>(); if (compMilk == null) { return(null); } if (!compMilk.ActiveAndCanBeMilked) { return(null); } if (!compMilk.MilkProps.canMilkThemselves) { return(null); } Pawn lover = LovePartnerRelationUtility.ExistingLovePartner(pawn); if (lover != null) { if (pawn.Faction == lover.Faction) { if (!lover.Drafted && !lover.Downed && !HealthAIUtility.ShouldSeekMedicalRest(lover)) { return(null); } } } return(new Job(MilkyDefOf.MilkySelf)); }
protected override bool Satisfied(Pawn pawn) { if (pawn.Downed || HealthAIUtility.ShouldSeekMedicalRest(pawn) || pawn.IsBurning()) { return(false); } return(true); }
protected override Job TryGiveJob(Pawn pawn) { Log.Message(pawn + " JobGiver_StockUp"); if (pawn.StockUpIsFull()) { return(null); } Log.Message("Skip need tend?"); if (pawn.Map.mapPawns.AllPawnsSpawned.Any(p => HealthAIUtility.ShouldBeTendedNow(p) && pawn.CanReserveAndReach(p, PathEndMode.ClosestTouch, Danger.Deadly))) { return(null); } Log.Message("any things?"); IEnumerable <Thing> things = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableEver); Predicate <Thing> validator = (Thing t) => pawn.StockingUpOn(t) && pawn.StockUpNeeds(t) > 0 && pawn.CanReserve(t, FindBestMedicine.maxPawns, 1) && !t.IsForbidden(pawn); Thing thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.HaulableEver), PathEndMode.ClosestTouch, TraverseParms.For(pawn), 9999, validator); if (thing != null) { int pickupCount = Math.Min(pawn.StockUpNeeds(thing), MassUtility.CountToPickUpUntilOverEncumbered(pawn, thing)); Log.Message(pawn + " stock thing is " + thing + ", count " + pickupCount); if (pickupCount > 0) { return new Job(SmartMedicineJobDefOf.StockUp, thing) { count = pickupCount } } ; } Log.Message(pawn + " looking to return"); Thing toReturn = pawn.StockUpThingToReturn(); if (toReturn == null) { return(null); } Log.Message("returning " + toReturn); int dropCount = -pawn.StockUpNeeds(toReturn); Log.Message("dropping " + dropCount); if (StoreUtility.TryFindBestBetterStoreCellFor(toReturn, pawn, pawn.Map, StoragePriority.Unstored, pawn.Faction, out IntVec3 dropLoc, true)) { return new Job(SmartMedicineJobDefOf.StockDown, toReturn, dropLoc) { count = dropCount } } ; Log.Message("nowhere to store"); return(null); } } }
// Token: 0x0600002D RID: 45 RVA: 0x00002758 File Offset: 0x00000958 public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParm) { bool flag = !HealthAIUtility.ShouldSeekMedicalRest(pawn); ThinkResult result; if (flag) { result = ThinkResult.NoJob; } else { bool flag2 = !HealthAIUtility.ShouldBeTendedNowByPlayer(pawn); if (flag2) { result = ThinkResult.NoJob; } else { bool flag3 = !GenCollection.Any <Apparel>(pawn.apparel.WornApparel, (Apparel x) => x.def.defName.Contains("RRY_Equipment_HunterGauntlet")); if (flag3) { result = ThinkResult.NoJob; } else { Thing thing = RestUtility.FindPatientBedFor(pawn); bool flag4 = thing == null; if (flag4) { result = ThinkResult.NoJob; } else { Thing thing2 = null; bool flag5 = Medicine.GetMedicineCountToFullyHeal(pawn) > 0; if (flag5) { thing2 = HealthAIUtility.FindBestMedicine(pawn, pawn); } bool flag6 = thing2 != null; Job job; if (flag6) { job = new Job(YautjaDefOf.RRY_Yautja_TendSelf, thing, thing2); } else { job = new Job(YautjaDefOf.RRY_Yautja_TendSelf, thing); } result = new ThinkResult(job, this, null, false); } } } } return(result); }
protected override bool Satisfied(Pawn pawn) { return((pawn.IsColonistPlayerControlled && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Moving)) && !pawn.Downed && !pawn.IsBurning() && !pawn.InMentalState && !pawn.Drafted && pawn.Awake() && !HealthAIUtility.ShouldSeekMedicalRest(pawn)); }
public bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Pawn pawn2 = t as Pawn; if (pawn2 == null || pawn.WorkTypeIsDisabled(WorkTypeDefOf.Doctor) || !GoodLayingStatusForTend(pawn2, pawn) || !HealthAIUtility.ShouldBeTendedNowByPlayer(pawn2) || !pawn.CanReserve(pawn2, 1, -1, null, forced)) { return(false); } return(true); }
private bool KeepRoomUnlockedForTending(Pawn patient) { if ((Settings.KeepUnlockedForUrgentTending && HealthAIUtility.ShouldBeTendedNowByPlayerUrgent(patient)) || (Settings.KeepUnlockedForSurgery && HealthAIUtility.ShouldHaveSurgeryDoneNow(patient)) || (Settings.KeepUnlockedForAnyTending && HealthAIUtility.ShouldBeTendedNowByPlayer(patient))) { return(true); } return(false); }
protected override bool Satisfied(Pawn pawn) { if (pawn.Faction == Faction.OfPlayer && pawn.IsHacked() && !pawn.IsActivated() && !pawn.CanStartWorkNow()) { return(true); } else if (HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn) && pawn.OnHackingTable()) { return(true); } return(false); }
private static void Postfix(ref bool __result, Pawn pawn) { if (__result || pawn is null) { return; } if (pawn.FindCage(null) != null) { __result = pawn.GetPosture() != PawnPosture.Standing && HealthAIUtility.ShouldSeekMedicalRest(pawn) && (pawn.HostFaction == null || pawn.HostFaction == Faction.OfPlayer && (pawn.guest?.CanBeBroughtFood ?? true)); } }
public override float GetPriority(Pawn pawn) { if (HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn)) { return(15f); } if (pawn.timetable != null && pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Sleep) { return(10f); } return(0f); }
// Token: 0x0600000B RID: 11 RVA: 0x0000278C File Offset: 0x0000098C internal static bool NearThingEffects(Thing thing, Pawn pawn) { var def = thing.def; if (ProximityGet.GetProxRoomOnly(def)) { // Func def changed, this used to be GetRoom var room = thing.Position.GetRoomOrAdjacent(thing.Map); var room2 = pawn?.Position.GetRoomOrAdjacent(thing.Map); if (room != null && room2 != null && room != room2) { return(false); } } if (pawn != null && pawn.IsColonist && !ProximityGet.GetProxColonist(def)) { return(false); } if (pawn != null && pawn.Drafted && !ProximityGet.GetProxDrafted(def)) { return(false); } if (!ProximityGet.GetProxComposMentis(def)) { return(pawn != null && (!pawn.RaceProps.IsMechanoid || ProximityGet.GetProxMechanoid(def)) && (pawn.RaceProps.FleshType.defName != "Insectoid" || ProximityGet.GetProxInsectoid(def)) && (!pawn.AnimalOrWildMan() || ProximityGet.GetProxAnimal(def)) && (!pawn.IsPrisoner || ProximityGet.GetProxPrisoner(def)) && (pawn.Faction == thing.Faction || GetEffectsOutsider(thing, pawn)) && (ProximityGet.GetProxEquipped(def) == null || GetPawnHasEquipment(thing, pawn))); } if (pawn != null && (pawn.Downed || pawn.InMentalState || pawn.IsBurning() || HealthAIUtility.ShouldSeekMedicalRest(pawn))) { return(false); } if (!pawn.Awake()) { return(false); } return(pawn != null && (!pawn.RaceProps.IsMechanoid || ProximityGet.GetProxMechanoid(def)) && (pawn.RaceProps.FleshType.defName != "Insectoid" || ProximityGet.GetProxInsectoid(def)) && (!pawn.AnimalOrWildMan() || ProximityGet.GetProxAnimal(def)) && (!pawn.IsPrisoner || ProximityGet.GetProxPrisoner(def)) && (pawn.Faction == thing.Faction || GetEffectsOutsider(thing, pawn)) && (ProximityGet.GetProxEquipped(def) == null || GetPawnHasEquipment(thing, pawn))); }
private float GetChangePoints() { if (pawn.IsPrisoner && pawn.IsPrisonerOfColony) { if (pawn.GetRoomGroup() != null) { var value = InspirationTracker.GetInsiprationValue(pawn, true); if (PrisonLaborUtility.LaborEnabled(pawn)) { if (IsPrisonerWorking) { value -= BGP.Laziness_LazyRate; if (HealthAIUtility.ShouldSeekMedicalRest(pawn)) { value -= BGP.Laziness_HealthRate; } if (pawn.needs.food != null) { //warforged value -= (int)pawn.needs.food.CurCategory * BGP.Laziness_HungryRate; } // Some pawns have no rest need (e.g. Pawns with Circadian Half Cycler or androids from other mods) if (pawn.needs.rest != null) { value -= (int)pawn.needs.rest.CurCategory * BGP.Laziness_TiredRate; } } else if (pawn.timetable != null && pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy) { value += BGP.Laziness_JoyRate; } } _GUIChangeArrow = value.CompareTo(0.0f); return(value); } else { _GUIChangeArrow = 0; return(0.0f); } } else { _GUIChangeArrow = 1; return(+0.01f); } }
public static bool Skip(Pawn pawn) { Log.Message($"Skip need tend?"); if (pawn.Map.mapPawns.AllPawnsSpawned.Any(p => HealthAIUtility.ShouldBeTendedNowByPlayer(p) && pawn.CanReserveAndReach(p, PathEndMode.ClosestTouch, Danger.Deadly, ignoreOtherReservations: true))) { return(true); } if (pawn.Map.mapPawns.AllPawnsSpawned.Any(p => p is IBillGiver billGiver && billGiver.BillStack.AnyShouldDoNow && pawn.CanReserveAndReach(p, PathEndMode.ClosestTouch, Danger.Deadly, ignoreOtherReservations: true))) { return(true); } return(false); }
private static void Postfix(ref bool __result, ref WorkGiver_Tend __instance, Pawn pawn, Thing t, bool forced) { if (__result || t == pawn && !(__instance is WorkGiver_TendSelf)) { return; } if (t is Pawn target && target.IsCaptiveOf(pawn.Faction) && !pawn.WorkTypeIsDisabled(WorkTypeDefOf.Doctor) && (!__instance.def.tendToHumanlikesOnly || target.RaceProps.Humanlike && !target.IsWildMan()) && (!__instance.def.tendToAnimalsOnly || target.AnimalOrWildMan()) && target.GetPosture() != PawnPosture.Standing && HealthAIUtility.ShouldBeTendedNowByPlayer(target) && pawn.CanReserve(target, 1, -1, null, forced)) { __result = true; } }
public void Update(RimworldTime time) { var hoursPassed = (time.Year - _updateTime.Year) * 60 * 24 + (time.Day - _updateTime.Day) * 24 + time.Hour - _updateTime.Hour; _updateTime.Day = time.Day; _updateTime.Hour = time.Hour; if (Prefs.DevMode && Settings.VerboseLogging) { Log.Message( $"----- Work Manager: Updating cache for {Pawn.LabelShort} (hours passed = {hoursPassed})... -----"); } IsCapable = !Pawn.Dead && !Pawn.Downed && !Pawn.InMentalState; IsRecovering = IsCapable && Settings.RecoveringPawnsUnfitForWork && HealthAIUtility.ShouldSeekMedicalRest(Pawn); IsManaged = WorkManager.GetPawnEnabled(Pawn); WorkPriorities.Clear(); _managedWorkTypes.Clear(); var workTypes = DefDatabase <WorkTypeDef> .AllDefsListForReading.Where(w => w.visible); foreach (var workType in workTypes) { WorkPriorities.Add(workType, IsManagedWork(workType) ? 0 : Pawn.workSettings.GetPriority(workType)); } if (!IsCapable) { return; } if (hoursPassed >= 24) { DisabledWorkTypes.Clear(); BadWorkTypes.Clear(); } if (hoursPassed >= 6) { if (Settings.UsePawnLearningRateThresholds) { _skillLearningRates.Clear(); foreach (var skill in DefDatabase <SkillDef> .AllDefsListForReading) { _skillLearningRates.Add(skill, Pawn.skills.GetSkill(skill).LearnRateFactor()); } } _workSkillLearningRates.Clear(); _workSkillLevels.Clear(); } }