private void addRewardTemplate(DisplayedTemplate newDisplayTemplate, bool isProgressionLocked)
 {
     if (rewardTemplates.Exists((DisplayedTemplate x) => x.Definition.Id == newDisplayTemplate.Definition.Id))
     {
     }
     if (Service.Get <CPDataEntityCollection>().IsLocalPlayerMember())
     {
         if (isProgressionLocked)
         {
             rewardTemplates.Add(newDisplayTemplate);
             return;
         }
         lastUnlockedIndex++;
         rewardTemplates.Insert(lastUnlockedIndex, newDisplayTemplate);
     }
     else if (newDisplayTemplate.Definition.IsMemberOnlyCreatable)
     {
         rewardTemplates.Add(newDisplayTemplate);
     }
     else
     {
         lastUnlockedIndex++;
         rewardTemplates.Insert(lastUnlockedIndex, newDisplayTemplate);
     }
 }
        private void parseRewardDefinition(TemplateDefinition[] unlocks, string mascotName)
        {
            if (unlocks == null || unlocks.Length <= 0)
            {
                return;
            }
            bool isProgressionLocked = false;

            for (int i = 0; i < unlocks.Length; i++)
            {
                if (unlocks[i] != null && unlocks[i].IsEditable)
                {
                    if (!progressionService.IsUnlocked(unlocks[i], ProgressionUnlockCategory.equipmentTemplates))
                    {
                        isProgressionLocked = true;
                    }
                    DisplayedTemplate newDisplayTemplate = new DisplayedTemplate(unlocks[i], -1, mascotName);
                    addRewardTemplate(newDisplayTemplate, isProgressionLocked);
                    if (progressionUnlockedRewards.Contains(unlocks[i]))
                    {
                        progressionUnlockedRewards.Remove(unlocks[i]);
                    }
                }
            }
        }
        private void onObjectAdded(RectTransform item, int index)
        {
            TemplateIcon      component         = item.GetComponent <TemplateIcon>();
            DisplayedTemplate displayedTemplate = displayedTemplates[index];

            component.gameObject.name = displayedTemplate.Definition.AssetName + "_button";
            RectTransform rectTransform = component.transform as RectTransform;

            rectTransform.anchoredPosition = Vector2.zero;
            rectTransform.anchorMin        = Vector2.zero;
            rectTransform.anchorMax        = Vector2.one;
            rectTransform.sizeDelta        = Vector2.zero;
            rectTransform.localScale       = Vector3.one;
            bool flag    = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember();
            bool canDrag = flag;

            if (!flag)
            {
                canDrag = !displayedTemplate.Definition.IsMemberOnlyCreatable;
            }
            string assetName = displayedTemplate.Definition.AssetName;
            Texture2DContentKey equipmentIconPath = EquipmentPathUtil.GetEquipmentIconPath(assetName);

            component.Init(equipmentIconPath, BreadcrumbType, displayedTemplate.Definition.Id, canDrag);
            if (!flag && displayedTemplate.Definition.IsMemberOnlyCreatable)
            {
                component.SetTemplateMemberLocked(displayedTemplate.Definition);
            }
            else if (userLevel < displayedTemplate.Level)
            {
                component.SetTemplateToLevelLocked(displayedTemplate.Definition, displayedTemplate.Level);
            }
            else if (!string.IsNullOrEmpty(displayedTemplate.MascotName))
            {
                component.SetTemplateToProgressionLocked(displayedTemplate.Definition, displayedTemplate.MascotName);
            }
            else
            {
                component.SetTemplateToUnlocked(displayedTemplate.Definition);
            }
            AccessibilitySettings component2 = component.GetComponent <AccessibilitySettings>();

            if (component2 != null)
            {
                component2.CustomToken = displayedTemplate.Definition.Name;
            }
        }
        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);
                }
            }
        }