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); }
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(); } }