Exemplo n.º 1
0
        public ItemDataManager()
        {
            // Load standard items
            foreach (var item in DiscoverItems())
            {
                var key = CreateItemKey(item);
                if (ItemBlacklist.Includes(key))
                {
                    continue;
                }

                if (Prototypes.ContainsKey(key))
                {
                    continue;
                }

                Prototypes.Add(key, item);
            }

            // Create Categories
            Categories = Prototypes.Keys
                         .GroupBy(GetCategoryName)
                         .ToDictionary(
                g => g.Key,
                g => (IList <ItemKey>)g.ToList()
                );
        }
Exemplo n.º 2
0
        public ItemKey GetItemKey(Item item)
        {
            if (item == null)
            {
                throw new Exception();
            }

            var key = CreateItemKey(item);

            if (Prototypes.ContainsKey(key))
            {
                return(key);
            }

            // Add to prototypes
            Prototypes.Add(key, item);

            var category = GetCategoryName(key);

            ModEntry.Log($"Added prototype for '{item.DisplayName}' ({key}) to category '{category}'", LogLevel.Debug);

            // Add to categories, if not blacklisted
            if (ItemBlacklist.Includes(key))
            {
                return(key);
            }

            if (!Categories.ContainsKey(category))
            {
                Categories.Add(category, new List <ItemKey>());
            }

            if (!Categories[category].Contains(key))
            {
                Categories[category].Add(key);
            }


            return(key);
        }