コード例 #1
0
        // Token: 0x0600038F RID: 911 RVA: 0x0000DB78 File Offset: 0x0000BD78
        public static void CollectAchievementDefs(Dictionary <string, AchievementDef> map)
        {
            List <AchievementDef> list = new List <AchievementDef>();

            map.Clear();
            foreach (Type type2 in from type in typeof(BaseAchievement).Assembly.GetTypes()
                     where type.IsSubclassOf(typeof(BaseAchievement))
                     orderby type.Name
                     select type)
            {
                RegisterAchievementAttribute registerAchievementAttribute = (RegisterAchievementAttribute)type2.GetCustomAttributes(false).FirstOrDefault((object v) => v is RegisterAchievementAttribute);
                if (registerAchievementAttribute != null)
                {
                    if (map.ContainsKey(registerAchievementAttribute.identifier))
                    {
                        Debug.LogErrorFormat("Class {0} attempted to register as achievement {1}, but class {2} has already registered as that achievement.", new object[]
                        {
                            type2.FullName,
                            registerAchievementAttribute.identifier,
                            AchievementManager.achievementNamesToDefs[registerAchievementAttribute.identifier].type.FullName
                        });
                    }
                    else
                    {
                        AchievementDef achievementDef = new AchievementDef
                        {
                            identifier = registerAchievementAttribute.identifier,
                            unlockableRewardIdentifier        = registerAchievementAttribute.unlockableRewardIdentifier,
                            prerequisiteAchievementIdentifier = registerAchievementAttribute.prerequisiteAchievementIdentifier,
                            nameToken         = "ACHIEVEMENT_" + registerAchievementAttribute.identifier.ToUpper(CultureInfo.InvariantCulture) + "_NAME",
                            descriptionToken  = "ACHIEVEMENT_" + registerAchievementAttribute.identifier.ToUpper(CultureInfo.InvariantCulture) + "_DESCRIPTION",
                            iconPath          = "Textures/AchievementIcons/tex" + registerAchievementAttribute.identifier + "Icon",
                            type              = type2,
                            serverTrackerType = registerAchievementAttribute.serverTrackerType
                        };
                        AchievementManager.achievementIdentifiers.Add(registerAchievementAttribute.identifier);
                        map.Add(registerAchievementAttribute.identifier, achievementDef);
                        list.Add(achievementDef);
                        UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(achievementDef.unlockableRewardIdentifier);
                        if (unlockableDef != null)
                        {
                            unlockableDef.getHowToUnlockString = (() => Language.GetStringFormatted("UNLOCK_VIA_ACHIEVEMENT_FORMAT", new object[]
                            {
                                Language.GetString(achievementDef.nameToken),
                                Language.GetString(achievementDef.descriptionToken)
                            }));
                            unlockableDef.getUnlockedString = (() => Language.GetStringFormatted("UNLOCKED_FORMAT", new object[]
                            {
                                unlockableDef.getHowToUnlockString()
                            }));
                        }
                    }
                }
            }
            AchievementManager.achievementDefs = list.ToArray();
            AchievementManager.SortAchievements(AchievementManager.achievementDefs);
            AchievementManager.serverAchievementDefs = (from achievementDef in AchievementManager.achievementDefs
                                                        where achievementDef.serverTrackerType != null
                                                        select achievementDef).ToArray <AchievementDef>();
            for (int i = 0; i < AchievementManager.achievementDefs.Length; i++)
            {
                AchievementManager.achievementDefs[i].index = new AchievementIndex
                {
                    intValue = i
                };
            }
            for (int j = 0; j < AchievementManager.serverAchievementDefs.Length; j++)
            {
                AchievementManager.serverAchievementDefs[j].serverIndex = new ServerAchievementIndex
                {
                    intValue = j
                };
            }
            for (int k = 0; k < AchievementManager.achievementIdentifiers.Count; k++)
            {
                string currentAchievementIdentifier = AchievementManager.achievementIdentifiers[k];
                map[currentAchievementIdentifier].childAchievementIdentifiers = (from v in AchievementManager.achievementIdentifiers
                                                                                 where map[v].prerequisiteAchievementIdentifier == currentAchievementIdentifier
                                                                                 select v).ToArray <string>();
            }
            Action action = AchievementManager.onAchievementsRegistered;

            if (action == null)
            {
                return;
            }
            action();
        }