Пример #1
0
        private bool TryMakeRecipe(Recipe recipe, TransferAssemblerTileEntity entity)
        {
            bool alchemy;

            if (!SearchStation(recipe, entity.Position.X, entity.Position.Y, out alchemy))
            {
                entity.Status = TransferAssemblerTileEntity.StatusKind.MissingStation;
                return(false);
            }

            for (int i = 0; i < Recipe.maxRequirements && !recipe.requiredItem[i].IsAir; i++)
            {
                if (!inventory.TryTakeIngredient(recipe, recipe.requiredItem[i]))
                {
                    entity.Status          = TransferAssemblerTileEntity.StatusKind.MissingItem;
                    entity.MissingItemType = recipe.requiredItem[i].type;
                    return(false);
                }
            }

            Item clone = recipe.createItem.Clone();

            if (!clone.IsAir)
            {
                //these can potentially cause issues in some cases, might have to remove them
                RecipeHooks.OnCraft(clone, recipe);
                ItemLoader.OnCraft(clone, recipe);
            }

            entity.stock  = clone;
            entity.Status = TransferAssemblerTileEntity.StatusKind.Success;
            inventory.Commit(alchemy);

            return(true);
        }