public static void SetQuality(TasharenWater.Quality q)
 {
     TasharenWater[] array = UnityEngine.Object.FindObjectsOfType(typeof(TasharenWater)) as TasharenWater[];
     if (array.Length > 0)
     {
         TasharenWater[] array2 = array;
         for (int i = 0; i < array2.Length; i++)
         {
             TasharenWater tasharenWater = array2[i];
             tasharenWater.quality = q;
         }
     }
     else
     {
         PlayerPrefs.SetInt("Water", (int)q);
     }
 }
    private void OnWillRenderObject()
    {
        if (TasharenWater.mIsRendering)
        {
            return;
        }
        if (!base.enabled || !this.mRen || !this.mRen.enabled)
        {
            this.Clear();
            return;
        }
        Material sharedMaterial = this.mRen.sharedMaterial;

        if (!sharedMaterial)
        {
            return;
        }
        Camera current = Camera.current;

        if (!current)
        {
            return;
        }
        bool supportsImageEffects = SystemInfo.supportsImageEffects;

        if (supportsImageEffects)
        {
            current.depthTextureMode |= DepthTextureMode.Depth;
        }
        else
        {
            this.quality = TasharenWater.Quality.Fastest;
        }
        if (!this.useRefraction)
        {
            sharedMaterial.shader.maximumLOD = ((!supportsImageEffects) ? 100 : 200);
            this.Clear();
            return;
        }
        LayerMask reflectionMask        = this.reflectionMask;
        int       reflectionTextureSize = this.reflectionTextureSize;

        if (reflectionMask == 0 || reflectionTextureSize < 512)
        {
            sharedMaterial.shader.maximumLOD = 300;
            this.Clear();
        }
        else
        {
            sharedMaterial.shader.maximumLOD = 400;
            TasharenWater.mIsRendering       = true;
            Camera  reflectionCamera = this.GetReflectionCamera(current, sharedMaterial, reflectionTextureSize);
            Vector3 position         = this.mTrans.position;
            Vector3 up = this.mTrans.up;
            this.CopyCamera(current, reflectionCamera);
            float     w     = -Vector3.Dot(up, position);
            Vector4   plane = new Vector4(up.x, up.y, up.z, w);
            Matrix4x4 zero  = Matrix4x4.zero;
            TasharenWater.CalculateReflectionMatrix(ref zero, plane);
            Vector3 position2 = current.transform.position;
            Vector3 position3 = zero.MultiplyPoint(position2);
            reflectionCamera.worldToCameraMatrix = current.worldToCameraMatrix * zero;
            Vector4   clipPlane        = this.CameraSpacePlane(reflectionCamera, position, up, 1f);
            Matrix4x4 projectionMatrix = current.projectionMatrix;
            TasharenWater.CalculateObliqueMatrix(ref projectionMatrix, clipPlane);
            reflectionCamera.projectionMatrix = projectionMatrix;
            reflectionCamera.cullingMask      = (-17 & reflectionMask.value);
            reflectionCamera.targetTexture    = this.mTex;
            GL.SetRevertBackfacing(true);
            reflectionCamera.transform.position = position3;
            Vector3 eulerAngles = current.transform.eulerAngles;
            reflectionCamera.transform.eulerAngles = new Vector3(0f, eulerAngles.y, eulerAngles.z);
            reflectionCamera.Render();
            reflectionCamera.transform.position = position2;
            GL.SetRevertBackfacing(false);
            TasharenWater.mIsRendering = false;
        }
    }
 private void Awake()
 {
     this.mTrans  = base.transform;
     this.mRen    = base.renderer;
     this.quality = TasharenWater.GetQuality();
 }