private void WeatherUpdate() { this.nextUpdate = EnviroSky.instance.currentTimeInHours + (double)this.WeatherUpdateIntervall; this.nextUpdateRealtime = Time.get_time() + this.WeatherUpdateIntervall * 60f; this.BuildNewWeatherList(); this.lastActiveZoneWeatherPrefab = this.currentActiveZoneWeatherPrefab; this.lastActiveZoneWeatherPreset = this.currentActiveZoneWeatherPreset; this.currentActiveZoneWeatherPrefab = this.PossibiltyCheck(); this.currentActiveZoneWeatherPreset = this.currentActiveZoneWeatherPrefab.weatherPreset; EnviroSky.instance.NotifyZoneWeatherChanged(this.currentActiveZoneWeatherPreset, this); }
void WeatherUpdate() { nextUpdate = EnviroSkyMgr.instance.GetCurrentTimeInHours() + WeatherUpdateIntervall; nextUpdateRealtime = Time.time + (WeatherUpdateIntervall * 60f); BuildNewWeatherList(); lastActiveZoneWeatherPrefab = currentActiveZoneWeatherPrefab; lastActiveZoneWeatherPreset = currentActiveZoneWeatherPreset; currentActiveZoneWeatherPrefab = PossibiltyCheck(); currentActiveZoneWeatherPreset = currentActiveZoneWeatherPrefab.weatherPreset; EnviroSkyMgr.instance.NotifyZoneWeatherChanged(currentActiveZoneWeatherPreset, this); }
private void UpdateEffectSystems(EnviroWeatherPrefab id, bool withTransition) { if (id != null) { float speed = 500f * Time.deltaTime; if (withTransition) { speed = weatherSettings.effectTransitionSpeed * Time.deltaTime; } for (int i = 0; i < id.effectSystems.Count; i++) { if (id.effectSystems[i].isStopped) { id.effectSystems[i].Play(); } // Set EmissionRate float val = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(id.effectSystems[i]), id.effectEmmisionRates[i] * qualitySettings.GlobalParticleEmissionRates, speed) * interiorZoneSettings.currentInteriorWeatherEffectMod; EnviroSkyMgr.instance.SetEmissionRate(id.effectSystems[i], val); } for (int i = 0; i < Weather.WeatherPrefabs.Count; i++) { if (Weather.WeatherPrefabs[i].gameObject != id.gameObject) { for (int i2 = 0; i2 < Weather.WeatherPrefabs[i].effectSystems.Count; i2++) { float val2 = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(Weather.WeatherPrefabs[i].effectSystems[i2]), 0f, speed); if (val2 < 1f) { val2 = 0f; } EnviroSkyMgr.instance.SetEmissionRate(Weather.WeatherPrefabs[i].effectSystems[i2], val2); if (val2 == 0f && !Weather.WeatherPrefabs[i].effectSystems[i2].isStopped) { Weather.WeatherPrefabs[i].effectSystems[i2].Stop(); } } } } UpdateWeatherVariables(id.weatherPreset); } }
private void UpdateWeatherEffects() { if (EnviroSky.instance.Weather.currentActiveWeatherPrefab == null || currentWeather == null) { return; } if (EnviroSky.instance.Weather.currentActiveWeatherPrefab.weatherPreset != currentWeather.weatherPreset) { for (int i = 0; i < zoneWeather.Count; i++) { if (zoneWeather[i].weatherPreset == EnviroSky.instance.Weather.currentActiveWeatherPrefab.weatherPreset) { currentWeather = zoneWeather[i]; } } } UpdateEffectSystems(currentWeather, true); }
public void CreateZoneWeatherTypeList() { // Add new WeatherPrefabs for (int i = 0; i < zoneWeatherPresets.Count; i++) { if (zoneWeatherPresets [i] == null) { Debug.Log("Warning! Missing Weather Preset in Zone: " + this.zoneName); return; } bool addThis = true; for (int i2 = 0; i2 < EnviroSkyMgr.instance.GetCurrentWeatherPresetList().Count; i2++) { if (zoneWeatherPresets [i] == EnviroSkyMgr.instance.GetCurrentWeatherPresetList()[i2]) { addThis = false; zoneWeather.Add(EnviroSkyMgr.instance.GetCurrentWeatherPrefabList()[i2]); } } if (addThis) { GameObject wPrefab = new GameObject(); EnviroWeatherPrefab wP = wPrefab.AddComponent <EnviroWeatherPrefab> (); wP.weatherPreset = zoneWeatherPresets [i]; wPrefab.name = wP.weatherPreset.Name; // Check and create particle systems. for (int w = 0; w < wP.weatherPreset.effectSystems.Count; w++) { if (wP.weatherPreset.effectSystems [w] == null || wP.weatherPreset.effectSystems [w].prefab == null) { Debug.Log("Warning! Missing Particle System Entry: " + wP.weatherPreset.Name); Destroy(wPrefab); return; } GameObject eS = (GameObject)Instantiate(wP.weatherPreset.effectSystems [w].prefab, wPrefab.transform); eS.transform.localPosition = wP.weatherPreset.effectSystems [w].localPositionOffset; eS.transform.localEulerAngles = wP.weatherPreset.effectSystems [w].localRotationOffset; ParticleSystem pS = eS.GetComponent <ParticleSystem> (); if (pS != null) { wP.effectSystems.Add(pS); } else { pS = eS.GetComponentInChildren <ParticleSystem> (); if (pS != null) { wP.effectSystems.Add(pS); } else { Debug.Log("No Particle System found in prefab in weather preset: " + wP.weatherPreset.Name); Destroy(wPrefab); return; } } } wP.effectEmmisionRates.Clear(); wPrefab.transform.parent = EnviroSkyMgr.instance.GetVFXHolder().transform; wPrefab.transform.localPosition = Vector3.zero; wPrefab.transform.localRotation = Quaternion.identity; zoneWeather.Add(wP); EnviroSkyMgr.instance.GetCurrentWeatherPrefabList().Add(wP); EnviroSkyMgr.instance.GetCurrentWeatherPresetList().Add(zoneWeatherPresets [i]); } } // Setup Particle Systems Emission Rates for (int i = 0; i < zoneWeather.Count; i++) { for (int i2 = 0; i2 < zoneWeather[i].effectSystems.Count; i2++) { zoneWeather[i].effectEmmisionRates.Add(EnviroSkyMgr.instance.GetEmissionRate(zoneWeather[i].effectSystems[i2])); EnviroSkyMgr.instance.SetEmissionRate(zoneWeather[i].effectSystems[i2], 0f); } } //Set initial weather if (isDefault && EnviroSkyMgr.instance.GetStartWeatherPreset() != null) { EnviroSkyMgr.instance.ChangeWeatherInstant(EnviroSkyMgr.instance.GetStartWeatherPreset()); for (int i = 0; i < zoneWeather.Count; i++) { if (zoneWeather[i].weatherPreset == EnviroSkyMgr.instance.GetStartWeatherPreset()) { currentActiveZoneWeatherPrefab = zoneWeather[i]; lastActiveZoneWeatherPrefab = zoneWeather[i]; } } currentActiveZoneWeatherPreset = EnviroSkyMgr.instance.GetStartWeatherPreset(); lastActiveZoneWeatherPreset = EnviroSkyMgr.instance.GetStartWeatherPreset(); } else { currentActiveZoneWeatherPrefab = zoneWeather [0]; lastActiveZoneWeatherPrefab = zoneWeather [0]; currentActiveZoneWeatherPreset = zoneWeatherPresets [0]; lastActiveZoneWeatherPreset = zoneWeatherPresets [0]; } nextUpdate = EnviroSkyMgr.instance.GetCurrentTimeInHours() + WeatherUpdateIntervall; }
/// <summary> /// Changes clouds, fog and particle effects to current weather settings instantly. /// </summary> public void InstantWeatherChange(EnviroWeatherPreset preset, EnviroWeatherPrefab prefab) { UpdateClouds(preset, false); UpdateFog(preset, false); UpdateEffectSystems(prefab, false); }
IEnumerator SetupWeatherEffects() { yield return(new WaitForSeconds(1f)); for (int i = 0; i < EnviroSky.instance.Weather.weatherPresets.Count; i++) { //Create Weather Prefab GameObject wPrefab = new GameObject(); EnviroWeatherPrefab wP = wPrefab.AddComponent <EnviroWeatherPrefab>(); wP.weatherPreset = EnviroSky.instance.Weather.weatherPresets[i]; wPrefab.name = wP.weatherPreset.Name; //Add Particle Effects for (int w = 0; w < wP.weatherPreset.effectSystems.Count; w++) { if (wP.weatherPreset.effectSystems[w] == null || wP.weatherPreset.effectSystems[w].prefab == null) { Debug.Log("Warning! Missing Particle System Entry: " + wP.weatherPreset.Name); Destroy(wPrefab); break; } GameObject eS = (GameObject)Instantiate(wP.weatherPreset.effectSystems[w].prefab, wPrefab.transform); eS.transform.localPosition = wP.weatherPreset.effectSystems[w].localPositionOffset; eS.transform.localEulerAngles = wP.weatherPreset.effectSystems[w].localRotationOffset; ParticleSystem pS = eS.GetComponent <ParticleSystem>(); if (pS != null) { wP.effectSystems.Add(pS); } else { pS = eS.GetComponentInChildren <ParticleSystem>(); if (pS != null) { wP.effectSystems.Add(pS); } else { Debug.Log("No Particle System found in prefab in weather preset: " + wP.weatherPreset.Name); Destroy(wPrefab); break; } } } wP.effectEmmisionRates.Clear(); wPrefab.transform.parent = VFX.transform; wPrefab.transform.localPosition = Vector3.zero; wPrefab.transform.localRotation = Quaternion.identity; zoneWeather.Add(wP); } // Setup Particle Systems Emission Rates for (int i = 0; i < zoneWeather.Count; i++) { for (int i2 = 0; i2 < zoneWeather[i].effectSystems.Count; i2++) { zoneWeather[i].effectEmmisionRates.Add(EnviroSkyMgr.instance.GetEmissionRate(zoneWeather[i].effectSystems[i2])); EnviroSkyMgr.instance.SetEmissionRate(zoneWeather[i].effectSystems[i2], 0f); } } //Set Current Weather if (EnviroSky.instance.Weather.currentActiveWeatherPrefab != null) { for (int i = 0; i < zoneWeather.Count; i++) { if (zoneWeather[i].weatherPreset == EnviroSky.instance.Weather.currentActiveWeatherPrefab.weatherPreset) { currentWeather = zoneWeather[i]; } } } }
public void CreateZoneWeatherTypeList() { for (int index1 = 0; index1 < this.zoneWeatherPresets.Count; ++index1) { if (Object.op_Equality((Object)this.zoneWeatherPresets[index1], (Object)null)) { Debug.Log((object)("Warning! Missing Weather Preset in Zone: " + this.zoneName)); return; } bool flag = true; for (int index2 = 0; index2 < EnviroSky.instance.Weather.weatherPresets.Count; ++index2) { if (Object.op_Equality((Object)this.zoneWeatherPresets[index1], (Object)EnviroSky.instance.Weather.weatherPresets[index2])) { flag = false; this.zoneWeather.Add(EnviroSky.instance.Weather.WeatherPrefabs[index2]); } } if (Object.op_Equality((Object)EnviroSky.instance.Weather.VFXHolder, (Object)null)) { flag = false; } if (flag) { GameObject gameObject = new GameObject(); EnviroWeatherPrefab enviroWeatherPrefab = (EnviroWeatherPrefab)gameObject.AddComponent <EnviroWeatherPrefab>(); enviroWeatherPrefab.weatherPreset = this.zoneWeatherPresets[index1]; ((Object)gameObject).set_name(enviroWeatherPrefab.weatherPreset.Name); enviroWeatherPrefab.effectEmmisionRates.Clear(); gameObject.get_transform().set_parent(EnviroSky.instance.Weather.VFXHolder.get_transform()); gameObject.get_transform().set_localPosition(Vector3.get_zero()); gameObject.get_transform().set_localRotation(Quaternion.get_identity()); this.zoneWeather.Add(enviroWeatherPrefab); EnviroSky.instance.Weather.WeatherPrefabs.Add(enviroWeatherPrefab); EnviroSky.instance.Weather.weatherPresets.Add(this.zoneWeatherPresets[index1]); } } for (int index1 = 0; index1 < this.zoneWeather.Count; ++index1) { for (int index2 = 0; index2 < this.zoneWeather[index1].effectSystems.Count; ++index2) { this.zoneWeather[index1].effectEmmisionRates.Add(EnviroSky.GetEmissionRate(this.zoneWeather[index1].effectSystems[index2])); EnviroSky.SetEmissionRate(this.zoneWeather[index1].effectSystems[index2], 0.0f); } } if (this.isDefault && Object.op_Inequality((Object)EnviroSky.instance.Weather.startWeatherPreset, (Object)null)) { EnviroSky.instance.SetWeatherOverwrite(EnviroSky.instance.Weather.startWeatherPreset); for (int index = 0; index < this.zoneWeather.Count; ++index) { if (Object.op_Equality((Object)this.zoneWeather[index].weatherPreset, (Object)EnviroSky.instance.Weather.startWeatherPreset)) { this.currentActiveZoneWeatherPrefab = this.zoneWeather[index]; this.lastActiveZoneWeatherPrefab = this.zoneWeather[index]; } } this.currentActiveZoneWeatherPreset = EnviroSky.instance.Weather.startWeatherPreset; this.lastActiveZoneWeatherPreset = EnviroSky.instance.Weather.startWeatherPreset; } else { this.currentActiveZoneWeatherPrefab = this.zoneWeather[0]; this.lastActiveZoneWeatherPrefab = this.zoneWeather[0]; this.currentActiveZoneWeatherPreset = this.zoneWeatherPresets[0]; this.lastActiveZoneWeatherPreset = this.zoneWeatherPresets[0]; } this.nextUpdate = EnviroSky.instance.currentTimeInHours + (double)this.WeatherUpdateIntervall; }