public override void PostIngested(Pawn ingester)
 {
     base.PostIngested(ingester);
     if (ingester.health.hediffSet.HasHediff(InfectionDefOf.MuscleParasites))
     {
         HediffWithComps hediff = (HediffWithComps)ingester.health.hediffSet.GetFirstHediffOfDef(InfectionDefOf.MuscleParasites);
         hediff.comps.First(h => h is HediffComp_TendDuration).CompTended(1.25f, 0);
     }
     if (ingester.health.hediffSet.HasHediff(InfectionDefOf.GutWorms))
     {
         HediffWithComps hediff = (HediffWithComps)ingester.health.hediffSet.GetFirstHediffOfDef(InfectionDefOf.GutWorms);
         hediff.comps.First(h => h is HediffComp_TendDuration).CompTended(1.25f, 0);
     }
     if (ingester.health.hediffSet.HasHediff(InfectionDefOf.FibrousMechanites))
     {
         HediffWithComps hediff           = (HediffWithComps)ingester.health.hediffSet.GetFirstHediffOfDef(InfectionDefOf.FibrousMechanites);
         HediffComp      hediffComp       = hediff.comps.First(h => h is HediffComp_Disappears);
         Traverse        field            = Traverse.Create(hediffComp).Field("ticksToDisappear");
         int             ticksToDisappear = field.GetValue <int>();
         field.SetValue(ticksToDisappear - 180000);
     }
     if (ingester.health.hediffSet.HasHediff(InfectionDefOf.SensoryMechanites))
     {
         HediffWithComps hediff           = (HediffWithComps)ingester.health.hediffSet.GetFirstHediffOfDef(InfectionDefOf.SensoryMechanites);
         HediffComp      hediffComp       = hediff.comps.First(h => h is HediffComp_Disappears);
         Traverse        field            = Traverse.Create(hediffComp).Field("ticksToDisappear");
         int             ticksToDisappear = field.GetValue <int>();
         field.SetValue(ticksToDisappear - 180000);
     }
     if (ingester.health.hediffSet.HasHediff(HediffDefOf.FoodPoisoning))
     {
         ingester.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.FoodPoisoning).Heal(1);
     }
 }
        public override string DebugString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(base.DebugString());
            if (this.comps != null)
            {
                for (int i = 0; i < this.comps.Count; i++)
                {
                    string     str;
                    HediffComp hediffComp = this.comps[i];
                    if (hediffComp.ToString().Contains("_"))
                    {
                        str = hediffComp.ToString().Split(new char[]
                        {
                            '_'
                        })[1];
                    }
                    else
                    {
                        str = hediffComp.ToString();
                    }
                    stringBuilder.Append("--").AppendLine(str);
                    string text = hediffComp.CompDebugString();
                    if (!text.NullOrEmpty())
                    {
                        stringBuilder.AppendLine(text.TrimEnd(new char[0]).Indented());
                    }
                }
            }
            return(stringBuilder.ToString());
        }
示例#3
0
 private void InitializeComps()
 {
     if (this.def.comps != null)
     {
         this.comps = new List <HediffComp>();
         for (int i = 0; i < this.def.comps.Count; i++)
         {
             HediffComp hediffComp = (HediffComp)Activator.CreateInstance(this.def.comps[i].compClass);
             hediffComp.props  = this.def.comps[i];
             hediffComp.parent = this;
             this.comps.Add(hediffComp);
         }
     }
 }