public static HashSet <AchievementCard> GetLongTickCards() { if (tickerAchievements.EnumerableNullOrEmpty()) { tickerAchievements.AddRange(AchievementList.Where(a => a.tracker.AttachToLongTick != null && !a.unlocked)); } return(tickerAchievements); }
/// <summary> /// Happens when an Achievement is changed in the AchievementManager /// </summary> public void Refresh() { IcUnlocked.Items.Clear(); foreach (Achievement achievement in AchievementList.Where(x => x.Unlocked)) { IcUnlocked.Items.Add(new AchievementControl(achievement) { Margin = new Thickness(5) }); } IcLocked.Items.Clear(); foreach (Achievement achievement in AchievementList.Where(x => !x.Unlocked)) { if (!achievement.Hidden) { IcLocked.Items.Add(new AchievementControl(achievement) { Margin = new Thickness(5) }); } } if (AchievementList.Any(x => x.Unlocked)) { UnlockedAchievementsVisibility = Visibility.Visible; } else { UnlockedAchievementsVisibility = Visibility.Collapsed; } if (AchievementList.Any(x => !x.Unlocked && !x.Hidden)) { LockedAchievementsVisibility = Visibility.Visible; } else { LockedAchievementsVisibility = Visibility.Collapsed; } if (AchievementList.Any(x => x.Unlocked) && AchievementList.Any(x => !x.Unlocked && !x.Hidden)) { SeparatorVisibility = Visibility.Visible; } else { SeparatorVisibility = Visibility.Collapsed; } }
public static HashSet <AchievementCard> GetCards <T>(bool locked = true) { lock (achievementLookup) { if (achievementLookup.TryGetValue(GetTrackerKey <T>(), out var hashset)) { if (locked) { return(hashset.Where(c => !c.unlocked).ToHashSet()); } return(hashset); } achievementLookup.Add(GetTrackerKey <T>(), AchievementList.Where(c => c.tracker.Key == GetTrackerKey <T>()).ToHashSet()); if (locked) { return(achievementLookup[GetTrackerKey <T>()].Where(c => !c.unlocked).ToHashSet()); } return(achievementLookup[GetTrackerKey <T>()]); } }