Example #1
0
        public static bool Prefix(Crop __instance, ref List <Descriptor> __result)
        {
            Dictionary <string, int> setting;

            if (CustomizePlantsState.StateManager.State.SpecialCropSettings == null ||
                CustomizePlantsState.StateManager.State.SpecialCropSettings.TryGetValue(__instance.cropId, out setting) == false)
            {
                return(true);
            }

            __result = new List <Descriptor>();

            foreach (KeyValuePair <string, int> entry in setting)
            {
                Tag        tag       = new Tag(entry.Key);
                GameObject prefab    = Assets.GetPrefab(tag);
                Edible     edible    = prefab.GetComponent <Edible>();
                float      calories1 = 0.0f;
                string     str1      = string.Empty;
                if (edible != null)
                {
                    calories1 = edible.FoodInfo.CaloriesPerUnit;
                }
                float           calories2       = calories1 * entry.Value;
                InfoDescription infoDescription = prefab.GetComponent <InfoDescription>();
                if (infoDescription != null)
                {
                    str1 = infoDescription.description;
                }
                string str2 = !GameTags.DisplayAsCalories.Contains(tag) ? (!GameTags.DisplayAsUnits.Contains(tag) ? GameUtil.GetFormattedMass(entry.Value, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}") : GameUtil.GetFormattedUnits(entry.Value, GameUtil.TimeSlice.None, false)) : GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true);

                __result.Add(new Descriptor(string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.YIELD, prefab.GetProperName(), str2), string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.YIELD, str1, GameUtil.GetFormattedCalories(calories1, GameUtil.TimeSlice.None, true), GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true)), Descriptor.DescriptorType.Effect, false));
            }

            if ((__instance.GetComponent <SeedProducer>()?.seedInfo.productionType ?? SeedProducer.ProductionType.DigOnly) == SeedProducer.ProductionType.Harvest)
            {
                __result.Add(new Descriptor(string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.BONUS_SEEDS, GameUtil.GetFormattedPercent(10f, GameUtil.TimeSlice.None)), string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.BONUS_SEEDS, GameUtil.GetFormattedPercent(10f, GameUtil.TimeSlice.None)), Descriptor.DescriptorType.Effect, false));
            }

            return(false);
        }