internal void ResetSimulation()
        {
            _surfaceHeighestPointDeltaHeight = 0f;

            if (!IsControlledByLargeWaterAreaManager)
            {
                _sineWavesSimulationElapsedTime = 0f;
            }

            if (_dynamicWavesVelocities == null || _dynamicWavesVelocities.Length != _meshModule.SurfaceVerticesCount)
            {
                var surfaceVertexCount = _meshModule.SurfaceVerticesCount;

                _dynamicWavesVelocities = new float[surfaceVertexCount];
                _dynamicWavesPositions  = new float[surfaceVertexCount];
                _sinesWavesPositions    = new float[surfaceVertexCount];
            }

            float waterPositionOfRest = _mainModule.Height * 0.5f;
            var   vertices            = _meshModule.Vertices;

            for (int i = 0, imax = _dynamicWavesVelocities.Length; i < imax; i++)
            {
                _dynamicWavesVelocities[i] = 0f;

                _sinesWavesPositions[i] = 0f;
                vertices[i].y           = _dynamicWavesPositions[i] = waterPositionOfRest;
            }
            _meshModule.UpdateMeshData();
        }
        private void UpdateWaterSize(Vector2 newWaterSize)
        {
            int surfaceVerticesCount = _meshModule.SurfaceVerticesCount;
            var vertices             = _meshModule.Vertices;

            if (_simulationModule.IsUsingCustomBoundaries)
            {
                if (newWaterSize.x != _lastWaterSize.x)
                {
                    int firstSurfaceVertexIndex = 0;                           //topLeft
                    int lastSurfaceVertexIndex  = surfaceVerticesCount - 1;    //topRight

                    int firstBottomVertexIndex = surfaceVerticesCount;         //bottomLeft
                    int lastBottomVertexIndex  = surfaceVerticesCount * 2 - 1; //bottomRight

                    float halfWidth = newWaterSize.x * 0.5f;
                    vertices[firstSurfaceVertexIndex].x = vertices[firstBottomVertexIndex].x = -halfWidth;
                    vertices[lastSurfaceVertexIndex].x  = vertices[lastBottomVertexIndex].x = halfWidth;
                }

                if (newWaterSize.y != _lastWaterSize.y)
                {
                    float halfDeltaHeight = (newWaterSize.y - _lastWaterSize.y) * 0.5f;
                    for (int surfaceVertexIndex = 0; surfaceVertexIndex < surfaceVerticesCount; surfaceVertexIndex++)
                    {
                        int bottomVertexIndex = surfaceVertexIndex + surfaceVerticesCount;

                        vertices[surfaceVertexIndex].y += halfDeltaHeight;
                        vertices[bottomVertexIndex].y  -= halfDeltaHeight;
                    }
                }
            }
            else
            {
                float halfDeltaHeight = (newWaterSize.y - _lastWaterSize.y) * 0.5f;
                float columnWidth     = newWaterSize.x / (surfaceVerticesCount - 1);

                float xPos = -newWaterSize.x * 0.5f;
                for (int surfaceVertexIndex = 0; surfaceVertexIndex < surfaceVerticesCount; surfaceVertexIndex++)
                {
                    int bottomVertexIndex = surfaceVertexIndex + surfaceVerticesCount;

                    vertices[surfaceVertexIndex].x  = vertices[bottomVertexIndex].x = xPos;
                    vertices[surfaceVertexIndex].y += halfDeltaHeight;
                    vertices[bottomVertexIndex].y  -= halfDeltaHeight;

                    xPos += columnWidth;
                }
            }

            _mainModule.SetSize(newWaterSize);
            _meshModule.UpdateMeshData();

            _lastWaterSize = newWaterSize;
        }
 internal void ResetSimulation()
 {
     if (_velocities == null || _velocities.Length != _meshModule.SurfaceVerticesCount)
     {
         _velocities = new float[_meshModule.SurfaceVerticesCount];
     }
     else
     {
         float waterPositionOfRest = _mainModule.Height * 0.5f;
         var   vertices            = _meshModule.Vertices;
         for (int i = 0, imax = _velocities.Length; i < imax; i++)
         {
             _velocities[i] = 0f;
             vertices[i].y  = waterPositionOfRest;
         }
         _meshModule.UpdateMeshData();
     }
 }