コード例 #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);
        }
コード例 #2
0
        public void AddParticleSound(MyParticleSound particleSound)
        {
            m_particleSounds.Add(particleSound);

            if (m_instances != null)
            {
                foreach (MyParticleEffect effect in m_instances)
                {
                    effect.AddParticleSound(particleSound.CreateInstance(effect));
                }
            }
        }
コード例 #3
0
        public MyParticleEffect CreateInstance()
        {
            MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate(true);

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

                effect.Name    = Name;
                effect.Enabled = Enabled;
                effect.SetLength(GetLength());
                effect.SetPreload(GetPreload());
                effect.LowRes = LowRes;

                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);
        }
コード例 #4
0
        public MyParticleSound Duplicate(MyParticleEffect effect)
        {
            MyParticleSound particleSound = MyParticlesManager.SoundsPool.Allocate();

            particleSound.Start(effect);

            particleSound.Name = Name;

            for (int i = 0; i < m_properties.Length; i++)
            {
                particleSound.m_properties[i] = m_properties[i].Duplicate();
            }

            return(particleSound);
        }
コード例 #5
0
        public void RemoveParticleSound(int index)
        {
            MyParticleSound particleSound = m_particleSounds[index];

            m_particleSounds.Remove(particleSound);

            particleSound.Close();
            MyParticlesManager.SoundsPool.Deallocate(particleSound);

            if (m_instances != null)
            {
                foreach (MyParticleEffect effect in m_instances)
                {
                    effect.RemoveParticleSound(index);
                }
            }
        }
コード例 #6
0
        public MyParticleSound CreateInstance(MyParticleEffect effect)
        {
            MyParticleSound particleSound = MyParticlesManager.SoundsPool.Allocate(true);

            if (particleSound == null)
            {
                return(null);
            }

            particleSound.Start(effect);

            particleSound.Name = Name;

            for (int i = 0; i < m_properties.Length; i++)
            {
                particleSound.m_properties[i] = m_properties[i];
            }

            return(particleSound);
        }
コード例 #7
0
        public void RemoveParticleSound(MyParticleSound particleSound)
        {
            int index = m_particleSounds.IndexOf(particleSound);

            RemoveParticleSound(index);
        }
コード例 #8
0
        public void Deserialize(XmlReader reader)
        {
            m_name = reader.GetAttribute("name");
            int version = Convert.ToInt32(reader.GetAttribute("version"), CultureInfo.InvariantCulture);

            reader.ReadStartElement(); //ParticleEffect

            m_particleID = reader.ReadElementContentAsInt();

            m_length = reader.ReadElementContentAsFloat();

            m_preload = reader.ReadElementContentAsFloat();

            if (reader.Name == "LowRes")
            {
                LowRes = reader.ReadElementContentAsBoolean();
            }

            bool isEmpty = reader.IsEmptyElement;

            reader.ReadStartElement(); //Generations

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                if (isEmpty)
                {
                    break;
                }

                if (reader.Name == "ParticleGeneration")
                {
                    MyParticleGeneration generation = MyParticlesManager.GenerationsPool.Allocate();
                    generation.Start(this);
                    generation.Init();

                    generation.Deserialize(reader);

                    AddGeneration(generation);
                }
                else
                if (reader.Name == "ParticleGPUGeneration")
                {
                    MyParticleGPUGeneration generation = MyParticlesManager.GPUGenerationsPool.Allocate();
                    generation.Start(this);
                    generation.Init();

                    generation.Deserialize(reader);

                    AddGeneration(generation);
                }
            }

            if (!isEmpty)
            {
                reader.ReadEndElement(); //Generations
            }
            if (reader.NodeType != XmlNodeType.EndElement)
            {
                isEmpty = reader.IsEmptyElement;
                if (isEmpty)
                {
                    reader.Read();
                }
                else
                {
                    reader.ReadStartElement(); //Particle lights

                    while (reader.NodeType != XmlNodeType.EndElement)
                    {
                        MyParticleLight particleLight = MyParticlesManager.LightsPool.Allocate();
                        particleLight.Start(this);
                        particleLight.Init();

                        particleLight.Deserialize(reader);

                        AddParticleLight(particleLight);
                    }

                    reader.ReadEndElement(); //Particle lights
                }
            }

            if (reader.NodeType != XmlNodeType.EndElement)
            {
                isEmpty = reader.IsEmptyElement;
                if (isEmpty)
                {
                    reader.Read();
                }
                else
                {
                    reader.ReadStartElement(); //Particle sounds

                    while (reader.NodeType != XmlNodeType.EndElement)
                    {
                        MyParticleSound particleSound = MyParticlesManager.SoundsPool.Allocate();
                        particleSound.Start(this);
                        particleSound.Init();

                        particleSound.Deserialize(reader);

                        AddParticleSound(particleSound);
                    }

                    reader.ReadEndElement(); //Particle sounds
                }
            }

            reader.ReadEndElement(); //ParticleEffect
        }