Exemple #1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Unicode;
            try
            {
                var dish = new Dish("Бутерброд с сыром", DishType.Dessert);

                var cheese = new Ingredient();
                cheese.Name = "Сыр";
                cheese.Quantity = 50;
                cheese.Unit = "гр";
                dish.AddIngredient(cheese);

                var bread = new Ingredient();
                bread.Name = "Хлеб";
                bread.Quantity = 50;
                bread.Unit = "гр";
                dish.AddIngredient(bread);

                var calories = new Calories("system_data.txt");
                var caloriesValue = calories.GetCaloriesFor(dish);

                Console.WriteLine("{0}: {1}", dish.Name, caloriesValue);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ОШИБКО!!! {0}", ex.ToString());
            }
        }
Exemple #2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Calories != null)
         {
             hashCode = hashCode * 59 + Calories.GetHashCode();
         }
         if (DailyValues != null)
         {
             hashCode = hashCode * 59 + DailyValues.GetHashCode();
         }
         if (Fat != null)
         {
             hashCode = hashCode * 59 + Fat.GetHashCode();
         }
         if (Carbs != null)
         {
             hashCode = hashCode * 59 + Carbs.GetHashCode();
         }
         if (Vitamins != null)
         {
             hashCode = hashCode * 59 + Vitamins.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemple #3
0
        public calorieViewModel()
        {
            CaloriesPerDay = new List <Calories>();
            List <Calories> DataCalories = App.Database.GetCalories(App.UserID);

            Calories SumCalories = new Calories();
            DateTime Preday      = new DateTime();

            foreach (Calories Calorie in DataCalories)
            {
                DateTime day = new DateTime(Calorie.time.Year, Calorie.time.Month, Calorie.time.Day);
                if (Preday == day)
                {
                    // sum all calorie in a day
                    SumCalories.Calorie += Calorie.Calorie;
                }
                else
                {
                    // add pre day calorie to CaloriesPerDay list
                    if (SumCalories.Calorie > 0) // at firt loop day calorie equal to 0
                    {
                        CaloriesPerDay.Add(SumCalories);
                    }
                    // create new object
                    SumCalories         = new Calories();
                    SumCalories.UserID  = Calorie.UserID;
                    SumCalories.Calorie = Calorie.Calorie;
                    SumCalories.time    = day;

                    Preday = day;
                }
            }
            CaloriesPerDay.Add(SumCalories); // add last loop calorie sumation
        }
 public Item(String name, int id, Calories cals, Nutrients nut)
 {
     this.name      = name;
     this.itemID    = id;
     this.calories  = cals;
     this.nutrients = nut;
 }
 public void DisplayCalories()
 {
     Console.WriteLine(GetType().Name + ": " + Calories.ToString() + " calories.");
     foreach (SoftDrink drink in Flavors)
     {
         drink.DisplayCalories();
     }
 }
    private Item CreateItemFromInfo(String[] info)
    {
        Calories  cals = new Calories(Convert.ToDouble(info[2]), Calories.GetUnitsFromString(info[3]));
        Nutrients nuts = new Nutrients(Convert.ToDouble(info[4]), Convert.ToDouble(info[5]), Convert.ToDouble(info[6]), Convert.ToDouble(info[7]));
        Item      item = new Item(info[1], idGen.GetNewID(), cals, nuts);

        return(item);
    }
Exemple #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Calories.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Allergens;
         hashCode = (hashCode * 397) ^ (int)Requirements;
         hashCode = (hashCode * 397) ^ (MacroNutrientQuantity != null ? MacroNutrientQuantity.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemple #8
0
        /// <summary>
        /// Преобразовать данные в строку
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string text = ProductName + " " + Quantity.ToString("f2") + "шт " + Calories.ToString("f2") + "Дж " + Price.ToString("f2") + "р,\r\n";

            text += "Состав: ";
            foreach (var item in CompositionList)
            {
                text += item.Name + " " + item.Value.ToString("f2") + "кг " + item.Calorie.ToString("f2") + "Дж " + item.Price.ToString("f2") + "р,\r\n";
            }
            return(text);
        }
Exemple #9
0
        private void LoadWeekCalories()
        {
            var calories = MainWindow.UserNutritionRepository.GetSumsOfCalories(MainWindow.UserId, 7);

            foreach (var i in calories)
            {
                Calories.Add(new GraphicPoint()
                {
                    Date = i.Key.ToShortDateString(), Number = i.Value
                });
            }
        }
Exemple #10
0
 public string AddCalorie(Calories Cal)
 {
     try
     {
         _database.Insert(Cal);
         return("Sucessfully Added");
     }
     catch (Exception e)
     {
         return($"Error :{e.Message}");
     }
 }
Exemple #11
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (Photos != null)
         {
             hashCode = hashCode * 59 + Photos.GetHashCode();
         }
         if (Gear != null)
         {
             hashCode = hashCode * 59 + Gear.GetHashCode();
         }
         if (Calories != null)
         {
             hashCode = hashCode * 59 + Calories.GetHashCode();
         }
         if (SegmentEfforts != null)
         {
             hashCode = hashCode * 59 + SegmentEfforts.GetHashCode();
         }
         if (DeviceName != null)
         {
             hashCode = hashCode * 59 + DeviceName.GetHashCode();
         }
         if (EmbedToken != null)
         {
             hashCode = hashCode * 59 + EmbedToken.GetHashCode();
         }
         if (SplitsMetric != null)
         {
             hashCode = hashCode * 59 + SplitsMetric.GetHashCode();
         }
         if (SplitsStandard != null)
         {
             hashCode = hashCode * 59 + SplitsStandard.GetHashCode();
         }
         if (Laps != null)
         {
             hashCode = hashCode * 59 + Laps.GetHashCode();
         }
         if (BestEfforts != null)
         {
             hashCode = hashCode * 59 + BestEfforts.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemple #12
0
        private async void AddNewCalorie_Clicked(object sender, EventArgs e)
        {
            // Create Calorie model for add to Database
            Calories calorie = new Calories();

            calorie.UserID = App.UserID;
            calorie.time   = DateTime.UtcNow;
            string Cal = await DisplayPromptAsync("Add Calorie", "How much Calorie eat in your courent meal?", "Add", "Cancel", "Kilo Calorie", 4, Keyboard.Numeric);

            calorie.Calorie = Convert.ToInt32(Cal);
            // Add to database
            App.Database.AddCalorie(calorie);
            // Show result of new sumerize
            DayVisulize();
        }
        public async void db()
        {
            calenDatabase = new CalendarTableDatabaseAzure();
            var details = await calenDatabase.GetCalendar();

            foreach (var row in details)
            {
                Calories.Add(new GraphModel {
                    Amount = row.Calorie, Date = row.Date.Date
                });
                Weights.Add(new GraphModel {
                    Amount = row.Weight, Date = row.Date.Date
                });
            }
        }
Exemple #14
0
        public void Validate()
        {
            FoodItem.ValidateRequired("FoodItem");

            ServingSize.ValidateOptional("ServingSize");
            ServingsConsumed.ValidateOptional("ServingsConsumed");
            Meal.ValidateOptional("Meal");
            When.ValidateOptional("When");

            Calories.ValidateOptional("Calories");
            CaloriesFromFat.ValidateOptional("CaloriesFromFat");
            TotalFat.ValidateOptional("TotalFat");
            SaturatedFat.ValidateOptional("SaturatedFat");
            MonounsaturatedFat.ValidateOptional("MonounsaturatedFat");
        }
Exemple #15
0
            public override int GetHashCode()
            {
                var hashCode = -1245731201;

                hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(To);

                hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(From);

                hashCode = hashCode * -1521134295 + StartTime.GetHashCode();
                hashCode = hashCode * -1521134295 + EndTime.GetHashCode();
                hashCode = hashCode * -1521134295 + TimeSpent.GetHashCode();
                hashCode = hashCode * -1521134295 + Calories.GetHashCode();
                hashCode = hashCode * -1521134295 + Cost.GetHashCode();
                return(hashCode);
            }
        public void UpdateCaloriesWithDriveBicycle(string login, double timeWalking)
        {
            var person = tracker.FirstOrDefault(c => c.Login == login);

            if (person == null)
            {
                Console.WriteLine($"{login} not found");
            }
            else
            {
                Actions  actions  = new Actions();
                var      walking  = actions.Drivebicycle(timeWalking);
                Calories calories = new Calories(walking);
                person.CaloriesPerDay.Add(calories);
            }
        }
Exemple #17
0
 public CaloriesController(User user, bool isNewUser)
 {
     User = user ?? throw new ArgumentNullException("Данные не могут быть пустыми или null", nameof(user));
     if (isNewUser)
     {
         Calories = new Calories(User);
     }
     else
     {
         Calories = GetCalories();
         if (Calories.NeedCalories > 1000)
         {
             isCalories = false;
         }
     }
 }
Exemple #18
0
 /// <summary>
 /// Расчет необходимых каллорий
 /// </summary>
 /// <param name="name">Цель.</param>
 public void ConsiderCalories(string name)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentNullException("Данные не могут быть пустыми или null", nameof(name));
     }
     if (name == "Mass gain")
     {
         var calories = MassGain();
         Calories.Add(name, calories);
     }
     else if (name == "Losing weight")
     {
         var calories1 = LosingWeight();
         Calories.Add(name, calories1);
     }
     Save();
 }
Exemple #19
0
        /// <summary>
        /// Returns true if RecipeObjectNutrients instances are equal
        /// </summary>
        /// <param name="other">Instance of RecipeObjectNutrients to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(RecipeObjectNutrients other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Calories == other.Calories ||
                     Calories != null &&
                     Calories.SequenceEqual(other.Calories)
                     ) &&
                 (
                     DailyValues == other.DailyValues ||
                     DailyValues != null &&
                     DailyValues.SequenceEqual(other.DailyValues)
                 ) &&
                 (
                     Fat == other.Fat ||
                     Fat != null &&
                     Fat.SequenceEqual(other.Fat)
                 ) &&
                 (
                     Carbs == other.Carbs ||
                     Carbs != null &&
                     Carbs.SequenceEqual(other.Carbs)
                 ) &&
                 (
                     Vitamins == other.Vitamins ||
                     Vitamins != null &&
                     Vitamins.SequenceEqual(other.Vitamins)
                 ));
        }
Exemple #20
0
        bool FinishCanExecute()
        {
            if (String.IsNullOrEmpty(Name))
            {
                return(false);
            }

            if (BulkQuantity == 0)
            {
                return(false);
            }

            if (StartingAmountIsChecked)
            {
                if (StartingAmount.GetValueOrDefault() == 0)
                {
                    return(false);
                }
            }

            if (NutritionIsChecked)
            {
                if (Calories.GetValueOrDefault() == 0)
                {
                    return(false);
                }

                if (ComplexNutritionIsChecked)
                {
                    if ((Protein.GetValueOrDefault() == 0) || (Fat.GetValueOrDefault() == 0) || (Carbohydrates.GetValueOrDefault() == 0))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        void FakeSomeData()
        {
            Calories.Clear();
            Weights.Clear();

            Calories.Add(new GraphModel {
                Amount = 0, Date = new DateTime(2016, 10, 28)
            });
            Calories.Add(new GraphModel {
                Amount = 10, Date = new DateTime(2016, 10, 29)
            });
            Calories.Add(new GraphModel {
                Amount = 20, Date = new DateTime(2016, 10, 30)
            });
            Calories.Add(new GraphModel {
                Amount = 30, Date = new DateTime(2016, 11, 1)
            });

            Weights.Add(new GraphModel {
                Amount = 0, Date = new DateTime(2016, 10, 28)
            });
            Weights.Add(new GraphModel {
                Amount = 10, Date = new DateTime(2016, 10, 29)
            });
            Weights.Add(new GraphModel {
                Amount = 20, Date = new DateTime(2016, 10, 30)
            });
            Weights.Add(new GraphModel {
                Amount = 30, Date = new DateTime(2016, 11, 1)
            });
            Weights.Add(new GraphModel {
                Amount = 10, Date = new DateTime(2016, 11, 2)
            });
            Weights.Add(new GraphModel {
                Amount = 20, Date = new DateTime(2016, 11, 3)
            });
        }
Exemple #22
0
        static void Main(string[] args)
        {
            Calories cl = new Calories(2, 3, 4);
            Calories c2 = 2 * cl;

            var potato  = new  Potato(100);
            var cucmber = new Cucumber(100);
            var carrot  = new Carrot(200);

            var cust = new CustomVegetable("1", 2, new Calories());

            Console.WriteLine(cust);
            cust.Weight   = 3;
            cust.Calories = new Calories();
            cust.Name     = "13";
            Console.WriteLine(cust);

            Console.WriteLine(potato.Name + " " + potato.Calories + " " + potato.Weight);
            Console.WriteLine(cucmber.Name + " " + cucmber.Calories + " " + cucmber.Weight);
            Console.WriteLine(carrot.Name + " " + carrot.Calories + " " + carrot.Weight);
            List <IVegetable> lst = new List <IVegetable>();

            lst.Add(cucmber);


            Salad salad = new Salad(new CloneList <IVegetable>());

            salad.Add(potato);
            salad.Add(carrot);
            salad.Add(cucmber);
            Console.WriteLine("total calories = " + salad.TotalCalories);
            Console.WriteLine();
            Console.WriteLine();
            salad.PrintVegetables();
            var tt = salad.GetVegetables(0, 1000);

            Console.WriteLine();
            Console.WriteLine();
            salad.PrintVegetables();

            salad.Sort(VegetableComparasions.CompareByName);
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("BEFORE SRT");
            salad.PrintVegetables();

            salad.Sort(vegetable => vegetable.Calories, new CompareByCalories());

            Func <int, int> d = delegate(int i) { return(i * 3); };

            Console.WriteLine("AFTER SRT");
            salad.PrintVegetables();
            salad.Sort(VegetableComparasions.CompareByWeight);
            Console.WriteLine("BEFORE REMOVE");
            salad.PrintVegetables();
            salad.Remove(potato);

            Console.WriteLine("AFTER REMOVE");
            salad.PrintVegetables();

            Console.WriteLine("TESTTTT");
            CloneList <IVegetable> list = new CloneList <IVegetable>();

            List <int> li = new List <int>();

            list.Add(potato);
            list.Add(cucmber);
            list.Add(carrot);
            foreach (var v in list)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            Console.WriteLine("CLONE");

            ICloneCollection <IVegetable> list2 = list.CloneObjects();

            foreach (var v in list2)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            list[0].Weight = 0;
            list[1].Weight = 0;
            list[2].Weight = 0;

            Console.WriteLine("TESTTTT");

            foreach (var v in list)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            Console.WriteLine("CLONE");


            foreach (var v in list2)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
        }
Exemple #23
0
 public override string ToString()
 {
     return($"{Name} made by {Manufacturer} has a serving size of {Cups.ToString("N1")} cups and has {Calories.ToString("N2")} calories.");
 }
Exemple #24
0
        public override string ToString()
        {
            string str = "";

            str += "&idserver=\"" + IDServer.ToString() + "\"";
            if (IDUnit != -1)
            {
                str += "&idunit=\"" + IDUnit.ToString() + "\"";
            }
            if (IDServerMeal != -1)
            {
                str += "&idmeal=\"" + IDServerMeal.ToString() + "\"";
            }
            if (IDUser != 0)
            {
                str += "&iduser=\"" + IDUser.ToString() + "\"";
            }
            if (Calories != -1)
            {
                str += "&calories=\"" + Calories.ToString() + "\"";
            }
            if (Protein != -1)
            {
                str += "&protein=\"" + Protein.ToString() + "\"";
            }
            if (Carb != -1)
            {
                str += "&carb=\"" + Carb.ToString() + "\"";
            }
            if (Fat != -1)
            {
                str += "&fat=\"" + Fat.ToString() + "\"";
            }
            if (SatFat != -1)
            {
                str += "&satfat=\"" + SatFat.ToString() + "\"";
            }
            if (UnSatFat != -1)
            {
                str += "&unsatfat=\"" + UnSatFat.ToString() + "\"";
            }
            if (Cholesterol != -1)
            {
                str += "&cholesterol=\"" + Cholesterol.ToString() + "\"";
            }
            if (Sugar != -1)
            {
                str += "&sugar=\"" + Sugar.ToString() + "\"";
            }
            if (Natrium != -1)
            {
                str += "&natrium=\"" + Natrium.ToString() + "\"";
            }
            if (Potassium != -1)
            {
                str += "&potassium=\"" + Potassium.ToString() + "\"";
            }
            if (Fiber != -1)
            {
                str += "&fiber=\"" + Fiber.ToString() + "\"";
            }
            if (Deleted != -1)
            {
                str += "&deleted=\"" + Deleted.ToString() + "\"";
            }
            if (InsertDate != null)
            {
                str += "&insertdate=\"" + InsertDate.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
            }
            if (UpdateDate != null)
            {
                str += "&updatedate=\"" + UpdateDate.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
            }

            return(str.Substring(1));
        }
 //public string Name { get; set; }
 //public double Weight { get; set; }
 //public Calories Calories { get; set; }
 public CustomVegetable(string name, double weight, Calories calories)
     : base(name, weight, calories)
 {
 }
Exemple #26
0
        private void printbutton_Click(object sender, EventArgs e)
        {
            var l = new Calories(Convert.ToChar(SexText.Text), Convert.ToDouble(HeightText.Text), Convert.ToDouble(WeightText.Text), Convert.ToDouble(YearsText.Text), Convert.ToDouble(RateText.Text));

            MessageBox.Show(l.ToString());
        }
Exemple #27
0
 public override int GetHashCode()
 {
     return(Calories.GetHashCode() ^ Name.GetHashCode() ^ Group.GetHashCode());
 }
Exemple #28
0
 protected Vegetable(string name, double weight, Calories calories)
 {
     this.Name = name;
     this.Weight = weight;
     this.Calories = calories;
 }
 public void Validate()
 {
     Calories.ValidateRequired("Calories");
     Display.ValidateOptional("Display");
 }
 public string ToString()
 {
     return(Weight.ToString() + "kg , " + Calories.ToString() + "cal");
 }
Exemple #31
0
        private User GetFitBitData(User user)
        {
            FitBitClient client  = new FitBitClient(Request.Url, HttpContext.Session.SessionID);
            string       content = client.GetProfile();

            if (client.isAuthorizated())
            {
                var feedDocument = XDocument.Parse(content);
                var userXml      = feedDocument.Element("result").Element("user");
                var fitBitId     = userXml.Element("encodedId").Value;


                //Get data from FitBit
                user.userId          = WebSecurity.GetUserId(User.Identity.Name);
                user.City            = userXml.Element("city").Value;
                user.FitBitEncodedID = userXml.Element("encodedId").Value;
                user.DisplayName     = userXml.Element("displayName").Value;
                user.FullName        = userXml.Element("fullName").Value;
                user.City            = userXml.Element("city").Value;
                user.State           = "WA";
                user.DistanceUnit    = userXml.Element("distanceUnit").Value;
                user.Gender          = userXml.Element("gender").Value;
                user.Avatar          = userXml.Element("avatar").Value;



                user.Height       = userXml.Element("height").Value;
                user.WeightFitBit = userXml.Element("weight").Value;



                //GET Calories
                var data = client.GetCalories();

                var collection = new List <Calories>();

                user.CaloriesList = collection;

                foreach (KeyValuePair <string, int> kvp in data)
                {
                    Calories Calories = new Calories();
                    Calories.date  = kvp.Key;
                    Calories.value = kvp.Value;

                    user.CaloriesList.Add(Calories);
                }
                user.ActualCalories = data.Values[data.Count - 1];

                user = GetCaloriesImage(user);


                //GET MinutesAsSleep
                var dataMinutesAsSleep = client.GetMinutesAsSleep();

                var collectionMinutesAsSleep = new List <MinutesAsSleep>();

                user.MinutesAsSleepList = collectionMinutesAsSleep;

                foreach (KeyValuePair <string, int> kvp in dataMinutesAsSleep)
                {
                    MinutesAsSleep MinutesAsSleep = new MinutesAsSleep();
                    MinutesAsSleep.date  = kvp.Key;
                    MinutesAsSleep.value = kvp.Value;

                    user.MinutesAsSleepList.Add(MinutesAsSleep);
                }
                user.ActualMinutesAsSleep = dataMinutesAsSleep.Values[dataMinutesAsSleep.Count - 1];

                user = GetMinutesAsSleepImage(user);

                //GET TotalNumberOfSteps
                var dataTotalNumberOfSteps = client.GetTotalNumberOfSteps();

                var collectionTotalNumberOfSteps = new List <TotalNumberOfSteps>();

                user.TotalNumberOfStepsList = collectionTotalNumberOfSteps;

                foreach (KeyValuePair <string, int> kvp in dataTotalNumberOfSteps)
                {
                    TotalNumberOfSteps TotalNumberOfSteps = new TotalNumberOfSteps();
                    TotalNumberOfSteps.date  = kvp.Key;
                    TotalNumberOfSteps.value = kvp.Value;

                    user.TotalNumberOfStepsList.Add(TotalNumberOfSteps);
                }
                user.ActualTotalNumberOfSteps = dataTotalNumberOfSteps.Values[dataTotalNumberOfSteps.Count - 1];

                user = GetTotalNumberOfStepsImage(user);

                //GET TotalFloorsClimbled
                var dataTotalFloorsClimbled = client.GetTotalFloorsClimbled();

                var collectionTotalFloorsClimbled = new List <TotalFloorsClimbled>();

                user.TotalFloorsClimbledList = collectionTotalFloorsClimbled;

                foreach (KeyValuePair <string, int> kvp in dataTotalFloorsClimbled)
                {
                    TotalFloorsClimbled TotalFloorsClimbled = new TotalFloorsClimbled();
                    TotalFloorsClimbled.date  = kvp.Key;
                    TotalFloorsClimbled.value = kvp.Value;

                    user.TotalFloorsClimbledList.Add(TotalFloorsClimbled);
                }
                user.ActualTotalFloorsClimbled = dataTotalFloorsClimbled.Values[dataTotalFloorsClimbled.Count - 1];

                user = GetTotalFloorsClimbledImage(user);



                user.HasFitBitData = true;
                db.SaveChanges();
                return(user);
            }
            else
            {
                Response.Redirect(content);
                return(user);
            }
        }
Exemple #32
0
        protected override void Update()
        {
            try
            {
                if (!(Scene.Atmosphere == null) && !SteamDSConfig.isDedicatedServer)
                {
                    float num = Convert.ToSingle(LocalPlayer.Stats.DaySurvived + TheForest.Utils.Scene.Atmosphere.DeltaTimeOfDay);
                    if (Mathf.FloorToInt(num) != Mathf.FloorToInt(LocalPlayer.Stats.DaySurvived))
                    {
                        LocalPlayer.Stats.DaySurvived = num;
                        EventRegistry.Player.Publish(TfEvent.SurvivedDay, null);
                    }
                    else
                    {
                        LocalPlayer.Stats.DaySurvived = num;
                    }
                    LocalPlayer.ScriptSetup.targetInfo.isRed = IsRed;
                    float num2 = 0f;
                    num2           = ((!coldSwitch || LocalPlayer.AnimControl.coldOffsetBool) ? 0f : 1f);
                    coldFloatBlend = Mathf.Lerp(coldFloatBlend, num2, Time.deltaTime * 10f);
                    if (coldFloatBlend > 0.01f)
                    {
                        BoltSetReflectedShim.SetFloatReflected(animator, "coldFloat", coldFloatBlend);
                    }
                    else
                    {
                        BoltSetReflectedShim.SetFloatReflected(animator, "coldFloat", 0f);
                    }
                    if (Run && HeartRate < 170)
                    {
                        HeartRate++;
                    }
                    else if (!Run && HeartRate > 70)
                    {
                        HeartRate--;
                    }
                    if (Sitted)
                    {
                        Energy += 0.02f * ModdedPlayer.instance.MaxEnergy * Time.deltaTime + ModdedPlayer.instance.StaminaAndEnergyRegenAmp * 6 * Time.deltaTime;
                    }
                    if (!Clock.Dark && IsCold && !LocalPlayer.IsInCaves && !IsInNorthColdArea())
                    {
                        goto IL_01cb;
                    }
                    if (LocalPlayer.IsInEndgame)
                    {
                        goto IL_01cb;
                    }
                    goto IL_01e2;
                }
                return;

IL_01e2:
                if (IsInNorthColdArea() && !Warm)
                {
                    SetCold(true);
                }
                if (ShouldDoWetColdRoll && !IsCold && (LocalPlayer.IsInCaves || Clock.Dark))
                {
                    if (!LocalPlayer.Buoyancy.InWater)
                    {
                        ShouldDoWetColdRoll = false;
                    }
                    else if (LocalPlayer.IsInCaves)
                    {
                        if (LocalPlayer.AnimControl.swimming)
                        {
                            if (Time.time - CaveStartSwimmingTime > 12f)
                            {
                                SetCold(true);
                                ShouldDoWetColdRoll = false;
                            }
                        }
                        else
                        {
                            CaveStartSwimmingTime = Time.time;
                        }
                    }
                    else
                    {
                        Vector3 position = LocalPlayer.Transform.position;
                        if (position.y - LocalPlayer.Buoyancy.WaterLevel < 1f)
                        {
                            if (UnityEngine.Random.Range(0, 100) < 30)
                            {
                                SetCold(true);
                            }
                            ShouldDoWetColdRoll = false;
                        }
                    }
                }
                if (ShouldDoGotCleanCheck)
                {
                    if (!LocalPlayer.Buoyancy.InWater)
                    {
                        ShouldDoGotCleanCheck = false;
                    }
                    else
                    {
                        Vector3 position2 = LocalPlayer.ScriptSetup.hipsJnt.position;
                        if (position2.y - LocalPlayer.Buoyancy.WaterLevel < -0.5f)
                        {
                            ShouldDoGotCleanCheck = false;
                            GotCleanReal();
                        }
                    }
                }
                if (Health <= GreyZoneThreshold && AudioListener.volume > 0.2f)
                {
                    AudioListener.volume -= 0.1f * Time.deltaTime;
                }
                else if (AudioListener.volume < 1f)
                {
                    AudioListener.volume += 0.1f * Time.deltaTime;
                }
                if (IsHealthInGreyZone)
                {
                    Tuts.LowHealthTutorial();
                }
                else
                {
                    Tuts.CloseLowHealthTutorial();
                }
                if (Energy < 15f)
                {
                    Tuts.LowEnergyTutorial();
                }
                else
                {
                    Tuts.CloseLowEnergyTutorial();
                }
                if (Stamina <= 5 && !IsTired)
                {
                    base.SendMessage("PlayStaminaBreath");
                    IsTired = true;
                    Run     = false;
                }

                HealthTarget      = Mathf.Clamp(HealthTarget, 0, ChampionsOfForest.ModdedPlayer.instance.MaxHealth);
                GreyZoneThreshold = Mathf.RoundToInt(ModdedPlayer.instance.MaxHealth * 0.05f);
                //if (HealthTarget > ChampionsOfForest.ModdedPlayer.instance.MaxHealth)
                //{
                //    HealthTarget = ChampionsOfForest.ModdedPlayer.instance.MaxHealth;
                //}
                if (Stamina > 5 && IsTired)
                {
                    IsTired = false;
                }
                fsmStamina.Value    = 100 * Stamina / ModdedPlayer.instance.MaxEnergy;
                fsmMaxStamina.Value = 100 * Energy / ModdedPlayer.instance.MaxEnergy;
                HealthResult        = Health / ChampionsOfForest.ModdedPlayer.instance.MaxHealth + (ChampionsOfForest.ModdedPlayer.instance.MaxHealth - Health) / ChampionsOfForest.ModdedPlayer.instance.MaxHealth * 0.5f;
                float num3 = HealthTarget / ChampionsOfForest.ModdedPlayer.instance.MaxHealth + (ChampionsOfForest.ModdedPlayer.instance.MaxHealth - HealthTarget) / ChampionsOfForest.ModdedPlayer.instance.MaxHealth * 0.5f;
                if (HealthTargetResult < num3)
                {
                    HealthTargetResult = Mathf.MoveTowards(HealthTargetResult, num3, 1f * Time.fixedDeltaTime);
                }
                else
                {
                    HealthTargetResult = num3;
                }
                StaminaResult = Stamina / ChampionsOfForest.ModdedPlayer.instance.MaxEnergy + (ChampionsOfForest.ModdedPlayer.instance.MaxEnergy - Stamina) / ChampionsOfForest.ModdedPlayer.instance.MaxEnergy * 0.5f;
                EnergyResult  = Energy / ChampionsOfForest.ModdedPlayer.instance.MaxEnergy + (ChampionsOfForest.ModdedPlayer.instance.MaxEnergy - Energy) / ChampionsOfForest.ModdedPlayer.instance.MaxEnergy * 0.5f;
                int num4 = 0;
                int num5 = 0;
                for (int i = 0; i < CurrentArmorTypes.Length; i++)
                {
                    switch (CurrentArmorTypes[i])
                    {
                    case ArmorTypes.DeerSkin:
                    case ArmorTypes.Warmsuit:
                        num5++;
                        break;

                    case ArmorTypes.LizardSkin:
                    case ArmorTypes.Leaves:
                    case ArmorTypes.Bone:
                        num4++;
                        break;

                    case ArmorTypes.Creepy:
                        num4++;
                        break;
                    }
                }
                ColdArmorResult                = num5 / 10f / 2f + 0.5f;
                ArmorResult                    = num4 / 10f / 2f + ColdArmorResult;
                Hud.ColdArmorBar.fillAmount    = ColdArmorResult;
                Hud.ArmorBar.fillAmount        = ArmorResult;
                Hud.StaminaBar.fillAmount      = StaminaResult;
                Hud.HealthBar.fillAmount       = HealthResult;
                Hud.HealthBarTarget.fillAmount = HealthTargetResult;
                Hud.EnergyBar.fillAmount       = EnergyResult;
                float num6 = (Fullness - 0.2f) / 0.8f;
                TheForest.Utils.Scene.HudGui.Stomach.fillAmount = Mathf.Lerp(0.21f, 0.81f, num6);
                if (num6 < 0.5)
                {
                    Hud.StomachOutline.SetActive(true);
                    if (!Hud.Tut_Hungry.activeSelf)
                    {
                        Tuts.HungryTutorial();
                    }
                }
                else
                {
                    if (Hud.Tut_Hungry.activeSelf)
                    {
                        Tuts.CloseHungryTutorial();
                    }
                    Hud.StomachOutline.SetActive(false);
                }
                if (!TheForest.Utils.Scene.Atmosphere.Sleeping || Fullness > StarvationSettings.SleepingFullnessThreshold)
                {
                    Fullness -= Convert.ToSingle(TheForest.Utils.Scene.Atmosphere.DeltaTimeOfDay * 1.6500000238418579 * 0.4f * ModdedPlayer.instance.HungerRate);
                }
                if (!Cheats.NoSurvival)
                {
                    if (Fullness < 0.2f)
                    {
                        if (Fullness < 0.19f)
                        {
                            Fullness = 0.19f;
                        }
                        if (DaySurvived >= StarvationSettings.StartDay && !Dead && !TheForest.Utils.Scene.Atmosphere.Sleeping && LocalPlayer.Inventory.enabled)
                        {
                            if (!TheForest.Utils.Scene.HudGui.StomachStarvation.gameObject.activeSelf)
                            {
                                if (Starvation == 0f)
                                {
                                    StarvationCurrentDuration = StarvationSettings.Duration;
                                }
                                TheForest.Utils.Scene.HudGui.StomachStarvation.gameObject.SetActive(true);
                            }
                            Starvation += Convert.ToSingle(TheForest.Utils.Scene.Atmosphere.DeltaTimeOfDay / StarvationCurrentDuration);
                            if (Starvation >= 1f)
                            {
                                if (!StarvationSettings.TakingDamage)
                                {
                                    StarvationSettings.TakingDamage = true;
                                    LocalPlayer.Tuts.ShowStarvationTut();
                                }
                                Hit(StarvationSettings.Damage, true, DamageType.Physical);
                                TheForest.Utils.Scene.HudGui.StomachStarvationTween.ResetToBeginning();
                                TheForest.Utils.Scene.HudGui.StomachStarvationTween.PlayForward();
                                Starvation = 0f;
                                StarvationCurrentDuration *= StarvationSettings.DurationDecay;
                            }
                            TheForest.Utils.Scene.HudGui.StomachStarvation.fillAmount = Mathf.Lerp(0.21f, 0.81f, Starvation);
                        }
                    }
                    else if (Starvation > 0f || TheForest.Utils.Scene.HudGui.StomachStarvation.gameObject.activeSelf)
                    {
                        Starvation = 0f;
                        StarvationCurrentDuration       = StarvationSettings.Duration;
                        StarvationSettings.TakingDamage = false;
                        LocalPlayer.Tuts.StarvationTutOff();
                        TheForest.Utils.Scene.HudGui.StomachStarvation.gameObject.SetActive(false);
                    }
                }
                else
                {
                    Fullness = 1f;
                    if (Starvation > 0f || TheForest.Utils.Scene.HudGui.StomachStarvation.gameObject.activeSelf)
                    {
                        Starvation = 0f;
                        StarvationCurrentDuration       = StarvationSettings.Duration;
                        StarvationSettings.TakingDamage = false;
                        TheForest.Utils.Scene.HudGui.StomachStarvation.gameObject.SetActive(false);
                    }
                }
                if (Fullness > 1f)
                {
                    Fullness = 1f;
                }
                if (!Cheats.NoSurvival)
                {
                    if (DaySurvived >= ThirstSettings.StartDay && !Dead && LocalPlayer.Inventory.enabled)
                    {
                        if (Thirst >= 1f)
                        {
                            if (!TheForest.Utils.Scene.HudGui.ThirstDamageTimer.gameObject.activeSelf)
                            {
                                TheForest.Utils.Scene.HudGui.ThirstDamageTimer.gameObject.SetActive(true);
                            }
                            if (ThirstCurrentDuration <= 0f)
                            {
                                ThirstCurrentDuration = ThirstSettings.DamageDelay;
                                if (!ThirstSettings.TakingDamage)
                                {
                                    ThirstSettings.TakingDamage = true;
                                    LocalPlayer.Tuts.ShowThirstTut();
                                }
                                Hit(Mathf.CeilToInt(ModdedPlayer.instance.MaxHealth * 0.2f * GameSettings.Survival.ThirstDamageRatio), true, DamageType.Physical);
                                BleedBehavior.BloodAmount += 0.6f;
                                TheForest.Utils.Scene.HudGui.ThirstDamageTimerTween.ResetToBeginning();
                                TheForest.Utils.Scene.HudGui.ThirstDamageTimerTween.PlayForward();
                            }
                            else
                            {
                                ThirstCurrentDuration -= Time.deltaTime;
                                TheForest.Utils.Scene.HudGui.ThirstDamageTimer.fillAmount = 1f - ThirstCurrentDuration / ThirstSettings.DamageDelay;
                            }
                        }
                        else if (Thirst < 0f)
                        {
                            Thirst = 0f;
                        }
                        else
                        {
                            if (!TheForest.Utils.Scene.Atmosphere.Sleeping || Thirst < ThirstSettings.SleepingThirstThreshold)
                            {
                                Thirst += Convert.ToSingle((TheForest.Utils.Scene.Atmosphere.DeltaTimeOfDay / ThirstSettings.Duration) * 1.1f * GameSettings.Survival.ThirstRatio * ModdedPlayer.instance.ThirstRate * 0.4f);
                            }
                            if (Thirst > ThirstSettings.TutorialThreshold)
                            {
                                //LocalPlayer.Tuts.ShowThirstyTut();
                                TheForest.Utils.Scene.HudGui.ThirstOutline.SetActive(true);
                            }
                            else
                            {
                                LocalPlayer.Tuts.HideThirstyTut();
                                TheForest.Utils.Scene.HudGui.ThirstOutline.SetActive(false);
                            }
                            if (ThirstSettings.TakingDamage)
                            {
                                ThirstSettings.TakingDamage = false;
                                LocalPlayer.Tuts.ThirstTutOff();
                            }
                            if (TheForest.Utils.Scene.HudGui.ThirstDamageTimer.gameObject.activeSelf)
                            {
                                TheForest.Utils.Scene.HudGui.ThirstDamageTimer.gameObject.SetActive(false);
                            }
                        }
                        TheForest.Utils.Scene.HudGui.Hydration.fillAmount = 1f - Thirst;
                    }
                }
                else if (TheForest.Utils.Scene.HudGui.Hydration.fillAmount != 1f)
                {
                    TheForest.Utils.Scene.HudGui.Hydration.fillAmount = 1f;
                }
                bool flag  = false;
                bool flag2 = false;
                if (LocalPlayer.WaterViz.ScreenCoverage > AirBreathing.ScreenCoverageThreshold && !Dead)
                {
                    if (!TheForest.Utils.Scene.HudGui.AirReserve.gameObject.activeSelf)
                    {
                        TheForest.Utils.Scene.HudGui.AirReserve.gameObject.SetActive(true);
                    }
                    if (!AirBreathing.UseRebreather && AirBreathing.RebreatherIsEquipped && AirBreathing.CurrentRebreatherAir > 0f)
                    {
                        AirBreathing.UseRebreather = true;
                    }
                    if (AirBreathing.UseRebreather)
                    {
                        flag = true;
                        AirBreathing.CurrentRebreatherAir -= Time.deltaTime;
                        TheForest.Utils.Scene.HudGui.AirReserve.fillAmount = AirBreathing.CurrentRebreatherAir / AirBreathing.MaxRebreatherAirCapacity;
                        if (AirBreathing.CurrentRebreatherAir < 0f)
                        {
                            AirBreathing.CurrentLungAir = 0f;
                            AirBreathing.UseRebreather  = false;
                        }
                        else if (AirBreathing.CurrentRebreatherAir < AirBreathing.OutOfAirWarningThreshold)
                        {
                            if (!TheForest.Utils.Scene.HudGui.AirReserveOutline.activeSelf)
                            {
                                TheForest.Utils.Scene.HudGui.AirReserveOutline.SetActive(true);
                            }
                        }
                        else if (TheForest.Utils.Scene.HudGui.AirReserveOutline.activeSelf)
                        {
                            TheForest.Utils.Scene.HudGui.AirReserveOutline.SetActive(false);
                        }
                    }
                    else
                    {
                        if (Time.timeScale > 0f)
                        {
                            if (!AirBreathing.CurrentLungAirTimer.IsRunning)
                            {
                                AirBreathing.CurrentLungAirTimer.Start();
                            }
                        }
                        else if (AirBreathing.CurrentLungAirTimer.IsRunning)
                        {
                            AirBreathing.CurrentLungAirTimer.Stop();
                        }
                        if (AirBreathing.CurrentLungAir > AirBreathing.MaxLungAirCapacityFinal)
                        {
                            AirBreathing.CurrentLungAir = AirBreathing.MaxLungAirCapacityFinal;
                        }
                        if (AirBreathing.CurrentLungAir > AirBreathing.CurrentLungAirTimer.Elapsed.TotalSeconds * Skills.LungBreathingRatio)
                        {
                            Skills.TotalLungBreathingDuration += Time.deltaTime;
                            TheForest.Utils.Scene.HudGui.AirReserve.fillAmount = Mathf.Lerp(TheForest.Utils.Scene.HudGui.AirReserve.fillAmount, AirBreathing.CurrentAirPercent, Mathf.Clamp01((Time.time - Time.fixedTime) / Time.fixedDeltaTime));
                            if (!TheForest.Utils.Scene.HudGui.AirReserveOutline.activeSelf)
                            {
                                TheForest.Utils.Scene.HudGui.AirReserveOutline.SetActive(true);
                            }
                        }
                        else if (!Cheats.NoSurvival)
                        {
                            flag2 = true;
                            AirBreathing.DamageCounter += AirBreathing.Damage * Time.deltaTime;
                            if (AirBreathing.DamageCounter >= 1f)
                            {
                                int dmg = 3 + (int)(ModdedPlayer.instance.MaxHealth * 0.1f);
                                Hit(dmg, true, DamageType.Drowning);
                                AirBreathing.DamageCounter -= (int)AirBreathing.DamageCounter;
                            }
                            if (Dead)
                            {
                                AirBreathing.DamageCounter = 0f;
                                DeadTimes++;
                                TheForest.Utils.Scene.HudGui.AirReserve.gameObject.SetActive(false);
                                TheForest.Utils.Scene.HudGui.AirReserveOutline.SetActive(false);
                            }
                            else if (!TheForest.Utils.Scene.HudGui.AirReserveOutline.activeSelf)
                            {
                                TheForest.Utils.Scene.HudGui.AirReserveOutline.SetActive(true);
                            }
                        }
                    }
                }
                else if (AirBreathing.CurrentLungAir < AirBreathing.MaxLungAirCapacityFinal || TheForest.Utils.Scene.HudGui.AirReserve.gameObject.activeSelf)
                {
                    if (GaspForAirEvent.Length > 0 && FMOD_StudioSystem.instance && !Dead)
                    {
                        FMOD_StudioSystem.instance.PlayOneShot(GaspForAirEvent, base.transform.position, delegate(FMOD.Studio.EventInstance instance)
                        {
                            float value = 85f;
                            if (!AirBreathing.UseRebreather)
                            {
                                value = (AirBreathing.CurrentLungAir - (float)AirBreathing.CurrentLungAirTimer.Elapsed.TotalSeconds) / AirBreathing.MaxLungAirCapacity * 100f;
                            }
                            UnityUtil.ERRCHECK(instance.setParameterValue("oxygen", value));
                            return(true);
                        });
                    }
                    AirBreathing.DamageCounter = 0f;
                    AirBreathing.CurrentLungAirTimer.Stop();
                    AirBreathing.CurrentLungAirTimer.Reset();
                    AirBreathing.CurrentLungAir = AirBreathing.MaxLungAirCapacityFinal;
                    TheForest.Utils.Scene.HudGui.AirReserve.gameObject.SetActive(false);
                    TheForest.Utils.Scene.HudGui.AirReserveOutline.SetActive(false);
                }
                if (flag)
                {
                    UpdateRebreatherEvent();
                }
                else
                {
                    StopIfPlaying(RebreatherEventInstance);
                }
                if (flag2)
                {
                    UpdateDrowningEvent();
                }
                else
                {
                    StopIfPlaying(DrowningEventInstance);
                }
                if (Energy > ChampionsOfForest.ModdedPlayer.instance.MaxEnergy)
                {
                    Energy = ChampionsOfForest.ModdedPlayer.instance.MaxEnergy;
                }
                if (Energy < 5)
                {
                    Energy = 5;
                }
                if (Health < 0f)
                {
                    Health = 0f;
                }
                if (Health > ChampionsOfForest.ModdedPlayer.instance.MaxHealth)
                {
                    Health = ChampionsOfForest.ModdedPlayer.instance.MaxHealth;
                }
                if (Health < HealthTarget)
                {
                    Health = Mathf.MoveTowards(Health, HealthTarget, (GameSettings.Survival.HealthRegenPerSecond + ModdedPlayer.instance.MaxHealth * 0.0025f + ModdedPlayer.instance.LifeRegen) * (ModdedPlayer.instance.HealthRegenPercent + 1) * ModdedPlayer.instance.HealingMultipier * Time.deltaTime);

                    TheForest.Utils.Scene.HudGui.HealthBarTarget.enabled = true;
                }
                else
                {
                    TheForest.Utils.Scene.HudGui.HealthBarTarget.enabled = false;
                }
                if (Health < 20f)
                {
                    Hud.HealthBarOutline.SetActive(true);
                }
                else
                {
                    Hud.HealthBarOutline.SetActive(false);
                }
                if (Energy < 15f || IsCold)
                {
                    Hud.EnergyBarOutline.SetActive(true);
                }
                else
                {
                    Hud.EnergyBarOutline.SetActive(false);
                }
                if (Stamina < 10f)
                {
                    Hud.StaminaBarOutline.SetActive(true);
                }
                else
                {
                    Hud.StaminaBarOutline.SetActive(false);
                }
                if (Stamina < 0f)
                {
                    Stamina = 0f;
                }
                if (Stamina < Energy)
                {
                    if (!LocalPlayer.FpCharacter.running && !(LocalPlayer.FpCharacter.recoveringFromRun > 0f))
                    {
                        Stamina += ModdedPlayer.instance.StaminaRecover * Time.deltaTime * ModdedPlayer.instance.StaminaAndEnergyRegenAmp * (1 + ModdedPlayer.instance.StaminaRegenPercent);
                        Energy  += ModdedPlayer.instance.EnergyPerSecond * ModdedPlayer.instance.StaminaAndEnergyRegenAmp * Time.deltaTime;
                    }
                    else if (LocalPlayer.FpCharacter.recoveringFromRun > 0f && Thirst < 1)
                    {
                        LocalPlayer.FpCharacter.recoveringFromRun -= Time.deltaTime;
                    }
                }
                else
                {
                    Stamina = Energy;
                    Energy += ModdedPlayer.instance.EnergyPerSecond * ModdedPlayer.instance.StaminaAndEnergyRegenAmp * Time.deltaTime;
                }
                if (CheckingBlood && TheForest.Utils.Scene.SceneTracker.proxyAttackers.arrayList.Count > 0)
                {
                    StopBloodCheck();
                }
                if (IsCold && !Warm && LocalPlayer.Inventory.enabled)
                {
                    if (BodyTemp > 14f)
                    {
                        BodyTemp -= 1f * (1f - Mathf.Clamp01(ColdArmor));
                    }
                    if (FrostDamageSettings.DoDeFrost)
                    {
                        if (FrostScript.coverage > FrostDamageSettings.DeFrostThreshold)
                        {
                            FrostScript.coverage -= 0.0159999728f * Time.deltaTime / FrostDamageSettings.DeFrostDuration;
                        }
                        else
                        {
                            FrostDamageSettings.DoDeFrost = false;
                        }
                    }
                    else if (FrostScript.coverage < 0.49f || ColdArmor >= 1f)
                    {
                        if (FrostScript.coverage < 0f)
                        {
                            FrostScript.coverage = 0f;
                        }
                        FrostScript.coverage += 0.01f * Time.deltaTime * (1f - Mathf.Clamp01(ColdArmor)) * GameSettings.Survival.FrostSpeedRatio;
                        if (FrostScript.coverage > 0.492f)
                        {
                            FrostScript.coverage = 0.491f;
                        }
                    }
                    else if (!Cheats.NoSurvival && TheForest.Utils.Scene.Clock.ElapsedGameTime >= FrostDamageSettings.StartDay && LocalPlayer.Inventory.CurrentView != PlayerInventory.PlayerViews.Book && LocalPlayer.Inventory.CurrentView != PlayerInventory.PlayerViews.Inventory && !LocalPlayer.AnimControl.doShellRideMode)
                    {
                        if (!LocalPlayer.FpCharacter.jumping && (!LocalPlayer.AnimControl.onRope || !LocalPlayer.AnimControl.VerticalMovement) && !IsLit && LocalPlayer.Rigidbody.velocity.sqrMagnitude < 0.3f && !Dead)
                        {
                            if (FrostDamageSettings.CurrentTimer >= FrostDamageSettings.Duration)
                            {
                                if (FrostDamageSettings.DamageChance == 0)
                                {
                                    Hit((int)((ModdedPlayer.instance.MaxHealth * 0.015f + FrostDamageSettings.Damage) * GameSettings.Survival.FrostDamageRatio), true, DamageType.Frost);
                                    FrostScript.coverage             = 0.506f;
                                    FrostDamageSettings.DoDeFrost    = true;
                                    FrostDamageSettings.CurrentTimer = 0f;
                                }
                            }
                            else
                            {
                                FrostDamageSettings.CurrentTimer += Time.deltaTime * ((1f - Mathf.Clamp01(ColdArmor)) * 1f);
                            }
                        }
                        else
                        {
                            FrostDamageSettings.CurrentTimer = 0f;
                        }
                    }
                }
                if (Warm)
                {
                    if (BodyTemp < 37f)
                    {
                        BodyTemp += 1f * (1f + Mathf.Clamp01(ColdArmor));
                    }
                    if (FrostScript.coverage > 0f)
                    {
                        FrostScript.coverage -= 0.01f * Time.deltaTime * (1f + Mathf.Clamp01(ColdArmor)) * GameSettings.Survival.DefrostSpeedRatio;
                        if (FrostScript.coverage < 0f)
                        {
                            FrostScript.coverage = 0f;
                        }
                    }
                    else
                    {
                        FrostDamageSettings.TakingDamage = false;
                    }
                    FrostDamageSettings.CurrentTimer = 0f;
                }
                if (LocalPlayer.IsInCaves)
                {
                    Sanity.InCave();
                }
                if (PlayerSfx.MusicPlaying)
                {
                    Sanity.ListeningToMusic();
                }
                if (Sitted)
                {
                    Sanity.SittingOnBench();
                }
                Calories.Refresh();
                if (DyingEventInstance != null && !flag2 && !Dead)
                {
                    UnityUtil.ERRCHECK(DyingEventInstance.set3DAttributes(UnityUtil.to3DAttributes(base.gameObject, null)));
                    UnityUtil.ERRCHECK(DyingHealthParameter.setValue(Health));
                }
                if (FireExtinguishEventInstance != null)
                {
                    UnityUtil.ERRCHECK(FireExtinguishEventInstance.set3DAttributes(UnityUtil.to3DAttributes(base.gameObject, null)));
                }
                if (Cheats.InfiniteEnergy)
                {
                    Energy  = ChampionsOfForest.ModdedPlayer.instance.MaxEnergy;
                    Stamina = ChampionsOfForest.ModdedPlayer.instance.MaxEnergy;
                }
                if (Cheats.GodMode)
                {
                    Health       = ChampionsOfForest.ModdedPlayer.instance.MaxHealth;
                    HealthTarget = ChampionsOfForest.ModdedPlayer.instance.MaxHealth;
                }
                return;

IL_01cb:
                SetCold(false);
                FrostScript.coverage = 0f;
                goto IL_01e2;
            }
            catch (Exception E)
            {
                ModAPI.Log.Write(E.ToString());
            }
        }
        public AccountView(TGFCContext _ctx, IEnumerable <Claim> _claims)
        {
            CurrentUser   = Queries.GetUserByClaims(_ctx, _claims);
            Disciplines   = Queries.GetAllDisciplines(_ctx);
            ActivityTypes = Queries.GetAllActivityTypes(_ctx);
            if (CurrentUser.Department.Directorate.ChallengeStartDate == null || CurrentUser.Department.Directorate.ChallengeEndDate == null)
            {
                ChallengeStartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                ChallengeEndDate   = ChallengeStartDate.AddMonths(1).AddMinutes(-1);
            }
            else
            {
                ChallengeStartDate = (DateTime)CurrentUser.Department.Directorate.ChallengeStartDate;
                ChallengeEndDate   = (DateTime)CurrentUser.Department.Directorate.ChallengeEndDate;
            }

            List <DateTime> dates = GetDatesBetween(ChallengeStartDate, ChallengeEndDate);

            foreach (var date in dates)
            {
                LineChartLabels.Add($"{date.ToString("dd/MM/yy")}");
            }

            TotalCalories = Calories.CalculateTotalCalories(CurrentUser.Activities.Where(a => a.StartTime >= ChallengeStartDate && a.EndTime <= ChallengeEndDate).ToList());

            for (int i = 0; i < Disciplines.Count; i++)
            {
                PieChartData.Add(0);
            }

            List <int> allCounter = new List <int>();

            for (int j = 0; j < dates.Count; j++)
            {
                allCounter.Add(0);
            }

            foreach (var dscpln in Disciplines)
            {
                List <int> temp;
                if (!LineChartData.TryGetValue(dscpln.NameNormalized, out temp))
                {
                    temp = new List <int>();
                    for (int j = 0; j < dates.Count; j++)
                    {
                        temp.Add(0);
                    }
                }
                LineChartData[dscpln.NameNormalized] = temp;
            }

            foreach (var ac in CurrentUser.Activities.Where(a => a.StartTime >= ChallengeStartDate && a.EndTime <= ChallengeEndDate))
            {
                List <int> temp;
                if (!LineChartData.TryGetValue(ac.ActivityType.Discipline.NameNormalized, out temp))
                {
                    temp = new List <int>();
                    for (int j = 0; j < dates.Count; j++)
                    {
                        temp.Add(0);
                    }
                }
                int day = (ac.StartTime.Day - ChallengeStartDate.Day);

                int value = temp[day];
                temp[day] = ++value;

                int value2 = allCounter[day];
                allCounter[day] = ++value2;

                LineChartData[ac.ActivityType.Discipline.NameNormalized] = temp;

                int index = Disciplines.IndexOf(ac.ActivityType.Discipline);
                PieChartData[index] = PieChartData[index] + 1;
            }
            LineChartData["all"] = allCounter;

            foreach (var dscpln in Disciplines)
            {
                DisciplineNames.Add(dscpln.NameNormalized);
                PieChartLabels.Add(dscpln.Name);
                PieChartColors.Add(dscpln.Color);
            }
            DisciplineNames.Add("all");
        }
Exemple #34
0
        static void Main(string[] args)
        {
            Calories cl = new Calories(2, 3, 4);
            Calories c2 = 2*cl;

            var potato = new  Potato(100);
            var cucmber = new Cucumber(100);
            var carrot = new Carrot(200);

            var cust = new CustomVegetable("1", 2, new Calories());
            Console.WriteLine(cust);
            cust.Weight = 3;
            cust.Calories = new Calories();
            cust.Name = "13";
            Console.WriteLine(cust);

            Console.WriteLine(potato.Name + " " + potato.Calories + " " + potato.Weight);
            Console.WriteLine(cucmber.Name + " " + cucmber.Calories + " " + cucmber.Weight);
            Console.WriteLine(carrot.Name + " " + carrot.Calories + " " + carrot.Weight);
            List<IVegetable> lst = new List<IVegetable>();
            lst.Add(cucmber);

            Salad salad = new Salad(new CloneList<IVegetable>());
            salad.Add(potato);
            salad.Add(carrot);
            salad.Add(cucmber);
            Console.WriteLine("total calories = " + salad.TotalCalories);
            Console.WriteLine();
            Console.WriteLine();
            salad.PrintVegetables();
            var tt = salad.GetVegetables(0, 1000);

            Console.WriteLine();
            Console.WriteLine();
            salad.PrintVegetables();

            salad.Sort(VegetableComparasions.CompareByName);
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("BEFORE SRT");
            salad.PrintVegetables();

            salad.Sort(vegetable => vegetable.Calories, new CompareByCalories());

            Func<int, int> d = delegate(int i) { return i*3; };

            Console.WriteLine("AFTER SRT");
            salad.PrintVegetables();
            salad.Sort(VegetableComparasions.CompareByWeight);
            Console.WriteLine("BEFORE REMOVE");
            salad.PrintVegetables();
            salad.Remove(potato);

            Console.WriteLine("AFTER REMOVE");
            salad.PrintVegetables();

            Console.WriteLine("TESTTTT");
            CloneList<IVegetable> list = new CloneList<IVegetable>();

            List<int> li = new List<int>();

            list.Add(potato);
            list.Add(cucmber);
            list.Add(carrot);
            foreach (var v in list)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            Console.WriteLine("CLONE");

            ICloneCollection<IVegetable> list2 = list.CloneObjects();
            foreach (var v in list2)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            list[0].Weight = 0;
            list[1].Weight = 0;
            list[2].Weight = 0;

            Console.WriteLine("TESTTTT");

            foreach (var v in list)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            Console.WriteLine("CLONE");

            foreach (var v in list2)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
        }