/// <summary> /// This method is called when the class has been added as a listener, and something has changed /// one of the WAPI settings. /// /// Use the HasChanged method to work out what was changed and respond accordingly. /// /// NOTE : As the majority of the World API values are properties, setting something /// is as easy as reading its value, and setting a property will cause another /// OnWorldChanged event to be raised. /// /// </summary> /// <param name="args"></param> public void OnWorldChanged(WorldChangeArgs args) { if (WeatherMakerScript.Instance == null) { return; } WorldManager m = args.manager; if (args.HasChanged(WorldConstants.WorldChangeEvents.CloudsChanged)) { WeatherMakerFullScreenCloudsScript s = WeatherMakerFullScreenCloudsScript.Instance; if (s != null && s.CloudProfile != null) { s.CloudProfile.CloudHeight.LastValue = m.CloudMinHeight; s.CloudProfile.CloudHeightTop.LastValue = m.CloudMaxHeight; if (s.CloudProfile.CloudLayerVolumetric1 != null && WeatherMakerScript.Instance.PerformanceProfile.EnableVolumetricClouds) { s.CloudProfile.WeatherMapCloudCoverageVelocity = CloudDirection * m.CloudSpeed; s.CloudProfile.CloudLayerVolumetric1.CloudCover = new RangeOfFloats { Minimum = m.CloudPower, Maximum = m.CloudPower }; } } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.FogChanged)) { WeatherMakerFullScreenFogScript s = WeatherMakerFullScreenFogScript.Instance; if (s != null && s.FogProfile != null) { s.FogProfile.FogEndDepth = m.FogDistanceMax; s.FogProfile.FogDensity = m.FogDistancePower; s.FogProfile.FogHeight = m.FogHeightMax; s.FogProfile.FogHeightFalloffPower = m.FogHeightPower; } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.HailChanged)) { WeatherMakerPrecipitationManagerScript p = WeatherMakerScript.Instance.PrecipitationManager as WeatherMakerPrecipitationManagerScript; if (p != null) { p.HailScript.Intensity = m.HailPower; } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.LatLngChanged)) { WeatherMakerDayNightCycleManagerScript d = WeatherMakerDayNightCycleManagerScript.Instance; if (d != null) { d.Latitude = m.Latitude; d.Longitude = m.Longitude; } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.RainChanged)) { WeatherMakerPrecipitationManagerScript p = WeatherMakerScript.Instance.PrecipitationManager as WeatherMakerPrecipitationManagerScript; if (p != null) { p.RainScript.Intensity = m.RainPower; } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.SeaChanged)) { } else if (args.HasChanged(WorldConstants.WorldChangeEvents.SnowChanged)) { WeatherMakerPrecipitationManagerScript p = WeatherMakerScript.Instance.PrecipitationManager as WeatherMakerPrecipitationManagerScript; if (p != null) { p.SnowScript.Intensity = m.SnowPower; } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.TempAndHumidityChanged)) { } else if (args.HasChanged(WorldConstants.WorldChangeEvents.ThunderChanged)) { WeatherMakerThunderAndLightningManagerScript t = WeatherMakerThunderAndLightningManagerScript.Instance; if (t != null) { t.ThunderAndLightningScript.LightningIntenseProbability = m.ThunderPower * 0.5f; t.ThunderAndLightningScript.LightningIntervalTimeRange = new RangeOfFloats { Minimum = Mathf.Lerp(5.0f, 30.0f, m.ThunderPower), Maximum = Mathf.Lerp(10.0f, 120.0f, m.ThunderPower) }; } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.VolumeChanged)) { WeatherMakerAudioManagerScript a = WeatherMakerAudioManagerScript.Instance; if (a != null) { a.WeatherVolumeModifier = m.VolumeWeather; a.AmbientVolumeModifier = m.VolumeEnvironment; } } else if (args.HasChanged(WorldConstants.WorldChangeEvents.WindChanged)) { WeatherMakerWindManagerScript w = WeatherMakerWindManagerScript.Instance; if (w != null) { w.WindScript.WindIntensity = m.WindSpeed; w.WindScript.WindProfile.WindTurbulenceRange = new RangeOfFloats { Minimum = m.WindTurbulence, Maximum = m.WindTurbulence }; w.WindScript.WindProfile.WindMaximumChangeRotation = new RangeOfFloats(); w.WindScript.transform.rotation = Quaternion.AngleAxis(m.WindDirection, Vector3.up); } } }