예제 #1
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);
                            }
                        }
                    }
                }
            }
        }
        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
            }
        }
예제 #3
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);
                }
            }
        }
예제 #4
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);
                }
            }
        }
예제 #5
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);
                        }
                    }
                }
            }
        }
예제 #6
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;
            }
        }