public void LoadCustomFarmByMtnData(string FarmType) { MtnFarmData farmData = new MtnFarmData { FarmTypeName = FarmType }; Canon = FarmManager.Load(farmData); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> public bool Load(MtnFarmData data) { string farmName = data.FarmTypeName; int index = FarmList.FindIndex(n => n.Name == farmName); if (index < 0) { return(true); } LoadedIndex = index; return(false); }
private void NewMtnSave(object sender, SaveCreatingEventArgs e) { MtnFarmData data = Helper.Data.ReadSaveData <MtnFarmData>("MtnFarmData"); if (data == null && !CustomManager.Canon) { CustomFarm farm = CustomManager.SelectedFarm; MtnFarmData customData = new MtnFarmData { FarmTypeName = farm.Name }; Helper.Data.WriteSaveData("MtnFarmData", customData); } }
private void TryToResolveFarmId(object sender, LoadStageChangedEventArgs e) { if (e.NewStage == StardewModdingAPI.Enums.LoadStage.SaveLoadedBasicInfo) { if (Game1.whichFarm >= 5) { MethodInfo keyReader = Helper.Data.GetType().GetMethod("GetSaveFileKey", BindingFlags.NonPublic | BindingFlags.Instance); string key = (string)keyReader.Invoke(Helper.Data, new object[] { "MtnFarmData" }); MtnFarmData farmData = JsonConvert.DeserializeObject <MtnFarmData>(SaveGame.loaded.CustomData[key]); if (farmData != null) { return; } CustomFarm farm = CustomManager.FarmList.Find(x => x.ID == Game1.whichFarm); MtnFarmData customData = new MtnFarmData { FarmTypeName = farm.Name }; Helper.Data.WriteSaveData("MtnFarmData", customData); Game1.whichFarm = 200; CustomManager.LoadCustomFarmByMtnData(); int farmIndex; Map map; string mapAssetKey; Game1.removeLocationFromLocationLookup("Farm"); for (farmIndex = 0; farmIndex < Game1.locations.Count; farmIndex++) { if (Game1.locations[farmIndex].Name == "Farm") { break; } } mapAssetKey = CustomManager.GetAssetKey(out map, "Farm"); Game1.locations[farmIndex] = new Farm(mapAssetKey, "Farm"); Game1.locations[farmIndex].reloadMap(); } } }
public void LoadCustomFarmByMtnData() { MtnFarmData farmData; MethodInfo keyReader = helper.Data.GetType().GetMethod("GetSaveFileKey", BindingFlags.NonPublic | BindingFlags.Instance); string key = (string)keyReader.Invoke(helper.Data, new object[] { "MtnFarmData" }); if (SaveGame.loaded.CustomData.TryGetValue(key, out string value)) { farmData = JsonConvert.DeserializeObject <MtnFarmData>(SaveGame.loaded.CustomData[key]); } else { CustomFarm farm = FarmList.Find(x => x.ID == Game1.whichFarm); farmData = new MtnFarmData { FarmTypeName = farm.Name }; helper.Data.WriteSaveData("MtnFarmData", farmData); } Canon = FarmManager.Load(farmData); }