Beispiel #1
0
 public static void Postfix(WeatherManager __instance, Map map)
 {
     if (map.weatherManager.curWeather.defName == "LotRW_HealingRainWD")
     {
         if (Find.TickManager.TicksGame % 10 == 0)
         {
             Pawn pawn = map.mapPawns.AllPawnsSpawned.RandomElement();
             if (!pawn.Position.Roofed(map))
             {
                 IEnumerable <Hediff_Injury> injuries = pawn.health.hediffSet.GetHediffs <Hediff_Injury>();
                 if (injuries != null && injuries.Count() > 0)
                 {
                     Hediff_Injury injury = injuries.RandomElement();
                     if (injury.CanHealNaturally() && !injury.IsPermanent())
                     {
                         injury.Heal(Rand.Range(.2f, 2f));
                         if (Rand.Chance(.5f))
                         {
                             EffectMaker.MakeEffect(ThingDef.Named("Mote_HealingWaves"), pawn.DrawPos, map, Rand.Range(.4f, .6f), 180, 1f, 0);
                         }
                         else
                         {
                             EffectMaker.MakeEffect(ThingDef.Named("Mote_HealingWaves"), pawn.DrawPos, map, Rand.Range(.4f, .6f), 180, 1f, 0, 180, .1f, .02f, .19f, false);
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 // Token: 0x06004BC8 RID: 19400 RVA: 0x0023675C File Offset: 0x00234B5C
 public static void HealNonPermanentInjuriesAndRestoreLegs(Pawn p)
 {
     if (p.Dead)
     {
         return;
     }
     HealthShardTendUtility.tmpHediffs.Clear();
     HealthShardTendUtility.tmpHediffs.AddRange(p.health.hediffSet.hediffs);
     for (int i = 0; i < HealthShardTendUtility.tmpHediffs.Count; i++)
     {
         Hediff_Injury hediff_Injury = HealthShardTendUtility.tmpHediffs[i] as Hediff_Injury;
         if (hediff_Injury != null && !hediff_Injury.IsPermanent())
         {
             p.health.RemoveHediff(hediff_Injury);
         }
         else
         {
             Hediff_MissingPart hediff_MissingPart = HealthShardTendUtility.tmpHediffs[i] as Hediff_MissingPart;
             if (hediff_MissingPart != null && hediff_MissingPart.Part.def.tags.Contains(BodyPartTagDefOf.MovingLimbCore) && (hediff_MissingPart.Part.parent == null || p.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null).Contains(hediff_MissingPart.Part.parent)))
             {
                 p.health.RestorePart(hediff_MissingPart.Part, null, true);
             }
         }
     }
     HealthShardTendUtility.tmpHediffs.Clear();
 }
Beispiel #3
0
        private Hediff_Injury FindPermanentInjury(Pawn pawn, IEnumerable <BodyPartRecord> allowedBodyParts = null)
        {
            Hediff_Injury hediff_Injury = null;
            List <Hediff> hediffs       = pawn.health.hediffSet.hediffs;

            for (int i = 0; i < hediffs.Count; i++)
            {
                Hediff_Injury hediff_Injury2 = hediffs[i] as Hediff_Injury;
                if (hediff_Injury2 != null && hediff_Injury2.Visible && hediff_Injury2.IsPermanent() && hediff_Injury2.def.everCurableByItem && (allowedBodyParts == null || allowedBodyParts.Contains(hediff_Injury2.Part)) && (hediff_Injury == null || hediff_Injury2.Severity > hediff_Injury.Severity))
                {
                    hediff_Injury = hediff_Injury2;
                }
            }
            return(hediff_Injury);
        }
Beispiel #4
0
        private static IEnumerable <Hediff_Injury> FindPermanentInjurys(Pawn pawn)
        {
            List <Hediff> hediffs = pawn.health.hediffSet.hediffs;

            for (int i = 0; i < hediffs.Count; i++)
            {
                Hediff_Injury hediff_Injury2 = hediffs[i] as Hediff_Injury;
                if (hediff_Injury2 != null && hediff_Injury2.Visible && hediff_Injury2.IsPermanent() && hediff_Injury2.def.everCurableByItem)
                {
                    //if (hediff_Injury == null || hediff_Injury2.Severity > hediff_Injury.Severity)
                    {
                        yield return(hediff_Injury2);
                    }
                }
            }
        }
Beispiel #5
0
        private Hediff_Injury FindPermanentInjury(Pawn pawn)
        {
            Hediff_Injury hediff_Injury = null;
            List <Hediff> hediffs       = pawn.health.hediffSet.hediffs;

            for (int i = 0; i < hediffs.Count; i++)
            {
                Hediff_Injury hediff_Injury2 = hediffs[i] as Hediff_Injury;
                if (hediff_Injury2 != null && hediff_Injury2.Visible && hediff_Injury2.IsPermanent() && hediff_Injury2.def.everCurableByItem && hediff_Injury2.def.isBad)
                {
                    if (hediff_Injury == null || hediff_Injury2.Severity > hediff_Injury.Severity)
                    {
                        hediff_Injury = hediff_Injury2;
                    }
                }
            }
            return(hediff_Injury);
        }
 private static void HealIfPossible(Pawn p)
 {
     PawnBanishUtility.tmpHediffs.Clear();
     PawnBanishUtility.tmpHediffs.AddRange(p.health.hediffSet.hediffs);
     for (int i = 0; i < PawnBanishUtility.tmpHediffs.Count; i++)
     {
         Hediff_Injury hediff_Injury = PawnBanishUtility.tmpHediffs[i] as Hediff_Injury;
         if (hediff_Injury != null && !hediff_Injury.IsPermanent())
         {
             p.health.RemoveHediff(hediff_Injury);
         }
         else
         {
             ImmunityRecord immunityRecord = p.health.immunity.GetImmunityRecord(PawnBanishUtility.tmpHediffs[i].def);
             if (immunityRecord != null)
             {
                 immunityRecord.immunity = 1f;
             }
         }
     }
 }
Beispiel #7
0
        public void RenderOverBody(Vector3 drawLoc, Mesh bodyMesh, Quaternion quat, bool forPortrait)
        {
            int           num     = 0;
            List <Hediff> hediffs = pawn.health.hediffSet.hediffs;

            for (int i = 0; i < hediffs.Count; i++)
            {
                if (hediffs[i].def.displayWound)
                {
                    Hediff_Injury hediff_Injury = hediffs[i] as Hediff_Injury;
                    if (hediff_Injury == null || !hediff_Injury.IsPermanent())
                    {
                        num++;
                    }
                }
            }
            int num2 = Mathf.CeilToInt((float)num / 2f);

            if (num2 > MaxDisplayWounds)
            {
                num2 = MaxDisplayWounds;
            }
            while (wounds.Count < num2)
            {
                wounds.Add(new Wound(pawn));
                PortraitsCache.SetDirty(pawn);
            }
            while (wounds.Count > num2)
            {
                wounds.Remove(wounds.RandomElement());
                PortraitsCache.SetDirty(pawn);
            }
            for (int j = 0; j < wounds.Count; j++)
            {
                wounds[j].DrawWound(drawLoc, quat, pawn.Rotation, forPortrait);
            }
        }
Beispiel #8
0
 // Token: 0x06004CAA RID: 19626 RVA: 0x0023A4A2 File Offset: 0x002388A2
 public static bool CanHealNaturally(this Hediff_Injury hd)
 {
     return(!hd.IsPermanent());
 }
Beispiel #9
0
 // Token: 0x06004CA9 RID: 19625 RVA: 0x0023A489 File Offset: 0x00238889
 public static bool CanHealFromTending(this Hediff_Injury hd)
 {
     return(hd.IsTended() && !hd.IsPermanent());
 }