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);
                }
            }
        }
        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);
                    }
                }
            }
        }
Example #3
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);
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }