示例#1
0
        public static bool TryTendRegularDisease(this HediffComp_Regeneration comp, out bool Impossible)
        {
            if (comp.currentHediff == null || !comp.currentHT.IsRegularDiseaseTending() ||
                !comp.Pawn.health.hediffSet.HasHediff(comp.currentHediff.def, comp.currentHediff.Part) ||
                comp.currentHediff.IsTended())
            {
                Impossible = true;
                return(false);
            }
            Impossible = false;
            Tools.Warn(comp.Pawn.LabelShort + " - TryTendRegularDisease calling HungerAndRestTransaction", comp.MyDebug);

            float TendingQuality = comp.Props.RegularDiseaseTendingParams.HealingQuality.RandomInRange;

            if (!comp.Pawn.HungerAndRestTransaction(
                    comp.Props.RegularDiseaseTendingParams.HungerCost,
                    comp.Props.RegularDiseaseTendingParams.RestCost,
                    TendingQuality / 2,
                    comp.MyDebug)
                )
            {
                return(false);
            }

            Tools.Warn("TryTendRegularDisease OK", comp.MyDebug);
            //comp.currentHediff.Tended_NewTemp(TendingQuality, 2f);
            comp.currentHediff.Tended(TendingQuality, 2f);

            if (comp.HasLimits)
            {
                comp.TreatmentPerformedQuality += TendingQuality;
            }

            return(true);
        }
示例#2
0
        public static bool GetBleedingHediff(this HediffComp_Regeneration comp, out Hediff hediff)
        {
            //Tools.Warn(comp.Pawn.LabelShort + " GetBleedingHediff", comp.MyDebug);

            /*
             * if (!comp.Pawn.health.HasHediffsNeedingTend())
             * {
             *  Tools.Warn(comp.Pawn.LabelShort + " GetBleedingHediff - HasHediffsNeedingTend == false ", comp.MyDebug);
             *  hediff = null;
             *  return false;
             * }
             */

            IEnumerable <Hediff> hediffs =
                comp.Pawn.health.hediffSet.GetHediffs <Hediff>().Where(
                    h => h.Bleeding &&
                    h.TendableNow() &&
                    !h.IsTended()
                    );

            if (hediffs.EnumerableNullOrEmpty())
            {
                //Tools.Warn(comp.Pawn.LabelShort + " GetBleedingHediff - Found no bloodloss", comp.MyDebug);
                hediff = null;
                return(false);
            }

            hediff = hediffs.MostSeverityHediff();

            return(true);
        }
示例#3
0
        public static bool TryRegrowProsthetic(this HediffComp_Regeneration RegenHComp, HediffDef ProstheticHediff)
        {
            if (ProstheticHediff == null)
            {
                return(false);
            }

            Pawn           p   = RegenHComp.Pawn;
            BodyPartRecord BPR = RegenHComp.currentHediff.Part;

            Tools.Warn(p.LabelShort + " TryRegrowProsthetic - hediffdef: " + ProstheticHediff?.defName + "; BP: " + BPR?.Label);

            float BPRMaxHealth      = BPR.def.GetMaxHealth(RegenHComp.Pawn);
            float PawnBodyPartRatio = BPRMaxHealth / RegenHComp.BodyPartsHealthSum;

            MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(p, BPR, p.Position, p.Map);
            p.health.AddHediff(ProstheticHediff, BPR);

            if (RegenHComp.HasLimits)
            {
                RegenHComp.TreatmentPerformedQuality += PawnBodyPartRatio * 10;
            }

            return(p.health.hediffSet.HasHediff(ProstheticHediff, BPR));
        }
示例#4
0
        public static bool TryRemovePermanentInjury(this HediffComp_Regeneration comp, out bool DoneWithIt, out bool Impossible)
        {
            if (comp.currentHediff == null || comp.currentHT != MyDefs.HealingTask.PermanentInjuryRegeneration ||
                !comp.Pawn.health.hediffSet.HasHediff(comp.currentHediff.def, comp.currentHediff.Part) ||
                comp.currentHediff.Severity == 0)
            {
                Impossible = true;
                DoneWithIt = false;
                return(false);
            }

            Impossible = false;
            if (comp.currentHediff.Severity > 0)
            {
                Tools.Warn(comp.Pawn.LabelShort + " - TryRemovePermanentInjury calling HungerAndRestTransaction", comp.MyDebug);

                float BPRMaxHealth = comp.currentHediff.Part.def.GetMaxHealth(comp.Pawn);

                float RegenQuantity = comp.Props.PermanentInjuryRegenParams.HealingQuality.RandomInRange * BPRMaxHealth;
                RegenQuantity = Math.Min(RegenQuantity, comp.currentHediff.Severity);
                float PawnBodyPartRatio = RegenQuantity / (float)comp.Pawn.MaxHitPoints;

                Tools.Warn(
                    comp.Pawn.LabelShort + " - TryBodyPartRegeneration " +
                    "BPRMaxHealth: " + BPRMaxHealth + "; " +
                    "Pawn maxHP: " + comp.Pawn.MaxHitPoints + "; " +
                    "RegenQuantity: " + RegenQuantity + "; " +
                    "PawnBodyPartRatio: " + PawnBodyPartRatio + "; "
                    , comp.MyDebug
                    );

                if (!comp.Pawn.HungerAndRestTransaction(
                        comp.Props.PermanentInjuryRegenParams.HungerCost,
                        comp.Props.PermanentInjuryRegenParams.RestCost,
                        PawnBodyPartRatio,
                        comp.MyDebug)
                    )
                {
                    DoneWithIt = false;
                    return(false);
                }

                Tools.Warn("TryRemovePermanentInjury OK", comp.MyDebug);
                comp.currentHediff.Severity -= RegenQuantity;
                DoneWithIt = (comp.currentHediff.Severity <= 0) ? true : false;

                if (comp.HasLimits)
                {
                    comp.TreatmentPerformedQuality += RegenQuantity;
                }

                return(true);
            }

            DoneWithIt = true;
            return(true);
        }
示例#5
0
        public static HediffDef TryFindBodyPartProsthetic(this HediffComp_Regeneration RegenHComp)
        {
            if (RegenHComp.Props.BodyPartRegenParams.techHediffTag.NullOrEmpty())
            {
                return(null);
            }

            string         techHediffTag = RegenHComp.Props.BodyPartRegenParams.techHediffTag;
            BodyPartRecord BPR           = RegenHComp.currentHediff.Part;

            Tools.Warn("Looking for one recipe with techHediff=" + techHediffTag + " and BP=" + BPR?.Label, RegenHComp.MyDebug);

            IEnumerable <ThingDef> Prosthetics = DefDatabase <ThingDef> .AllDefs.Where(
                TD =>
                !TD.techHediffsTags.NullOrEmpty() &&
                TD.techHediffsTags.Contains(techHediffTag)
                );

            if (Prosthetics.EnumerableNullOrEmpty())
            {
                Tools.Warn("TryFindBodyPartProsthetic - found no prosthetic with techHediff=" + techHediffTag, RegenHComp.MyDebug);
            }

            IEnumerable <RecipeDef> recipes = DefDatabase <RecipeDef> .AllDefs.Where(
                r =>
                !r.appliedOnFixedBodyParts.NullOrEmpty() &&
                r.appliedOnFixedBodyParts.Contains(BPR.def) &&

                !r.fixedIngredientFilter.AllowedThingDefs.EnumerableNullOrEmpty() &&
                r.fixedIngredientFilter.AllowedThingDefs.Intersect(Prosthetics).Count() > 0
                );

            if (recipes.EnumerableNullOrEmpty())
            {
                Tools.Warn("TryFindBodyPartProsthetic - empty recipes ", RegenHComp.MyDebug);
                return(null);
            }


            if (recipes.Count() > 1)
            {
                Tools.Warn("Found more than one recipe with techHediff=" + techHediffTag + " and BP=" + BPR.Label, RegenHComp.MyDebug);
                foreach (RecipeDef RD in recipes)
                {
                    Tools.Warn(RD.defName, RegenHComp.MyDebug);
                }
            }

            HediffDef answer = recipes.RandomElement().addsHediff;

            Tools.Warn("TryFindBodyPartProsthetic - Found " + answer.defName, RegenHComp.MyDebug);

            return(answer);
        }
示例#6
0
        public static string GetTreatmentLabel(this HediffComp_Regeneration comp)
        {
            //Tools.Warn(comp.Pawn.LabelShort + " - Entering GetTreatmentLabel - cutHT=" + comp.currentHT.DescriptionAttr(), comp.MyDebug);

            MyDefs.HealingTask curHT = comp.currentHT;
            HealingParams      HP    = comp.GetParams();

            if (HP == null || HP.TreatmentLabel.NullOrEmpty())
            {
                return(curHT.DescriptionAttr());
            }

            return(HP.TreatmentLabel);
        }
        public static bool RequiresProgressHediffRemoval(this HediffComp_Regeneration comp, out HediffDef hediffToRemove)
        {
            MyDefs.HealingTask curHT = comp.currentHT;
            HealingParams      HP    = comp.GetParams();

            hediffToRemove = null;
            if (HP == null || HP.HediffToApplyDuringProgress == null)
            {
                return(false);
            }

            hediffToRemove = HP.HediffToApplyDuringProgress;
            return(HP.RemoveHediffWhenProgressOver);
        }
        public static bool RequiresCompleteHediff(this HediffComp_Regeneration comp, out HediffDef hediffToApply)
        {
            MyDefs.HealingTask curHT = comp.currentHT;
            HealingParams      HP    = comp.GetParams();

            hediffToApply = null;
            if (HP == null || HP.HediffToApplyWhenComplete == null)
            {
                return(false);
            }

            hediffToApply = HP.HediffToApplyWhenComplete;
            return(true);
        }
示例#9
0
        public static int ResetHealingTicks(this HediffComp_Regeneration comp)
        {
            Tools.Warn(comp.Pawn.LabelShort + " - Entering ResetHealingTicks - cutHT=" + comp.currentHT.DescriptionAttr(), comp.MyDebug);

            MyDefs.HealingTask curHT = comp.currentHT;
            HealingParams      HP    = comp.GetParams();

            if (HP == null)
            {
                Tools.Warn(comp.Pawn.LabelShort + " - ResetHealingTicks - Found not params for task=" + curHT.DescriptionAttr(), comp.MyDebug);
                return(600);
            }

            return(HP.PeriodBase.RandomInRange);
        }
示例#10
0
        public static HealingParams GetParams(this HediffComp_Regeneration comp)
        {
            HealingTask curHT = comp.currentHT;

            if (comp.Effect_TendBleeding && curHT.IsBloodLossTending())
            {
                return(comp.Props.BloodLossTendingParams);
            }
            // 01 chronic disease tending
            else if (comp.Effect_TendChronicDisease && curHT.IsChronicDiseaseTending())
            {
                return(comp.Props.ChronicHediffTendingParams);
            }
            // 02 regular disease tending
            else if (comp.Effect_TendRegularDisease && curHT.IsRegularDiseaseTending())
            {
                return(comp.Props.RegularDiseaseTendingParams);
            }
            // 03 regular injury
            else if (comp.Effect_RegeneratePhysicalInjuries && curHT.IsInjuryRegeneration())
            {
                return(comp.Props.PhysicalInjuryRegenParams);
            }
            // 04 regular disease
            else if (comp.Effect_HealDiseases && curHT.IsDiseaseHealing())
            {
                return(comp.Props.DiseaseHediffRegenParams);
            }
            // 05 chemicals
            else if (comp.Effect_RemoveChemicals && curHT.IsChemicalRemoval())
            {
                return(comp.Props.ChemicalHediffRegenParams);
            }
            // 06 permanent
            else if (comp.Effect_RemoveScares && curHT.IsPermanentInjuryRegeneration())
            {
                return(comp.Props.PermanentInjuryRegenParams);
            }
            // 07 Bodypart regen
            else if (comp.Effect_RegenerateBodyParts && curHT.IsBodyPartRegeneration())
            {
                return(comp.Props.BodyPartRegenParams);
            }

            return(null);
        }
        // Applied when doneWithIt or DidIt in dispatcher
        public static void ApplyCompleteHediff(this HediffComp_Regeneration comp)
        {
            if (comp.RequiresCompleteHediff(out HediffDef CompleteHediff))
            {
                if (CompleteHediff == null)
                {
                    return;
                }

                if (comp.Pawn.health.hediffSet.HasHediff(CompleteHediff))
                {
                    return;
                }

                Hediff NewHediff = HediffMaker.MakeHediff(CompleteHediff, comp.Pawn);
                comp.Pawn.health.AddHediff(NewHediff);
            }
        }
        // Applied when doneWithIt or DidIt in dispatcher
        public static void RemoveProgressHediff(this HediffComp_Regeneration comp)
        {
            if (comp.RequiresProgressHediffRemoval(out HediffDef ProgressHediff))
            {
                if (ProgressHediff == null)
                {
                    return;
                }

                if (!comp.Pawn.health.hediffSet.HasHediff(ProgressHediff))
                {
                    return;
                }

                Hediff hediff = comp.Pawn.health.hediffSet.GetFirstHediffOfDef(ProgressHediff);
                comp.Pawn.health.RemoveHediff(hediff);
            }
        }
        // Applied when nexthediff
        public static void ApplyProgressHediff(this HediffComp_Regeneration comp, Hediff OldHediff)
        {
            if (comp.HasPendingTreatment && comp.HealingTickCounter != 0 && OldHediff != comp.currentHediff && comp.RequiresProgressHediff(out HediffDef ProgressHediff))
            {
                if (ProgressHediff == null)
                {
                    return;
                }

                if (comp.Pawn.health.hediffSet.HasHediff(ProgressHediff))
                {
                    return;
                }

                Hediff NewHediff = HediffMaker.MakeHediff(ProgressHediff, comp.Pawn);
                comp.Pawn.health.AddHediff(NewHediff);
            }
        }
示例#14
0
        public static bool TryCureDisease(this HediffComp_Regeneration comp, out bool DoneWithIt, out bool Impossible)
        {
            if (comp.currentHediff == null || comp.currentHT != MyDefs.HealingTask.DiseaseHealing ||
                !comp.Pawn.health.hediffSet.HasHediff(comp.currentHediff.def, comp.currentHediff.Part) ||
                comp.currentHediff.Severity == 0)
            {
                Impossible = true;
                DoneWithIt = false;
                return(false);
            }

            Impossible = false;
            if (comp.currentHediff.Severity > 0)
            {
                Tools.Warn(comp.Pawn.LabelShort + " - TryCureDisease calling HungerAndRestTransaction", comp.MyDebug);

                float RegenQuantity = comp.Props.DiseaseHediffRegenParams.HealingQuality.RandomInRange;
                if (!comp.Pawn.HungerAndRestTransaction(
                        comp.Props.DiseaseHediffRegenParams.HungerCost,
                        comp.Props.DiseaseHediffRegenParams.RestCost,
                        RegenQuantity,
                        comp.MyDebug)
                    )
                {
                    DoneWithIt = false;
                    return(false);
                }

                Tools.Warn("TryCureDisease OK", comp.MyDebug);
                comp.currentHediff.Severity -= RegenQuantity;
                // Immunity ?
                DoneWithIt = (comp.currentHediff.Severity <= 0) ? true : false;

                if (comp.HasLimits)
                {
                    comp.TreatmentPerformedQuality += RegenQuantity;
                }

                return(true);
            }

            DoneWithIt = true;
            return(true);
        }
示例#15
0
        public RegenerationPriority(HediffComp_Regeneration RegenHComp)
        {
            parent = RegenHComp;

            //CreatePriorities();
        }
        public static void Dispatcher(this HediffComp_Regeneration comp)
        {
            MyDefs.HealingTask curHT = comp.currentHT;
            HealingParams      HP    = comp.GetParams();

            Pawn p       = comp.Pawn;
            bool MyDebug = comp.MyDebug;

            bool     DidIt                  = false;
            bool     DoneWithIt             = false;
            bool     Impossible             = false;
            bool     NextHediffIfDidIt      = false;
            bool     NextHediffIfDoneWithIt = false;
            bool     ResetHealingTick       = true;
            FleckDef MyFleckDef             = HP.FleckDef ?? null;

            // 00 Tending - Blood loss
            if (curHT.IsBloodLossTending())
            {
                NextHediffIfDidIt = true;
                DidIt             = comp.TryTendBleeding(out Impossible);
            }
            // 01 Tending - Chronic disease
            else if (curHT.IsChronicDiseaseTending())
            {
                NextHediffIfDidIt = true;
                DidIt             = comp.TryTendChronic(out Impossible);
            }
            // 02 Tending - Regular disease
            else if (curHT.IsRegularDiseaseTending())
            {
                NextHediffIfDidIt = true;
                DidIt             = comp.TryTendRegularDisease(out Impossible);
            }
            // 03 Regeneration - Injury
            else if (curHT.IsDiseaseHealing())
            {
                NextHediffIfDoneWithIt = true;
                DidIt = comp.TryCureDisease(out DoneWithIt, out Impossible);
            }
            // 04 Regeneration - Injury
            else if (curHT.IsInjuryRegeneration())
            {
                NextHediffIfDoneWithIt = true;
                DidIt = comp.TryRegenInjury(out DoneWithIt, out Impossible);
            }
            // 05 Regeneration - Chemical
            else if (curHT.IsChemicalRemoval())
            {
                NextHediffIfDoneWithIt = true;
                DidIt = comp.TryChemicalRemoval(out DoneWithIt, out Impossible);
            }
            // 06 Regeneration - Permanent injury
            else if (curHT.IsPermanentInjuryRegeneration())
            {
                NextHediffIfDoneWithIt = true;
                DidIt = comp.TryRemovePermanentInjury(out DoneWithIt, out Impossible);
            }
            // 07 Regeneration -Bodypart
            else if (curHT.IsBodyPartRegeneration())
            {
                NextHediffIfDidIt = true;
                bool AppliedProsthetic = false;

                if (comp.Effect_GrowProsthetic)
                {
                    HediffDef ProstheticHediff = comp.TryFindBodyPartProsthetic();
                    if (ProstheticHediff != null)
                    {
                        DidIt = AppliedProsthetic = comp.TryRegrowProsthetic(ProstheticHediff);
                    }
                }

                if (!AppliedProsthetic)
                {
                    if (comp.Effect_RegenBodyPartChildrenAtOnce)
                    {
                        //DidIt = this.TryBodyPartFullRegeneration(out Impossible);
                        DidIt            = comp.TryBodyPartRegeneration(out Impossible);
                        ResetHealingTick = false;
                    }
                    else
                    {
                        DidIt = comp.TryBodyPartRegeneration(out Impossible);
                    }
                }
            }

            if (DidIt)
            {
                Tools.Warn(p.LabelShort + " had " + curHT.DescriptionAttr() + " performed", MyDebug);
            }
            if (DoneWithIt)
            {
                Tools.Warn(p.LabelShort + " had " + curHT.DescriptionAttr() + " fully cured/healed/regen", MyDebug);
            }

            if (NextHediffIfDidIt && DidIt || NextHediffIfDoneWithIt && DoneWithIt)
            {
                if (MyFleckDef != null)
                {
                    FleckMaker.ThrowMetaIcon(p.Position, p.Map, MyFleckDef);
                }
                //MoteMaker.ThrowMetaIcon(p.Position, p.Map, MyMoteDef);

                comp.RemoveProgressHediff();
                comp.ApplyCompleteHediff();

                if (ResetHealingTick)
                {
                    comp.NextHediff();
                }
                else
                {
                    comp.NextHediffWithoutTickReset();
                }

                Tools.Warn(p.LabelShort +
                           " ResetHealingTick:" + ResetHealingTick + "; HealingTicks:" + comp.HealingTickCounter +
                           "; new HT: " + curHT.DescriptionAttr() +
                           "; BP:" + comp.currentHediff?.Part?.def?.defName, MyDebug);
            }
            else if (Impossible)
            {
                comp.NextHediff();
                Tools.Warn(p.LabelShort + " Impossible to heal hediff found - new HT: " + curHT.DescriptionAttr(), MyDebug);
            }

            if (comp.HasNoPendingTreatment)
            {
                Tools.Warn(
                    p.LabelShort +
                    "no pending treatment, InitCheckCounter", MyDebug);
                comp.InitCheckCounter();
            }
        }
示例#17
0
 public static bool GetPhysicalHediff(this HediffComp_Regeneration comp, out Hediff hediff)
 {
     return(GetHediffFromRegenParamsHediffArray(comp.Pawn, comp.Props.PhysicalInjuryRegenParams, out hediff));
 }
示例#18
0
 public static bool GetDiseaseHediff(this HediffComp_Regeneration comp, out Hediff hediff)
 {
     return(GetHediffFromRegenParamsHediffArray(comp.Pawn, comp.Props.DiseaseHediffRegenParams, out hediff));
 }
示例#19
0
        public static bool TryBodyPartRegeneration(this HediffComp_Regeneration comp, out bool Impossible)
        {
            if (
                comp.currentHediff == null ||
                comp.currentHediff.def != HediffDefOf.MissingBodyPart ||
                comp.currentHediff.Part == null ||
                comp.currentHT != MyDefs.HealingTask.BodyPartRegeneration ||
                !comp.Pawn.health.hediffSet.HasHediff(comp.currentHediff.def, comp.currentHediff.Part)
                )
            {
                Impossible = true;
                return(false);
            }

            Impossible = false;
            Tools.Warn(comp.Pawn.LabelShort + " - TryBodyPartRegeneration calling HungerAndRestTransaction", comp.MyDebug);

            BodyPartRecord BPR             = comp.currentHediff.Part;
            float          BPRMaxHealth    = BPR.def.GetMaxHealth(comp.Pawn);
            float          TheoricSeverity = BPRMaxHealth * (1 - comp.Props.BodyPartRegenParams.BPMaxHealth);

            float PawnBodyPartRatio = BPRMaxHealth * comp.Props.BodyPartRegenParams.BPMaxHealth / comp.BodyPartsHealthSum;

            Tools.Warn(
                comp.Pawn.LabelShort + " - TryBodyPartRegeneration " +
                "BPRMH: " + BPRMaxHealth + "+; " +
                "TheoricSeverity: " + TheoricSeverity + "+; " +
                "PawnBodyPartRatio: " + PawnBodyPartRatio + "+; "
                , comp.MyDebug
                );

            if (!comp.Pawn.HungerAndRestTransaction(
                    comp.Props.BodyPartRegenParams.HungerCost,
                    comp.Props.BodyPartRegenParams.RestCost,
                    PawnBodyPartRatio,
                    comp.MyDebug)
                )
            {
                return(false);
            }

            Tools.Warn("TryBodyPartRegeneration OK", comp.MyDebug);
            comp.Pawn.health.RemoveHediff(comp.currentHediff);

            // artificial, needs parameter ?
            if (comp.HasLimits)
            {
                comp.TreatmentPerformedQuality += PawnBodyPartRatio * 10;
            }

            if (comp.Effect_PartialHealthUponRegrow && !comp.Effect_RegenBodyPartChildrenAtOnce)
            {
                Hediff BarelyAliveBP = HediffMaker.MakeHediff(HediffDefOf.SurgicalCut, comp.Pawn, BPR);
                BarelyAliveBP.Severity = TheoricSeverity;

                comp.Pawn.health.AddHediff(BarelyAliveBP, BPR);
            }

            //pawn.health.hediffSet.DirtyCache();
            return(true);
        }
示例#20
0
        public static MyDefs.HealingTask InitHealingTask(this HediffComp_Regeneration comp, out Hediff hediffToTreat, out int InitTicks)
        {
            //Tools.Warn(comp.Pawn.LabelShort + " - Entering InitHealingTask", comp.MyDebug);
            //for (int i = 0; i < comp.regenerationPriority.DefaultPriority.Count; i++)
            for (int i = 0; i < MyDefs.DefaultPriority.Count; i++)
            {
                //MyDefs.HealingTask curHealingTask = comp.regenerationPriority.DefaultPriority[i];

                MyDefs.HealingTask curHealingTask = MyDefs.DefaultPriority[i];

                //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask task[" + i + "]: " + curHealingTask.DescriptionAttr(), comp.MyDebug);

                // 00 bloodloss tending
                if (comp.Effect_TendBleeding && curHealingTask.IsBloodLossTending())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_TendBleeding", comp.MyDebug);
                    if (comp.GetBleedingHediff(out hediffToTreat))
                    {
                        InitTicks = comp.Props.BloodLossTendingParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }
                // 01 chronic disease tending
                else if (comp.Effect_TendChronicDisease && curHealingTask.IsChronicDiseaseTending())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_TendChronicDisease", comp.MyDebug);

                    if (comp.Pawn.GetTendableChronicDisease(out hediffToTreat))
                    {
                        InitTicks = comp.Props.ChronicHediffTendingParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }
                // 02 regular disease tending
                else if (comp.Effect_TendRegularDisease && curHealingTask.IsRegularDiseaseTending())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_TendRegularDisease", comp.MyDebug);

                    if (comp.HasTendRegularDiseaseTargets)
                    {
                        if (comp.Pawn.GetTendableRegularDisease(out hediffToTreat, comp.Props.RegularDiseaseTendingParams.TargetedHediffDefs, comp.MyDebug))
                        {
                            InitTicks = comp.Props.RegularDiseaseTendingParams.PeriodBase.RandomInRange;
                            return(curHealingTask);
                        }
                    }
                    else if (comp.Pawn.GetTendableRegularDisease(out hediffToTreat, null, comp.MyDebug))
                    {
                        InitTicks = comp.Props.RegularDiseaseTendingParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }

                // 03 regular injury
                else if (comp.Effect_RegeneratePhysicalInjuries && curHealingTask.IsInjuryRegeneration())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_RegeneratePhysicalInjuries", comp.MyDebug);

                    if (comp.GetPhysicalHediff(out hediffToTreat))
                    {
                        InitTicks = comp.Props.PhysicalInjuryRegenParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }
                // 04 regular disease
                else if (comp.Effect_HealDiseases && curHealingTask.IsDiseaseHealing())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_HealDiseases", comp.MyDebug);

                    if (comp.GetDiseaseHediff(out hediffToTreat))
                    {
                        InitTicks = comp.Props.DiseaseHediffRegenParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }
                // 05 chemicals
                else if (comp.Effect_RemoveChemicals && curHealingTask.IsChemicalRemoval())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_RemoveChemicals", comp.MyDebug);

                    if (comp.GetChemicalHediff(out hediffToTreat))
                    {
                        InitTicks = comp.Props.ChemicalHediffRegenParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }
                // 06 permanent
                else if (comp.Effect_RemoveScares && curHealingTask.IsPermanentInjuryRegeneration())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_RemoveScares", comp.MyDebug);
                    if (comp.Pawn.GetPermanentHediff(out hediffToTreat))
                    {
                        InitTicks = comp.Props.PermanentInjuryRegenParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }

                // 07 Bodypart regen
                else if (comp.Effect_RegenerateBodyParts && curHealingTask.IsBodyPartRegeneration())
                {
                    //Tools.Warn(comp.Pawn.LabelShort + " InitHealingTask Effect_RegenerateBodyParts", comp.MyDebug);
                    if (comp.Pawn.GetMissingBodyPart(out hediffToTreat))
                    {
                        InitTicks = comp.Props.BodyPartRegenParams.PeriodBase.RandomInRange;
                        return(curHealingTask);
                    }
                }
            }

            //Tools.Warn(comp.Pawn.LabelShort + " - Exiting InitHealingTask: found nothing to do", comp.MyDebug);

            InitTicks     = 0;
            hediffToTreat = null;
            return(MyDefs.HealingTask.None);
        }