예제 #1
0
        /// <summary>
        /// Perform new day tasks, including:
        /// - refresh TV channel data
        /// - reset UV data and lotion data
        /// - obtain and update sunburn severity level
        /// - lose start of day health and energy if sunburnt
        /// - display a message if sunburnt or newly healed
        /// </summary>
        private void DoNewDayStuff()
        {
            if (Config.DebugMode)
            {
                Monitor.Log("Doing new day stuff.", LogLevel.Info);
            }
            Helper.Content.InvalidateCache("Strings\\StringsFromCSFiles"); //Refresh TV weather info

            TotalUVExposure = 0;

            Lotion.HasAppliedAloeToday = false;
            Sunscreen.RemoveSunscreen();

            int initialLevel = Burn.SunburnLevel; //Yesterday's sunburn severity level

            Burn.UpdateForNewDay();               //Includes a message about taking new damage or sunburn improving

            int    burnLevel = Burn.SunburnLevel;
            Farmer who       = Game1.player;

            //if has sunburn damage
            if (burnLevel > 0)
            {
                who.health  -= Config.HealthLossPerLevel * burnLevel; //Lose health at the start of a day
                who.Stamina -= Config.EnergyLossPerLevel * burnLevel; //Lose energy at the start of a day
                Monitor.Log($"New day: Lost {Config.HealthLossPerLevel * burnLevel} health " +
                            $"and {Config.EnergyLossPerLevel * burnLevel} energy " +
                            $"due to sunburn damage.", LogLevel.Debug);
            }
            //if has sunburn, or healed existing sunburn from yesterday
            if (burnLevel > 0 || (initialLevel != burnLevel && burnLevel == 0))
            {
                Burn.DisplaySunburnStatus();                                                                 //Info: new sunburn or newly healed
            }
            if (Config.DebugMode)
            {
                Monitor.Log($"Current health: {who.health}/{who.maxHealth} | Current stamina: {who.Stamina}/{who.MaxStamina}", LogLevel.Info);
            }

            RemoveFlag("NewDay");
        }
예제 #2
0
        /// <summary>Apply aloe vera gel to the specified player, reducing burn level and healing accordingly with an HUD message.</summary>
        /// <param name="who">The player to be treated with aloe gel</param>
        public void ApplyAloeGel(Farmer who = null)
        {
            who = who ?? Game1.player;
            Sunburn burn = ModEntry.Instance.Burn;

            int initialLevel = burn.SunburnLevel;

            //apply the gel's effects
            burn.SunburnLevel -= 1;

            //if the gel had an effect
            if (initialLevel != burn.SunburnLevel)
            {
                who.health   = Math.Min(who.maxHealth, who.health + Config.HealthLossPerLevel);
                who.Stamina += (float)Config.EnergyLossPerLevel;
                if (Config.DebugMode)
                {
                    Monitor.Log($"Current health: {who.health}/{who.maxHealth} | Current stamina: {who.Stamina}/{who.MaxStamina}", LogLevel.Info);
                }

                Item   gel         = Game1.player.ActiveObject;
                string messagetext = i18n.Get("Apply.AloeGel", new { lotionName = gel.DisplayName });
                Game1.addHUDMessage(new HUDMessage(messagetext, 4)); //stamina_type HUD message
                Monitor.Log($"Applied aloe gel: {messagetext}", LogLevel.Info);

                burn.DisplaySunburnStatus(); //Info: new sunburn level, or healed if healed
            }
            else
            {
                string messagetext = i18n.Get("Apply.AloeNoEffect");
                Game1.addHUDMessage(new HUDMessage(messagetext, 2)); //Exclamation mark message type
                Monitor.Log($"Applied aloe gel: {messagetext}", LogLevel.Info);
            }

            //TODO: make skin briefly green????

            //Prevent using aloe again today
            HasAppliedAloeToday = true;
        }