Beispiel #1
0
 private void Update()
 {
     if (Input.GetKeyUp(KeyCode.A))
     {
         ParticleAdapter.AdaptDown();
     }
 }
Beispiel #2
0
 private void Update()
 {
     if (!this.adaptOn)
     {
         return;
     }
     this.step++;
     this.acc += Time.deltaTime;
     if (this.step % this.frameCount == 0)
     {
         this.fps  = (int)((float)this.frameCount / this.acc);
         this.step = 0;
         this.acc  = 0f;
         if (this.fps < this.particleFPS)
         {
             ParticleAdapter.AdaptDown();
         }
         if (this.checkShadow)
         {
             if (this.fps < this.shadowFPS)
             {
                 this.shadowAcc++;
                 if (this.shadowAcc > 10)
                 {
                     AdaptCenter.TurnOffShadows();
                     this.checkShadow = false;
                 }
             }
             else
             {
                 this.shadowAcc = 0;
             }
         }
     }
 }
    private static bool AdaptDown(ParticleSystem p, int k, ParticleAdapter ad)
    {
        if (p == null || !p.enableEmission)
        {
            return(false);
        }
        int   num  = 0;
        float num2 = 0f;

        if (k < ad.countVault.Length)
        {
            num = ad.countVault[k];
        }
        if (k < ad.rateVault.Length)
        {
            num2 = ad.rateVault[k];
        }
        int   maxParticles = p.maxParticles;
        float emissionRate = p.emissionRate;

        if (maxParticles <= num && emissionRate <= num2)
        {
            return(false);
        }
        int   num3 = (int)(ad.countStep * (float)maxParticles);
        float num4 = ad.rateStep * emissionRate;

        if (num3 < num)
        {
            num3             = num;
            ad.checkCount[k] = false;
        }
        if (num4 < num2)
        {
            num4            = num2;
            ad.checkRate[k] = false;
        }
        if (num3 == 0)
        {
            p.enableEmission = false;
            ad.checkCount[k] = false;
        }
        else
        {
            p.maxParticles = num3;
        }
        p.emissionRate = num4;
        return(true);
    }
    public bool ToDown()
    {
        int num = 0;

        for (int i = 0; i < this.ps.Length; i++)
        {
            int  num2 = this.ps.Length - 1 - i;
            bool flag = false;
            if (this.checkCount[num2] || this.checkRate[num2])
            {
                flag = ParticleAdapter.AdaptDown(this.ps[num2], num2, this);
            }
            if (flag)
            {
                num++;
                if (num >= this.adaptRange)
                {
                    break;
                }
            }
        }
        return(num > 0);
    }