private void TryToSetWeather() {
if (SelectedWeatherType == WeatherType.None) return;
try {
var candidates = WeatherManager.Instance.LoadedOnly.Where(x => x.Enabled && x.TemperatureDiapason?.DiapasonContains(Temperature) != false
&& x.TimeDiapason?.TimeDiapasonContains(Time) != false).ToList();
var closest = WeatherDescription.FindClosestWeather(from w in candidates select w.Type, SelectedWeatherType);
if (closest == null) {
IsWeatherNotSupported = true;
} else {
candidates = candidates.Where(x => x.Type == closest).ToList();
var footprint = candidates.Select(x => x.Id).JoinToString(';');
if (footprint != _weatherCandidatesFootprint || !candidates.Contains(SelectedWeather)) {
SelectedWeather = candidates.RandomElement();
_weatherCandidatesFootprint = footprint;
}
IsWeatherNotSupported = false;
}
} catch (Exception e) {
IsWeatherNotSupported = true;
Logging.Warning("TryToSetWeatherType(): " + e);
}
}