Example #1
0
        /// <summary>Calculates current UV intensity and adds that value to the damage counter.</summary>
        public void CheckForBurnDamage(SDVTime time)
        {
            //TODO? maybe check for sunscreen here
            int newDamage = UVIndex.UVIntensityAt(time);

            SunDamageCounter += newDamage;
            if (Config.DebugMode)
            {
                Monitor.Log($"New burn damage level is {NewBurnDamageLevel} | SunDamageCounter is at {SunDamageCounter}", LogLevel.Debug);
            }
        }
        /// <summary>Print the UV value (no scaling) and UV index high for a specific date (int days since start).</summary>
        /// <param name="_command">The name of the command invoked.</param>
        /// <param name="_args">The arguments received by the command. Each word after the command name is a separate argument.</param>
        private static void getUV(string _command, string[] _args)
        {
            try
            {
                int days;
                int dailyMaxUV;
                int uvIndex;

                if (_args.Length > 0)
                {
                    days = int.Parse(_args[0]);
                    SDate date = SDate.FromDaysSinceStart(days);

                    if (date == SDate.Now().AddDays(1)) //date is tomorrow, can be more accurate with weather
                    {
                        dailyMaxUV = UVIndex.DailyMaxUV(days, Game1.weatherForTomorrow);
                        uvIndex    = Convert.ToInt32((double)dailyMaxUV / 25);
                        Monitor.Log($"Tomorrow's max UV value: {dailyMaxUV} | UV Index: {uvIndex}", LogLevel.Debug);
                        return;
                    }
                    else if (date != SDate.Now()) //any other day except today
                    {
                        dailyMaxUV = UVIndex.DailyMaxUV(days);
                        uvIndex    = Convert.ToInt32((double)dailyMaxUV / 25);
                        Monitor.Log($"Forecasted max UV value (if sunny): {dailyMaxUV} | UV Index: {uvIndex}", LogLevel.Debug);
                        return;
                    }
                }
                //No date argument provided OR day provided is today
                days       = SDate.Now().DaysSinceStart;
                dailyMaxUV = UVIndex.DailyMaxUV(days, UVIndex.GetTodaysWeather());
                uvIndex    = Convert.ToInt32((double)dailyMaxUV / 25);
                Monitor.Log($"Today's max UV value: {dailyMaxUV} | UV Index: {uvIndex}", LogLevel.Debug);
            }
            catch (Exception ex)
            {
                Monitor.Log($"Command getUV failed:\n{ex}", LogLevel.Warn);
            }
        }
Example #3
0
        /// <summary>
        /// Update suncreen status and check for damage from sun exposure. Raised when the game time changes (10-minute intervals).
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void onTimeChanged(object sender, TimeChangedEventArgs e)
        {
            SDVTime time    = SDVTime.CurrentTime;
            int     UV      = UVIndex.UVIntensityAt(time);
            int     uvIndex = Convert.ToInt32((double)UV / 25);

            TotalUVExposure += UV;
            if (Config.DebugMode)
            {
                Monitor.Log($"Time is {time.Get12HourTime()} - current UV strength is {UV} or index {uvIndex}. Total exposure is {TotalUVExposure}", LogLevel.Debug);
            }

            //Possibly redundant? (Also in this.onHalfSecondUpdateTicked)
            Sunscreen.UpdateStatus(); //Checks and updates if sunscreen has worn off or washed off

            if (Config.EnableSunburn &&
                Config.SunburnPossible(SDate.Now()) && //Check config settings
                e.NewTime != e.OldTime && e.NewTime % 10 == 0 &&
                Game1.currentLocation.IsOutdoors &&
                !Sunscreen.IsProtected()) // Outdoors and not protected by sunscreen
            {
                Burn.CheckForBurnDamage(time);
            }
        }