internal static bool TestForSpecialWeather(WeatherConditions curr, FerngillClimateTimeSpan ClimateForDay) { bool specialWeatherTriggered = false; // Conditions: Blizzard - occurs in weather_snow in "winter" // Dry Lightning - occurs if it's sunny in any season if temps exceed 25C. // Frost and Heatwave check against the configuration. // Thundersnow - as Blizzard, but really rare. Will not happen in fog, may happen in Blizzard/WhiteOut // Sandstorm - windy, with no precip for several days. Spring-Fall only, highest chance in summer. // Fog - per climate, although night fog in winter is double normal chance curr.GenerateEveningFog = (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.EveningFogChance * ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth)) && !curr.GetCurrentConditions().HasFlag(CurrentWeather.Wind); bool blockFog = ClimatesOfFerngill.MoonAPI != null && ClimatesOfFerngill.MoonAPI.IsSolarEclipse(); if (blockFog || ClimatesOfFerngill.WeatherOpt.DisableAllFog) { curr.GenerateEveningFog = false; } double fogRoll = (ClimatesOfFerngill.WeatherOpt.DisableAllFog ? 1.1 : ClimatesOfFerngill.Dice.NextDoublePositive()); if (fogRoll < ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth) && !curr.GetCurrentConditions().HasFlag(CurrentWeather.Wind) && !blockFog) { curr.CreateWeather("Fog"); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"{curr.FogDescription(fogRoll, ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth))}"); } specialWeatherTriggered = true; } //set special temps before we check for the results of them if (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.HeatwaveChance) { SetHotwave(); } else if (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.ChillwaveChance) { SetChillWave(); } //do these here //20190626 - Thanks to Crops Anywhere, I have to add this if ((curr.TodayLow < ClimatesOfFerngill.WeatherOpt.TooColdOutside && !Game1.IsWinter) || (curr.TodayLow < ClimatesOfFerngill.WeatherOpt.TooColdOutside && Game1.IsWinter && ClimatesOfFerngill.WeatherOpt.ApplyFrostsInWinter)) { if (ClimatesOfFerngill.WeatherOpt.HazardousWeather) { curr.AddWeather(CurrentWeather.Frost); specialWeatherTriggered = true; } } //test for spring conversion if (curr.HasWeather(CurrentWeather.Rain) && curr.HasWeather(CurrentWeather.Frost) && (Game1.currentSeason == "spring" || Game1.currentSeason == "fall") && ClimatesOfFerngill.Dice.NextDoublePositive() <= ClimatesOfFerngill.WeatherOpt.RainToSnowConversion) { curr.RemoveWeather(CurrentWeather.Rain); if (curr.HasWeather(CurrentWeather.Lightning)) { curr.RemoveWeather(CurrentWeather.Lightning); Game1.isLightning = false; } curr.AddWeather(CurrentWeather.Snow); Game1.isRaining = false; Game1.isSnowing = true; specialWeatherTriggered = true; } if (curr.HasWeather(CurrentWeather.Snow)) { double blizRoll = ClimatesOfFerngill.Dice.NextDoublePositive(); double blizOdds = ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "blizzard", Game1.dayOfMonth); if (blizRoll <= blizOdds) { curr.CreateWeather("Blizzard"); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {blizRoll:N3} against {blizOdds}, there will be blizzards today"); } if (ClimatesOfFerngill.Dice.NextDoublePositive() < ClimatesOfFerngill.WeatherOpt.WhiteOutChances && ClimatesOfFerngill.WeatherOpt.HazardousWeather) { curr.CreateWeather("WhiteOut"); } } specialWeatherTriggered = true; } //Dry Lightning is also here for such like the dry and arid climates // which have so low rain chances they may never storm. if (curr.HasWeather(CurrentWeather.Snow)) { double oddsRoll = ClimatesOfFerngill.Dice.NextDoublePositive(); double thunderSnowOdds = ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "storm", Game1.dayOfMonth); if (oddsRoll <= thunderSnowOdds && !curr.HasWeather(CurrentWeather.Fog)) { curr.AddWeather(CurrentWeather.Lightning); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {thunderSnowOdds}, there will be thundersnow today"); } specialWeatherTriggered = true; } } if (!(curr.HasPrecip())) { double oddsRoll = ClimatesOfFerngill.Dice.NextDoublePositive(); if (oddsRoll <= ClimatesOfFerngill.WeatherOpt.DryLightning && curr.TodayHigh >= ClimatesOfFerngill.WeatherOpt.DryLightningMinTemp && !curr.HasWeather(CurrentWeather.Frost)) { curr.AddWeather(CurrentWeather.Lightning); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {ClimatesOfFerngill.WeatherOpt.DryLightning}, there will be dry lightning today."); } specialWeatherTriggered = true; } if (curr.TodayHigh > ClimatesOfFerngill.WeatherOpt.TooHotOutside && ClimatesOfFerngill.WeatherOpt.HazardousWeather) { curr.AddWeather(CurrentWeather.Heatwave); specialWeatherTriggered = true; } double sandstormOdds = .18; if (Game1.currentSeason == "summer") { sandstormOdds *= 1.2; } if (oddsRoll < sandstormOdds && ClimatesOfFerngill.WeatherOpt.HazardousWeather && Game1.isDebrisWeather) { curr.AddWeather(CurrentWeather.Sandstorm); specialWeatherTriggered = true; curr.CreateWeather("Sandstorm"); Game1.populateDebrisWeatherArray(); //repopulate for sandstorm weather //code here to set wind conditions for heavy! SetWindToHeavy(); } } //and finally, test for thunder frenzy if (curr.HasWeather(CurrentWeather.Lightning) && curr.HasWeather(CurrentWeather.Rain) && ClimatesOfFerngill.WeatherOpt.HazardousWeather) { double oddsRoll = ClimatesOfFerngill.Dice.NextDouble(); if (oddsRoll < ClimatesOfFerngill.WeatherOpt.ThunderFrenzyOdds) { curr.AddWeather(CurrentWeather.ThunderFrenzy); specialWeatherTriggered = true; if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {ClimatesOfFerngill.WeatherOpt.ThunderFrenzyOdds}, there will be a thunder frenzy today"); } curr.CreateWeather("ThunderFrenzy"); } } return(specialWeatherTriggered); }
private void UpdateWeatherOnNewDay() { if (!Context.IsMainPlayer) { return; } if (Game1.dayOfMonth == 0) //do not run on day 0. { return; } int loopCount = 0; //Set Temperature for today and tommorow. Get today's conditions. // If tomorrow is set, move it to today, and autoregen tomorrow. // *201711 Due to changes in the object, it auto attempts to update today from tomorrow. if (!Conditions.IsTodayTempSet) { if (!Conditions.IsTomorrowTempSet) { Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice)); if (Game1.weatherForTomorrow == Game1.weather_snow) { while (!WeatherConditions.IsValidWeatherForSnow(Conditions.GetTodayTemps()) && loopCount <= 1000) { Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice)); loopCount++; } } } else { Conditions.SetTodayTempsFromTomorrow(); } Conditions.SetTomorrowTemps(GameClimate.GetTemperatures(SDate.Now().AddDays(1), Dice)); } if (WeatherOpt.Verbose) { Monitor.Log($"Updated the temperature for tommorow and today. Setting weather for today... ", LogLevel.Trace); } //if today is a festival or wedding, do not go further. if (Conditions.GetCurrentConditions().HasAnyFlags(CurrentWeather.Festival | CurrentWeather.Wedding)) { if (WeatherOpt.Verbose) { Monitor.Log("It is a wedding or festival today. Not attempting to run special weather or fog."); } return; } //variable rain conditions WeatherProcessing.DynamicRainOnNewDay(Conditions, Dice); if (!Conditions.IsVariableRain) { WeatherProcessing.CheckForStaticRainChanges(Conditions, Dice, GameClimate.ChanceForNonNormalRain); } if (WeatherProcessing.TestForSpecialWeather(Conditions, GameClimate.GetClimateForDate(SDate.Now()))) { if (WeatherOpt.Verbose) { Monitor.Log("Special weather created!"); } Conditions.UpdateClimateTracker(); } }
public string GetCurrentWeatherName() { return(CurrentConditions.Weathers[(int)CurrentConditions.GetCurrentConditions()].ConditionName); }
/// <summary>Render the UI.</summary> /// <param name="spriteBatch">The sprite batch being drawn.</param> public override void draw(SpriteBatch spriteBatch) { // disable when game is using immediate sprite sorting if (!ValidatedDrawMode) { IReflectedField <SpriteSortMode> sortModeField = Reflection.GetField <SpriteSortMode>(Game1.spriteBatch, "spriteSortMode", required: false) // XNA ?? Reflection.GetField <SpriteSortMode>(Game1.spriteBatch, "_sortMode"); // MonoGame if (sortModeField.GetValue() == SpriteSortMode.Immediate) { Monitor.Log("Aborted the weather draw because the game's current rendering mode isn't compatible with the mod's UI. This only happens in rare cases (e.g. the Stardew Valley Fair).", LogLevel.Warn); exitThisMenu(playSound: false); return; } ValidatedDrawMode = true; } // calculate dimensions int x = xPositionOnScreen; int y = yPositionOnScreen; const int gutter = 15; float leftOffset = gutter; float topOffset = gutter; float contentWidth = width - gutter * 2; float contentHeight = height - gutter * 2; // get font SpriteFont font = Game1.smallFont; float lineHeight = font.MeasureString("ABC").Y; //at this point I'm going to manually put this in as I don't need in many places, // and I kinda want to have this where I can understand what it's for float spaceWidth = DrawHelper.GetSpaceWidth(font); // draw background // (This uses a separate sprite batch because it needs to be drawn before the // foreground batch, and we can't use the foreground batch because the background is // outside the clipping area.) spriteBatch.DrawSprite(Sprites.Letter.Sheet, Sprites.Letter.Sprite, x, y, scale: width / (float)Sprites.Letter.Sprite.Width); // begin draw // draw weather icon spriteBatch.Draw(IconSheet.WeatherSource, new Vector2(x + leftOffset, y + topOffset), IconSheet.GetWeatherSprite(CurrentWeather.GetCurrentConditions()), Color.White); leftOffset += 72; // draw text as sent from outside the menu float wrapWidth = width - leftOffset - gutter; { Vector2 textSize = spriteBatch.DrawTextBlock(font, MenuText, new Vector2(x + leftOffset, y + topOffset), wrapWidth); topOffset += textSize.Y; topOffset += lineHeight; } drawMouse(Game1.spriteBatch); }