public void AddRecipeAsConfigRecord(RecipeHelper rh) { ConfigRecipeData newData = new ConfigRecipeData(); var existingRecord = recipeConfigs.Where(rc => rc.ItemPrefab == rh.GetPrefabName()).FirstOrDefault(); if (existingRecord != null) { newData.Enabled = existingRecord.Enabled; } newData.ReadConfigFromRecipeHelper(rh); recipeConfigs.RemoveAll(rc => rc.ItemPrefab == rh.GetPrefabName()); recipeConfigs.Add(newData); }
public void ReadConfigFromRecipeHelper(RecipeHelper rh) { ItemPrefab = rh.GetPrefabName(); CraftingStation = rh.GetCraftingStation(); //Recipe rec = rh.GetRecipeInstance(); MinimumStationLevel = rh.GetRecipeInstance().m_minStationLevel; ResourceElement[] resources = rh.GetResourceElements(); List <ConfigResource> lcr = new List <ConfigResource>(); foreach (var re in resources) { ConfigResource tempCR = new ConfigResource(); tempCR.ItemPrefab = re.prefabItemName; tempCR.CraftingCost = re.amount; tempCR.UpgradePerLevelCost = re.amountPerLevel; lcr.Add(tempCR); } CraftingRequirementsArray = lcr.ToArray(); }