private void parseItemGroups() { progressionService = Service.Get <ProgressionService>(); TemplateDefinition[] unlockedDefinitionsForCategory = progressionService.GetUnlockedDefinitionsForCategory <TemplateDefinition>(ProgressionUnlockCategory.equipmentTemplates); progressionUnlockedRewards = new HashSet <TemplateDefinition>(unlockedDefinitionsForCategory); userLevel = progressionService.Level; for (int i = 0; i <= progressionService.MaxUnlockLevel; i++) { TemplateDefinition[] array = progressionService.GetUnlockedDefinitionsForLevel(i, ProgressionUnlockCategory.equipmentTemplates).Definitions as TemplateDefinition[]; if (array == null || array.Length <= 0) { continue; } bool isProgressionLocked = i > userLevel; for (int j = 0; j < array.Length; j++) { if (array[j] != null && array[j].IsEditable) { DisplayedTemplate newDisplayTemplate = new DisplayedTemplate(array[j], i, null); addRewardTemplate(newDisplayTemplate, isProgressionLocked); if (progressionUnlockedRewards.Contains(array[j])) { progressionUnlockedRewards.Remove(array[j]); } } } } QuestService questService = Service.Get <QuestService>(); Dictionary <string, Mascot> questToMascotMap = questService.QuestToMascotMap; foreach (QuestDefinition knownQuest in questService.KnownQuests) { questToMascotMap.TryGetValue(knownQuest.name, out var value); if (value == null) { continue; } string mascotName = value.Name; Quest quest = questService.GetQuest(knownQuest); if (knownQuest.StartReward != null) { if (quest.State == Quest.QuestState.Active || quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0) { mascotName = ""; } parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.StartReward.GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName); } if (knownQuest.CompleteReward != null) { if (quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0) { mascotName = ""; } parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.CompleteReward.GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName); } if (knownQuest.ObjectiveRewards != null) { if (quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0) { mascotName = ""; } for (int j = 0; j < knownQuest.ObjectiveRewards.Length; j++) { parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.ObjectiveRewards[j].GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName); } } } if (progressionUnlockedRewards.Count <= 0) { return; } TemplateDefinition[] array2 = new TemplateDefinition[progressionUnlockedRewards.Count]; progressionUnlockedRewards.CopyTo(array2); for (int j = 0; j < array2.Length; j++) { if (array2[j].IsEditable) { DisplayedTemplate newDisplayTemplate = new DisplayedTemplate(array2[j], -1, null); lastUnlockedIndex++; rewardTemplates.Insert(lastUnlockedIndex, newDisplayTemplate); } } }
public static List <ParsedProgression <TDefinition> > RetrieveProgressionLockedItems <TDefinition, TReward>(ProgressionUnlockCategory category, Func <List <TReward>, TDefinition[]> getRewards) where TDefinition : StaticGameDataDefinition, IMemberLocked where TReward : AbstractStaticGameDataRewardDefinition <TDefinition> { ProgressionService progressionService = Service.Get <ProgressionService>(); TDefinition[] unlockedDefinitionsForCategory = progressionService.GetUnlockedDefinitionsForCategory <TDefinition>(category); HashSet <TDefinition> hashSet = new HashSet <TDefinition>(unlockedDefinitionsForCategory); int level = progressionService.Level; List <ParsedProgression <TDefinition> > list = new List <ParsedProgression <TDefinition> >(); int lastUnlockedIndex = -1; bool isLocalPlayerMember = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember(); for (int i = 0; i <= progressionService.MaxUnlockLevel; i++) { TDefinition[] array = progressionService.GetUnlockedDefinitionsForLevel(i, category).Definitions as TDefinition[]; if (array == null || array.Length <= 0) { continue; } bool flag = i > level; for (int j = 0; j < array.Length; j++) { if ((UnityEngine.Object)array[j] != (UnityEngine.Object)null) { ParsedProgression <TDefinition> parsedProgression = new ParsedProgression <TDefinition>(array[j], i, null, flag, progressionLocked: false, array[j].IsMemberOnly); addParsedProgression(list, parsedProgression, flag, isLocalPlayerMember, ref lastUnlockedIndex); if (hashSet.Contains(array[j])) { hashSet.Remove(array[j]); } } } } QuestService questService = Service.Get <QuestService>(); Dictionary <string, Mascot> questToMascotMap = questService.QuestToMascotMap; foreach (QuestDefinition knownQuest in questService.KnownQuests) { questToMascotMap.TryGetValue(knownQuest.name, out Mascot value); if (value != null) { string name = value.Name; questService.GetQuest(knownQuest); if (knownQuest.StartReward != null) { parseRewardDefinition(list, getRewards(knownQuest.StartReward.GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex); } if (knownQuest.CompleteReward != null) { parseRewardDefinition(list, getRewards(knownQuest.CompleteReward.GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex); } if (knownQuest.ObjectiveRewards != null) { for (int j = 0; j < knownQuest.ObjectiveRewards.Length; j++) { parseRewardDefinition(list, getRewards(knownQuest.ObjectiveRewards[j].GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex); } } } } if (hashSet.Count > 0) { TDefinition[] array2 = new TDefinition[hashSet.Count]; hashSet.CopyTo(array2); for (int j = 0; j < array2.Length; j++) { ParsedProgression <TDefinition> parsedProgression = new ParsedProgression <TDefinition>(array2[j], -1, null, levelLocked: false, progressionLocked: false, array2[j].IsMemberOnly); lastUnlockedIndex++; list.Insert(lastUnlockedIndex, parsedProgression); } } return(list); }
protected virtual void parseItemGroups() { T[] collection = filterDefinitions(progressionService.GetUnlockedDefinitionsForCategory <T>(UnlockCategory)); progressionUnlockedRewards = new HashSet <T>(collection); bool flag = isLocalPlayerMember(); for (int i = 0; i <= progressionService.MaxUnlockLevel; i++) { ProgressionService.UnlockDefinition unlockedDefinitionsForLevel = progressionService.GetUnlockedDefinitionsForLevel(i, UnlockCategory); T[] array = filterDefinitions(unlockedDefinitionsForLevel.Definitions as T[]); List <T> list = new List <T>(); List <T> list2 = new List <T>(); List <T> list3 = new List <T>(); if (array == null || array.Length <= 0) { continue; } for (int j = 0; j < array.Length; j++) { if (array[j].IsMemberOnly && !flag) { list.Add(array[j]); } else if (i > progressionService.Level) { list2.Add(array[j]); } else { list3.Add(array[j]); } } if (list3.Count > 0) { addItems(list3.ToArray(), ItemGroup.LockedState.Unlocked, i, null, unlockedDefinitionsForLevel.ThemeDefinition); } if (list2.Count > 0) { addItems(list2.ToArray(), ItemGroup.LockedState.LevelLocked, i, null, unlockedDefinitionsForLevel.ThemeDefinition); } if (list.Count > 0) { addItems(list.ToArray(), ItemGroup.LockedState.MemberLocked, i, null, unlockedDefinitionsForLevel.ThemeDefinition); } removeUnlocksFromRewardSet(array); } Dictionary <string, Mascot> questToMascotMap = questService.QuestToMascotMap; foreach (QuestDefinition knownQuest in questService.KnownQuests) { questToMascotMap.TryGetValue(knownQuest.name, out var value); if (value == null) { continue; } if (knownQuest.StartReward != null) { CPRewardDefinition cPRewardDefinition = knownQuest.StartReward as CPRewardDefinition; parseRewardDefinition(getRewards(knownQuest.StartReward), flag, value.Definition.ProgressionLockedIconContentKey, cPRewardDefinition.ThemeDefinition); } if (knownQuest.CompleteReward != null) { CPRewardDefinition cPRewardDefinition = knownQuest.CompleteReward as CPRewardDefinition; parseRewardDefinition(getRewards(knownQuest.CompleteReward), flag, value.Definition.ProgressionLockedIconContentKey, cPRewardDefinition.ThemeDefinition); } if (knownQuest.ObjectiveRewards != null) { for (int i = 0; i < knownQuest.ObjectiveRewards.Length; i++) { CPRewardDefinition cPRewardDefinition = knownQuest.ObjectiveRewards[i] as CPRewardDefinition; parseRewardDefinition(getRewards(knownQuest.ObjectiveRewards[i]), flag, value.Definition.ProgressionLockedIconContentKey, cPRewardDefinition.ThemeDefinition); } } } parseDisneyShopRewards(); parseClaimableRewards(); if (progressionUnlockedRewards.Count > 0) { if (flag) { T[] array2 = new T[progressionUnlockedRewards.Count]; progressionUnlockedRewards.CopyTo(array2); addItems(array2, ItemGroup.LockedState.Unlocked, -1); } else { List <T> list4 = new List <T>(); List <T> list5 = new List <T>(); foreach (T progressionUnlockedReward in progressionUnlockedRewards) { T current2 = progressionUnlockedReward; if (current2.IsMemberOnly) { list4.Add(current2); } else { list5.Add(current2); } } if (list5.Count > 0) { T[] array2 = new T[progressionUnlockedRewards.Count]; list5.CopyTo(array2); addItems(array2, ItemGroup.LockedState.Unlocked, -1); } if (list4.Count > 0) { T[] array2 = new T[progressionUnlockedRewards.Count]; list4.CopyTo(array2); addItems(array2, ItemGroup.LockedState.MemberLocked, -1); } } } parseUnlockedItems(); }