private void CreateGreenhouseTemplate(IModHelper helper) { CustomGreenHouse template = new CustomGreenHouse(); template.Name = "Example"; template.Folder = "Example"; template.Version = 2.0f; template.GreenhouseMap = new MapFile("GreenHouse_Example"); template.Enterance = new Structure(new Placement(), new Interaction(10, 23)) { Coordinates = null }; helper.Data.WriteJsonFile("greenHouseType.json", template); }
private bool ProcessGreenHouseType(IContentPack contentPack, out CustomGreenHouse greenHouse) { Dictionary <string, object> Extra; if (contentPack.Manifest.ExtraFields != null && contentPack.Manifest.ExtraFields.ContainsKey("ContentPackType")) { Extra = (Dictionary <string, object>)ObjectToDictionaryHelper.ToDictionary(contentPack.Manifest.ExtraFields["ContentPackType"]); if (Extra.ContainsKey("Greenhouse") && bool.Parse(Extra["Greenhouse"].ToString())) { greenHouse = contentPack.ReadJsonFile <CustomGreenHouse>("greenHouseType.json"); return(true); } } greenHouse = null; return(false); }
/// <summary> /// Populates the List<CustomFarm> FarmList variable with all the Content Packs /// registered to MTN. /// </summary> /// <param name="Helper">SMAPI's IModHelper, to load in the Content Packs</param> /// <param name="Monitor">SMAPI's IMonitor, to print useful information</param> public void Populate(IModHelper Helper, IMonitor Monitor) { CustomFarm FarmData; CustomGreenHouse GreenHouseData; bool ContainsFarm = false; bool ContainsGreenHouse = false; FarmList = new List <CustomFarm>(); foreach (IContentPack ContentPack in Helper.ContentPacks.GetOwned()) { FarmData = new CustomFarm(); GreenHouseData = new CustomGreenHouse(); Monitor.Log($"Reading content pack: {ContentPack.Manifest.Name} {ContentPack.Manifest.Version}."); ContainsFarm = ProcessFarmType(ContentPack, out FarmData); ContainsGreenHouse = ProcessGreenHouseType(ContentPack, out GreenHouseData); if (FarmData.Version < 2.1) { FarmData = PopulateOld(ContentPack, Monitor, FarmData.Version); } if (ContainsFarm) { Monitor.Log($"\t + Contains a custom farm.", LogLevel.Trace); LoadIcon(Helper, ContentPack, FarmData); Validate(FarmData); } if (FarmData != null) { FarmData.ContentPack = ContentPack; FarmList.Add(FarmData); } if (GreenHouseData != null) { GreenHouseData.ContentPack = ContentPack; GreenHouseList.Add(GreenHouseData); } } return; }