Exemplo n.º 1
0
        public MyParticleEffect CreateInstance()
        {
            MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate(true);

            if (effect != null)
            {
                effect.Start(m_particleID);

                effect.Name          = Name;
                effect.Enabled       = Enabled;
                effect.Length        = Length;
                effect.m_globalScale = m_globalScale;
                effect.LowRes        = LowRes;
                effect.Loop          = m_loop;
                effect.DurationMin   = m_durationMin;
                effect.DurationMax   = m_durationMax;
                effect.SetRandomDuration();

                foreach (IMyParticleGeneration generation in m_generations)
                {
                    IMyParticleGeneration gen = generation.CreateInstance(effect);
                    if (gen != null)
                    {
                        effect.AddGeneration(gen);
                    }
                }

                foreach (MyParticleLight particleLight in m_particleLights)
                {
                    MyParticleLight pl = particleLight.CreateInstance(effect);
                    if (pl != null)
                    {
                        effect.AddParticleLight(pl);
                    }
                }

                foreach (MyParticleSound particleSound in m_particleSounds)
                {
                    MyParticleSound ps = particleSound.CreateInstance(effect);
                    if (ps != null)
                    {
                        effect.AddParticleSound(ps);
                    }
                }

                if (m_instances == null)
                {
                    m_instances = new List <MyParticleEffect>();
                }

                m_instances.Add(effect);
            }

            return(effect);
        }