Esempio n. 1
0
 public static void RebuildRecipes()
 {
     if (IsObjectDBValid())
     {
         foreach (var recipeToApply in cc.recipeConfigs)
         {
             if (recipeToApply.Enabled)
             {
                 GameObject go = myItemList.Where(mil => mil.name == recipeToApply.ItemPrefab).FirstOrDefault();
                 if (go == null)
                 {
                     continue;
                 }
                 RecipeHelper rh = recipeToApply.LoadConfigedRecipeHelper(go);
                 rh.FixResources();
                 Recipe updatedRecipe = rh.GetRecipe();
                 if (updatedRecipe != null)
                 {
                     AddRecipeToObjectDB(updatedRecipe);
                     continue;
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public RecipeHelper ApplyRecipeHelperFromConfigRecord(GameObject go)
 {
     if (recipeConfigsToApply.Count > 0 && recipeConfigsToApply.ContainsKey(go.name))
     {
         RecipeHelper outputRH = recipeConfigsToApply[go.name].LoadConfigedRecipeHelper(go);
         recipeConfigsToApply.Remove(go.name);
         return(outputRH);
     }
     return(null);
 }
Esempio n. 3
0
            public RecipeHelper LoadConfigedRecipeHelper(GameObject itemToCraft)
            {
                RecipeHelper outputRH = new RecipeHelper(itemToCraft, CraftingStation, MinimumStationLevel, 1);

                outputRH.recipeEnabled = Enabled;
                foreach (ConfigResource cr in CraftingRequirementsArray)
                {
                    outputRH.AddResource(cr.ItemPrefab, cr.CraftingCost, cr.UpgradePerLevelCost);
                }
                return(outputRH);
            }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
            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();
            }