void TransformArea() { List <Thing> thingList = GenRadial.RadialDistinctThingsAround(parent.PositionHeld, parent.Map, Props.explosiveRadius, true).ToList(); List <Pawn> pawnsAffected = new List <Pawn>(); HediffDef hediff = Props.HediffToAdd; float chance = Props.AddHediffChance; foreach (Pawn pawn in thingList.OfType <Pawn>()) { if (!pawnsAffected.Contains(pawn) && Props.CanAddHediffToPawn(pawn)) { pawnsAffected.Add(pawn); } } TransformPawn.ApplyHediff(pawnsAffected, parent.Map, hediff, chance); // Does the list need clearing? }
/// <summary> /// called when the attached pawn dies. /// </summary> /// <param name="corpse">The corpse.</param> public override void PawnDied(Corpse corpse) { GenExplosion.DoExplosion(radius: (corpse.InnerPawn.ageTracker.CurLifeStageIndex == 0) ? 2.9f : ((corpse.InnerPawn.ageTracker.CurLifeStageIndex != 1) ? 5.9f : 3.9f), center: corpse.Position, map: corpse.Map, damType: DamageDefOf.Flame, instigator: corpse.InnerPawn); List <Thing> thingList = GenRadial.RadialDistinctThingsAround(corpse.PositionHeld, corpse.Map, (corpse.InnerPawn.ageTracker.CurLifeStageIndex == 0) ? 2.9f : ((corpse.InnerPawn.ageTracker.CurLifeStageIndex != 1) ? 5.9f : 3.9f), true).ToList(); List <Pawn> pawnsAffected = new List <Pawn>(); HediffDef hediff = MorphTransformationDefOf.FullRandomTF; float chance = 0.7f; foreach (Pawn pawn in thingList.OfType <Pawn>()) { if (!pawnsAffected.Contains(pawn) && MutagenDefOf.defaultMutagen.CanInfect(pawn)) { pawnsAffected.Add(pawn); } } TransformPawn.ApplyHediff(pawnsAffected, corpse.InnerPawn.Map, hediff, chance); }
// An override of the Explode method that allows us to insert our own custom code first. protected override void Explode() { List <Thing> thingList = GenRadial.RadialDistinctThingsAround(Position, Map, def.projectile.explosionRadius, true).ToList(); List <Pawn> pawnsAffected = new List <Pawn>(); HediffDef hediff = Def.HediffToAdd; float chance = Def.AddHediffChance; for (int i = 0; i < thingList.Count; i++) { Pawn pawn = thingList[i] as Pawn; if (pawn != null && !pawnsAffected.Contains(pawn)) { pawnsAffected.Add(pawn); } } TransformPawn.ApplyHediff(pawnsAffected, Map, hediff, chance); // No idea why, but it errors if we call the underride before the custom check. base.Explode(); }