Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentPack"></param>
        /// <param name="monitor"></param>
        public void Populate(IContentPack contentPack, IMonitor monitor)
        {
            CustomGreenHouse GreenHouseData = new CustomGreenHouse();

            if (ProcessContentPack(contentPack, out GreenHouseData))
            {
                monitor.Log($"\t + Contains a custom greenhouse.", LogLevel.Trace);
                //Version control?
                //Validate?
                GreenHouseData.ContentPack = contentPack;
                GreenHouseList.Add(GreenHouseData);
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentPack"></param>
        /// <param name="greenHouse"></param>
        /// <returns></returns>
        private bool ProcessContentPack(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);
        }