示例#1
0
        public override void AddToPawn(CustomPawn customPawn, Pawn pawn)
        {
            if (Option.Giver != null)
            {
                Hediff hediff = HediffMaker.MakeHediff(Option.HediffDef, pawn, BodyPartRecord);
                hediff.Severity = this.Severity;
                pawn.health.AddHediff(hediff, BodyPartRecord, null);
                this.hediff = hediff;
            }
            else if (Option.IsOldInjury)
            {
                Hediff hediff = HediffMaker.MakeHediff(Option.HediffDef, pawn, null);
                hediff.Severity = this.Severity;

                HediffComp_GetsPermanent getsPermanent = hediff.TryGetComp <HediffComp_GetsPermanent>();
                if (getsPermanent != null)
                {
                    getsPermanent.IsPermanent = true;
                    ReflectionUtil.SetNonPublicField(getsPermanent, "painFactor", painFactor == null ? 0 : painFactor.Value);
                }

                pawn.health.AddHediff(hediff, BodyPartRecord, null);
                this.hediff = hediff;
            }
            else
            {
                Hediff hediff = HediffMaker.MakeHediff(Option.HediffDef, pawn, null);
                hediff.Severity = this.Severity;
                pawn.health.AddHediff(hediff, null, null);
                this.hediff = hediff;
            }
            pawn.health.capacities.Clear();
        }
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (billDoer != null)
     {
         if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
         Hediff hediff = pawn.health.hediffSet.hediffs.Find((Hediff x) => x.IsPermanent() && x.Part == part && x.Visible);
         if (hediff != null)
         {
             HediffComp_GetsPermanent permanent = hediff.TryGetComp <HediffComp_GetsPermanent>();
             if (permanent != null && part.def.permanentInjuryChanceFactor < 1.1f && hediff.def.injuryProps != null)
             {
                 permanent.IsPermanent = false;
             }
             else
             {
                 pawn.health.RemoveHediff(hediff);
             }
             if (PawnUtility.ShouldSendNotificationAbout(pawn) || PawnUtility.ShouldSendNotificationAbout(billDoer))
             {
                 Messages.Message("PolarisMessageSuccessfullyRemovedHediffIsOld".Translate(billDoer.LabelShort, pawn.LabelShort, hediff.LabelCap), pawn, MessageTypeDefOf.PositiveEvent);
             }
         }
     }
 }
示例#3
0
        public static void Scarify(this Pawn pawn)
        {
            int num = 0;

            using (List <Hediff> .Enumerator enumerator = pawn.health.hediffSet.hediffs.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.def == HediffDefOf.Scarification)
                    {
                        num++;
                    }
                }
            }

            for (int i = num; i < pawn.ideo.Ideo.RequiredScars; i++)
            {
                IEnumerable <BodyPartRecord> partsToApplyOn = JobDriver_Scarify.GetPartsToApplyOn(pawn);
                List <BodyPartRecord>        list           = partsToApplyOn.Where((BodyPartRecord p) => JobDriver_Scarify.AvailableOnNow(pawn, p)).ToList();
                BodyPartRecord           part   = list.RandomElement();
                Hediff                   hediff = HediffMaker.MakeHediff(HediffDefOf.Scarification, pawn, part);
                HediffComp_GetsPermanent hediffComp_GetsPermanent = hediff.TryGetComp <HediffComp_GetsPermanent>();
                hediffComp_GetsPermanent.IsPermanent = true;
                hediffComp_GetsPermanent.SetPainCategory(JobDriver_Scarify.InjuryPainCategories.RandomElementByWeight((HealthTuning.PainCategoryWeighted e) => e.weight).category);
                pawn.health.AddHediff(hediff, null, null, null);
            }
        }
示例#4
0
        // Token: 0x06004B89 RID: 19337 RVA: 0x002347B4 File Offset: 0x00232BB4
        protected float FinalizeAndAddInjury(Pawn pawn, float totalDamage, DamageInfo dinfo, DamageWorker.DamageResult result)
        {
            if (pawn.health.hediffSet.PartIsMissing(dinfo.HitPart))
            {
                return(0f);
            }
            HediffDef     hediffDefFromDamage = HealthUtility.GetHediffDefFromDamage(dinfo.Def, pawn, dinfo.HitPart);
            Hediff_Injury hediff_Injury       = (Hediff_Injury)HediffMaker.MakeHediff(hediffDefFromDamage, pawn, null);

            hediff_Injury.Part   = dinfo.HitPart;
            hediff_Injury.source = dinfo.Weapon;
            hediff_Injury.sourceBodyPartGroup = dinfo.WeaponBodyPartGroup;
            hediff_Injury.sourceHediffDef     = dinfo.WeaponLinkedHediff;
            hediff_Injury.Severity            = totalDamage;
            if (dinfo.InstantPermanentInjury)
            {
                HediffComp_GetsPermanent hediffComp_GetsPermanent = hediff_Injury.TryGetComp <HediffComp_GetsPermanent>();
                if (hediffComp_GetsPermanent != null)
                {
                    hediffComp_GetsPermanent.IsPermanent = true;
                }
                else
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Tried to create instant permanent injury on Hediff without a GetsPermanent comp: ",
                        hediffDefFromDamage,
                        " on ",
                        pawn
                    }), false);
                }
            }
            return(this.FinalizeAndAddInjury(pawn, hediff_Injury, dinfo, result));
        }
示例#5
0
        // Token: 0x06004CA7 RID: 19623 RVA: 0x0023A424 File Offset: 0x00238824
        public static bool IsPermanent(this Hediff hd)
        {
            HediffWithComps hediffWithComps = hd as HediffWithComps;

            if (hediffWithComps == null)
            {
                return(false);
            }
            HediffComp_GetsPermanent hediffComp_GetsPermanent = hediffWithComps.TryGetCompFast <HediffComp_GetsPermanent>();

            return(hediffComp_GetsPermanent != null && hediffComp_GetsPermanent.IsPermanent);
        }
 public static bool Prefix(HediffComp_GetsPermanent __instance, bool value)
 {
     if (value)
     {
         var skin = __instance.Pawn.health.hediffSet.GetFirstHediffOfDef(HML_DefOf.HRM_SyntheticSkin);
         if (skin != null)
         {
             if (Rand.Chance(0.15f))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
示例#7
0
        // Token: 0x06004B8A RID: 19338 RVA: 0x0023489C File Offset: 0x00232C9C
        protected float FinalizeAndAddInjury(Pawn pawn, Hediff_Injury injury, DamageInfo dinfo, DamageWorker.DamageResult result)
        {
            HediffComp_GetsPermanent hediffComp_GetsPermanent = injury.TryGetComp <HediffComp_GetsPermanent>();

            if (hediffComp_GetsPermanent != null)
            {
                hediffComp_GetsPermanent.PreFinalizeInjury();
            }
            pawn.health.AddHediff(injury, null, new DamageInfo?(dinfo), result);
            float num = Mathf.Min(injury.Severity, pawn.health.hediffSet.GetPartHealth(injury.Part));

            result.totalDamageDealt += num;
            result.wounded           = true;
            result.AddPart(pawn, injury.Part);
            result.AddHediff(injury);
            return(num);
        }
        public bool RegenerateInjury(Pawn pawn, float amount)
        {
            var           injuries = pawn.health.hediffSet.hediffs.OfType <Hediff_Injury>().Where(x => x.Severity > 0 && x.Part != null);
            Hediff_Injury injury   = injuries.RandomElementWithFallback();

            if (injury == null)
            {
                return(false);
            }

            HediffComp_GetsPermanent hediffComp_GetsPermanent = injury.TryGetComp <HediffComp_GetsPermanent>();

            if (hediffComp_GetsPermanent != null)
            {
                hediffComp_GetsPermanent.IsPermanent = false;
            }

            injury.Severity = Mathf.Max(injury.Severity - amount);
            pawn.health.hediffSet.DirtyCache();

            RadiologyEffectSpawnerDef.Spawn(effectRegeneration, pawn);
            return(true);
        }
        public bool RegenerateInjury()
        {
            var           permanentInjuries = pawn.health.hediffSet.hediffs.OfType <Hediff_Injury>().Where(x => x.IsPermanent() && x.Part != null);
            Hediff_Injury injury            = permanentInjuries.RandomElementWithFallback();

            if (injury == null)
            {
                return(false);
            }

            HediffComp_GetsPermanent hediffComp_GetsPermanent = injury.TryGetComp <HediffComp_GetsPermanent>();

            if (hediffComp_GetsPermanent == null)
            {
                return(false);
            }

            hediffComp_GetsPermanent.IsPermanent = false;
            injury.Severity = injury.Part.def.hitPoints - 1;
            pawn.health.hediffSet.DirtyCache();

            RadiologyEffectSpawnerDef.Spawn(def.effectRegeneration, pawn);
            return(true);
        }
        public override void CompPostMake()
        {
            HediffComp_GetsPermanent permanentcomp = this.parent.TryGetComp <HediffComp_GetsPermanent>();

            permanentcomp.IsPermanent = true;
        }