public CombatBodyPart RollBodyPart(Quadrant quadrant) { var idx = (int)quadrant.GetIndex(); var bodyParts = Quadrants[idx]; var total = bodyParts.Sum(i => i.Probability); if (total == 0.0f) { return(CombatBodyPart.Undefined); } var rng = ThreadSafeRandom.Next(0.0f, total); var totalProbability = 0.0f; foreach (var bodyPart in bodyParts) { totalProbability += bodyPart.Probability; if (rng < totalProbability) { return((CombatBodyPart)bodyPart.BodyPart); } } return(CombatBodyPart.Undefined); }