Exemple #1
0
        private void CalculateOldInjuryDamageThreshold(Pawn pawn, Hediff_Injury injury)
        {
            HediffCompProperties_GetsOld hediffCompProperties_GetsOld = injury.def.CompProps <HediffCompProperties_GetsOld>();

            if (hediffCompProperties_GetsOld != null && !injury.Part.def.IsSolid(injury.Part, pawn.health.hediffSet.hediffs) && !pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(injury.Part) && !injury.IsOld() && !(injury.Part.def.oldInjuryBaseChance < 9.9999997473787516E-06))
            {
                bool isDelicate = injury.Part.def.IsDelicate;
                if ((!(Rand.Value <= injury.Part.def.oldInjuryBaseChance * hediffCompProperties_GetsOld.becomeOldChance) || !(injury.Severity >= injury.Part.def.GetMaxHealth(pawn) * 0.25) || !(injury.Severity >= 7.0)) && !isDelicate)
                {
                    return;
                }
                HediffComp_GetsOld hediffComp_GetsOld = injury.TryGetComp <HediffComp_GetsOld>();
                float num  = 1f;
                float num2 = (float)(injury.Severity / 2.0);
                if (num <= num2)
                {
                    hediffComp_GetsOld.oldDamageThreshold = Rand.Range(num, num2);
                }
                if (isDelicate)
                {
                    hediffComp_GetsOld.oldDamageThreshold = injury.Severity;
                    hediffComp_GetsOld.IsOld = true;
                }
            }
        }
Exemple #2
0
        private void CalculateOldInjuryDamageThreshold(Pawn pawn, Hediff_Injury injury)
        {
            HediffCompProperties_GetsOld hediffCompProperties_GetsOld = injury.def.CompProps <HediffCompProperties_GetsOld>();

            if (hediffCompProperties_GetsOld == null)
            {
                return;
            }
            if (injury.Part.def.IsSolid(injury.Part, pawn.health.hediffSet.hediffs) || pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(injury.Part) || injury.IsOld() || injury.Part.def.oldInjuryBaseChance < 1E-05f)
            {
                return;
            }
            bool isDelicate = injury.Part.def.IsDelicate;

            if ((Rand.Value <= injury.Part.def.oldInjuryBaseChance * hediffCompProperties_GetsOld.becomeOldChance && injury.Severity >= injury.Part.def.GetMaxHealth(pawn) * 0.25f && injury.Severity >= 7f) || isDelicate)
            {
                HediffComp_GetsOld hediffComp_GetsOld = injury.TryGetComp <HediffComp_GetsOld>();
                float num  = 1f;
                float num2 = injury.Severity / 2f;
                if (num <= num2)
                {
                    hediffComp_GetsOld.oldDamageThreshold = Rand.Range(num, num2);
                }
                if (isDelicate)
                {
                    hediffComp_GetsOld.oldDamageThreshold = injury.Severity;
                    hediffComp_GetsOld.IsOld = true;
                }
            }
        }
Exemple #3
0
        protected float FinalizeAndAddInjury(Pawn pawn, float totalDamage, DamageInfo dinfo, ref 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.InstantOldInjury)
            {
                HediffComp_GetsOld hediffComp_GetsOld = hediff_Injury.TryGetComp <HediffComp_GetsOld>();
                if (hediffComp_GetsOld != null)
                {
                    hediffComp_GetsOld.IsOld = true;
                }
                else
                {
                    Log.Error("Tried to create instant old injury on Hediff without a GetsOld comp: " + hediffDefFromDamage + " on " + pawn);
                }
            }
            return(this.FinalizeAndAddInjury(pawn, hediff_Injury, dinfo, ref result));
        }
        public static bool IsOld(this Hediff hd)
        {
            HediffWithComps hediffWithComps = hd as HediffWithComps;

            if (hediffWithComps == null)
            {
                return(false);
            }
            HediffComp_GetsOld hediffComp_GetsOld = hediffWithComps.TryGetComp <HediffComp_GetsOld>();

            return(hediffComp_GetsOld != null && hediffComp_GetsOld.IsOld);
        }