internal static HUDMessage HandleOnSaving(WeatherConditions Conditions, MersenneTwister Dice) { if (Conditions.HasWeather(CurrentWeather.Frost) && ClimatesOfFerngill.WeatherOpt.AllowCropDeath) { Farm f = Game1.getFarm(); int count = 0, maxCrops = (int)Math.Floor(SDVUtilities.CropCountInFarm(f) * ClimatesOfFerngill.WeatherOpt.DeadCropPercentage); foreach (KeyValuePair <Vector2, TerrainFeature> tf in f.terrainFeatures.Pairs) { if (count >= maxCrops) { break; } if (tf.Value is HoeDirt curr && curr.crop != null) { Crop test = new Crop(curr.crop.indexOfHarvest.Value, 0, 0); if (Dice.NextDouble() > ClimatesOfFerngill.WeatherOpt.CropResistance && (!test.seasonsToGrowIn.Contains("winter") || !SDVUtilities.IsWinterForageable(test.indexOfHarvest.Value))) { CropList.Add(tf.Key); count++; } } } if (count > 0) { foreach (Vector2 v in CropList) { HoeDirt hd = (HoeDirt)f.terrainFeatures[v]; hd.crop.dead.Value = true; } return(new HUDMessage( ClimatesOfFerngill.Translator.Get("hud-text.desc_frost_killed", new { deadCrops = count }), Color.SeaGreen, 5250f, true) { whatType = 2 }); } } return(null); }