public static void TryRegisterRecipes() { if (ObjectDB.instance == null || ObjectDB.instance.m_items.Count == 0) { return; } var fineWoodToWood = new RecipeConfig() { amount = (int)FineWoodToWoodCount.Value.y, enabled = true, resources = new List <RecipeRequirementConfig> { new RecipeRequirementConfig() { item = "FineWood", amount = (int)FineWoodToWoodCount.Value.x } } }; PrefabCreator.AddNewRecipe("Recipe_FineWoodToWood", "Wood", fineWoodToWood); var coreWoodToWood = new RecipeConfig() { amount = (int)CoreWoodToWoodCount.Value.y, enabled = true, resources = new List <RecipeRequirementConfig> { new RecipeRequirementConfig() { item = "RoundLog", amount = (int)CoreWoodToWoodCount.Value.x } } }; PrefabCreator.AddNewRecipe("Recipe_CoreWoodToWood", "Wood", coreWoodToWood); var ancientBarkToWood = new RecipeConfig() { amount = (int)AncientBarkToWoodCount.Value.y, enabled = true, resources = new List <RecipeRequirementConfig> { new RecipeRequirementConfig() { item = "ElderBark", amount = (int)AncientBarkToWoodCount.Value.x } } }; PrefabCreator.AddNewRecipe("Recipe_AncientBarkWoodToWood", "Wood", ancientBarkToWood); }
private void registerObjects(object sender, EventArgs e) { string[] itemsArray = { "RepairKitBronze", "RepairKitIron", "RepairKitSilver", "RepairKitBlackMetal", "RepairKitAdvanced" }; foreach (string item in itemsArray) { ObjectManager.Instance.RegisterItem(item); } string recipesFileName = "recipes.json"; if (customJsonRecipes.Value == true && File.Exists(Path.Combine(Paths.PluginPath, "Whetstone", "custom_recipes.json"))) { recipesFileName = "custom_recipes.json"; } string jsonString = File.ReadAllText(Path.Combine(Paths.PluginPath, "Whetstone", recipesFileName)); RecipeList recipeList = LitJson.JsonMapper.ToObject <RecipeList>(jsonString); if (recipeList != null) { foreach (var recipe in recipeList.recipes) { RecipeConfig recipeConfig = new RecipeConfig { Name = recipe.name, Item = recipe.item, Amount = recipe.amount, CraftingStation = recipe.craftingStation, MinStationLevel = recipe.minStationLevel }; List <PieceRequirementConfig> list = new List <PieceRequirementConfig>(); foreach (var recipeReq in recipe.requirements) { list.Add( new PieceRequirementConfig() { Item = recipeReq.item, Amount = recipeReq.amount }); } recipeConfig.Requirements = list.ToArray(); if (itemsArray.Contains(recipeConfig.Item)) { ObjectManager.Instance.RegisterRecipe(recipeConfig); } } } }
public void Regenerate() { Config = new RecipeConfig() { EntityType = _entityType, EntityProperty = Component, Output = new TypeIntTuple() { EntityType = _entityType, Amount = Random.Range(1, 10), } }; }
/// <summary> /// Registers a new recipe /// </summary> /// <param name="recipeConfig">Recipe details</param> public void RegisterRecipe(RecipeConfig recipeConfig) { Recipe recipe = recipeConfig.GetRecipe(); if (recipe == null) { Debug.LogError("Failed to add recipe for item: " + recipeConfig.Item); return; } Recipes.Add(recipe); }
/// <summary> /// Adds recipes defined in a JSON file at given path, relative to BepInEx/plugins /// </summary> /// <param name="path">JSON file path, relative to BepInEx/plugins folder</param> public void AddRecipesFromJson(string path) { string json = AssetUtils.LoadText(path); if (string.IsNullOrEmpty(json)) { Logger.LogError($"Failed to load recipes from invalid JSON: {path}"); return; } List <RecipeConfig> recipes = RecipeConfig.ListFromJson(json); foreach (RecipeConfig recipe in recipes) { AddRecipe(new CustomRecipe(recipe)); } }
private string CreateProjectJson(List <IPolygon> polygons) { // get the geojson of the aois var aoi = Jarvis.ConvertPolygonsToGeoJson(polygons); var newProject = new Project(); newProject.aois.Add(aoi); newProject.originalGeometries.Add(aoi); newProject.namedBuffers.Add(new NamedBuffer { name = "original AOI", buffer = aoi }); newProject.name = this.projectNameTextbox.Text; if (this.availableRecipesCombobox.SelectedIndex != -1) { var recName = this.availableRecipesCombobox.Items[this.availableRecipesCombobox.SelectedIndex].ToString(); var recipe = this.GetRecipe(recName); if (recipe != null) { var recipeConfig = new RecipeConfig { recipeId = recipe.id, recipeName = recipe.name }; newProject.recipeConfigs.Add(recipeConfig); } } var projectJson = JsonConvert.SerializeObject(newProject).Replace("\\", ""); projectJson = projectJson.Replace("\"aois\":[\"{\"", "\"aois\":[{\""); projectJson = projectJson.Replace("\"],\"recipeConfigs\"", "],\"recipeConfigs\""); projectJson = projectJson.Replace("\"originalGeometries\":[\"", "\"originalGeometries\":["); projectJson = projectJson.Replace("\"],\"namedBuffers\"", "],\"namedBuffers\""); projectJson = projectJson.Replace("\"buffer\":\"{", "\"buffer\":{"); projectJson = projectJson.Replace("]]}\"}]}", "]]}}]}"); return(projectJson); }
public void Init() { Config = new GameConfig(); rawAtoms = new AtomConfig(); rawAtoms.Load(); Atoms = rawAtoms.atoms; AtomsBySymbol = rawAtoms.AtomsBySymbol; rawUser = new UserConfig(); rawUser.Load(); User = rawUser.userModel; rawRecipes = new RecipeConfig(); rawRecipes.Load(AtomsBySymbol); Recipes = rawRecipes.Data; AMM = new AtomsModelManager(); AMM.Setup(this); Messenger.Dispatch(GameMessage.MODEL_LOADED); }
/// <summary> /// Custom recipe from a <see cref="RecipeConfig"/>.<br /> /// The <see cref="global::Recipe"/> is created automatically by Jötunn at runtime. /// </summary> /// <param name="recipeConfig">The <see cref="RecipeConfig"/> for a custom recipe.</param> public CustomRecipe(RecipeConfig recipeConfig) { Recipe = recipeConfig.GetRecipe(); FixReference = true; FixRequirementReferences = true; }
public FeatureConfig(string name, string baseDirectory, RecipeConfig recipe) { mName = name; mBaseDirectory = baseDirectory; mRecipe = recipe; }