private void FixedUpdate() { WaterForce.Data item; item.Position = base.transform.position; item.Force = this.Force * Time.fixedDeltaTime; WaterForce._ForceData.Clear(); WaterForce._ForceData.Add(item); WaterRipples.AddForce(WaterForce._ForceData, this.Radius); }
private void OnDisable() { WaterRipples.Unregister(this); DynamicWater.RemoveRenderer <WaterSimulationArea>(this); this.ReleaseDepthCamera(); this.ReleaseTextures(); if (this._CommandBuffer != null) { this._CommandBuffer.Release(); this._CommandBuffer = null; } }
private void Update() { if (!this.Initialized || this._System.particleCount == 0) { return; } WaterParticleDisplacement._Data.Clear(); int particles = this._System.GetParticles(this._Particles); int num = 0; int num2 = 0; int num3 = particles; if (particles > 64) { num2 = (int)((float)particles * (float)this._CurrentFrame / ((float)this.FrameSplit + 1f)); num3 = (int)((float)particles * ((float)this._CurrentFrame + 1f) / ((float)this.FrameSplit + 1f)); this.NextBatch(); } for (int i = num2; i < num3; i++) { if (this._Particles[i].remainingLifetime > 0f) { float x = this._Particles[i].position.x; float z = this._Particles[i].position.z; float y = this._Particles[i].position.y; Vector3 andReset = this._Sampler.GetAndReset(x, z, WaterSample.ComputationsMode.Normal); if (y < andReset.y && Mathf.Abs(y - andReset.y) < 0.1f) { if (this._Particles[i].startLifetime - this._Particles[i].remainingLifetime >= 0.1f && this.UsedParticles > UnityEngine.Random.Range(0f, 1f)) { float magnitude = this._Particles[i].velocity.magnitude; float num4 = this.ForceOverSpeed.Evaluate(magnitude); float num5 = this.Force * (1f + magnitude * num4 * 0.1f); WaterForce.Data item; item.Position = new Vector3(x, 0f, z); item.Force = num5 * (1f + this.SizeMultipier * this._Particles[i].GetCurrentSize(this._System)); WaterParticleDisplacement._Data.Add(item); } this._Particles[i].remainingLifetime = 0f; num++; } } } if (WaterParticleDisplacement._Data.Count != 0) { WaterRipples.AddForce(WaterParticleDisplacement._Data, 1f); } if (num != 0) { this._System.SetParticles(this._Particles, particles); } }
private void OnEnable() { this._Position = base.transform.position; this._Scale = base.transform.localScale; this._CommandBuffer = new CommandBuffer { name = "[Ultimate Water]: Water Simulation Area" }; this.CreateDepthCamera(); this.CreateTextures(); this.UpdateShaderVariables(); this.RenderStaticDepthTexture(); DynamicWater.AddRenderer <WaterSimulationArea>(this); WaterRipples.Register(this); }