Ejemplo n.º 1
0
        public static void LoadRecipes()
        {
            foreach (var modAssembly in ModLoader.LoadedMods)
            {
                if (modAssembly.HasAssembly)
                {
                    foreach (Type type in modAssembly.LoadedAssemblyTypes)
                    {
                        if (type.IsDefined(typeof(AutoLoadRecipeAttribute), true))
                        {
                            BaseRecipe newRecipe = Activator.CreateInstance(type) as BaseRecipe;

                            if (newRecipe.key.Equals("NOT_INIZILIZED"))
                            {
                                Log.Write("<color=red>Trying to add a BaseRecipe without defining the key property.</color>");
                                return;
                            }

                            if (!recipes.ContainsKey(newRecipe.key))
                            {
                                recipes.Add(newRecipe.key, newRecipe);
                            }
                            else
                            {
                                Log.Write(string.Format("<color=red>{0} already has a callback registered in ExtendedAPI.</color>", newRecipe.key));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public static bool TryGet(string key, out BaseRecipe recipe)
 {
     return(recipes.TryGetValue(key, out recipe));
 }