Пример #1
0
        private void UpdateBlueprint(ItemBlueprint bp, JSONObject o)
        {
            bp.rarity = GetRarity(o);
            if (!_craftingController)
            {
                bp.time = o.GetFloat("time", 0);
            }
            bp.amountToCreate = o.GetInt("amountToCreate", 1);
            //bp.UnlockPrice = o.GetInt("UnlockPrice", 0);
            //bp.UnlockLevel = o.GetInt("UnlockLevel", 10);
            bp.blueprintStackSize = o.GetInt("blueprintStackSize");
            //bp.userCraftable = o.GetBoolean("userCraftable", true);
            bp.isResearchable = o.GetBoolean("isResearchable", true);
            bp.NeedsSteamItem = o.GetBoolean("NeedsSteamItem", false);
            var ingredients = o.GetArray("ingredients");

            bp.ingredients.Clear();
            foreach (var ingredient in ingredients)
            {
                var itemDef = GetItem(ingredient.Obj, "shortname");
                if (itemDef == null)
                {
                    continue;
                }
                bp.ingredients.Add(new ItemAmount(itemDef, ingredient.Obj.GetFloat("amount", 0)));
            }
        }
Пример #2
0
        private static void UpdateBlueprint(ItemBlueprint bp, JSONObject o)
        {
            bp.rarity           = (Rarity)Enum.Parse(typeof(Rarity), o.GetString("rarity", "None"));
            bp.time             = o.GetInt("time", 0);
            bp.amountToCreate   = o.GetInt("amountToCreate", 1);
            bp.userCraftable    = o.GetBoolean("userCraftable", true);
            bp.defaultBlueprint = o.GetBoolean("defaultBlueprint", false);
            var ingredients = o.GetArray("ingredients");
            var manager     = SingletonComponent <ItemManager> .Instance;

            bp.ingredients.Clear();
            foreach (var ingredient in ingredients)
            {
                var itemid     = ingredient.Obj.GetInt("itemid", 0);
                var definition = manager.itemList.Find(x => x.itemid == itemid);
                bp.ingredients.Add(new ItemAmount(definition, ingredient.Obj.GetFloat("amount", 0)));
            }
        }