public bool ShouldAlert(HashSet<string> currencyNames, ItemAlertSettings settings) { Mods mods = _item.GetComponent<Mods>(); QualityItemsSettings qualitySettings = settings.QualityItems; rarity = mods.ItemRarity; // set rarity if (_item.HasComponent<Quality>()) { quality = _item.GetComponent<Quality>().ItemQuality; // update quality variable } alertText = string.Concat(quality > 0 ? "Superior " : String.Empty, _name); // Check if Map/Vaal Frag if (settings.Maps && (_item.HasComponent<Map>() || _item.Path.Contains("VaalFragment"))) { borderWidth = 1; return true; } // Check if Currency if (settings.Currency && _item.Path.Contains("Currency")) { color = HudSkin.CurrencyColor; return currencyNames?.Contains(_name) ?? (!_name.Contains("Wisdom") && !_name.Contains("Portal")); } // Check if DivinationCard if (settings.DivinationCards && _item.Path.Contains("DivinationCards")) { color = HudSkin.DivinationCardColor; return true; } Sockets sockets = _item.GetComponent<Sockets>(); // Check link REQ. if (sockets.LargestLinkSize >= settings.MinLinks) { if (sockets.LargestLinkSize == 6) // If 6 link change icon { alertIcon = 3; } return true; } // Check if Crafting Base if (IsCraftingBase(mods.ItemLevel)) { alertIcon = 2; return true; } // Check # socket REQ. if (sockets.NumberOfSockets >= settings.MinSockets) { alertIcon = 0; return true; } // RGB if (settings.Rgb && sockets.IsRGB) { alertIcon = 1; return true; } // Check if Jewel if (settings.Jewels && _item.Path.Contains("Jewels")) { return true; } // meets rarity conidtions switch (rarity) { case ItemRarity.Rare: return settings.Rares; case ItemRarity.Unique: return settings.Uniques; } // Other (no icon change) if (qualitySettings.Enable) { if (qualitySettings.Flask.Enable && _item.HasComponent<Flask>()) { return (quality >= qualitySettings.Flask.MinQuality); } else if (qualitySettings.SkillGem.Enable && _item.HasComponent<SkillGem>()) { color = HudSkin.SkillGemColor; return (quality >= qualitySettings.SkillGem.MinQuality); } else if (qualitySettings.Weapon.Enable && _item.HasComponent<Weapon>()) { return (quality >= qualitySettings.Weapon.MinQuality); } else if (qualitySettings.Armour.Enable && _item.HasComponent<Armour>()) { return (quality >= qualitySettings.Armour.MinQuality); } } return false; // Meets no checks }
public virtual string GetUnique(string desiredName, IIdentifier whoIsAsking, IEnumerable<IIdentifier> reservedNames, IEnumerable<IIdentifier> siblingNames, HashSet<string> locallyReservedNames = null) { // can't disambiguate on an empty name. if (string.IsNullOrEmpty(desiredName)) { return desiredName; } #if refactoring_out // special case: properties can actually have the same name as a composite type // as long as that type is not the parent class of the property itself. if (whoIsAsking is Property) { reservedNames = reservedNames.Where(each => !(each is CompositeType)); var parent = (whoIsAsking as IChild)?.Parent as IIdentifier; if (parent != null) { reservedNames = reservedNames.ConcatSingleItem(parent); } } #endif var names = new HashSet<IIdentifier>(reservedNames.Where(each => !IsSpecialCase(whoIsAsking, each))); // is this a legal name? -- add a Qualifier Suffix (ie, Method/Model/Property/etc) string conflict; while ((conflict = IsNameLegal(desiredName, whoIsAsking)) != null) { desiredName += whoIsAsking.Qualifier; // todo: gws: log the name change because it conflicted with a reserved word. // Singleton<Log>.Instance?.Add(new Message {Text = $"todo:{conflict}"}); } // does it conflict with a type name locally? (add a Qualifier Suffix) IIdentifier confl; while (null != (confl = IsNameAvailable(desiredName, names))) { desiredName += whoIsAsking.Qualifier; // todo: gws: log the name change because there was something else named that. // Singleton<Log>.Instance?.Add(new Message {Text = $"todo:{confl}"}); // reason = string.Format(CultureInfo.InvariantCulture, Resources.NamespaceConflictReasonMessage,desiredName, ...? } // special case (corolary): a compositeType can actually have the same name as a property if (whoIsAsking is CompositeType) { siblingNames= siblingNames.Where(each => !(each is Property)); } if (whoIsAsking is Property) { siblingNames = siblingNames.Where(each => !(each is CompositeType)); } // does it have a sibling collision? names = new HashSet<IIdentifier>(siblingNames); var baseName = desiredName; var suffix = 0; while (IsNameAvailable(desiredName, names) != null) { desiredName = baseName + ++suffix; } // is there a collision with any local name we care about? while (true == locallyReservedNames?.Contains(desiredName)) { desiredName = baseName + ++suffix; } return desiredName; }