Exemplo n.º 1
0
        /// <summary>
        /// Crafts an item from the added ingredients
        /// </summary>
        /// <returns>true if item was succesfully created</returns>
        public bool CraftItem()
        {
            if (items.Count < 2)
            {
                UISystem.Message("You need to put in at least two items!");
                ResetCrafting();
                return(false);
            }

            ExtractSubstances();

            // TODO: other crafting than alchemy
            int newItem = Alchemy();

            if (newItem == 0)
            {
                // something went wrong before and
                // should have already been handled
                ResetCrafting();
                return(false);
            }

            UISystem.Message("You just crafted something!");

            substances.Clear();

            foreach (var itemID in items)
            {
                ItemSystem.TryDeleteItem(itemID);
            }

            items.Clear();

            //var description = EntityManager.GetComponent<DescriptionComponent>(newItem);
            //description.Name = "Crafted " + description.Name;
            ItemAddedEvent?.Invoke(Util.PlayerID, newItem);

            string info = DescriptionSystem.GetDebugInfoEntity(newItem);

            Log.Message("Crafting successful:");
            Log.Data(info);

            Util.TurnOver(Util.PlayerID);
            return(true);
        }
Exemplo n.º 2
0
        public void AddIngredient(int item)
        {
            if (items.Count >= maxSlots)
            {
                UISystem.Message("You can't use that many ingredients at once! (max. " + maxSlots + ")");
                return;
            }

            var substance = EntityManager.GetComponent <SubstanceComponent>(item);

            if (substance == null)
            {
                UISystem.Message("This item can not be used for crafting!");
                return;
            }

            // remember item and remove it from player inventory
            items.Add(item);
            ItemSystem.DecreaseItemCount(Util.PlayerID, item);
        }