internal void ImmunityHandlerTick()
        {
            List <ImmunityInfo> list = NeededImmunitiesNow();

            for (int i = 0; i < list.Count; i++)
            {
                TryAddImmunityRecord(list[i].immunity, list[i].source);
            }
            for (int j = 0; j < immunityList.Count; j++)
            {
                ImmunityRecord immunityRecord   = immunityList[j];
                Hediff         firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(immunityRecord.hediffDef);
                immunityRecord.ImmunityTick(pawn, firstHediffOfDef != null, firstHediffOfDef);
            }
            for (int num = immunityList.Count - 1; num >= 0; num--)
            {
                if (immunityList[num].immunity <= 0f)
                {
                    bool flag = false;
                    for (int k = 0; k < list.Count; k++)
                    {
                        if (list[k].immunity == immunityList[num].hediffDef)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        immunityList.RemoveAt(num);
                    }
                }
            }
        }
        internal void ImmunityHandlerTick()
        {
            List <HediffDef> list = this.NeededImmunitiesNow();

            for (int i = 0; i < list.Count; i++)
            {
                this.TryAddImmunityRecord(list[i]);
            }
            for (int j = 0; j < this.immunityList.Count; j++)
            {
                ImmunityRecord immunityRecord   = this.immunityList[j];
                Hediff         firstHediffOfDef = this.pawn.health.hediffSet.GetFirstHediffOfDef(immunityRecord.hediffDef, false);
                immunityRecord.ImmunityTick(this.pawn, firstHediffOfDef != null, firstHediffOfDef);
                if (firstHediffOfDef == null && this.AnyHediffMakesFullyImmuneTo(immunityRecord.hediffDef))
                {
                    immunityRecord.immunity = Mathf.Clamp(0.650000036f, immunityRecord.immunity, 1f);
                }
            }
            for (int num = this.immunityList.Count - 1; num >= 0; num--)
            {
                if (this.immunityList[num].immunity <= 0.0 && !list.Contains(this.immunityList[num].hediffDef))
                {
                    this.immunityList.RemoveAt(num);
                }
            }
        }
 private void TryAddImmunityRecord(HediffDef def)
 {
     if (def.CompProps <HediffCompProperties_Immunizable>() != null && !this.ImmunityRecordExists(def))
     {
         ImmunityRecord immunityRecord = new ImmunityRecord();
         immunityRecord.hediffDef = def;
         this.immunityList.Add(immunityRecord);
     }
 }
 public float GetImmunity(HediffDef def)
 {
     for (int i = 0; i < this.immunityList.Count; i++)
     {
         ImmunityRecord immunityRecord = this.immunityList[i];
         if (immunityRecord.hediffDef == def)
         {
             return(immunityRecord.immunity);
         }
     }
     return(0f);
 }
        private void TryAddImmunityRecord(HediffDef def, HediffDef source)
        {
            if (def.CompProps <HediffCompProperties_Immunizable>() == null)
            {
                return;
            }
            if (this.ImmunityRecordExists(def))
            {
                return;
            }
            ImmunityRecord immunityRecord = new ImmunityRecord();

            immunityRecord.hediffDef = def;
            immunityRecord.source    = source;
            this.immunityList.Add(immunityRecord);
        }
Esempio n. 6
0
        public override string CompDebugString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(base.CompDebugString());
            if (this.severityPerDayNotImmuneRandomFactor != 1f)
            {
                stringBuilder.AppendLine("severityPerDayNotImmuneRandomFactor: " + this.severityPerDayNotImmuneRandomFactor.ToString("0.##"));
            }
            if (!base.Pawn.Dead)
            {
                ImmunityRecord immunityRecord = base.Pawn.health.immunity.GetImmunityRecord(base.Def);
                if (immunityRecord != null)
                {
                    stringBuilder.AppendLine("immunity change per day: " + (immunityRecord.ImmunityChangePerTick(base.Pawn, true, this.parent) * 60000f).ToString("F3"));
                }
            }
            return(stringBuilder.ToString());
        }
        public float GetImmunity(HediffDef def)
        {
            float num = 0f;

            for (int i = 0; i < immunityList.Count; i++)
            {
                ImmunityRecord immunityRecord = immunityList[i];
                if (immunityRecord.hediffDef == def)
                {
                    num = immunityRecord.immunity;
                    break;
                }
            }
            if (AnyHediffMakesFullyImmuneTo_NewTemp(def, out var _) && num < 0.650000036f)
            {
                num = 0.650000036f;
            }
            return(num);
        }
Esempio n. 8
0
        internal void ImmunityHandlerTick()
        {
            List <ImmunityInfo> list = NeededImmunitiesNow();

            for (int i = 0; i < list.Count; i++)
            {
                ImmunityInfo immunityInfo  = list[i];
                HediffDef    immunity      = immunityInfo.immunity;
                ImmunityInfo immunityInfo2 = list[i];
                TryAddImmunityRecord(immunity, immunityInfo2.source);
            }
            for (int j = 0; j < immunityList.Count; j++)
            {
                ImmunityRecord immunityRecord   = immunityList[j];
                Hediff         firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(immunityRecord.hediffDef);
                immunityRecord.ImmunityTick(pawn, firstHediffOfDef != null, firstHediffOfDef);
                if (firstHediffOfDef == null && AnyHediffMakesFullyImmuneTo(immunityRecord.hediffDef))
                {
                    immunityRecord.immunity = Mathf.Clamp(0.650000036f, immunityRecord.immunity, 1f);
                }
            }
            for (int num = immunityList.Count - 1; num >= 0; num--)
            {
                if (immunityList[num].immunity <= 0f)
                {
                    bool flag = false;
                    for (int k = 0; k < list.Count; k++)
                    {
                        ImmunityInfo immunityInfo3 = list[k];
                        if (immunityInfo3.immunity == immunityList[num].hediffDef)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        immunityList.RemoveAt(num);
                    }
                }
            }
        }
Esempio n. 9
0
        public override string CompDebugString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(base.CompDebugString());
            if (this.severityPerDayNotImmuneRandomFactor != 1f)
            {
                stringBuilder.AppendLine("severityPerDayNotImmuneRandomFactor: " + this.severityPerDayNotImmuneRandomFactor.ToString("0.##"));
            }
            if (!base.Pawn.Dead)
            {
                ImmunityRecord immunityRecord = base.Pawn.health.immunity.GetImmunityRecord(base.Def);
                if (immunityRecord != null)
                {
                    stringBuilder.AppendLine("immunity change per day: " + (immunityRecord.ImmunityChangePerTick(base.Pawn, true, this.parent) * 60000f).ToString("F3"));
                    stringBuilder.AppendLine("  pawn immunity gain speed: " + StatDefOf.ImmunityGainSpeed.ValueToString(base.Pawn.GetStatValue(StatDefOf.ImmunityGainSpeed, true), ToStringNumberSense.Absolute));
                }
            }
            return(stringBuilder.ToString());
        }
        internal void ImmunityHandlerTick()
        {
            List <ImmunityHandler.ImmunityInfo> list = this.NeededImmunitiesNow();

            for (int i = 0; i < list.Count; i++)
            {
                this.TryAddImmunityRecord(list[i].immunity, list[i].source);
            }
            for (int j = 0; j < this.immunityList.Count; j++)
            {
                ImmunityRecord immunityRecord   = this.immunityList[j];
                Hediff         firstHediffOfDef = this.pawn.health.hediffSet.GetFirstHediffOfDef(immunityRecord.hediffDef, false);
                immunityRecord.ImmunityTick(this.pawn, firstHediffOfDef != null, firstHediffOfDef);
                if (firstHediffOfDef == null && this.AnyHediffMakesFullyImmuneTo(immunityRecord.hediffDef))
                {
                    immunityRecord.immunity = Mathf.Clamp(0.650000036f, immunityRecord.immunity, 1f);
                }
            }
            for (int k = this.immunityList.Count - 1; k >= 0; k--)
            {
                if (this.immunityList[k].immunity <= 0f)
                {
                    bool flag = false;
                    for (int l = 0; l < list.Count; l++)
                    {
                        if (list[l].immunity == this.immunityList[k].hediffDef)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        this.immunityList.RemoveAt(k);
                    }
                }
            }
        }
        public ImmunityRecord GetImmunityRecord(HediffDef def)
        {
            ImmunityRecord immunityRecord = null;

            for (int i = 0; i < immunityList.Count; i++)
            {
                if (immunityList[i].hediffDef == def)
                {
                    immunityRecord = immunityList[i];
                    break;
                }
            }
            if (AnyHediffMakesFullyImmuneTo_NewTemp(def, out var sourceHediff) && (immunityRecord == null || immunityRecord.immunity < 0.650000036f))
            {
                immunityRecord = new ImmunityRecord
                {
                    immunity  = 0.650000036f,
                    hediffDef = def,
                    source    = sourceHediff.def
                };
            }
            return(immunityRecord);
        }