예제 #1
0
        public bool IsUnlocked(StaticGameDataDefinition definition, ProgressionUnlockCategory category)
        {
            bool flag = false;

            for (int i = 0; i <= Level; i++)
            {
                if (unlockDefinitions.Length > i && unlockDefinitions[i].ContainsKey(category) && Array.IndexOf(unlockDefinitions[i][category].Definitions, definition) != -1)
                {
                    flag = true;
                    break;
                }
            }
            if (rewardDefinitions.ContainsKey(category))
            {
                if (!flag && rewardDefinitions[category].Contains(definition))
                {
                    flag = true;
                }
            }
            else
            {
                Log.LogErrorFormatted(this, "Category {0} was not found in Reward Definitions.", category);
            }
            return(flag);
        }
예제 #2
0
        public override Dictionary <string, object> GetExportParameters()
        {
            Dictionary <string, object> exportParameters = base.GetExportParameters();

            exportParameters.Add("templates", StaticGameDataDefinition.ToList <int>(Templates));
            exportParameters.Add("decals", StaticGameDataDefinition.ToList <int>(Decals));
            exportParameters.Add("fabrics", StaticGameDataDefinition.ToList <int>(Fabrics));
            return(exportParameters);
        }
        private void onPooledObjectAdded(RectTransform item, int index)
        {
            if (index >= filteredDefinitions.Count)
            {
                return;
            }
            StaticGameDataDefinition staticGameDataDefinition = filteredDefinitions[index];
            IglooCatalogItem         component            = item.GetComponent <IglooCatalogItem>();
            IglooCatalogItemData     iglooCatalogItemData = null;

            if (staticGameDataDefinition.GetType() == typeof(DecorationDefinition))
            {
                DecorationDefinition decorationDefinition = (DecorationDefinition)staticGameDataDefinition;
                if (!decorationProgressionStatus.TryGetValue(decorationDefinition.Id, out var value))
                {
                    value = new ProgressionUtils.ParsedProgression <DecorationDefinition>(decorationDefinition, -1, null, levelLocked: false, progressionLocked: false, decorationDefinition.IsMemberOnly);
                }
                iglooCatalogItemData = new IglooCatalogItemData(decorationDefinition, value);
                component.SetItem(iglooCatalogItemData, this);
                try
                {
                    Content.LoadAsync(component.SetImageFromTexture2D, decorationDefinition.Icon);
                }
                catch (Exception ex)
                {
                    Log.LogException(this, ex);
                }
            }
            else if (staticGameDataDefinition.GetType() == typeof(StructureDefinition))
            {
                StructureDefinition structureDefinition = (StructureDefinition)staticGameDataDefinition;
                if (!structureProgressionStatus.TryGetValue(structureDefinition.Id, out var value2))
                {
                    value2 = new ProgressionUtils.ParsedProgression <StructureDefinition>(structureDefinition, -1, null, levelLocked: false, progressionLocked: false, structureDefinition.IsMemberOnly);
                }
                iglooCatalogItemData = new IglooCatalogItemData(structureDefinition, value2);
                component.SetItem(iglooCatalogItemData, this);
                try
                {
                    Content.LoadAsync(component.SetImageFromTexture2D, structureDefinition.Icon);
                }
                catch (Exception ex)
                {
                    Log.LogException(this, ex);
                }
            }
            else
            {
                Log.LogErrorFormatted(this, "Definition was not a Decoration or a Structure!");
            }
        }
예제 #4
0
        public int GetUnlockLevelFromDefinition(StaticGameDataDefinition definition, ProgressionUnlockCategory category)
        {
            int result = -1;

            for (int i = 0; i <= MaxUnlockLevel; i++)
            {
                if (unlockDefinitions.Length > i && unlockDefinitions[i].ContainsKey(category) && Array.IndexOf(unlockDefinitions[i][category].Definitions, definition) != -1)
                {
                    result = i;
                    break;
                }
            }
            return(result);
        }
예제 #5
0
        private void addRewardItem(string identifier, object item)
        {
            if (item == null)
            {
                return;
            }
            ProgressionUnlockCategory?progressionUnlockCategory = ProgressionUtils.RewardToProgressionCategory(identifier);

            if (!progressionUnlockCategory.HasValue)
            {
                return;
            }
            ProgressionUnlockCategory value = progressionUnlockCategory.Value;

            if (typeof(IList).IsAssignableFrom(item.GetType()))
            {
                IList list = (IList)item;
                if (list == null)
                {
                    return;
                }
                FieldInfo field = typeof(ProgressionUnlockDefinition).GetField(identifier);
                if (field.FieldType.IsArray)
                {
                    Type      elementType     = field.FieldType.GetElementType();
                    FieldInfo attributedField = StaticGameDataDefinitionIdAttribute.GetAttributedField(elementType);
                    if (attributedField == null)
                    {
                        Log.LogErrorFormatted(this, "The type {0} did not contain a field with the StaticGameDataDefinitionId attribute", elementType.Name);
                        return;
                    }
                    Type        fieldType  = attributedField.FieldType;
                    Type        type       = typeof(Dictionary <, >).MakeGenericType(fieldType, elementType);
                    IDictionary dictionary = (IDictionary)Service.Get <GameData>().Get(type);
                    List <StaticGameDataDefinition> list2 = new List <StaticGameDataDefinition>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        StaticGameDataDefinition staticGameDataDefinition = dictionary[list[i]] as StaticGameDataDefinition;
                        if (staticGameDataDefinition != null)
                        {
                            list2.Add(staticGameDataDefinition);
                        }
                    }
                    if (rewardDefinitions.ContainsKey(value))
                    {
                        rewardDefinitions[value].UnionWith(list2);
                    }
                    else
                    {
                        rewardDefinitions[value] = new HashSet <StaticGameDataDefinition>(list2);
                    }
                }
                else if (rewardItems.ContainsKey(value))
                {
                    rewardItems[value].UnionWith((List <string>)list);
                }
                else
                {
                    rewardItems[value] = new HashSet <string>((List <string>)list);
                }
            }
            else
            {
                if (item.GetType() != typeof(int))
                {
                    return;
                }
                int num = (int)item;
                if (num > 0)
                {
                    if (rewardCounts.ContainsKey(value))
                    {
                        rewardCounts[value] += num;
                    }
                    else
                    {
                        rewardCounts[value] = num;
                    }
                }
            }
        }
        private List <StaticGameDataDefinition> sortDisplayedList(List <StaticGameDataDefinition> listToSort)
        {
            List <StaticGameDataDefinition> list  = new List <StaticGameDataDefinition>();
            List <StaticGameDataDefinition> list2 = new List <StaticGameDataDefinition>();
            SortedDictionary <int, List <StaticGameDataDefinition> >    sortedDictionary  = new SortedDictionary <int, List <StaticGameDataDefinition> >();
            SortedDictionary <string, List <StaticGameDataDefinition> > sortedDictionary2 = new SortedDictionary <string, List <StaticGameDataDefinition> >();

            for (int i = 0; i < listToSort.Count; i++)
            {
                StaticGameDataDefinition staticGameDataDefinition = listToSort[i];
                if (listToSort[i].GetType() == typeof(DecorationDefinition))
                {
                    int id = (staticGameDataDefinition as DecorationDefinition).Id;
                    if (decorationProgressionStatus.TryGetValue(id, out var value))
                    {
                        if (value.MemberLocked && !Service.Get <CPDataEntityCollection>().IsLocalPlayerMember())
                        {
                            list2.Add(staticGameDataDefinition);
                        }
                        else if (value.LevelLocked)
                        {
                            if (!sortedDictionary.ContainsKey(value.Level))
                            {
                                List <StaticGameDataDefinition> value2 = new List <StaticGameDataDefinition>();
                                sortedDictionary.Add(value.Level, value2);
                            }
                            sortedDictionary[value.Level].Add(staticGameDataDefinition);
                        }
                        else if (value.ProgressionLocked)
                        {
                            if (!sortedDictionary2.ContainsKey(value.MascotName))
                            {
                                List <StaticGameDataDefinition> value2 = new List <StaticGameDataDefinition>();
                                sortedDictionary2.Add(value.MascotName, value2);
                            }
                            sortedDictionary2[value.MascotName].Add(staticGameDataDefinition);
                        }
                        else
                        {
                            list.Add(staticGameDataDefinition);
                        }
                    }
                    else if ((staticGameDataDefinition as DecorationDefinition).IsMemberOnly && !Service.Get <CPDataEntityCollection>().IsLocalPlayerMember())
                    {
                        list2.Add(staticGameDataDefinition);
                    }
                    else
                    {
                        list.Add(staticGameDataDefinition);
                    }
                }
                else
                {
                    if (listToSort[i].GetType() != typeof(StructureDefinition))
                    {
                        continue;
                    }
                    int id = (listToSort[i] as StructureDefinition).Id;
                    if (structureProgressionStatus.TryGetValue(id, out var value3))
                    {
                        if (value3.MemberLocked && !Service.Get <CPDataEntityCollection>().IsLocalPlayerMember())
                        {
                            list2.Add(staticGameDataDefinition);
                        }
                        else if (value3.LevelLocked)
                        {
                            if (!sortedDictionary.ContainsKey(value3.Level))
                            {
                                List <StaticGameDataDefinition> value2 = new List <StaticGameDataDefinition>();
                                sortedDictionary.Add(value3.Level, value2);
                            }
                            sortedDictionary[value3.Level].Add(staticGameDataDefinition);
                        }
                        else if (value3.ProgressionLocked)
                        {
                            if (!sortedDictionary2.ContainsKey(value3.MascotName))
                            {
                                List <StaticGameDataDefinition> value2 = new List <StaticGameDataDefinition>();
                                sortedDictionary2.Add(value3.MascotName, value2);
                            }
                            sortedDictionary2[value3.MascotName].Add(staticGameDataDefinition);
                        }
                        else
                        {
                            list.Add(staticGameDataDefinition);
                        }
                    }
                    else if ((listToSort[i] as StructureDefinition).IsMemberOnly && !Service.Get <CPDataEntityCollection>().IsLocalPlayerMember())
                    {
                        list2.Add(staticGameDataDefinition);
                    }
                    else
                    {
                        list.Add(staticGameDataDefinition);
                    }
                }
            }
            List <StaticGameDataDefinition> list3 = new List <StaticGameDataDefinition>();

            foreach (KeyValuePair <int, List <StaticGameDataDefinition> > item in sortedDictionary)
            {
                list3.AddRange(item.Value);
            }
            list.AddRange(list3);
            List <StaticGameDataDefinition> list4 = new List <StaticGameDataDefinition>();

            foreach (KeyValuePair <string, List <StaticGameDataDefinition> > item2 in sortedDictionary2)
            {
                list4.AddRange(item2.Value);
            }
            list.AddRange(list4);
            list.AddRange(list2);
            return(list);
        }