public IEnumerable <IItem> GetLoot(ILootTable lootTable) { var droppedLoot = new List <IItem>(); var possibleLootGroups = lootTable.LootGroups .Where(g => g.IsPossible && RandomGenerationHelper.RandomNumber(0, 10000) <= g.LootGroupRollProbability); foreach (var lootGroup in possibleLootGroups) { droppedLoot.AddRange(ProcessLootGroup(lootGroup)); } return(droppedLoot.Any() ? droppedLoot : Enumerable.Empty <IItem>()); }
private IEnumerable <IItem> ProcessLootGroup(ILootGroup lootGroup) { var droppedLoot = new List <IItem>(); droppedLoot.AddRange(_itemFactory.GetItems(lootGroup.LootItems.Where(c => c.IsGuaranteed))); List <ILootItem> possibleLootItems = lootGroup.LootItems.Where(g => g.IsPossible && !g.IsGuaranteed).ToList(); foreach (var lootItem in possibleLootItems) { if (RandomGenerationHelper.RandomNumber(0, 10000) <= lootItem.Probability) { droppedLoot.Add(_itemFactory.GetItem(lootItem)); possibleLootItems = CheckLootItemsForExclusion(lootItem.ItemsExcludedIfDropped, possibleLootItems); } } return(droppedLoot.Any() ? droppedLoot : Enumerable.Empty <IItem>()); }