private static void ProcessScripts(WeatherObject weather, IniFile file, int?customTime = null) { if (customTime.HasValue) { file = file.Clone(); file["LIGHTING"].Set("SUN_ANGLE", Game.ConditionProperties.GetSunAngle(customTime.Value)); } WeatherProceduralContext context = null; WeatherProceduralContext GetContext() { return(context ?? (context = new WeatherProceduralContext(file, weather.Location))); } var destination = customTime.HasValue ? Path.Combine(weather.Location, @"__special", customTime.Value.ToString()) : null; ProcessFile(weather, GetContext, @"weather.ini", new[] { @"CLOUDS", @"FOG", @"CAR_LIGHTS", @"__CLOUDS_TEXTURES", @"__CUSTOM_LIGHTING" }, (table, ini) => { var customClouds = table[@"CLOUDS_TEXTURES"]; if (customClouds != null) { ini[@"__CLOUDS_TEXTURES"].Set("LIST", ToIniFileValue(customClouds)); } var extraParams = table[@"EXTRA_PARAMS"]; if (extraParams != null) { var s = new IniFileSection(null); MapOutputSection(extraParams, s); if (s.ContainsKey(@"TEMPERATURE_COEFF")) { ini[@"LAUNCHER"].Set("TEMPERATURE_COEFF", s.GetNonEmpty("TEMPERATURE_COEFF")); } if (s.ContainsKey(@"DISABLE_SHADOWS")) { ini[@"__LAUNCHER_CM"].Set("DISABLE_SHADOWS", s.GetNonEmpty("DISABLE_SHADOWS")); } if (s.ContainsKey(@"SKYBOX_REFLECTION_GAIN")) { ini[@"__LAUNCHER_CM"].Set("SKYBOX_REFLECTION_GAIN", s.GetNonEmpty("SKYBOX_REFLECTION_GAIN")); } } MapOutputSection(table[@"LAUNCHER"], ini[@"LAUNCHER"], "TEMPERATURE_COEFF"); MapOutputSection(table[@"__LAUNCHER_CM"], ini[@"__LAUNCHER_CM"], "DISABLE_SHADOWS", "SKYBOX_REFLECTION_GAIN"); MapOutputSection(table[@"CUSTOM_LIGHTING"], ini[@"__CUSTOM_LIGHTING"]); }, destination); ProcessFile(weather, GetContext, @"colorCurves.ini", new[] { @"HEADER", @"HORIZON", @"SKY", @"SUN", @"AMBIENT" }, null, destination); ProcessFile(weather, GetContext, @"filter.ini", new[] { @"YEBIS", @"OPTIMIZATIONS", @"VARIOUS", @"AUTO_EXPOSURE", @"GODRAYS", @"HEAT_SHIMMER", @"TONEMAPPING", @"DOF", @"CHROMATIC_ABERRATION", @"FEEDBACK", @"VIGNETTING", @"DIAPHRAGM", @"AIRYDISC", @"GLARE", @"LENSDISTORTION", @"ANTIALIAS", @"COLOR" }, null, destination); ProcessFile(weather, GetContext, @"tyre_smoke.ini", new[] { @"SETTINGS", @"TRIGGERS" }, null, destination); ProcessFile(weather, GetContext, @"tyre_smoke_grass.ini", new[] { @"SETTINGS" }, null, destination); ProcessFile(weather, GetContext, @"tyre_pieces_grass.ini", new[] { @"SETTINGS" }, null, destination); ProcessFile(weather, GetContext, @"track_state.ini", new[] { @"TRACK_STATE" }, null, destination); }
private bool FixShadowMapBias(IniFileSection section) { var result = false; if (!section.ContainsKey("SHADOW_MAP_BIAS_0")) { result = true; section.Set("SHADOW_MAP_BIAS_0", "0.000002"); } if (!section.ContainsKey("SHADOW_MAP_BIAS_1")) { result = true; section.Set("SHADOW_MAP_BIAS_1", "0.000015"); } if (!section.ContainsKey("SHADOW_MAP_BIAS_2")) { result = true; section.Set("SHADOW_MAP_BIAS_2", "0.0003"); } return result; }
private bool FixShadowMapBias(IniFileSection section) { var result = false; if (!section.ContainsKey("SHADOW_MAP_BIAS_0")) { result = true; section.Set("SHADOW_MAP_BIAS_0", "0.000002"); } if (!section.ContainsKey("SHADOW_MAP_BIAS_1")) { result = true; section.Set("SHADOW_MAP_BIAS_1", "0.000015"); } if (!section.ContainsKey("SHADOW_MAP_BIAS_2")) { result = true; section.Set("SHADOW_MAP_BIAS_2", "0.0003"); } return(result); }
protected override bool SetOverride(WeatherObject weather, IniFile file) { WeatherProceduralContext context = null; WeatherProceduralContext GetContext() { return(context ?? (context = new WeatherProceduralContext(file, weather.Location))); } var directory = Environment.CurrentDirectory; Environment.CurrentDirectory = AcRootDirectory.Instance.RequireValue; try { ProcessFile(weather, GetContext, @"weather.ini", new[] { @"CLOUDS", @"FOG", @"CAR_LIGHTS", @"__CLOUDS_TEXTURES", @"__CUSTOM_LIGHTING" }, (table, ini) => { var customClouds = table[@"CLOUDS_TEXTURES"]; if (customClouds != null) { ini[@"__CLOUDS_TEXTURES"].Set("LIST", ToIniFileValue(customClouds)); } var extraParams = table[@"EXTRA_PARAMS"]; if (extraParams != null) { var s = new IniFileSection(null); MapOutputSection(extraParams, s); if (s.ContainsKey(@"TEMPERATURE_COEFF")) { ini[@"LAUNCHER"].Set("TEMPERATURE_COEFF", s.GetNonEmpty("TEMPERATURE_COEFF")); } if (s.ContainsKey(@"DISABLE_SHADOWS")) { ini[@"__LAUNCHER_CM"].Set("DISABLE_SHADOWS", s.GetNonEmpty("DISABLE_SHADOWS")); } } MapOutputSection(table[@"LAUNCHER"], ini[@"LAUNCHER"], "TEMPERATURE_COEFF"); MapOutputSection(table[@"__LAUNCHER_CM"], ini[@"__LAUNCHER_CM"], "DISABLE_SHADOWS"); MapOutputSection(table[@"CUSTOM_LIGHTING"], ini[@"__CUSTOM_LIGHTING"]); }); ProcessFile(weather, GetContext, @"colorCurves.ini", new[] { @"HEADER", @"HORIZON", @"SKY", @"SUN", @"AMBIENT" }); ProcessFile(weather, GetContext, @"filter.ini", new[] { @"YEBIS", @"OPTIMIZATIONS", @"VARIOUS", @"AUTO_EXPOSURE", @"GODRAYS", @"HEAT_SHIMMER", @"TONEMAPPING", @"DOF", @"CHROMATIC_ABERRATION", @"FEEDBACK", @"VIGNETTING", @"DIAPHRAGM", @"AIRYDISC", @"GLARE", @"LENSDISTORTION", @"ANTIALIAS", @"COLOR" }); ProcessFile(weather, GetContext, @"tyre_smoke.ini", new[] { @"SETTINGS", @"TRIGGERS" }); ProcessFile(weather, GetContext, @"tyre_smoke_grass.ini", new[] { @"SETTINGS" }); if (_updateRoadTemperature) { var section = new IniFile(weather.IniFilename)["LAUNCHER"]; if (section.ContainsKey(@"TEMPERATURE_COEFF")) { file["TEMPERATURE"].Set("ROAD", Game.ConditionProperties.GetRoadTemperature( Game.ConditionProperties.GetSeconds(file["LIGHTING"].GetDouble("SUN_ANGLE", 0d)), file["TEMPERATURE"].GetDouble("AMBIENT", 20d), section.GetDouble(@"TEMPERATURE_COEFF", 0d)), "F0"); } } } catch (ScriptRuntimeException e) { NonfatalError.NotifyBackground("Can’t run weather script", $"Exception at {e.DecoratedMessage}.", e); } catch (Exception e) { NonfatalError.NotifyBackground("Can’t run weather script", e); } finally { Environment.CurrentDirectory = directory; } return(false); }