private void AddParticleGroup(WaveParticlesGroup group) { if (this._ParticleGroups.Length == this._NumParticleGroups) { Array.Resize <WaveParticlesGroup>(ref this._ParticleGroups, this._NumParticleGroups << 1); } this._LastGroupIndex++; while (this._LastGroupIndex < this._ParticleGroups.Length) { if (this._ParticleGroups[this._LastGroupIndex] == null) { this._NumParticleGroups++; this._ParticleGroups[this._LastGroupIndex] = group; return; } this._LastGroupIndex++; } this._LastGroupIndex = 0; while (this._LastGroupIndex < this._ParticleGroups.Length) { if (this._ParticleGroups[this._LastGroupIndex] == null) { this._NumParticleGroups++; this._ParticleGroups[this._LastGroupIndex] = group; return; } this._LastGroupIndex++; } }
private bool HasParticleGroup(WaveParticlesGroup group) { for (int i = 0; i < this._ParticleGroups.Length; i++) { if (this._ParticleGroups[i] == group) { return(true); } } return(false); }
private bool RectContainsParticleGroup(WaveParticlesGroup group) { WaveParticle waveParticle = group.LeftParticle; if (!waveParticle.IsAlive) { return(false); } while (!this._MarginRect.Contains(waveParticle.Position)) { waveParticle = waveParticle.RightNeighbour; if (waveParticle == null) { return(false); } } return(true); }
public void CostlyUpdate(WaveParticlesQuadtree quadtree, float time) { WaveParticle waveParticle = this.LeftParticle; float deltaTime = time - this.LastCostlyUpdateTime; this.LastCostlyUpdateTime = time; int num = 0; do { WaveParticle waveParticle2 = waveParticle; waveParticle = waveParticle.RightNeighbour; num += waveParticle2.CostlyUpdate((num >= 30) ? null : quadtree, deltaTime); }while (waveParticle != null); waveParticle = this.LeftParticle; if (waveParticle == null) { return; } WaveParticle waveParticle3 = waveParticle; int num2 = 0; do { WaveParticle waveParticle4 = waveParticle; waveParticle = waveParticle.RightNeighbour; num2++; if (waveParticle4 != waveParticle3 && (waveParticle4.DisallowSubdivision || waveParticle == null)) { if (num2 > 3) { WaveParticlesGroup.FilterRefractedDirections(waveParticle3, num2); } waveParticle3 = waveParticle; num2 = 0; } }while (waveParticle != null); }
private void UpdateParticles(float time) { List <WaterCamera> enabledWaterCameras = WaterCamera.EnabledWaterCameras; int count = enabledWaterCameras.Count; bool flag = false; for (int i = 0; i < count; i++) { if (base.Rect.Overlaps(enabledWaterCameras[i].LocalMapsRect)) { flag = true; break; } } int num; int num2; int num3; if (!flag) { num = this._LastUpdateIndex; num2 = this._LastUpdateIndex + 8; num3 = num << 2; if (num2 >= this._Elements.Length) { num2 = this._Elements.Length; this._LastUpdateIndex = 0; } else { this._LastUpdateIndex = num2; } } else { num = 0; num2 = this._Elements.Length; num3 = 0; } WaveParticlesQuadtree quadtree = (!flag) ? null : this._Qroot; float num4 = (!flag) ? 1.5f : 0.01f; float num5 = (!flag) ? 8f : 0.4f; bool flag2 = false; num4 *= this._Qroot._Stress; num5 *= this._Qroot._Stress; int num6 = 0; while (this._ParticleGroups != null && num6 < this._ParticleGroups.Length) { WaveParticlesGroup waveParticlesGroup = this._ParticleGroups[num6]; if (waveParticlesGroup != null) { if (waveParticlesGroup.LeftParticle == null || !waveParticlesGroup.LeftParticle.IsAlive) { this._NumParticleGroups--; this._ParticleGroups[num6] = null; } else if (time >= waveParticlesGroup.LastUpdateTime + num4) { if (time >= waveParticlesGroup.LastCostlyUpdateTime + num5 && !flag2) { if (!this.RectContainsParticleGroup(waveParticlesGroup)) { this._NumParticleGroups--; this._ParticleGroups[num6] = null; goto IL_201; } waveParticlesGroup.CostlyUpdate(quadtree, time); flag2 = true; if (waveParticlesGroup.LeftParticle == null || !waveParticlesGroup.LeftParticle.IsAlive) { this._NumParticleGroups--; this._ParticleGroups[num6] = null; goto IL_201; } } waveParticlesGroup.Update(time); } } IL_201: num6++; } if (this._Elements != null) { for (int j = num; j < num2; j++) { WaveParticle waveParticle = this._Elements[j]; if (waveParticle != null) { if (waveParticle.IsAlive) { if (this._MarginRect.Contains(waveParticle.Position)) { Vector3 vertexData = waveParticle.VertexData; Vector4 packedParticleData = waveParticle.PackedParticleData; this._Vertices[num3] = vertexData; this._TangentsPack[num3++] = packedParticleData; this._Vertices[num3] = vertexData; this._TangentsPack[num3++] = packedParticleData; this._Vertices[num3] = vertexData; this._TangentsPack[num3++] = packedParticleData; this._Vertices[num3] = vertexData; this._TangentsPack[num3++] = packedParticleData; this._TangentsPackChanged = true; } else { base.RemoveElementAt(j); this._Vertices[num3++].x = float.NaN; this._Vertices[num3++].x = float.NaN; this._Vertices[num3++].x = float.NaN; this._Vertices[num3++].x = float.NaN; this._Qroot.AddElement(waveParticle); } } else { base.RemoveElementAt(j); this._Vertices[num3++].x = float.NaN; this._Vertices[num3++].x = float.NaN; this._Vertices[num3++].x = float.NaN; this._Vertices[num3++].x = float.NaN; waveParticle.AddToCache(); } } else { num3 += 4; } } } }