예제 #1
0
        public void TrySealWounds()
        {
            IEnumerable <Hediff> enumerable = from hd in this.pawn.health.hediffSet.hediffs
                                              where hd.Bleeding
                                              select hd;
            bool flag = enumerable != null;

            if (flag && canHeal)
            {
                foreach (Hediff hediff in enumerable)
                {
                    HediffWithComps hediffWithComps = hediff as HediffWithComps;
                    bool            flag2           = hediffWithComps != null;
                    Rand.PushState();
                    float chance = Rand.Value;
                    Rand.PopState();
                    if (flag2 && canHeal && chance < Props.sealWoundsChance)
                    {
                        HediffComp_TendDuration hediffComp_TendDuration = HediffUtility.TryGetComp <HediffComp_TendDuration>(hediffWithComps);
                        hediffComp_TendDuration.tendQuality   = 0f;
                        hediffComp_TendDuration.tendTicksLeft = Find.TickManager.TicksGame;
                        this.pawn.health.Notify_HediffChanged(hediff);
                    }
                }
            }
        }
예제 #2
0
 // Token: 0x06000050 RID: 80 RVA: 0x000054F0 File Offset: 0x000036F0
 private static bool ImmuneNow(Pawn pawn, HediffDef chkhdef)
 {
     if (pawn != null && chkhdef != null)
     {
         HediffSet hediffSet;
         if (pawn == null)
         {
             hediffSet = null;
         }
         else
         {
             Pawn_HealthTracker health = pawn.health;
             hediffSet = (health?.hediffSet);
         }
         HediffSet set = hediffSet;
         if (set != null)
         {
             Hediff chk = set.GetFirstHediffOfDef(chkhdef, false);
             if (chk != null && HediffUtility.FullyImmune(chk))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
예제 #3
0
        public void TryHealWounds()
        {
            IEnumerable <Hediff> enumerable = from hd in pawn.health.hediffSet.hediffs
                                              where !hd.IsTended()
                                              select hd;

            if (enumerable != null)
            {
                foreach (Hediff item in enumerable)
                {
                    HediffWithComps val = item as HediffWithComps;
                    if (val != null && val.TendableNow())
                    {
                        if (val.Bleeding)
                        {
                            //Log.Message("TrySealWounds " + xxx.get_pawnname(pawn) + ", Bleeding " + item.Label);
                            HediffComp_TendDuration val2 = HediffUtility.TryGetComp <HediffComp_TendDuration>(val);
                            val2.tendQuality   = 2f;
                            val2.tendTicksLeft = Find.TickManager.TicksGame;
                            pawn.health.Notify_HediffChanged(item);
                        }
                        // infections  etc
                        else                        // if (val.def.lethalSeverity > 0f)
                        {
                            //Log.Message("TryHeal " + xxx.get_pawnname(pawn) + ", infection(?) " + item.Label);
                            HediffComp_TendDuration val2 = HediffUtility.TryGetComp <HediffComp_TendDuration>(val);
                            val2.tendQuality   = 2f;
                            val2.tendTicksLeft = Find.TickManager.TicksGame;
                            pawn.health.Notify_HediffChanged(item);
                        }
                    }
                }
            }
        }
예제 #4
0
        public override void CompTick()
        {
            /*
             * if (parent.Faction == null)
             * {
             *  parent.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph));
             * }
             */
            base.CompTick();
            this.ticksSinceHeal++;
            bool flag = this.ticksSinceHeal > this.healIntervalTicks;

            if (flag)
            {
                bool flag2 = pawn.health.hediffSet.HasNaturallyHealingInjury();
                if (flag2)
                {
                    this.ticksSinceHeal = 0;
                    float num = 10f;
                    num = num * pawn.HealthScale * 0.01f;
                    Need_Food food = pawn.needs.food;
                    if (food.CurLevel > (num / 100))
                    {
                        Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury>
                                                          (from x in pawn.health.hediffSet.GetHediffs <Hediff_Injury>()
                                                          where HediffUtility.CanHealNaturally(x)
                                                          select x);
                        doClot(pawn);
                        if (hediff_Injury != null)
                        {
                            hediff_Injury.Heal(num);
                            food.CurLevel -= (num / 100);
                            string text     = string.Format("{0} healed {1} for {2} and food reduced to {3}", pawn.LabelCap, hediff_Injury.Label, num, food.CurLevel);
                            bool   selected = Find.Selector.SingleSelectedThing == pawn;
                            if (selected && Prefs.DevMode)
                            {
                                //    Log.Message(text);
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        public void TrySealWounds()
        {
            IEnumerable <Hediff> enumerable = from hd in this.pawn.health.hediffSet.hediffs
                                              where hd.TendableNow(false)
                                              select hd;

            if (enumerable != null)
            {
                foreach (Hediff hediff in enumerable)
                {
                    HediffWithComps hediffWithComps = hediff as HediffWithComps;
                    if (hediffWithComps != null)
                    {
                        HediffComp_TendDuration hediffComp_TendDuration = HediffUtility.TryGetComp <HediffComp_TendDuration>(hediffWithComps);
                        hediffComp_TendDuration.tendQuality   = 2f;
                        hediffComp_TendDuration.tendTicksLeft = Find.TickManager.TicksGame;
                        this.pawn.health.Notify_HediffChanged(hediff);
                    }
                }
            }
        }
예제 #6
0
        public void TrySealWounds()
        {
            IEnumerable <Hediff> hediffs = ((IEnumerable <Hediff>)((HediffSet)((Pawn_HealthTracker)((Pawn)((Hediff)this).pawn).health).hediffSet).hediffs).Where <Hediff>((Func <Hediff, bool>)(hd => hd.get_Bleeding()));

            if (hediffs == null)
            {
                return;
            }
            using (IEnumerator <Hediff> enumerator = hediffs.GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    Hediff current = enumerator.Current;
                    if (current is HediffWithComps hediffWithComps)
                    {
                        HediffComp_TendDuration comp = (HediffComp_TendDuration)HediffUtility.TryGetComp <HediffComp_TendDuration>((Hediff)hediffWithComps);
                        comp.tendQuality   = (__Null)2.0;
                        comp.tendTicksLeft = (__Null)Find.get_TickManager().get_TicksGame();
                        ((Pawn_HealthTracker)((Pawn)((Hediff)this).pawn).health).Notify_HediffChanged(current);
                    }
                }
            }
        }
예제 #7
0
        public void HealWounds()
        {
            IEnumerable <Hediff> enumerable = from hd in pawn.health.hediffSet.hediffs
                                              where !hd.IsTended() && hd.TendableNow()
                                              select hd;

            if (enumerable != null)
            {
                foreach (Hediff item in enumerable)
                {
                    HediffWithComps val = item as HediffWithComps;
                    if (val != null)
                    {
                        if (val.Bleeding)
                        {
                            //Log.Message("TrySealWounds " + xxx.get_pawnname(pawn) + ", Bleeding " + item.Label);
                            //HediffComp_TendDuration val2 = HediffUtility.TryGetComp<HediffComp_TendDuration>(val);
                            val.Heal(0.25f);
                            //val2.tendQuality = 1f;
                            //val2.tendTicksLeft = 10000;
                            //pawn.health.Notify_HediffChanged(item);
                        }
                        // tend infections
                        // tend lifeThreatening chronic
                        else if ((!val.def.chronic && val.def.lethalSeverity > 0f) || (val.CurStage?.lifeThreatening ?? false))
                        {
                            //Log.Message("TryHeal " + xxx.get_pawnname(pawn) + ", infection(?) " + item.Label);
                            HediffComp_TendDuration val2 = HediffUtility.TryGetComp <HediffComp_TendDuration>(val);
                            val2.tendQuality   = 1f;
                            val2.tendTicksLeft = 10000;
                            pawn.health.Notify_HediffChanged(item);
                        }
                    }
                }
            }
        }
        private static void TryHealRandomInjury(Pawn_HealthTracker __instance, Pawn pawn, float healAmount, Building_BaseMechanoidPlatform platform = null)
        {
            IEnumerable <Hediff_Injury> hediffs = __instance.hediffSet.GetHediffs <Hediff_Injury>().Where((Hediff_Injury i) => HediffUtility.CanHealNaturally(i));

            if (hediffs.Count() == 0)
            {
                return;
            }
            Hediff_Injury hediff_Injury = hediffs.RandomElement();

            hediff_Injury.Heal(healAmount);
            if (pawn.IsHashIntervalTick(50) && !pawn.IsHashIntervalTick(100) && pawn.Map != null && !pawn.Position.Fogged(pawn.Map))
            {
                MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_HealingCross);
            }
            if (platform != null)
            {
                platform.refuelableComp.ConsumeFuel((platform.GetStatValue(WTH_DefOf.WTH_PartConsumptionRate) * 10f) / GenDate.TicksPerDay);//TODO no magic number
            }
        }
예제 #9
0
        // Token: 0x06000007 RID: 7 RVA: 0x00002274 File Offset: 0x00000474
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            this.ticksSinceHeal++;
            bool flag = this.ticksSinceHeal > this.Props.healIntervalTicks;

            if (flag)
            {
                bool flag2 = base.Pawn.health.hediffSet.HasNaturallyHealingInjury();
                if (flag2)
                {
                    this.ticksSinceHeal = 0;
                    float         num           = 8f;
                    Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury>(from x in base.Pawn.health.hediffSet.GetHediffs <Hediff_Injury>()
                                                                                              where HediffUtility.CanHealNaturally(x)
                                                                                              select x);
                    hediff_Injury.Heal(num * base.Pawn.HealthScale * 0.01f);
                    string text = string.Format("{0} healed.", base.Pawn.LabelCap);
                }
            }
        }
예제 #10
0
        public override void CompTick()
        {
            if (pawn.ageTracker.CurLifeStage != XenomorphDefOf.RRY_XenomorphFullyFormed)
            {
                if (pawn.CurJobDef == JobDefOf.Ingest && Hidden)
                {
                    hidden = false;
                }
                else if (!Hidden)
                {
                    hidden = true;
                }
            }
            if (pawn.Faction == null)
            {
                if (Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph) != null)
                {
                    pawn.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph));
                }
            }
            base.CompTick();
            this.ticksSinceHeal++;
            bool flag = this.ticksSinceHeal > this.healIntervalTicks;

            if (flag)
            {
                bool flag2 = ((Pawn)base.parent).health.hediffSet.HasNaturallyHealingInjury();
                if (flag2)
                {
                    this.ticksSinceHeal = 0;
                    float         num           = 8f;
                    Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury>(from x in ((Pawn)base.parent).health.hediffSet.GetHediffs <Hediff_Injury>()
                                                                                              where HediffUtility.CanHealNaturally(x)
                                                                                              select x);
                    doClot(pawn);
                    hediff_Injury.Heal(num * ((Pawn)base.parent).HealthScale * 0.01f);
                    string text = string.Format("{0} healed.", ((Pawn)base.parent).LabelCap);
                }
            }
        }
예제 #11
0
        public override void CompTick()
        {
            if (Facehugger.Faction == null && Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph) != null)
            {
                Facehugger.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph));
            }
            base.CompTick();
            this.ticksSinceHeal++;
            if (Impregnations >= maxImpregnations)
            {
                this.ticksSinceImpregnation++;
            }
            bool flag = this.ticksSinceHeal > this.healIntervalTicks;

            if (flag)
            {
                bool flag2 = Facehugger.health.hediffSet.HasNaturallyHealingInjury();
                if (flag2)
                {
                    float         num           = 4f;
                    Hediff_Injury hediff_Injury = GenCollection.RandomElement <Hediff_Injury>(from x in Facehugger.health.hediffSet.GetHediffs <Hediff_Injury>()
                                                                                              where HediffUtility.CanHealNaturally(x)
                                                                                              select x);
                    hediff_Injury.Heal(num * Facehugger.HealthScale * 0.01f);
                    string text = string.Format("{0} healed.", Facehugger.LabelCap);
                }
                if (Impregnations >= maxImpregnations)
                {
                    bool flag3 = this.ticksSinceImpregnation > this.deathIntervalTicks;
                    if (flag3)
                    {
                        this.ticksSinceImpregnation = 0;
                        if (Rand.Chance(0.5f))
                        {
                            Facehugger.Kill(null);
                        }
                    }
                }
            }
        }
예제 #12
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;
            }
        }