static public void OnLoad() { Debug.LogFormat("CookingTweaks: init"); string settings = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CookingTweaks.json")); SaveDataProxy data = FastJson.Deserialize <SaveDataProxy>(settings); WaterSettings waterSettings = new WaterSettings(); FoodSettings foodSettings = new FoodSettings(data.food.ElementAt(0).Key); // m_water = data.water; // m_food = data.food; // // waterSettings.enabled = m_water.enabled; // waterSettings.melting = m_water.melting; // waterSettings.boiling = m_water.boiling; // waterSettings.drying = m_water.drying; // // string firstFood = ((FoodTypes)0).ToString(); // foodSettings.foodType = 0; // if (!m_food.ContainsKey(firstFood)) // { // m_food[((FoodTypes)0).ToString()] = GetEmptyStructure(); // } // // foodSettings.enabled = m_food[firstFood].enabled; // foodSettings.cooking = m_food[firstFood].cooking; // foodSettings.burning = m_food[firstFood].burning; // // waterSettings.AddToModSettings("Cooking Tweaks"); // foodSettings.AddToModSettings("Cooking Tweaks"); }
protected override void OnConfirm() { string food = foodType.ToString(); m_changes[food] = new CookingTime { name = "", enabled = enabled, cooking = cooking, burning = burning, }; m_changes.ToList().ForEach(delegate(KeyValuePair <string, CookingTime> x) { m_food[x.Key] = new CookingTime { name = m_food[x.Key].name, enabled = x.Value.enabled, cooking = x.Value.cooking, burning = x.Value.burning, };; }); SaveDataProxy data = new SaveDataProxy { water = m_water, food = m_food }; string settings = FastJson.Serialize(data); File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CookingTweaks.json"), settings); }
protected override void OnConfirm() { m_water.enabled = enabled; m_water.melting = melting; m_water.boiling = boiling; m_water.drying = drying; SaveDataProxy data = new SaveDataProxy { water = m_water, food = m_food }; string settings = FastJson.Serialize(data); File.WriteAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CookingTweaks.json"), settings); }