コード例 #1
0
        private void Start()
        {
            int   currentParticleQuality = GraphicsSettings.INSTANCE.CurrentParticleQuality;
            float num2 = this.coefficient[currentParticleQuality];

            ParticleSystem[] componentsInChildren = base.GetComponentsInChildren <ParticleSystem>();
            int index = 0;

            while (index < componentsInChildren.Length)
            {
                ParticleSystem            system = componentsInChildren[index];
                ParticleSystem.MainModule main   = system.main;
                main.maxParticles = Mathf.Max(Mathf.Min(main.maxParticles, 1), (int)(main.maxParticles * num2));
                ParticleSystem.EmissionModule emission = system.emission;
                emission.rateOverTimeMultiplier     = Mathf.Max(Mathf.Min(emission.rateOverTimeMultiplier, 1f), (float)((int)(emission.rateOverTimeMultiplier * num2)));
                emission.rateOverDistanceMultiplier = Mathf.Max(Mathf.Min(emission.rateOverDistanceMultiplier, 1f), (float)((int)(emission.rateOverDistanceMultiplier * num2)));
                ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[emission.burstCount];
                emission.GetBursts(bursts);
                int num4 = 0;
                while (true)
                {
                    if (num4 >= emission.burstCount)
                    {
                        emission.SetBursts(bursts);
                        index++;
                        break;
                    }
                    bursts[num4].minCount = (short)Mathf.Max((float)Mathf.Min(bursts[num4].minCount, 1), bursts[num4].minCount * num2);
                    bursts[num4].maxCount = (short)Mathf.Max((float)Mathf.Min(bursts[num4].maxCount, 1), bursts[num4].maxCount * num2);
                    num4++;
                }
            }
        }
コード例 #2
0
        public override void GetDepsFrom(object obj, GetDepsFromContext context)
        {
            base.GetDepsFrom(obj, context);
            ParticleSystem.EmissionModule o = (ParticleSystem.EmissionModule)obj;

            ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[o.burstCount];
            o.GetBursts(bursts);
            AddSurrogateDeps(bursts, v_ => (PersistentParticleSystemNestedBurst)v_, context);
        }
コード例 #3
0
 protected void GetParticleInfo()                                                 // get particle burst info to replicate the emission when needed
 {
     //Get Particle Burst Info
     emission = muzzle.emission;
     ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[emission.burstCount];
     emission.GetBursts(bursts);
     minParticles = bursts[0].minCount;
     maxParticles = bursts[0].maxCount;
 }
コード例 #4
0
 private void setcount(ParticleSystem.EmissionModule emission, short[] counts, float scale)
 {
     ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[emission.burstCount];
     emission.GetBursts(bursts);
     for (int i = 0; i < bursts.Length; i++)
     {
         bursts[i].maxCount = (short)(counts[i] * scale);
     }
     emission.SetBursts(bursts);
 }
コード例 #5
0
        public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }

            ParticleSystem.EmissionModule o = (ParticleSystem.EmissionModule)obj;

            m_bursts = new ParticleSystem.Burst[o.burstCount];
            o.GetBursts(m_bursts);
        }
コード例 #6
0
 private void Start()
 {
     // copy components
     explosionMask = owner.m_EnemyStats.hitMask;
     damage        = owner.m_EnemyStats.attackValue;
     // get the particle burst info
     emission = thisParticle.emission;
     ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[emission.burstCount];
     emission.GetBursts(bursts);
     min = bursts[0].minCount;
     max = bursts[0].maxCount;
     transform.parent = null;
 }
コード例 #7
0
    public void TriggerWave(int wave)
    {
        currentEnemy = 0;
        currentWave  = wave;
        int particleCount = Waves[currentWave].Enemies.Length;

        ParticleSystem.Burst[]        bursts    = new ParticleSystem.Burst[1];
        ParticleSystem.EmissionModule emissions = particlesystem.emission;
        emissions.GetBursts(bursts);
        bursts[0].minCount = (short)particleCount;
        bursts[0].maxCount = (short)particleCount;
        emissions.SetBursts(bursts);

        particlesystem.Play();
    }
        public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }

            ParticleSystem.EmissionModule o = (ParticleSystem.EmissionModule)obj;
            m_bursts = new PersistentParticleSystemNestedBurst[o.burstCount];

            ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[o.burstCount];
            o.GetBursts(bursts);

            for (int i = 0; i < bursts.Length; ++i)
            {
                m_bursts[i] = new PersistentParticleSystemNestedBurst();
                m_bursts[i].ReadFrom(bursts[i]);
            }
        }
コード例 #9
0
    static void WriteParticleSystemEmission(ParticleSystem.EmissionModule module)
    {
        m_writer.Write(module.enabled);
        if (!module.enabled)
        {
            return;
        }

        WriteMinMaxCurve(module.rateOverTime);
        WriteMinMaxCurve(module.rateOverDistance);

        m_writer.Write(module.burstCount);
        ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[module.burstCount];
        module.GetBursts(bursts);
        for (int i = 0; i < bursts.Length; i++)
        {
            m_writer.Write(bursts[i].time);
            m_writer.Write(bursts[i].minCount);
            m_writer.Write(bursts[i].maxCount);
            m_writer.Write(bursts[i].cycleCount);
            m_writer.Write(bursts[i].repeatInterval);
        }
    }
コード例 #10
0
        private static void EnforceParticleLimits(GameObject avatar)
        {
            ParticleScanOptions options = Config.ParticleScanOptions;

            ParticleSystem[] systems = avatar.GetComponentsInChildren <ParticleSystem>(true);

            if (systems.Length == 0)
            {
                Log.Debug("Skipping particle limit check - no particles found on avatar.");
                return;
            }

            if (systems.Length > options.MaxSystems)
            {
                UnityEngine.Object.Destroy(avatar);
                Log.Debug($"Particle limit check - destroyed avatar {avatar.name} - too many particle systems");
                return;
            }

            for (int i = 0; i < systems.Length; i++)
            {
                void DestroyMe()
                {
                    Log.Debug($"Particle limit check - destroyed {systems[i].name}");
                    UnityEngine.Object.Destroy(systems[i].gameObject);
                    UnityEngine.Object.Destroy(systems[i]);
                }

                ParticleSystem.EmissionModule  emission     = systems[i].emission;
                ParticleSystem.Burst[]         bursts       = new ParticleSystem.Burst[emission.burstCount];
                ParticleSystem.CollisionModule collisionMod = systems[i].collision;
                ParticleSystem.LightsModule    lightsMod    = systems[i].lights;

                if (emission.rateOverTime.constantMax > options.Emission || emission.rateOverTime.constantMax < 0)
                {
                    Log.Debug($"Particle limit check - destroying particle system for {emission.rateOverTime.constantMax} rateOverTime emission");
                    DestroyMe();
                }
                else if (emission.rateOverDistance.constantMax > options.Emission || emission.rateOverDistance.constantMax < 0)
                {
                    Log.Debug($"Particle limit check - destroying particle system for {emission.rateOverDistance.constantMax} rateOverDistance emission");
                    DestroyMe();
                }
                else if (lightsMod.maxLights > options.MaxLights)
                {
                    Log.Debug($"Particle limit check - destroying particle system for {lightsMod.maxLights} lights maxcount");
                    DestroyMe();
                }
                else if (emission.burstCount != 0)
                {
                    emission.GetBursts(bursts);

                    for (int x = 0; x < bursts.Length; x++)
                    {
                        if (systems[i] == null)
                        {
                            continue;
                        }

                        short count = bursts[x].maxCount;

                        if (count > options.Bursts || count < 0)
                        {
                            Log.Debug($"Particle limit check - destroying particle system for {count} burst maxCount");
                            DestroyMe();
                        }
                    }
                }

                if (!options.Collision && collisionMod.collidesWith.value == 1024)
                {
                    Log.Debug("Particle limit check - disabling PlayerLocal collision");
                    collisionMod.enabled = false;
                }
                if (collisionMod.maxKillSpeed > options.MaxKill || collisionMod.maxKillSpeed < options.MinKill)
                {
                    Log.Debug($"Particle limit check - disabling collision for {collisionMod.maxKillSpeed} maxKillSpeed");
                    collisionMod.enabled = false;
                }

                if (options.LightSizeConstraint)
                {
                    Log.Debug($"Particle limit check - lights on particle system have had their size constrained");
                    lightsMod.sizeAffectsRange = false;
                }

                if (collisionMod.maxCollisionShapes > 256)
                {
                    Log.Debug($"Particle limit check - destroyed particle system for {collisionMod.maxCollisionShapes} maxCollisionShapes");
                    UnityEngine.Object.Destroy(systems[i]);
                }
            }
        }
コード例 #11
0
    // Linked Particle Objects 들을 노드 위치에 정렬하여 Play 해준다.
    private void PlayLinkedParticles(Vector3 particlePos, int nodeIndex)
    {
        if (soxLtn.particleObjs == null)
        {
            return;
        }
        if (soxLtn.particleObjs.Length == 0)
        {
            return;
        }

        // Linked particle의 개수가 노드 개수보다 작을 수 있어서 파티클 배열 개수보다 높은 인덱스가 들어오면 그냥 리턴
        if (nodeIndex > (soxLtn.particleObjs.Length - 1))
        {
            return;
        }

        if (soxLtn.particleObjs[nodeIndex].particleObj == null)
        {
            return;                                                     // 중간노드 등에서 링크 파티클이 없을 경우 재생 없이 그냥 리턴
        }
        if (ifDisableParticle)
        {
            for (int i = 0; i < soxLtn.particleObjs.Length; i++)
            {
                if (soxLtn.particleObjs[i].particleObj)
                {
                    soxLtn.particleObjs[i].particleObj.SetActive(true);
                }
            }
            ifDisableParticle = false;
        }

        //플레이 위치로 이동
        soxLtn.particleObjs[nodeIndex].particleObj.transform.position = particlePos;
        //조건부 회전
        if (soxLtn.particleObjs[nodeIndex].rotationAlign)
        {
            soxLtn.particleObjs[nodeIndex].particleObj.transform.rotation = soxLtnNodes[nodeIndex].transform.rotation;
        }
        soxLtn.particleObjs[nodeIndex].particleObj.transform.localScale = Vector3.one;

        if (firstStreakAtFrame)
        {
            // 현재 프레임에서 첫 파티클 플레이인 경우
            ParticleSystem[] tParticles = soxLtn.particleObjs[nodeIndex].particleObj.GetComponentsInChildren <ParticleSystem>();
            foreach (ParticleSystem tParticle in tParticles)
            {
                tParticle.Play();
            }
        }
        else
        {
            if (soxLtn.oneLinkedParticleAtFrame == false)
            {
                // 현재 프레임에서 첫 Streak이 아닌 나머지 것들은 Emit()으로 처리해야함
                // 몇 개가 될지 모르는 파티클들에게 Emit 신호 뿌려주기
                ParticleSystem[] tParticles = soxLtn.particleObjs[nodeIndex].particleObj.GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem ps in tParticles)
                {
                    int emitCount = 0;
                    ParticleSystem.EmissionModule e = ps.emission;

                    if (e.burstCount > 0)
                    {
                        ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[e.burstCount];

                        e.GetBursts(bursts);
                        emitCount = (int)bursts[0].maxCount;
                    }
                    ps.Emit(emitCount);
                }
            }
        }
    } // end of PlayLinkedParticles()