public int CostlyUpdate(WaveParticlesQuadtree quadtree, float deltaTime) { float num; if (this.Frequency < 0.025f) { float x = this._Position.x + this.Direction.x / this.Frequency; float z = this._Position.y + this.Direction.y / this.Frequency; num = Mathf.Max(StaticWaterInteraction.GetTotalDepthAt(this._Position.x, this._Position.y), StaticWaterInteraction.GetTotalDepthAt(x, z)); } else { num = StaticWaterInteraction.GetTotalDepthAt(this._Position.x, this._Position.y); } if (num <= 0.001f) { this.Destroy(); return(0); } this.UpdateWaveParameters(deltaTime, num); int result = 0; if (quadtree != null && !this.DisallowSubdivision) { if (this.LeftNeighbour != null) { this.Subdivide(quadtree, this.LeftNeighbour, this, ref result); } if (this.RightNeighbour != null) { this.Subdivide(quadtree, this, this.RightNeighbour, ref result); } } return(result); }
private void CreateShoalingSpawnPoints() { Bounds bounds = new Bounds(base.transform.position, new Vector3(this._BoundsSize.x, 0f, this._BoundsSize.y)); float x = bounds.min.x; float z = bounds.min.z; float x2 = bounds.max.x; float z2 = bounds.max.z; float num = Mathf.Sqrt(this._SpawnPointsDensity); float num2 = Mathf.Max(35f, bounds.size.x / 256f) / num; float num3 = Mathf.Max(35f, bounds.size.z / 256f) / num; bool[,] array = new bool[32, 32]; List <ComplexWavesEmitter.SpawnPoint> list = new List <ComplexWavesEmitter.SpawnPoint>(); GerstnerWave[] array2 = this._WindWaves.SpectrumResolver.SelectShorelineWaves(50, 0f, 360f); if (array2.Length == 0) { this._SpawnPoints = new ComplexWavesEmitter.SpawnPoint[0]; return; } float num4 = this._SpawnDepth * 0.85f; float num5 = this._SpawnDepth * 1.18f; for (float num6 = z; num6 < z2; num6 += num3) { for (float num7 = x; num7 < x2; num7 += num2) { int num8 = Mathf.FloorToInt(32f * (num7 - x) / (x2 - x)); int num9 = Mathf.FloorToInt(32f * (num6 - z) / (z2 - z)); if (!array[num8, num9]) { float totalDepthAt = StaticWaterInteraction.GetTotalDepthAt(num7, num6); if (totalDepthAt > num4 && totalDepthAt < num5 && UnityEngine.Random.value < 0.06f) { array[num8, num9] = true; Vector2 vector; vector.x = StaticWaterInteraction.GetTotalDepthAt(num7 - 3f, num6) - StaticWaterInteraction.GetTotalDepthAt(num7 + 3f, num6); vector.y = StaticWaterInteraction.GetTotalDepthAt(num7, num6 - 3f) - StaticWaterInteraction.GetTotalDepthAt(num7, num6 + 3f); vector.Normalize(); GerstnerWave gerstnerWave = array2[0]; float num10 = Vector2.Dot(vector, array2[0].Direction); for (int i = 1; i < array2.Length; i++) { float num11 = Vector2.Dot(vector, array2[i].Direction); if (num11 > num10) { num10 = num11; gerstnerWave = array2[i]; } } list.Add(new ComplexWavesEmitter.SpawnPoint(new Vector2(num7, num6), vector, gerstnerWave.Frequency, Mathf.Abs(gerstnerWave.Amplitude), gerstnerWave.Speed)); } } } } this._SpawnPoints = list.ToArray(); }