private static string CheckLocavore()
        {
            var goal = 400000;

            var cal  = RationTracker.Get().GetCaloriesConsumed();
            var kcal = cal / 1000f;

            var hasPlantables = false;

            foreach (var plantablePlot in Components.PlantablePlots.Items)
            {
                if (plantablePlot.Occupant != null)
                {
                    foreach (var depositObjectTag in plantablePlot.possibleDepositObjectTags)
                    {
                        if (depositObjectTag != GameTags.DecorSeed)
                        {
                            hasPlantables = true;
                        }
                        break;
                    }
                }
            }

            return(!hasPlantables?FormatProgress(kcal, goal, "kcal")
                       : "<color=#ff0000>failed</color>");
        }
Exemple #2
0
        public void OnEatComplete(object data)
        {
            Edible edible = (Edible)data;

            base.sm.rationsAteToday.Delta(edible.caloriesConsumed, base.smi);
            RationTracker.Get().RegisterRationsConsumed(edible);
        }
        /// <summary>
        /// Retrieves the number of calories consumed of this food type.
        /// </summary>
        /// <returns>The calories consumed of this food type for the current colony.</returns>
        private float GetCaloriesConsumed()
        {
            var byFood = RationTracker.Get()?.caloriesConsumedByFood;

            if (byFood == null || !byFood.TryGetValue(foodTag, out float calories))
            {
                calories = 0.0f;
            }
            return(calories);
        }
Exemple #4
0
 private void RefreshRations()
 {
     if ((Object)RationsText != (Object)null && (Object)RationTracker.Get() != (Object)null)
     {
         long num = (long)RationTracker.Get().CountRations(null, true);
         if (cachedCalories != num)
         {
             RationsText.text = GameUtil.GetFormattedCalories((float)num, GameUtil.TimeSlice.None, true);
             cachedCalories   = num;
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// Applied before Success runs.
        /// </summary>
        internal static bool Prefix(ref bool __result, EatXKCalProducedByY __instance)
        {
            var inst = AchievementPatches.Instance;
            // If this is the not-raw achievement
            bool cont = inst != null || !Db.Get().ColonyAchievements.EatCookedFood.
                        requirementChecklist.Contains(__instance);

            if (!cont)
            {
                __result = RationTracker.Get().GetCaloiresConsumedByFood(inst.targetFoods) *
                           0.001f > __instance.numCalories;
            }
            return(cont);
        }
    private string GetCurrentQuantity()
    {
        if (ElementLoader.GetElement(info.id.ToTag()) != null)
        {
            float amount = WorldInventory.Instance.GetAmount(info.id.ToTag());
            return(string.Format(UI.IMMIGRANTSCREEN.CARE_PACKAGE_CURRENT_AMOUNT, GameUtil.GetFormattedMass(amount, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")));
        }
        if (Game.Instance.ediblesManager.GetFoodInfo(info.id) != null)
        {
            float calories = RationTracker.Get().CountRationsByFoodType(info.id, true);
            return(string.Format(UI.IMMIGRANTSCREEN.CARE_PACKAGE_CURRENT_AMOUNT, GameUtil.GetFormattedCalories(calories, GameUtil.TimeSlice.None, true)));
        }
        float amount2 = WorldInventory.Instance.GetAmount(info.id.ToTag());

        return(string.Format(UI.IMMIGRANTSCREEN.CARE_PACKAGE_CURRENT_AMOUNT, amount2.ToString()));
    }
        public static List <string> CarnivoreFormatter(ColonyAchievementStatus cas)
        {
            List <string> outStrings = new List <string>();

            EatXCaloriesFromY __instance = (EatXCaloriesFromY)cas.Requirements.Find(s => s is EatXCaloriesFromY);


            var           priv      = Traverse.Create(__instance);
            List <string> foodTypes = (List <string>)priv.Field("fromFoodType").GetValue();
            int           numCal    = (int)priv.Field("numCalories").GetValue();

            var num = (double)RationTracker.Get().GetCaloiresConsumedByFood(foodTypes) / 1000.0;

            string output = string.Format("Meats Eaten: {0} / {1}", (double)num, (double)numCal);

            outStrings.Add(output);
            return(outStrings);
        }
        private static string CheckCarnivore()
        {
            var goal  = 400000;
            var foods = new List <string>
            {
                FOOD.FOOD_TYPES.MEAT.Id,
                FOOD.FOOD_TYPES.FISH_MEAT.Id,
                FOOD.FOOD_TYPES.COOKED_MEAT.Id,
                FOOD.FOOD_TYPES.COOKED_FISH.Id,
                FOOD.FOOD_TYPES.SURF_AND_TURF.Id,
                FOOD.FOOD_TYPES.BURGER.Id
            };

            var cal  = RationTracker.Get().GetCaloiresConsumedByFood(foods);
            var kcal = cal / 1000f;

            var before100 = GameClock.Instance.GetCycle() + 1 <= 100;

            return(before100 ? FormatProgress(kcal, goal, "kcal")
                                : "<color=#ff0000>failed</color>");
        }
Exemple #9
0
        public override bool Success()
        {
            List <string>        list    = new List <string>();
            List <ComplexRecipe> recipes = ComplexRecipeManager.Get().recipes;

            foreach (ComplexRecipe item in recipes)
            {
                foreach (Tag foodProducer in foodProducers)
                {
                    foreach (Tag fabricator in item.fabricators)
                    {
                        if (fabricator == foodProducer)
                        {
                            list.Add(item.FirstResult.ToString());
                        }
                    }
                }
            }
            float caloiresConsumedByFood = RationTracker.Get().GetCaloiresConsumedByFood(list.Distinct().ToList());

            return(caloiresConsumedByFood / 1000f > (float)numCalories);
        }
        public static List <string> LocavoreFormatter(ColonyAchievementStatus cas)
        {
            //This will not be possible if the "No Farmtiles" requirement has ever reported failure.
            //That can't be tracked this way, though, so leaving it out of the "quick and dirty" tracking
            //we're doing here.
            List <string> outStrings = new List <string>();

            EatXCalories __instance = (EatXCalories)cas.Requirements.Find(s => s is EatXCalories);


            var priv = Traverse.Create(__instance);

            int toEat = (int)priv.Field("numCalories").GetValue();

            var num = (double)RationTracker.Get().GetCaloriesConsumed() / 1000.0;

            string output = string.Format("Calories Consumed: {0} / {1}", num, toEat);

            outStrings.Add(output);

            return(outStrings);
        }
Exemple #11
0
    private string OnRationsTooltip()
    {
        rationsDict.Clear();
        float calories = RationTracker.Get().CountRations(rationsDict, true);

        RationsText.text = GameUtil.GetFormattedCalories(calories, GameUtil.TimeSlice.None, true);
        RationsTooltip.ClearMultiStringTooltip();
        RationsTooltip.AddMultiStringTooltip(string.Format(UI.TOOLTIPS.METERSCREEN_MEALHISTORY, GameUtil.GetFormattedCalories(calories, GameUtil.TimeSlice.None, true)), ToolTipStyle_Header);
        RationsTooltip.AddMultiStringTooltip(string.Empty, ToolTipStyle_Property);
        IOrderedEnumerable <KeyValuePair <string, float> > source = rationsDict.OrderByDescending(delegate(KeyValuePair <string, float> x)
        {
            EdiblesManager.FoodInfo foodInfo2 = Game.Instance.ediblesManager.GetFoodInfo(x.Key);
            return(x.Value * (foodInfo2?.CaloriesPerUnit ?? (-1f)));
        });
        Dictionary <string, float> dictionary = source.ToDictionary((KeyValuePair <string, float> t) => t.Key, (KeyValuePair <string, float> t) => t.Value);

        foreach (KeyValuePair <string, float> item in dictionary)
        {
            EdiblesManager.FoodInfo foodInfo = Game.Instance.ediblesManager.GetFoodInfo(item.Key);
            RationsTooltip.AddMultiStringTooltip((foodInfo == null) ? string.Format(UI.TOOLTIPS.METERSCREEN_INVALID_FOOD_TYPE, item.Key) : $"{foodInfo.Name}: {GameUtil.GetFormattedCalories(item.Value * foodInfo.CaloriesPerUnit, GameUtil.TimeSlice.None, true)}", ToolTipStyle_Property);
        }
        return(string.Empty);
    }
Exemple #12
0
 public override string GetProgress(bool complete)
 {
     return(string.Format(COLONY_ACHIEVEMENTS.MISC_REQUIREMENTS.STATUS.CALORIE_SURPLUS, GameUtil.GetFormattedCalories((!complete) ? RationTracker.Get().CountRations(null, true) : ((float)surplusAmount), GameUtil.TimeSlice.None, true), GameUtil.GetFormattedCalories((float)surplusAmount, GameUtil.TimeSlice.None, true)));
 }
Exemple #13
0
 public override bool Success()
 {
     return((double)(RationTracker.Get().CountRations(null, true) / 1000f) >= surplusAmount);
 }
Exemple #14
0
 private void OnCraft(object data)
 {
     RationTracker.Get().RegisterCaloriesProduced(Calories);
 }
Exemple #15
0
 public override bool Success()
 {
     return(RationTracker.Get().GetCaloriesConsumed() / 1000f > (float)numCalories);
 }
Exemple #16
0
 public override bool Success()
 {
     return(RationTracker.Get().GetCaloiresConsumedByFood(fromFoodType) / 1000f > (float)numCalories);
 }
Exemple #17
0
 public override string GetProgress(bool complete)
 {
     return(string.Format(COLONY_ACHIEVEMENTS.MISC_REQUIREMENTS.STATUS.CALORIES_FROM_MEAT, GameUtil.GetFormattedCalories((!complete) ? RationTracker.Get().GetCaloiresConsumedByFood(fromFoodType) : ((float)numCalories * 1000f), GameUtil.TimeSlice.None, true), GameUtil.GetFormattedCalories((float)numCalories * 1000f, GameUtil.TimeSlice.None, true)));
 }