/// <summary>Returns the time when the applied sunscreen will wear off.</summary> SDVTime GetExpiryTime() { if (TimeOfApplication == null) { return(null); } SDVTime expiry = new SDVTime(TimeOfApplication); expiry.AddMinutes(SDVTime.MINPERHR * Config.SunscreenDuration); return(expiry); }
/// <summary>Check if new suncreen was applied within the last 30 minutes.</summary> public bool AppliedSunscreenRecently() { SDVTime now = SDVTime.CurrentTime; SDVTime last30Mins = new SDVTime(now); last30Mins.AddMinutes(-30); if (IsProtected() && TimeOfApplication > last30Mins) { return(true); } return(false); }
/// <summary>Calculates immediate UV intensity for the current date at a given time.</summary> /// <param name="time">Time of day to calculate for</param> /// <returns>UV intensity at time of day</returns> public static int UVIntensityAt(SDVTime time) { if (!Context.IsWorldReady) { throw new Exception("Couldn't get date and time as no save is loaded."); //Ignore before a save is loaded. } int today = SDate.Now().DaysSinceStart; int todaysWeather = Game1.weather_sunny; if (Game1.isDebrisWeather) { todaysWeather = Game1.weather_debris; } if (Game1.isRaining) { todaysWeather = Game1.weather_rain; } if (Game1.isLightning) { todaysWeather = Game1.weather_lightning; } if (Game1.isSnowing) { todaysWeather = Game1.weather_snow; } int todayMaxUV = DailyMaxUV(today, todaysWeather); SDVTime solarNoon = new SDVTime(SOLAR_NOON); SDVTime sunset = new SDVTime(Game1.getTrulyDarkTime()); int halfCycleMinutes = SDVTime.ConvertTimeToMinutes(sunset - solarNoon); int solarNoonMinutes = SDVTime.ConvertTimeToMinutes(solarNoon); int timeMinutes = SDVTime.ConvertTimeToMinutes(time); SDVTime sunrise = new SDVTime(solarNoon); sunrise.AddMinutes(-1 * halfCycleMinutes); if (time <= sunrise || time >= sunset) { return(0); } else { double ampitude = todayMaxUV / 2; double UV = ampitude * Math.Cos(Math.PI / halfCycleMinutes * (timeMinutes - solarNoonMinutes)) + ampitude; return(Convert.ToInt32(UV)); } }