Esempio n. 1
0
        /// <summary>
        /// Harmony postfix method for Hediff_PartBaseNatural.Tick and Hediff_PartBaseNatural.Tick. Applies organ contraction
        /// </summary>
        /// <param name="__instance"></param>
        public static void PartBase_Tick_Postfix(HediffWithComps __instance)
        {
            // Only runs once per 14 hours 40 minutes (to contract by 50% in 30 days)
            if (__instance.ageTicks % 36000 != 0)
            {
                return;
            }

            // Skip unspawned pawns
            if (!__instance.pawn.Spawned)
            {
                return;
            }

            // Only works for orifices
            if (!IsOrifice(__instance))
            {
                return;
            }

            // Only contracts organs more than 0.5 in size
            if (__instance.Severity <= 0.5)
            {
                return;
            }

            // Contract the part by 1%
            __instance.Heal(0.01f);
        }
Esempio n. 2
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);
                        }
                    }
                }
            }
        }