private float GetWeatherThresholdMultiplier(WeatherDefinition.Preferences weatherPreferences, string overrideKeyMatchCase) { if (weatherPreferences == null || string.IsNullOrEmpty(overrideKeyMatchCase)) { return(1f); } WeatherDefinition.Preferences.PreferencesOverride[] overrides = weatherPreferences.Overrides; if (overrides != null && overrides.Length > 0) { for (int i = 0; i < overrides.Length; i++) { string overrideKey = overrides[i].OverrideKey; if (!string.IsNullOrEmpty(overrideKey) && overrideKey.Equals(overrideKeyMatchCase)) { return(overrides[i].ThresholdMultiplier); } } } return(1f); }
private void RunGenerationForWeather(WeatherDefinition weatherDefinition, int seed, string presetName) { string currentSeasonType; if (!string.IsNullOrEmpty(presetName)) { currentSeasonType = presetName; } else { currentSeasonType = this.seasonService.GetCurrentSeason().SeasonDefinition.SeasonType; } if (string.IsNullOrEmpty(currentSeasonType)) { Diagnostics.LogError("currentSeasonType can't be null or empty"); return; } WeatherDefinition.Preferences preferences = weatherDefinition.GameSettingsPreferences.First((WeatherDefinition.Preferences pref) => pref.SeasonType == currentSeasonType && pref.GameDifficulty == this.weatherDifficulty); if (preferences == null) { Diagnostics.LogWarning("No preferences were found corresponding to season type and game difficulty"); return; } float num = preferences.Threshold; WeatherDefinition.Preferences.PreferencesOverride[] overrides = preferences.Overrides; if (overrides != null && overrides.Length > 0) { string seasonIntensityName = this.seasonService.GetSeasonIntensityName(); if (!string.IsNullOrEmpty(seasonIntensityName)) { num *= this.GetWeatherThresholdMultiplier(preferences, seasonIntensityName); } } if (num > 1f || preferences.Priority <= 0f) { return; } NoiseHelper.BufferGenerationData bufferGenerationData = preferences.BufferGenerationData; NoiseHelper.ApplyRandomOffsetToBufferGenerationData(seed, ref bufferGenerationData); Vector2 mapSize = new Vector2((float)this.weatherMap.Width, (float)this.weatherMap.Height); for (int i = 0; i < this.weatherMap.Height; i++) { for (int j = 0; j < this.weatherMap.Width; j++) { Vector2 uv = new Vector2((float)j / mapSize.x, (float)i / mapSize.y); float num2 = NoiseHelper.GetNoiseCyclicMap(uv, bufferGenerationData, mapSize); if (num2 >= num) { num2 *= preferences.Priority; if (weatherDefinition.AffectedByWind) { if (num2 > this.tempData.GetValue(i, j)) { this.tempData.SetValue(i, j, num2); this.weatherMap.SetValue(i, j, (byte)weatherDefinition.Value); } } else if (num2 > this.staticTempData.GetValue(i, j)) { this.staticTempData.SetValue(i, j, num2); this.staticWeatherMap.SetValue(i, j, (byte)weatherDefinition.Value); } } } } }