public void ToggleItemAutofill(Object Item) { if (Item != null) { if (Enum.IsDefined(typeof(ObjectQuality), Item.Quality)) { ObjectQuality ItemQuality = (ObjectQuality)Item.Quality; if (ExcludedAutofillItems.TryGetValue(Item.DisplayName, out HashSet <ObjectQuality> ExcludedQualities)) { if (ExcludedQualities.Contains(ItemQuality)) { ExcludedQualities.Remove(ItemQuality); if (!ExcludedQualities.Any()) { ExcludedAutofillItems.Remove(Item.DisplayName); } } else { ExcludedQualities.Add(ItemQuality); } } else { ExcludedQualities = new HashSet <ObjectQuality>(); ExcludedQualities.Add(ItemQuality); ExcludedAutofillItems.Add(Item.DisplayName, ExcludedQualities); } } } }
public bool CanAutofillWithItem(Object item) { if (item == null) { return(false); } else if (ExcludedAutofillItems.TryGetValue(item.DisplayName, out HashSet <ObjectQuality> ExcludedQualities)) { if (!Enum.IsDefined(typeof(ObjectQuality), item.Quality)) { return(true); } else { ObjectQuality ItemQuality = (ObjectQuality)item.Quality; return(!ExcludedQualities.Contains(ItemQuality)); } } else { return(true); } }