コード例 #1
0
        public static float FlatHill(float minY, float min, float lower, float upper, float max, float maxY, float x)
        {
            float result;

            if (x < min)
            {
                result = minY;
            }
            else if (x < lower)
            {
                result = GenMath.LerpDouble(min, lower, minY, 1f, x);
            }
            else if (x < upper)
            {
                result = 1f;
            }
            else if (x < max)
            {
                result = GenMath.LerpDouble(upper, max, 1f, maxY, x);
            }
            else
            {
                result = maxY;
            }
            return(result);
        }
コード例 #2
0
ファイル: DebugOutputsPawns.cs プロジェクト: potsh/RimWorld
        public static void AnimalsBasics()
        {
            Func <PawnKindDef, float> dps         = (PawnKindDef d) => RaceMeleeDpsEstimate(d.race);
            Func <PawnKindDef, float> pointsGuess = delegate(PawnKindDef d)
            {
                float num2 = 15f;
                num2 += dps(d) * 10f;
                num2 *= Mathf.Lerp(1f, d.race.GetStatValueAbstract(StatDefOf.MoveSpeed) / 3f, 0.25f);
                num2 *= d.RaceProps.baseHealthScale;
                num2 *= GenMath.LerpDouble(0.25f, 1f, 1.65f, 1f, Mathf.Clamp(d.RaceProps.baseBodySize, 0.25f, 1f));
                return(num2 * 0.76f);
            };
            Func <PawnKindDef, float> mktValGuess = delegate(PawnKindDef d)
            {
                float num = 18f;
                num += pointsGuess(d) * 2.7f;
                if (d.RaceProps.trainability == TrainabilityDefOf.None)
                {
                    num *= 0.5f;
                }
                else if (d.RaceProps.trainability == TrainabilityDefOf.Simple)
                {
                    num *= 0.8f;
                }
                else if (d.RaceProps.trainability == TrainabilityDefOf.Intermediate)
                {
                    num = num;
                }
                else
                {
                    if (d.RaceProps.trainability != TrainabilityDefOf.Advanced)
                    {
                        throw new InvalidOperationException();
                    }
                    num += 250f;
                }
                num += d.RaceProps.baseBodySize * 80f;
                if (d.race.HasComp(typeof(CompMilkable)))
                {
                    num += 125f;
                }
                if (d.race.HasComp(typeof(CompShearable)))
                {
                    num += 90f;
                }
                if (d.race.HasComp(typeof(CompEggLayer)))
                {
                    num += 90f;
                }
                num *= Mathf.Lerp(0.8f, 1.2f, d.RaceProps.wildness);
                return(num * 0.75f);
            };

            DebugTables.MakeTablesDialog(from d in DefDatabase <PawnKindDef> .AllDefs
                                         where d.race != null && d.RaceProps.Animal
                                         select d, new TableDataGetter <PawnKindDef>("defName", (PawnKindDef d) => d.defName), new TableDataGetter <PawnKindDef>("dps", (PawnKindDef d) => dps(d).ToString("F2")), new TableDataGetter <PawnKindDef>("healthScale", (PawnKindDef d) => d.RaceProps.baseHealthScale.ToString("F2")), new TableDataGetter <PawnKindDef>("points", (PawnKindDef d) => d.combatPower.ToString("F0")), new TableDataGetter <PawnKindDef>("points guess", (PawnKindDef d) => pointsGuess(d).ToString("F0")), new TableDataGetter <PawnKindDef>("speed", (PawnKindDef d) => d.race.GetStatValueAbstract(StatDefOf.MoveSpeed).ToString("F2")), new TableDataGetter <PawnKindDef>("mktval", (PawnKindDef d) => d.race.GetStatValueAbstract(StatDefOf.MarketValue).ToString("F0")), new TableDataGetter <PawnKindDef>("mktval guess", (PawnKindDef d) => mktValGuess(d).ToString("F0")), new TableDataGetter <PawnKindDef>("bodySize", (PawnKindDef d) => d.RaceProps.baseBodySize.ToString("F2")), new TableDataGetter <PawnKindDef>("hunger", (PawnKindDef d) => d.RaceProps.baseHungerRate.ToString("F2")), new TableDataGetter <PawnKindDef>("wildness", (PawnKindDef d) => d.RaceProps.wildness.ToStringPercent()), new TableDataGetter <PawnKindDef>("lifespan", (PawnKindDef d) => d.RaceProps.lifeExpectancy.ToString("F1")), new TableDataGetter <PawnKindDef>("trainability", (PawnKindDef d) => (d.RaceProps.trainability == null) ? "null" : d.RaceProps.trainability.label), new TableDataGetter <PawnKindDef>("tempMin", (PawnKindDef d) => d.race.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin).ToString("F0")), new TableDataGetter <PawnKindDef>("tempMax", (PawnKindDef d) => d.race.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax).ToString("F0")));
        }
コード例 #3
0
ファイル: SimpleCurve.cs プロジェクト: KraigXu/GameProject
        public float EvaluateInverted(float y)
        {
            if (points.Count == 0)
            {
                Log.Error("Evaluating a SimpleCurve with no points.");
                return(0f);
            }
            if (points.Count == 1)
            {
                return(points[0].x);
            }
            for (int i = 0; i < points.Count - 1; i++)
            {
                if ((y >= points[i].y && y <= points[i + 1].y) || (y <= points[i].y && y >= points[i + 1].y))
                {
                    if (y == points[i].y)
                    {
                        return(points[i].x);
                    }
                    if (y == points[i + 1].y)
                    {
                        return(points[i + 1].x);
                    }
                    return(GenMath.LerpDouble(points[i].y, points[i + 1].y, points[i].x, points[i + 1].x, y));
                }
            }
            if (y < points[0].y)
            {
                float result = 0f;
                float num    = 0f;
                for (int j = 0; j < points.Count; j++)
                {
                    if (j == 0 || points[j].y < num)
                    {
                        num    = points[j].y;
                        result = points[j].x;
                    }
                }
                return(result);
            }
            float result2 = 0f;
            float num2    = 0f;

            for (int k = 0; k < points.Count; k++)
            {
                if (k == 0 || points[k].y > num2)
                {
                    num2    = points[k].y;
                    result2 = points[k].x;
                }
            }
            return(result2);
        }
コード例 #4
0
 public static float FlatHill(float minY, float min, float lower, float upper, float max, float maxY, float x)
 {
     if (x < min)
     {
         return(minY);
     }
     if (x < lower)
     {
         return(GenMath.LerpDouble(min, lower, minY, 1f, x));
     }
     if (x < upper)
     {
         return(1f);
     }
     if (x < max)
     {
         return(GenMath.LerpDouble(upper, max, 1f, maxY, x));
     }
     return(maxY);
 }
コード例 #5
0
 public void HealthTick()
 {
     if (!this.Dead)
     {
         for (int i = this.hediffSet.hediffs.Count - 1; i >= 0; i--)
         {
             Hediff hediff = this.hediffSet.hediffs[i];
             try
             {
                 hediff.Tick();
                 hediff.PostTick();
             }
             catch (Exception ex)
             {
                 Log.Error(string.Concat(new object[]
                 {
                     "Exception ticking hediff ",
                     hediff.ToStringSafe <Hediff>(),
                     " for pawn ",
                     this.pawn.ToStringSafe <Pawn>(),
                     ". Removing hediff... Exception: ",
                     ex
                 }), false);
                 try
                 {
                     this.RemoveHediff(hediff);
                 }
                 catch (Exception arg)
                 {
                     Log.Error("Error while removing hediff: " + arg, false);
                 }
             }
         }
         bool flag = false;
         for (int j = this.hediffSet.hediffs.Count - 1; j >= 0; j--)
         {
             Hediff hediff2 = this.hediffSet.hediffs[j];
             if (hediff2.ShouldRemove)
             {
                 this.hediffSet.hediffs.RemoveAt(j);
                 hediff2.PostRemoved();
                 flag = true;
             }
         }
         if (flag)
         {
             this.Notify_HediffChanged(null);
         }
         if (!this.Dead)
         {
             this.immunity.ImmunityHandlerTick();
             if (this.pawn.RaceProps.IsFlesh && this.pawn.IsHashIntervalTick(600) && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving))
             {
                 bool flag2 = false;
                 if (this.hediffSet.HasNaturallyHealingInjury())
                 {
                     float num = 8f;
                     if (this.pawn.GetPosture() != PawnPosture.Standing)
                     {
                         num += 4f;
                         Building_Bed building_Bed = this.pawn.CurrentBed();
                         if (building_Bed != null)
                         {
                             num += building_Bed.def.building.bed_healPerDay;
                         }
                     }
                     Hediff_Injury hediff_Injury = (from x in this.hediffSet.GetHediffs <Hediff_Injury>()
                                                    where x.CanHealNaturally()
                                                    select x).RandomElement <Hediff_Injury>();
                     hediff_Injury.Heal(num * this.pawn.HealthScale * 0.01f);
                     flag2 = true;
                 }
                 if (this.hediffSet.HasTendedAndHealingInjury() && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving))
                 {
                     Hediff_Injury hediff_Injury2 = (from x in this.hediffSet.GetHediffs <Hediff_Injury>()
                                                     where x.CanHealFromTending()
                                                     select x).RandomElement <Hediff_Injury>();
                     float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality;
                     float num2        = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality));
                     hediff_Injury2.Heal(22f * num2 * this.pawn.HealthScale * 0.01f);
                     flag2 = true;
                 }
                 if (flag2 && !this.HasHediffsNeedingTendByPlayer(false) && !HealthAIUtility.ShouldSeekMedicalRest(this.pawn) && !this.hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(this.pawn))
                 {
                     Messages.Message("MessageFullyHealed".Translate(new object[]
                     {
                         this.pawn.LabelCap
                     }), this.pawn, MessageTypeDefOf.PositiveEvent, true);
                 }
             }
             if (this.pawn.RaceProps.IsFlesh && this.hediffSet.BleedRateTotal >= 0.1f)
             {
                 float num3 = this.hediffSet.BleedRateTotal * this.pawn.BodySize;
                 if (this.pawn.GetPosture() == PawnPosture.Standing)
                 {
                     num3 *= 0.004f;
                 }
                 else
                 {
                     num3 *= 0.0004f;
                 }
                 if (Rand.Value < num3)
                 {
                     this.DropBloodFilth();
                 }
             }
             if (this.pawn.IsHashIntervalTick(60))
             {
                 List <HediffGiverSetDef> hediffGiverSets = this.pawn.RaceProps.hediffGiverSets;
                 if (hediffGiverSets != null)
                 {
                     for (int k = 0; k < hediffGiverSets.Count; k++)
                     {
                         List <HediffGiver> hediffGivers = hediffGiverSets[k].hediffGivers;
                         for (int l = 0; l < hediffGivers.Count; l++)
                         {
                             hediffGivers[l].OnIntervalPassed(this.pawn, null);
                             if (this.pawn.Dead)
                             {
                                 return;
                             }
                         }
                     }
                 }
                 if (this.pawn.story != null)
                 {
                     List <Trait> allTraits = this.pawn.story.traits.allTraits;
                     for (int m = 0; m < allTraits.Count; m++)
                     {
                         TraitDegreeData currentData = allTraits[m].CurrentData;
                         if (currentData.randomDiseaseMtbDays > 0f && Rand.MTBEventOccurs(currentData.randomDiseaseMtbDays, 60000f, 60f))
                         {
                             BiomeDef biome;
                             if (this.pawn.Tile != -1)
                             {
                                 biome = Find.WorldGrid[this.pawn.Tile].biome;
                             }
                             else
                             {
                                 biome = DefDatabase <BiomeDef> .GetRandom();
                             }
                             IncidentDef incidentDef = (from d in DefDatabase <IncidentDef> .AllDefs
                                                        where d.category == IncidentCategoryDefOf.DiseaseHuman
                                                        select d).RandomElementByWeightWithFallback((IncidentDef d) => biome.CommonalityOfDisease(d), null);
                             if (incidentDef != null)
                             {
                                 ((IncidentWorker_Disease)incidentDef.Worker).ApplyToPawns(Gen.YieldSingle <Pawn>(this.pawn));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
 public static float LerpDoubleClamped(float inFrom, float inTo, float outFrom, float outTo, float x)
 {
     return(GenMath.LerpDouble(inFrom, inTo, outFrom, outTo, Mathf.Clamp(x, Mathf.Min(inFrom, inTo), Mathf.Max(inFrom, inTo))));
 }
コード例 #7
0
        public void HealthTick()
        {
            if (this.Dead)
            {
                return;
            }
            for (int i = this.hediffSet.hediffs.Count - 1; i >= 0; i--)
            {
                Hediff hediff = this.hediffSet.hediffs[i];
                hediff.Tick();
                hediff.PostTick();
            }
            bool flag = false;

            for (int j = this.hediffSet.hediffs.Count - 1; j >= 0; j--)
            {
                Hediff hediff2 = this.hediffSet.hediffs[j];
                if (hediff2.ShouldRemove)
                {
                    this.hediffSet.hediffs.RemoveAt(j);
                    hediff2.PostRemoved();
                    flag = true;
                }
            }
            if (flag)
            {
                this.Notify_HediffChanged(null);
            }
            if (this.Dead)
            {
                return;
            }
            this.immunity.ImmunityHandlerTick();
            if (this.pawn.RaceProps.IsFlesh && this.pawn.IsHashIntervalTick(600) && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving))
            {
                bool flag2 = false;
                if (this.hediffSet.HasNaturallyHealingInjury())
                {
                    float num = 8f;
                    if (this.pawn.GetPosture() != PawnPosture.Standing)
                    {
                        num += 4f;
                        Building_Bed building_Bed = this.pawn.CurrentBed();
                        if (building_Bed != null)
                        {
                            num += building_Bed.def.building.bed_healPerDay;
                        }
                    }
                    Hediff_Injury hediff_Injury = this.hediffSet.GetHediffs <Hediff_Injury>().Where(new Func <Hediff_Injury, bool>(HediffUtility.CanHealNaturally)).RandomElement <Hediff_Injury>();
                    hediff_Injury.Heal(num * this.pawn.HealthScale * 0.01f);
                    flag2 = true;
                }
                if (this.hediffSet.HasTendedAndHealingInjury() && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving))
                {
                    Hediff_Injury hediff_Injury2 = this.hediffSet.GetHediffs <Hediff_Injury>().Where(new Func <Hediff_Injury, bool>(HediffUtility.CanHealFromTending)).RandomElement <Hediff_Injury>();
                    float         tendQuality    = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality;
                    float         num2           = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality));
                    hediff_Injury2.Heal(22f * num2 * this.pawn.HealthScale * 0.01f);
                    flag2 = true;
                }
                if (flag2 && !this.HasHediffsNeedingTendByColony(false) && !HealthAIUtility.ShouldSeekMedicalRest(this.pawn) && !this.hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(this.pawn))
                {
                    Messages.Message("MessageFullyHealed".Translate(new object[]
                    {
                        this.pawn.LabelCap
                    }), this.pawn, MessageTypeDefOf.PositiveEvent);
                }
            }
            if (this.pawn.RaceProps.IsFlesh && this.hediffSet.BleedRateTotal >= 0.1f)
            {
                float num3 = this.hediffSet.BleedRateTotal * this.pawn.BodySize;
                if (this.pawn.GetPosture() == PawnPosture.Standing)
                {
                    num3 *= 0.008f;
                }
                else
                {
                    num3 *= 0.0008f;
                }
                if (Rand.Value < num3)
                {
                    this.TryDropBloodFilth();
                }
            }
            List <HediffGiverSetDef> hediffGiverSets = this.pawn.RaceProps.hediffGiverSets;

            if (hediffGiverSets != null && this.pawn.IsHashIntervalTick(60))
            {
                for (int k = 0; k < hediffGiverSets.Count; k++)
                {
                    List <HediffGiver> hediffGivers = hediffGiverSets[k].hediffGivers;
                    for (int l = 0; l < hediffGivers.Count; l++)
                    {
                        hediffGivers[l].OnIntervalPassed(this.pawn, null);
                        if (this.pawn.Dead)
                        {
                            return;
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: Pawn_HealthTracker.cs プロジェクト: potsh/RimWorld
 public void HealthTick()
 {
     if (!Dead)
     {
         for (int num = hediffSet.hediffs.Count - 1; num >= 0; num--)
         {
             Hediff hediff = hediffSet.hediffs[num];
             try
             {
                 hediff.Tick();
                 hediff.PostTick();
             }
             catch (Exception ex)
             {
                 Log.Error("Exception ticking hediff " + hediff.ToStringSafe() + " for pawn " + pawn.ToStringSafe() + ". Removing hediff... Exception: " + ex);
                 try
                 {
                     RemoveHediff(hediff);
                 }
                 catch (Exception arg)
                 {
                     Log.Error("Error while removing hediff: " + arg);
                 }
             }
         }
         bool flag = false;
         for (int num2 = hediffSet.hediffs.Count - 1; num2 >= 0; num2--)
         {
             Hediff hediff2 = hediffSet.hediffs[num2];
             if (hediff2.ShouldRemove)
             {
                 hediffSet.hediffs.RemoveAt(num2);
                 hediff2.PostRemoved();
                 flag = true;
             }
         }
         if (flag)
         {
             Notify_HediffChanged(null);
         }
         if (!Dead)
         {
             immunity.ImmunityHandlerTick();
             if (pawn.RaceProps.IsFlesh && pawn.IsHashIntervalTick(600) && (pawn.needs.food == null || !pawn.needs.food.Starving))
             {
                 bool flag2 = false;
                 if (hediffSet.HasNaturallyHealingInjury())
                 {
                     float num3 = 8f;
                     if (pawn.GetPosture() != 0)
                     {
                         num3 += 4f;
                         Building_Bed building_Bed = pawn.CurrentBed();
                         if (building_Bed != null)
                         {
                             num3 += building_Bed.def.building.bed_healPerDay;
                         }
                     }
                     Hediff_Injury hediff_Injury = hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealNaturally).RandomElement();
                     hediff_Injury.Heal(num3 * pawn.HealthScale * 0.01f);
                     flag2 = true;
                 }
                 if (hediffSet.HasTendedAndHealingInjury() && (pawn.needs.food == null || !pawn.needs.food.Starving))
                 {
                     Hediff_Injury hediff_Injury2 = hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealFromTending).RandomElement();
                     float         tendQuality    = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality;
                     float         num4           = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality));
                     hediff_Injury2.Heal(8f * num4 * pawn.HealthScale * 0.01f);
                     flag2 = true;
                 }
                 if (flag2 && !HasHediffsNeedingTendByPlayer() && !HealthAIUtility.ShouldSeekMedicalRest(pawn) && !hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(pawn))
                 {
                     Messages.Message("MessageFullyHealed".Translate(pawn.LabelCap, pawn), pawn, MessageTypeDefOf.PositiveEvent);
                 }
             }
             if (pawn.RaceProps.IsFlesh && hediffSet.BleedRateTotal >= 0.1f)
             {
                 float num5 = hediffSet.BleedRateTotal * pawn.BodySize;
                 num5 = ((pawn.GetPosture() != 0) ? (num5 * 0.0004f) : (num5 * 0.004f));
                 if (Rand.Value < num5)
                 {
                     DropBloodFilth();
                 }
             }
             if (pawn.IsHashIntervalTick(60))
             {
                 List <HediffGiverSetDef> hediffGiverSets = pawn.RaceProps.hediffGiverSets;
                 if (hediffGiverSets != null)
                 {
                     for (int i = 0; i < hediffGiverSets.Count; i++)
                     {
                         List <HediffGiver> hediffGivers = hediffGiverSets[i].hediffGivers;
                         for (int j = 0; j < hediffGivers.Count; j++)
                         {
                             hediffGivers[j].OnIntervalPassed(pawn, null);
                             if (pawn.Dead)
                             {
                                 return;
                             }
                         }
                     }
                 }
                 if (pawn.story != null)
                 {
                     List <Trait> allTraits = pawn.story.traits.allTraits;
                     for (int k = 0; k < allTraits.Count; k++)
                     {
                         TraitDegreeData currentData = allTraits[k].CurrentData;
                         if (currentData.randomDiseaseMtbDays > 0f && Rand.MTBEventOccurs(currentData.randomDiseaseMtbDays, 60000f, 60f))
                         {
                             BiomeDef biome;
                             if (pawn.Tile != -1)
                             {
                                 biome = Find.WorldGrid[pawn.Tile].biome;
                             }
                             else
                             {
                                 biome = DefDatabase <BiomeDef> .GetRandom();
                             }
                             IncidentDef incidentDef = (from d in DefDatabase <IncidentDef> .AllDefs
                                                        where d.category == IncidentCategoryDefOf.DiseaseHuman
                                                        select d).RandomElementByWeightWithFallback((IncidentDef d) => biome.CommonalityOfDisease(d));
                             if (incidentDef != null)
                             {
                                 string      blockedInfo;
                                 List <Pawn> list = ((IncidentWorker_Disease)incidentDef.Worker).ApplyToPawns(Gen.YieldSingle(pawn), out blockedInfo);
                                 if (PawnUtility.ShouldSendNotificationAbout(pawn))
                                 {
                                     if (list.Contains(pawn))
                                     {
                                         Find.LetterStack.ReceiveLetter("LetterLabelTraitDisease".Translate(incidentDef.diseaseIncident.label), "LetterTraitDisease".Translate(pawn.LabelCap, incidentDef.diseaseIncident.label, pawn.Named("PAWN")).AdjustedFor(pawn), LetterDefOf.NegativeEvent, pawn);
                                     }
                                     else if (!blockedInfo.NullOrEmpty())
                                     {
                                         Messages.Message(blockedInfo, pawn, MessageTypeDefOf.NeutralEvent);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #9
0
 static float pointsGuess(PawnKindDef d)
 {
     return((15f + dps(d) * 10f) * Mathf.Lerp(1f, d.race.GetStatValueAbstract(StatDefOf.MoveSpeed) / 3f, 0.25f) * d.RaceProps.baseHealthScale * GenMath.LerpDouble(0.25f, 1f, 1.65f, 1f, Mathf.Clamp(d.RaceProps.baseBodySize, 0.25f, 1f)) * 0.76f);
 }
コード例 #10
0
 public void HealthTick()
 {
     if (!this.Dead)
     {
         for (int num = this.hediffSet.hediffs.Count - 1; num >= 0; num--)
         {
             Hediff hediff = this.hediffSet.hediffs[num];
             hediff.Tick();
             hediff.PostTick();
         }
         bool flag = false;
         for (int num2 = this.hediffSet.hediffs.Count - 1; num2 >= 0; num2--)
         {
             Hediff hediff2 = this.hediffSet.hediffs[num2];
             if (hediff2.ShouldRemove)
             {
                 this.hediffSet.hediffs.RemoveAt(num2);
                 hediff2.PostRemoved();
                 flag = true;
             }
         }
         if (flag)
         {
             this.Notify_HediffChanged(null);
         }
         if (!this.Dead)
         {
             this.immunity.ImmunityHandlerTick();
             if (this.pawn.RaceProps.IsFlesh && this.pawn.IsHashIntervalTick(600) && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving))
             {
                 bool flag2 = false;
                 if (this.hediffSet.HasNaturallyHealingInjury())
                 {
                     float num3 = 8f;
                     if (this.pawn.GetPosture() != 0)
                     {
                         num3 = (float)(num3 + 4.0);
                         Building_Bed building_Bed = this.pawn.CurrentBed();
                         if (building_Bed != null)
                         {
                             num3 += building_Bed.def.building.bed_healPerDay;
                         }
                     }
                     Hediff_Injury hediff_Injury = this.hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealNaturally).RandomElement();
                     hediff_Injury.Heal((float)(num3 * this.pawn.HealthScale * 0.0099999997764825821));
                     flag2 = true;
                 }
                 if (this.hediffSet.HasTendedAndHealingInjury() && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving))
                 {
                     Hediff_Injury hediff_Injury2 = this.hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealFromTending).RandomElement();
                     float         tendQuality    = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality;
                     float         num4           = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality));
                     hediff_Injury2.Heal((float)(22.0 * num4 * this.pawn.HealthScale * 0.0099999997764825821));
                     flag2 = true;
                 }
                 if (flag2 && !this.HasHediffsNeedingTendByColony(false) && !HealthAIUtility.ShouldSeekMedicalRest(this.pawn) && !this.hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(this.pawn))
                 {
                     Messages.Message("MessageFullyHealed".Translate(this.pawn.LabelCap), this.pawn, MessageTypeDefOf.PositiveEvent);
                 }
             }
             if (this.pawn.RaceProps.IsFlesh && this.hediffSet.BleedRateTotal >= 0.10000000149011612)
             {
                 float num5 = this.hediffSet.BleedRateTotal * this.pawn.BodySize;
                 num5 = (float)((this.pawn.GetPosture() != 0) ? (num5 * 0.00079999997979030013) : (num5 * 0.00800000037997961));
                 if (Rand.Value < num5)
                 {
                     this.TryDropBloodFilth();
                 }
             }
             List <HediffGiverSetDef> hediffGiverSets = this.pawn.RaceProps.hediffGiverSets;
             if (hediffGiverSets != null && this.pawn.IsHashIntervalTick(60))
             {
                 for (int i = 0; i < hediffGiverSets.Count; i++)
                 {
                     List <HediffGiver> hediffGivers = hediffGiverSets[i].hediffGivers;
                     int num6 = 0;
                     while (num6 < hediffGivers.Count)
                     {
                         hediffGivers[num6].OnIntervalPassed(this.pawn, null);
                         if (!this.pawn.Dead)
                         {
                             num6++;
                             continue;
                         }
                         return;
                     }
                 }
             }
         }
     }
 }