Exemple #1
0
        /*
         * 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));
        }
        // 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);
        }
        // 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);
        }
 static bool Prefix(ref Job __result, Pawn pawn)
 {
     if (pawn.RaceProps.Animal && pawn.InBed() && (pawn.CurrentBed().Medical || HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) || pawn.health.hediffSet.HasTendedAndHealingInjury()))
     {
         __result = null;
         return(false);
     }
     return(true);
 }
 public override bool ShouldMeasureTimeNow(Pawn pawn)
 {
     return(pawn.InBed() && (HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) || HealthAIUtility.ShouldSeekMedicalRest(pawn) || pawn.CurJob.restUntilHealed));
 }
Exemple #6
0
        public static bool VampCanMeditateNow(ref bool __result, Pawn pawn)
        {
            bool flag = pawn.IsVampire();
            bool result;

            if (flag)
            {
                bool flag2 = pawn.needs.rest != null && pawn.needs.rest.CurCategory >= RestCategory.VeryTired;
                if (flag2)
                {
                    __result = false;
                    result   = false;
                }
                else
                {
                    bool starving = pawn.needs.TryGetNeed <Need_Blood>().Starving;
                    if (starving)
                    {
                        __result = false;
                        result   = false;
                    }
                    else
                    {
                        bool flag3 = !pawn.Awake();
                        if (flag3)
                        {
                            __result = false;
                            result   = false;
                        }
                        else
                        {
                            bool flag4 = pawn.health.hediffSet.BleedRateTotal <= 0f;
                            if (flag4)
                            {
                                bool flag5 = HealthAIUtility.ShouldSeekMedicalRest(pawn);
                                if (flag5)
                                {
                                    Pawn_TimetableTracker timetable = pawn.timetable;
                                    bool flag6 = ((timetable != null) ? timetable.CurrentAssignment : null) != TimeAssignmentDefOf.Meditate;
                                    if (flag6)
                                    {
                                        __result = false;
                                        return(false);
                                    }
                                }
                                bool flag7 = !HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn);
                                if (flag7)
                                {
                                    __result = true;
                                    return(false);
                                }
                            }
                            __result = false;
                            result   = false;
                        }
                    }
                }
            }
            else
            {
                result = true;
            }
            return(result);
        }