/// <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="changeArgs"></param> public void OnWorldChanged(WorldChangeArgs changeArgs) { if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.SnowChanged) || changeArgs.HasChanged(WorldConstants.WorldChangeEvents.SeasonChanged)) { GlobalSnow.instance.minimumAltitude = WorldManager.Instance.SnowMinHeight + 125f * (2f - Mathf.Abs(2f - WorldManager.Instance.Season)); GlobalSnow.instance.UpdateSnowfallProperties(); } }
/// <summary> /// Handle updates from world api /// </summary> /// <param name="changeArgs">Change arguements</param> public void OnWorldChanged(WorldChangeArgs changeArgs) { if (m_weatherManager == null) { m_weatherManager = GetComponent <CTSWeatherManager>(); } if (m_updateSnow && changeArgs.HasChanged(WorldConstants.WorldChangeEvents.SnowChanged)) { m_weatherManager.SnowPower = WorldManager.Instance.SnowPowerTerrain; m_weatherManager.SnowMinHeight = WorldManager.Instance.SnowMinHeight; } if (m_updateWetness && changeArgs.HasChanged(WorldConstants.WorldChangeEvents.RainChanged)) { m_weatherManager.RainPower = WorldManager.Instance.RainPowerTerrain; } if (m_updateSeasons && changeArgs.HasChanged(WorldConstants.WorldChangeEvents.SeasonChanged)) { m_weatherManager.Season = WorldManager.Instance.Season; } }
/// <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="changeArgs"></param> public void OnWorldChanged(WorldChangeArgs changeArgs) { if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.FogChanged)) { WorldManager wm = WorldManager.Instance; VolumetricFog.instance.height = wm.FogHeightMax; VolumetricFog.instance.maxFogLength = wm.FogDistanceMax; VolumetricFog.instance.maxFogLengthFallOff = wm.FogDistancePower; VolumetricFog.instance.windDirection = wm.WindSpeed * new Vector3(Mathf.Cos(wm.WindDirection * Mathf.Deg2Rad), 0, Mathf.Sin(wm.WindDirection * Mathf.Deg2Rad)); VolumetricFog.instance.turbulenceStrength = wm.WindTurbulence; } }
/// <summary> /// Handle updates from world manager /// </summary> /// <param name="changeArgs">Change to time of day</param> public void OnWorldChanged(WorldChangeArgs changeArgs) { if (EnviroSkyMgr.instance == null || !EnviroSkyMgr.instance.IsAvailable()) { return; } // Get Time from WAPI if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.GameTimeChanged) && time == GetSet.GetFromWAPI) { float newTimeOfDay = (float)changeArgs.manager.GetTimeDecimal(); if (newTimeOfDay != timeOfDay) { timeOfDay = newTimeOfDay; EnviroSkyMgr.instance.SetTimeOfDay(timeOfDay); } } //Get Season from WAPI if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.SeasonChanged) && seasons == GetSet.GetFromWAPI) { if (WorldManager.Instance.Season < 1f) { EnviroSkyMgr.instance.ChangeSeason(EnviroSeasons.Seasons.Winter); } else if (WorldManager.Instance.Season < 2f) { EnviroSkyMgr.instance.ChangeSeason(EnviroSeasons.Seasons.Spring); } else if (WorldManager.Instance.Season < 3f) { EnviroSkyMgr.instance.ChangeSeason(EnviroSeasons.Seasons.Summer); } else { EnviroSkyMgr.instance.ChangeSeason(EnviroSeasons.Seasons.Autumn); } } // Set Lat/Lng from WAPI if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.LatLngChanged) && location == GetSet.GetFromWAPI) { EnviroSkyMgr.instance.Time.Latitude = WorldManager.Instance.Latitude; EnviroSkyMgr.instance.Time.Longitude = WorldManager.Instance.Longitude; } // Set Distance and Height Fog from WAPI if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.FogChanged) && fogPower == GetSet.GetFromWAPI) { EnviroSkyMgr.instance.FogSettings.distanceFogIntensity = WorldManager.Instance.FogDistancePower * 10f; EnviroSkyMgr.instance.FogSettings.heightFogIntensity = WorldManager.Instance.FogHeightPower; EnviroSkyMgr.instance.FogSettings.height = WorldManager.Instance.FogHeightMax; } // Change Weather Based on WAPI Rain and Snow if (Application.isPlaying && EnviroSkyMgr.instance.Weather.currentActiveWeatherPreset != null) { // Cloudy if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.CloudsChanged) && cloudCover == GetSet.GetFromWAPI) { ChangeWeatherOnCloudCoverChanged(); } //Rain if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.RainChanged) && wetnessPower == GetSet.GetFromWAPI) { ChangeWeatherOnRainChanged(WorldManager.Instance.RainPower, WorldManager.Instance.SnowPower); } //Snow if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.SnowChanged) && snowPower == GetSet.GetFromWAPI) { ChangeWeatherOnSnowChanged(WorldManager.Instance.RainPower, WorldManager.Instance.SnowPower); } } }
/// <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); } } }