public void InitComp(Pawn pawn = null)
        {
            var def = DefDatabase <HediffDef> .GetNamed(parent.def.defName);

            //pick random pawn to create temp hediff
            pawn = PawnsFinder.AllMaps_FreeColonistsAndPrisonersSpawned.RandomElement();
            //pawn = PawnsFinder.All_AliveOrDead.RandomElement(); //TODO: maybe some day add immobilizing size?

            Hediff hd = HediffMaker.MakeHediff(def, pawn);

            CompHediffBodyPart CompHediff = hd.TryGetComp <CompHediffBodyPart>();

            if (CompHediff != null)
            {
                CompHediff.initComp(pawn);
                CompHediff.updatesize();

                FluidType     = CompHediff.FluidType;
                FluidAmmount  = CompHediff.FluidAmmount;
                FluidModifier = CompHediff.FluidModifier;
                Size          = CompHediff.Size;
                SizeBase      = CompHediff.SizeBase;
                SizeOwner     = CompHediff.SizeOwner;
                RaceOwner     = "Unknown";
                PreviousOwner = "Unknown";
                Eggs          = CompHediff.Eggs;
            }
        }
 public override void PostAdd(DamageInfo?dinfo)
 {
     foreach (Hediff hed in pawn.health.hediffSet.hediffs.Where(x => x.Part != null && x.Part == Part && (x is Hediff_PartBaseNatural || x is Hediff_PartBaseArtifical)).ToList())
     {
         CompHediffBodyPart CompHediff = hed.TryGetComp <rjw.CompHediffBodyPart>();
         if (CompHediff != null)
         {
             CompHediff.SizeBase = this.def.initialSeverity;
             CompHediff.initComp(reroll: true);
             CompHediff.updatesize();
         }
     }
     pawn.health.RemoveHediff(this);
 }
Beispiel #3
0
        /// <summary>
        /// generate part hediff
        /// </summary>
        public static Hediff MakePart(HediffDef def, Pawn pawn, BodyPartRecord bpr)
        {
            //Log.Message("SexPartAdder::PartMaker ( " + xxx.get_pawnname(pawn) + " ) " + def.defName);
            Hediff hd = HediffMaker.MakeHediff(def, pawn, bpr);
            //Log.Message("SexPartAdder::PartMaker ( " + xxx.get_pawnname(pawn) + " ) " + hd.def.defName);
            CompHediffBodyPart compHediff = hd.TryGetComp <CompHediffBodyPart>();

            if (compHediff != null)
            {
                //Log.Message("SexPartAdder::PartMaker init comps");
                compHediff.initComp(pawn);
                compHediff.updatesize();
            }
            return(hd);
        }
 public override void PostAdd(DamageInfo?dinfo)
 {
     foreach (Hediff hed in pawn.health.hediffSet.hediffs.Where(x => x.Part != null && x.Part == Part && (x is Hediff_PartBaseNatural || x is Hediff_PartBaseArtifical)).ToList())
     {
         CompHediffBodyPart CompHediff = hed.TryGetComp <rjw.CompHediffBodyPart>();
         if (CompHediff != null)
         {
             //Log.Message("  Hediff_PartsSizeChanger: " + hed.Label);
             //Log.Message("  Hediff_PartsSizeChanger: " + hed.Severity);
             //Log.Message("  Hediff_PartsSizeChanger: " + CompHediff.SizeBase);
             //Log.Message("  Hediff_PartsSizeChanger: " + "-----");
             //Log.Message("  Hediff_PartsSizeChanger: " + this.Label);
             //Log.Message("  Hediff_PartsSizeChanger: " + this.Severity);
             CompHediff.SizeBase = this.CurStage.minSeverity;
             CompHediff.initComp(reroll: true);
             CompHediff.updatesize();
             //Log.Message("  Hediff_PartsSizeChanger: " + "-----");
             //Log.Message("  Hediff_PartsSizeChanger: " + hed.Label);
             //Log.Message("  Hediff_PartsSizeChanger: " + hed.Severity);
             //Log.Message("  Hediff_PartsSizeChanger: " + CompHediff.SizeBase);
         }
     }
     pawn.health.RemoveHediff(this);
 }