public EnvironmentLightingPalette Lerp(WeatherPreset weather, bool presetA, float t) { EnvironmentLightingTimesOfDay cur_time = null; switch (weather) { case WeatherPreset.Default: cur_time = Clear; break; case WeatherPreset.Raining: cur_time = Raining; break; case WeatherPreset.Snowing: cur_time = Snowing; break; case WeatherPreset.Unknown2: cur_time = ForestParticles; break; default: return(null); } return(cur_time.Lerp(t)); }
public static void load(Arg args) { if (!SingletonComponent <Climate> .Instance) { return; } string name = args.GetString(0); if (string.IsNullOrEmpty(name)) { args.ReplyWith("Weather preset name invalid."); return; } WeatherPreset weatherPreset = Array.Find(SingletonComponent <Climate> .Instance.WeatherPresets, (WeatherPreset x) => x.name.Contains(name, CompareOptions.IgnoreCase)); if (weatherPreset == null) { args.ReplyWith("Weather preset not found: " + name); return; } SingletonComponent <Climate> .Instance.WeatherOverrides.Set(weatherPreset); if (args.IsServerside) { ServerMgr.SendReplicatedVars("weather."); } }
private IEnumerator LerpWeather(WeatherPreset weatherPreset, float duration) { Light directionLight = GameObject.Find("Directional Light").GetComponent <Light>(); RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat; Quaternion directionLightRotation = directionLight.transform.rotation; Color directionLightColor = directionLight.color; float directionLightIntensity = directionLight.intensity; float directionLightShadowStrength = directionLight.shadowStrength; Color backgroundColor = Camera.main.backgroundColor; Color ambientLight = RenderSettings.ambientLight; float startTime = Time.time; while (Time.time - startTime < duration) { float timePassed = (Time.time - startTime) / duration; directionLight.transform.rotation = Quaternion.Slerp(directionLightRotation, Quaternion.Euler(weatherPreset.lightDirection), timePassed); directionLight.color = Color.Lerp(directionLightColor, weatherPreset.lightColor, timePassed); directionLight.intensity = Mathf.Lerp(directionLightIntensity, weatherPreset.lightIntensity, timePassed); directionLight.shadowStrength = Mathf.Lerp(directionLightShadowStrength, weatherPreset.shadowStrength, timePassed); Camera.main.backgroundColor = Color.Lerp(backgroundColor, weatherPreset.backgroundColor, timePassed); Shader.SetGlobalColor(Shader.PropertyToID("_BackgroundColor"), Camera.main.backgroundColor.linear); RenderSettings.ambientLight = Color.Lerp(ambientLight, weatherPreset.ambientLighting, timePassed); yield return(null); } directionLight.transform.rotation = Quaternion.Euler(weatherPreset.lightDirection); directionLight.color = weatherPreset.lightColor; directionLight.intensity = weatherPreset.lightIntensity; directionLight.shadowStrength = weatherPreset.shadowStrength; Camera.main.backgroundColor = weatherPreset.backgroundColor; Shader.SetGlobalColor(Shader.PropertyToID("_BackgroundColor"), Camera.main.backgroundColor.linear); RenderSettings.ambientLight = weatherPreset.ambientLighting; }
public LegacyWeatherState(WeatherPreset preset) { this.preset = preset; }
public LightingPalette Lerp(WeatherPreset weather, bool presetA, float t) { LightingTimePreset[] timePreset = presetA ? WeatherA : WeatherB; return(timePreset[(int)weather].Lerp(t, presetA)); }