internal virtual void OnProfilesChanged()
        {
            Water.WeightedProfile[] profiles = this._Water.ProfilesManager.Profiles;
            Dictionary <WaterWavesSpectrum, WaterWavesSpectrumData> .Enumerator enumerator = this._SpectraDataCache.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <WaterWavesSpectrum, WaterWavesSpectrumData> keyValuePair = enumerator.Current;
                keyValuePair.Value.Weight = 0f;
            }
            enumerator.Dispose();
            foreach (Water.WeightedProfile weightedProfile in profiles)
            {
                if (weightedProfile.Weight > 0.0001f)
                {
                    WaterWavesSpectrum     spectrum = weightedProfile.Profile.Spectrum;
                    WaterWavesSpectrumData spectrumData;
                    if (!this._SpectraDataCache.TryGetValue(spectrum, out spectrumData))
                    {
                        spectrumData = this.GetSpectrumData(spectrum);
                    }
                    spectrumData.Weight = weightedProfile.Weight;
                }
            }
            this.SetDirectionalSpectrumDirty();
            this.StdDev = 0f;
            float num = 0f;

            enumerator = this._SpectraDataCache.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <WaterWavesSpectrum, WaterWavesSpectrumData> keyValuePair2 = enumerator.Current;
                WaterWavesSpectrumData value = keyValuePair2.Value;
                value.ValidateSpectrumData();
                this.StdDev += value.GetStandardDeviation() * value.Weight;
                if (value.CpuWaves.Length != 0)
                {
                    num += value.CpuWaves[0]._Amplitude * value.Weight;
                }
            }
            enumerator.Dispose();
            for (int j = this._OverlayedSpectra.Count - 1; j >= 0; j--)
            {
                WaterWavesSpectrumDataBase waterWavesSpectrumDataBase = this._OverlayedSpectra[j];
                waterWavesSpectrumDataBase.ValidateSpectrumData();
                this.StdDev += waterWavesSpectrumDataBase.GetStandardDeviation() * waterWavesSpectrumDataBase.Weight;
                if (waterWavesSpectrumDataBase.CpuWaves.Length != 0)
                {
                    num += waterWavesSpectrumDataBase.CpuWaves[0]._Amplitude * waterWavesSpectrumDataBase.Weight;
                }
            }
            this.MaxVerticalDisplacement   = this.StdDev * 1.6f + num;
            this.MaxHorizontalDisplacement = this.MaxVerticalDisplacement * this._Water.Materials.HorizontalDisplacementScale;
        }
        internal void Update()
        {
            this._SurfaceOffset = this._Water.SurfaceOffset;
            float num = this._Water.Time;

            if (this._WindWaves.LoopDuration != 0f)
            {
                num %= this._WindWaves.LoopDuration;
            }
            this.LastFrameTime      = num;
            this._UniformWaterScale = this._Water.UniformWaterScale;
            this.UpdateCachedSeed();
            bool allowCpuFFT = WaterProjectSettings.Instance.AllowCpuFFT;

            for (int i = 0; i < this._NumTiles; i++)
            {
                int num2 = 16;
                int num3 = 0;
                for (;;)
                {
                    float num4 = 0f;
                    for (int j = this._SpectraDataList.Count - 1; j >= 0; j--)
                    {
                        WaterWavesSpectrumDataBase waterWavesSpectrumDataBase = this._SpectraDataList[j];
                        waterWavesSpectrumDataBase.ValidateSpectrumData();
                        float standardDeviation = waterWavesSpectrumDataBase.GetStandardDeviation(i, num3);
                        num4 += standardDeviation * waterWavesSpectrumDataBase.Weight;
                    }
                    for (int k = this._OverlayedSpectra.Count - 1; k >= 0; k--)
                    {
                        WaterWavesSpectrumDataBase waterWavesSpectrumDataBase2 = this._OverlayedSpectra[k];
                        waterWavesSpectrumDataBase2.ValidateSpectrumData();
                        float standardDeviation2 = waterWavesSpectrumDataBase2.GetStandardDeviation(i, num3);
                        num4 += standardDeviation2 * waterWavesSpectrumDataBase2.Weight;
                    }
                    if (num4 < this._WindWaves.CpuDesiredStandardError * 0.25f || num2 >= this._WindWaves.FinalResolution)
                    {
                        break;
                    }
                    num2 <<= 1;
                    num3++;
                }
                if (num2 > this._WindWaves.FinalResolution)
                {
                    num2 = this._WindWaves.FinalResolution;
                }
                WaterTileSpectrum waterTileSpectrum = this._TileSpectra[i];
                if (waterTileSpectrum.SetResolveMode(num2 >= 16 && allowCpuFFT, num2))
                {
                    this._CpuWavesDirty = true;
                }
            }
        }