public void ApplyToPawns(IEnumerable <Pawn> pawns)
        {
            Dictionary <HediffDef, List <Pawn> > dictionary = new Dictionary <HediffDef, List <Pawn> >();

            foreach (Pawn pawn in pawns)
            {
                HediffDef hediffDef = null;
                if (Rand.Chance(pawn.health.immunity.DiseaseContractChanceFactor(this.def.diseaseIncident, out hediffDef, null)))
                {
                    HediffGiveUtility.TryApply(pawn, this.def.diseaseIncident, this.def.diseasePartsToAffect, false, 1, null);
                }
                else if (hediffDef != null)
                {
                    if (!dictionary.ContainsKey(hediffDef))
                    {
                        dictionary[hediffDef] = new List <Pawn>();
                    }
                    dictionary[hediffDef].Add(pawn);
                }
            }
            foreach (KeyValuePair <HediffDef, List <Pawn> > keyValuePair in dictionary)
            {
                if (keyValuePair.Key != this.def.diseaseIncident)
                {
                    string   key   = "MessageBlockedHediff";
                    object[] array = new object[3];
                    array[0] = keyValuePair.Key.LabelCap;
                    array[1] = this.def.diseaseIncident.LabelCap;
                    array[2] = (from victim in keyValuePair.Value
                                select victim.LabelShort).ToCommaList(true);
                    Messages.Message(key.Translate(array), MessageTypeDefOf.NeutralEvent, true);
                }
            }
        }
Exemplo n.º 2
0
        public override void Effect(Pawn target)
        {
            if (VampireUtility.CanGrapple(this.CasterPawn, target))
            {
                base.Effect(target);
                int       boolSel      = Rand.Range(0, 2);
                string    tagOne       = "";
                string    tagTwo       = "";
                HediffDef hediffDefOne = null;
                HediffDef hediffDefTwo = null;
                switch (boolSel)
                {
                case 0:
                    tagOne       = "MovingLimbCore";
                    tagTwo       = "SightSource";
                    hediffDefOne = VampDefOf.ROMV_CorruptFormHediff_Legs;
                    hediffDefTwo = VampDefOf.ROMV_CorruptFormHediff_Sight;

                    break;

                case 1:
                    tagOne       = "ManipulationLimbCore";
                    tagTwo       = "SightSource";
                    hediffDefOne = VampDefOf.ROMV_CorruptFormHediff_Arms;
                    hediffDefTwo = VampDefOf.ROMV_CorruptFormHediff_Sight;
                    break;

                case 2:
                    tagOne       = "ManipulationLimbCore";
                    tagTwo       = "MovingLimbCore";
                    hediffDefOne = VampDefOf.ROMV_CorruptFormHediff_Arms;
                    hediffDefTwo = VampDefOf.ROMV_CorruptFormHediff_Legs;
                    break;
                }

                IEnumerable <BodyPartRecord> recs = target.health.hediffSet.GetNotMissingParts();
                if (recs.FirstOrDefault(x => (x.def.tags.Contains(tagOne))) is BodyPartRecord bp)
                {
                    HediffGiveUtility.TryApply(target, hediffDefOne, new List <BodyPartDef> {
                        bp.def
                    });
                }
                if (recs.FirstOrDefault(x => (x.def.tags.Contains(tagTwo))) is BodyPartRecord bpII)
                {
                    HediffGiveUtility.TryApply(target, hediffDefTwo, new List <BodyPartDef> {
                        bpII.def
                    });
                }
            }
        }
Exemplo n.º 3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            int num           = this.PotentialVictimCandidates(parms.target).Count();
            int randomInRange = new IntRange(Mathf.RoundToInt((float)num * base.def.diseaseVictimFractionRange.min), Mathf.RoundToInt((float)num * base.def.diseaseVictimFractionRange.max)).RandomInRange;

            randomInRange = Mathf.Clamp(randomInRange, 1, base.def.diseaseMaxVictims);
            int  num2 = 0;
            Pawn pawn = default(Pawn);

            while (num2 < randomInRange && this.PotentialVictims(parms.target).TryRandomElementByWeight <Pawn>((Func <Pawn, float>)((Pawn x) => x.health.immunity.DiseaseContractChanceFactor(base.def.diseaseIncident, null)), out pawn))
            {
                HediffGiveUtility.TryApply(pawn, base.def.diseaseIncident, base.def.diseasePartsToAffect, false, 1, null);
                num2++;
            }
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            int      num      = this.PotentialVictimCandidates(parms.target).Count <Pawn>();
            IntRange intRange = new IntRange(Mathf.RoundToInt((float)num * this.def.diseaseVictimFractionRange.min), Mathf.RoundToInt((float)num * this.def.diseaseVictimFractionRange.max));
            int      num2     = intRange.RandomInRange;

            num2 = Mathf.Clamp(num2, 1, this.def.diseaseMaxVictims);
            for (int i = 0; i < num2; i++)
            {
                Pawn pawn;
                if (!this.PotentialVictims(parms.target).TryRandomElementByWeight((Pawn x) => x.health.immunity.DiseaseContractChanceFactor(this.def.diseaseIncident, null), out pawn))
                {
                    break;
                }
                HediffGiveUtility.TryApply(pawn, this.def.diseaseIncident, this.def.diseasePartsToAffect, false, 1, null);
            }
            return(true);
        }