private void GenerateShoreVector(out float[] distances, out Vector2[] vectors) { object obj; object obj1; float single = this.terrainSize / (float)this.shoreMapSize; Vector3 position = this.terrain.GetPosition(); int layer = LayerMask.NameToLayer("Terrain"); NativeArray <RaycastHit> raycastHits = new NativeArray <RaycastHit>(this.shoreMapSize * this.shoreMapSize, Allocator.TempJob, NativeArrayOptions.ClearMemory); NativeArray <RaycastCommand> raycastCommands = new NativeArray <RaycastCommand>(this.shoreMapSize * this.shoreMapSize, Allocator.TempJob, NativeArrayOptions.ClearMemory); for (int i = 0; i < this.shoreMapSize; i++) { for (int j = 0; j < this.shoreMapSize; j++) { float single1 = ((float)j + 0.5f) * single; float single2 = ((float)i + 0.5f) * single; Vector3 vector3 = new Vector3(position.x, 0f, position.z) + new Vector3(single1, 1000f, single2); Vector3 vector31 = Vector3.down; raycastCommands[i * this.shoreMapSize + j] = new RaycastCommand(vector3, vector31, Single.MaxValue, -5, 1); } } JobHandle jobHandle = new JobHandle(); RaycastCommand.ScheduleBatch(raycastCommands, raycastHits, 1, jobHandle).Complete(); byte[] numArray = new byte[this.shoreMapSize * this.shoreMapSize]; distances = new float[this.shoreMapSize * this.shoreMapSize]; vectors = new Vector2[this.shoreMapSize * this.shoreMapSize]; int num = 0; int num1 = 0; while (num < this.shoreMapSize) { int num2 = 0; while (num2 < this.shoreMapSize) { RaycastHit item = raycastHits[num * this.shoreMapSize + num2]; bool flag = item.collider.gameObject.layer == layer; byte[] numArray1 = numArray; int num3 = num1; if (flag) { obj = 255; } else { obj = null; } numArray1[num3] = (byte)obj; float[] singleArray = distances; int num4 = num1; if (flag) { obj1 = 256; } else { obj1 = null; } singleArray[num4] = (float)obj1; num2++; num1++; } num++; } byte num5 = 127; DistanceField.Generate(ref this.shoreMapSize, ref num5, ref numArray, ref distances); DistanceField.ApplyGaussianBlur(this.shoreMapSize, distances, 0); DistanceField.GenerateVectors(ref this.shoreMapSize, ref distances, ref vectors); raycastHits.Dispose(); raycastCommands.Dispose(); }