示例#1
0
 public static void LoadRecipes()
 {
     buildtoolRecipe = new Recipe(JOB_ITEM_KEY + ".recipe", new List <InventoryItem> ()
     {
         new InventoryItem(BuiltinBlocks.IronIngot, 1),
         new InventoryItem(BuiltinBlocks.Planks, 1)
     }, new InventoryItem(JOB_ITEM_KEY, 1), 0);
     RecipeStorage.AddDefaultLimitTypeRecipe("pipliz.crafter", buildtoolRecipe);
     RecipePlayer.AddDefaultRecipe(buildtoolRecipe);
 }
示例#2
0
        public static void Register()
        {
            var oil   = new InventoryItem(BuiltinBlocks.LinseedOil, 1);
            var linen = new InventoryItem(BuiltinBlocks.Linen, 1);

            var recipe = new Recipe(Item.name,
                                    new List <InventoryItem> {
                linen, oil
            },
                                    new InventoryItem(Item.ItemIndex, 1),
                                    50);

            RecipeStorage.AddDefaultLimitTypeRecipe(ApothecaryRegister.JOB_NAME, recipe);
        }
示例#3
0
        public static void AfterWorldLoad()
        {
            var flax   = new InventoryItem(BuiltinBlocks.Flax, 1);
            var planks = new InventoryItem(BuiltinBlocks.Planks, 1);
            var linen  = new InventoryItem(BuiltinBlocks.Linen, 1);

            var recipe = new Recipe(NAME,
                                    new List <InventoryItem>()
            {
                flax, planks, linen
            },
                                    new InventoryItem(Item.ItemIndex, 1), 2);

            RecipeStorage.AddDefaultLimitTypeRecipe(Register.TALIOR_JOB, recipe);
        }
示例#4
0
        public static void RegisterBerryPie()
        {
            var flour    = new InventoryItem(BuiltinBlocks.Flour, 4);
            var Berries  = new InventoryItem(BuiltinBlocks.Berry, 4);
            var firewood = new InventoryItem("firewood");

            var recipe = new Recipe(Item.name,
                                    new List <InventoryItem> {
                flour, Berries, firewood
            },
                                    new InventoryItem(Item.ItemIndex, 2),
                                    50, false, 100);

            RecipeStorage.AddDefaultLimitTypeRecipe(ItemFactory.JOB_BAKER, recipe);
        }
示例#5
0
        public static void AfterWorldLoad()
        {
            var flax   = new InventoryItem(BuiltinBlocks.Flax, 1);
            var planks = new InventoryItem(BuiltinBlocks.Planks, 1);
            var linen  = new InventoryItem(BuiltinBlocks.Linen, 1);

            var recipe = new Recipe(NAME,
                                    new List <InventoryItem> {
                flax, planks, linen
            },
                                    new InventoryItem(Item.ItemIndex, 1), 2);

            //ItemTypesServer.LoadSortOrder(NAME, GameLoader.GetNextItemSortIndex());
            RecipeStorage.AddDefaultLimitTypeRecipe(Register.DYER_JOB, recipe);
        }
示例#6
0
        public static void Register()
        {
            var herbs   = new InventoryItem(Jobs.HerbalistRegister.HerbItem.ItemIndex, 4);
            var oil     = new InventoryItem(BuiltinBlocks.LinseedOil, 1);
            var Berries = new InventoryItem(BuiltinBlocks.Berry, 4);

            var recipe = new Recipe(Item.name,
                                    new List <InventoryItem>()
            {
                herbs, Berries, oil
            },
                                    new InventoryItem(Item.ItemIndex, 1),
                                    50);

            RecipeStorage.AddDefaultLimitTypeRecipe(Jobs.ApothecaryRegister.JOB_NAME, recipe);
        }
        /// <summary>
        /// Does all the work of adding this recipe to the server's database. Should be called in the AfterItemTypesDefined callback.
        /// </summary>
        public void addRecipeToLimitType()
        {
            if (enabled)
            {
                try
                {
                    // First remove any recipes we are replacing.
                    foreach (string deleteMe in Replaces)
                    {
                        Pipliz.Log.Write("{0}: Recipe {1} is marked as replacing {2}, attempting to comply.", NAMESPACE == null ? "" : NAMESPACE, this.Name, deleteMe);
                        RecipeHelper.tryRemoveRecipe(deleteMe);
                    }

                    // Convert shell references into actual InventoryItem objects.
                    foreach (ItemShell I in Results)
                    {
                        if (Variables.itemsMaster == null)
                        {
                            Pipliz.Log.WriteError("{0}.SimpleRecipe.addRecipeToLimitType() has reached a critical error: 'Variables.itemsMaster' is not yet available. Recipe: {1}", NAMESPACE == null ? "" : NAMESPACE, this.Name);
                        }
                        else
                        {
                            string useKey = I.asSimpleItem == null ? I.strItemkey : I.asSimpleItem.ID;
                            if (Variables.itemsMaster.ContainsKey(useKey))
                            {
                                realResults.Add(new InventoryItem(useKey, I.intAmount));
                            }
                            else
                            {
                                Pipliz.Log.WriteError("{0}: A problem occurred adding recipe RESULT {1} to recipe {2}, the item key was not found.", NAMESPACE == null ? "" : NAMESPACE, I.strItemkey, this.Name);
                            }
                        }
                    }
                    foreach (ItemShell I in Requirements)
                    {
                        if (Variables.itemsMaster == null)
                        {
                            Pipliz.Log.WriteError("{0}.SimpleRecipe.addRecipeToLimitType() has reached a critical error: 'Variables.itemsMaster' is not yet available. Recipe: {1}", NAMESPACE == null ? "" : NAMESPACE, this.Name);
                        }
                        else
                        {
                            string useKey = I.asSimpleItem == null ? I.strItemkey : I.asSimpleItem.ID;
                            if (Variables.itemsMaster.ContainsKey(useKey))
                            {
                                realRequirements.Add(new InventoryItem(useKey, I.intAmount));
                            }
                            else
                            {
                                Pipliz.Log.WriteError("{0}: A problem occurred adding recipe REQUIREMENT {1} to recipe {2}, the item key was not found.", NAMESPACE == null ? "" : NAMESPACE, I.strItemkey, this.Name);
                            }
                        }
                    }

                    // Build actual Recipe object.
                    Recipe thisRecipe = new Recipe(this.fullName, this.realRequirements, this.realResults, this.defaultLimit, this.isOptional, this.defaultPriority);

                    // Commence registering it.
                    Pipliz.Log.Write("{0}: Attempting to register recipe {1}", NAMESPACE == null ? "" : NAMESPACE, thisRecipe.Name);
                    if (this.limitType != null)
                    {
                        if (isOptional)
                        {
                            Pipliz.Log.Write("{0}: Attempting to register optional limit type recipe {1}", NAMESPACE == null ? "" : NAMESPACE, thisRecipe.Name);
                            RecipeStorage.AddOptionalLimitTypeRecipe(limitType, thisRecipe);
                        }
                        else
                        {
                            Pipliz.Log.Write("{0}: Attempting to register default limit type recipe {1}", NAMESPACE == null ? "" : NAMESPACE, thisRecipe.Name);
                            RecipeStorage.AddDefaultLimitTypeRecipe(limitType, thisRecipe);
                        }
                    }

                    if (userCraftable)
                    {
                        Recipe playerRecipe = new Recipe("player." + this.Name, this.realRequirements, this.realResults, this.defaultLimit, this.isOptional);
                        Pipliz.Log.Write("{0}: Attempting to register default player type recipe {1}", NAMESPACE == null ? "" : NAMESPACE, playerRecipe.Name);
                        RecipePlayer.AddDefaultRecipe(playerRecipe);
                    }
                }
                catch (Exception ex)
                {
                    Pipliz.Log.WriteError("{0}: Error adding recipe: {1}", NAMESPACE == null ? "" : NAMESPACE, ex.Message);
                }
            }
            else
            {
                Pipliz.Log.Write("{0}: Recipe {1} has been disabled and will NOT be registered.", NAMESPACE == null ? "" : NAMESPACE, this.Name);
            }
        }