Beispiel #1
0
 public void TryRegrowBodyparts(bool Forced = false)
 {
     using IEnumerator <BodyPartRecord> enumerator = this.Pawn.GetFirstMatchingBodyparts(this.Pawn.RaceProps.body.corePart, HediffDefOf.MissingBodyPart, AdeptusHediffDefOf.OG_Regenerating, (Hediff hediff) => hediff is Hediff_AddedPart).GetEnumerator();
     while (enumerator.MoveNext())
     {
         BodyPartRecord part = enumerator.Current;
         bool           any  = this.Pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.Part == part && hediff.def == HediffDefOf.MissingBodyPart && (HealableHediffs.Contains(hediff) || Forced));
         if (any)
         {
             Hediff hediff2 = this.Pawn.health.hediffSet.hediffs.First((Hediff hediff) => hediff.Part == part && hediff.def == HediffDefOf.MissingBodyPart && (HealableHediffs.Contains(hediff) || Forced));
             bool   flag    = hediff2 != null;
             if (flag)
             {
                 this.Pawn.health.RemoveHediff(hediff2);
                 this.Pawn.health.AddHediff(AdeptusHediffDefOf.OG_Regenerating, part, null, null);
                 this.Pawn.health.hediffSet.DirtyCache();
             }
         }
     }
 }
Beispiel #2
0
        public void TryRemoveHediff(bool Forced = false)
        {
            bool any = this.Pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.def != HediffDefOf.MissingBodyPart && (Forced || HealableHediffs.Contains(hediff)));

            if (any)
            {
                Hediff hediff2 = this.Pawn.health.hediffSet.hediffs.First((Hediff hediff) => hediff.def != HediffDefOf.MissingBodyPart && (Forced || HealableHediffs.Contains(hediff)));
                bool   flag    = hediff2 != null;
                if (flag)
                {
                    this.Pawn.health.RemoveHediff(hediff2);
                    this.Pawn.health.hediffSet.DirtyCache();
                }
            }
        }
Beispiel #3
0
        public void TryHeal(bool Forced = false)
        {
            bool flag2 = HealableHediffs.Any(x => !Pawn.health.hediffSet.PartIsMissing(x.Part) && x is Hediff_Injury);
            bool flag3 = HealableHediffs.Any(x => Pawn.health.hediffSet.PartIsMissing(x.Part));
            bool flag4 = HealableHediffs.Any(x => x.def == AdeptusHediffDefOf.OG_Regenerating);

            Rand.PushState();
            float num = Rand.RangeInclusive(1, 100);

            Rand.PopState();
            Hediff hediff;

            if (flag2)
            {
                if (logging == true)
                {
                    Log.Message(string.Format("flag2"));
                }
                hediff = GenCollection.RandomElement <Hediff_Injury>(from x in Pawn.health.hediffSet.GetHediffs <Hediff_Injury>()
                                                                     where HediffUtility.CanHealNaturally(x) && (HealableHediffs.Contains(x) || Forced)
                                                                     select x);
                num = num * Pawn.HealthScale * 0.1f;
                hediff.Heal(num);
                string text = string.Format("flag2 the {1} on {0}'s {2} healed by {3}.", Pawn.LabelCap, hediff.Label, hediff.Part.customLabel, num);
                if (hediff.Severity == 0f)
                {
                    text += " and was removed";
                    Pawn.health.RemoveHediff(hediff);
                }
                if (logging == true)
                {
                    Log.Message(string.Format(text));
                }
            }
            else if (flag4)
            {
                if (logging == true)
                {
                    Log.Message(string.Format("flag4"));
                }
#pragma warning disable CS0436 // Type conflicts with imported type
                hediff = Pawn.health.hediffSet.GetHediffs <Hediff_RegeneratingPart>().RandomElement();
#pragma warning restore CS0436 // Type conflicts with imported type
                num = num * Pawn.HealthScale * 0.001f;
                hediff.Heal(num);
                string text = string.Format("flag5 the {1} on {0}'s {2} regenerated by {3}.", Pawn.LabelCap, hediff.Label, hediff.Part.customLabel, num);
                if (hediff.Severity == 0f)
                {
                    text += " and was removed";
                    Pawn.health.RemoveHediff(hediff);
                }
                if (logging == true)
                {
                    Log.Message(string.Format(text));
                }
            }
            else if (flag3)
            {
                if (logging == true)
                {
                    Log.Message(string.Format("flag3"));
                }
                bool flag3B = Pawn.health.hediffSet.hediffs.Any(x => Pawn.health.hediffSet.PartIsMissing(x.Part) && HealableHediffs.Contains(x));
                if (flag3B)
                {
                    if (logging == true)
                    {
                        Log.Message(string.Format("flag3B"));
                    }
                    TryRegrowBodyparts();
                }
                else
                {
                    if (logging == true)
                    {
                        Log.Message(string.Format("flag3 {0}'s hediff_Injury flag3B: {1}", Pawn.Label, flag3B));
                    }
                }
            }
            else
            {
                hediff = null;
            }
        }