public static HashSet <int> SelectOption( EquipmentItemOptionSheet optionSheet, SkillSheet skillSheet, EquipmentItemSubRecipeSheet.Row subRecipe, IRandom random, Equipment equipment ) { var optionSelector = new WeightedSelector <EquipmentItemOptionSheet.Row>(random); var optionIds = new HashSet <int>(); // Skip sort subRecipe.Options because it had been already sorted in WeightedSelector.Select(); foreach (var optionInfo in subRecipe.Options) { if (!optionSheet.TryGetValue(optionInfo.Id, out var optionRow)) { continue; } optionSelector.Add(optionRow, optionInfo.Ratio); } IEnumerable <EquipmentItemOptionSheet.Row> optionRows = new EquipmentItemOptionSheet.Row[0]; try { optionRows = optionSelector.SelectV1(subRecipe.MaxOptionLimit); } catch (Exception e) when( e is InvalidCountException || e is ListEmptyException ) { return(optionIds); } finally { foreach (var optionRow in optionRows.OrderBy(r => r.Id)) { if (optionRow.StatType != StatType.NONE) { var statMap = GetStat(optionRow, random); equipment.StatsMap.AddStatAdditionalValue(statMap.StatType, statMap.Value); } else { var skill = GetSkill(optionRow, skillSheet, random); if (!(skill is null)) { equipment.Skills.Add(skill); } } optionIds.Add(optionRow.Id); } } return(optionIds); }