public TArmor(IArmorGetter armor, string material) { FormKey = armor.FormKey; EditorID = armor.EditorID; Material = material; BodySlots = ArmorUtils.GetBodySlots(armor); Type = ArmorUtils.GetArmorType(armor); Gender = ArmorUtils.GetGender(armor); Name = armor.Name == null || armor.Name.String.Length < 1 ? armor.EditorID : armor.Name.ToString(); }
public static void ProcessAndDistributeJewelary(IPatcherState <ISkyrimMod, ISkyrimModGetter> state) { Logger.InfoFormat("Creating Leveled list for Jewelary....."); ISkyrimMod patchedMod = FileUtils.GetOrAddPatch("ZZZ Jewelry"); Dictionary <string, HashSet <IArmorGetter> > jewelleries = new Dictionary <string, HashSet <IArmorGetter> >(); // Adding all the patches to load order foreach (IModListing <ISkyrimModGetter> modlist in state.LoadOrder.PriorityOrder .Where(x => Configuration.User.JewelryMods.Contains(x.ModKey.FileName) && x.Mod.Armors.Count > 0)) { // Getting Jewelary Armors ISkyrimModGetter mod = modlist.Mod; IEnumerable <IArmorGetter> armors = mod.Armors .Where(x => ArmorUtils.IsValidArmor(x) && x.Name != null); for (int i = 0; i < armors.Count(); i++) { IArmorGetter armor = armors.ElementAtOrDefault(i); IArmorAddonGetter addon = armor.Armature.FirstOrDefault().Resolve(Configuration.Cache); string gender = (addon.WorldModel.Male != null && addon.WorldModel.Female != null ? "_C_" : addon.WorldModel.Male == null ? "_F_" : "_M_"); var bodyFlags = armor.BodyTemplate.FirstPersonFlags; var key = bodyFlags.ToString() + gender; if (!jewelleries.ContainsKey(key)) { jewelleries.Add(key, new HashSet <IArmorGetter>()); } jewelleries.GetValueOrDefault(key).Add(armor); } } // Creating leveled list for the jewelleries string prefix = Configuration.Patcher.LeveledListPrefix + "_LL_Jewels_"; jewelleries.Where(x => !Regex.Match(x.Key.ToString(), "Decapitate", RegexOptions.IgnoreCase).Success) .ForEach(j => { string lvli_eid = prefix + j.Key.ToString().Replace(" ", "_"); OutfitUtils.CreateLeveledList(patchedMod, j.Value, lvli_eid, 1, LeveledItem.Flag.CalculateForEachItemInCount); }); Logger.InfoFormat("Leveled List created for Jewelary...."); // Writing patched mod to disk DistributeJewelaryUsingSPID(state, patchedMod); Logger.InfoFormat("Distribution of Jewelaries is completed...\n\n"); }
public void CreateMatchingSetFrom(IEnumerable <IArmorGetter> others, bool addAll = false) { ConcurrentDictionary <string, ConcurrentDictionary <string, TArmor> > matchedArmors1 = new(); IEnumerable <TArmor> armorParts = others .Where(x => (ArmorUtils.GetMaterial(x).Equals(Material) || x.HasKeyword(Skyrim.Keyword.ArmorJewelry)) && Type.Equals(ArmorUtils.GetArmorType(x))) .Select(x => new TArmor(x)); if (!addAll) { var block = new ActionBlock <TArmor>( armor => { var armorName = armor.Name; if (HelperUtils.GetMatchingWordCount(Body.Name, armorName) > 0) { armor.BodySlots.Select(x => x.ToString()).ForEach(flag => { if (!matchedArmors1.ContainsKey(flag)) { matchedArmors1.TryAdd(flag, new ConcurrentDictionary <string, TArmor>()); } matchedArmors1.GetValueOrDefault(flag) .TryAdd(HelperUtils.GetMatchingWordCount(Body.Name, armorName).ToString(), armor); }); } }, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 30 }); foreach (var armor in armorParts) { block.Post(armor); } block.Complete(); block.Completion.Wait(); var armors = matchedArmors1.Values.Select(x => x.OrderBy(k => k.Key).Last().Value); this.AddArmors(armors); Logger.DebugFormat("Created Armors Set: {0}=> [{1}]", Body.FormKey.ModKey.FileName, string.Join(", ", Armors.Select(x => x.Name))); } else { this.AddArmors(armorParts); } }
public void CreateMatchingSetFrom(IEnumerable <IWeaponGetter> weapons, int bodyCounts, bool addAll = false) { ConcurrentDictionary <string, SortedSet <IWeaponGetter> > map = new(); ConcurrentDictionary <string, ConcurrentDictionary <string, IWeaponGetter> > matchedMap = new(); bool matched = false; if (!addAll) { var block = new ActionBlock <IWeaponGetter>( weapon => { var weaponName = ArmorUtils.ResolveItemName(weapon); if (HelperUtils.GetMatchingWordCount(Body.Name, weaponName) > 0) { matched = true; var type = weapon.Data.AnimationType.ToString(); if (!matchedMap.ContainsKey(type)) { matchedMap.TryAdd(type, new ConcurrentDictionary <string, IWeaponGetter>()); } matchedMap.GetValueOrDefault(type) .TryAdd(HelperUtils.GetMatchingWordCount(Body.Name, weaponName).ToString(), weapon); } }, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 10 }); foreach (var weapon in weapons) { block.Post(weapon); } block.Complete(); block.Completion.Wait(); var weaps = matchedMap.Values.Select(x => x.OrderBy(k => k.Key).Last().Value); this.AddWeapons(weaps); } else if (addAll || (!matched && bodyCounts < 5)) { this.AddWeapons(weapons); } }
public bool IsBody() { return(BodySlots.Any(x => ArmorUtils.IsUpperArmor(x))); }
public TArmor(IArmorGetter armor) : this(armor, ArmorUtils.GetMaterial(armor)) { }