示例#1
0
        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*/;
            }
        }
示例#2
0
 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());
 }
        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);
        }
        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()));
        }
示例#6
0
 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 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 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 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*/;
        }
示例#10
0
 public override Job NonScanJob(Pawn pawn)
 {
     if (!HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn))
     {
         return(null);
     }
     if (!AnyAvailableDoctorFor(pawn))
     {
         return(null);
     }
     return(base.NonScanJob(pawn));
 }
 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);
 }
示例#12
0
        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);
        }
        public override Job NonScanJob(Pawn pawn)
        {
            Job result;

            if (!HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn))
            {
                result = null;
            }
            else if (!this.AnyAvailableDoctorFor(pawn))
            {
                result = null;
            }
            else
            {
                result = base.NonScanJob(pawn);
            }
            return(result);
        }
示例#14
0
 public override bool ShouldMeasureTimeNow(Pawn pawn)
 {
     if (!pawn.InBed())
     {
         return(false);
     }
     if (!HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn))
     {
         if (HealthAIUtility.ShouldSeekMedicalRest(pawn))
         {
             if (pawn.needs.rest != null && !(pawn.needs.rest.CurLevel >= 1f))
             {
                 return(pawn.CurJob.restUntilHealed);
             }
             return(true);
         }
         return(false);
     }
     return(true);
 }
 public static bool CanMeditateNow(Pawn pawn)
 {
     if (pawn.needs.rest != null && (int)pawn.needs.rest.CurCategory >= 2)
     {
         return(false);
     }
     if (pawn.needs.food.Starving)
     {
         return(false);
     }
     if (!pawn.Awake())
     {
         return(false);
     }
     if (pawn.health.hediffSet.BleedRateTotal > 0f || (HealthAIUtility.ShouldSeekMedicalRest(pawn) && pawn.timetable?.CurrentAssignment != TimeAssignmentDefOf.Meditate) || HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn))
     {
         return(false);
     }
     return(true);
 }
示例#16
0
 public static bool FianceReadyToStartCeremony(Pawn pawn)
 {
     return(MarriageCeremonyUtility.FianceCanContinueCeremony(pawn) && pawn.health.hediffSet.BleedRateTotal <= 0f && !HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) && !PawnUtility.WillSoonHaveBasicNeed(pawn) && !MarriageCeremonyUtility.IsCurrentlyMarryingSomeone(pawn) && pawn.GetLord() == null && (!pawn.Drafted && !pawn.InMentalState && pawn.Awake() && !pawn.IsBurning()) && !pawn.InBed());
 }
示例#17
0
 public static bool ShouldSeekMedicalRest(Pawn pawn)
 {
     return(HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) || pawn.health.hediffSet.HasTendedAndHealingInjury() || pawn.health.hediffSet.HasImmunizableNotImmuneHediff());
 }