public MyParticleGeneration Duplicate(MyParticleEffect effect)
        {
            MyParticleGeneration generation = MyParticlesManager.GenerationsPool.Allocate();

            generation.Start(effect);

            generation.Name = Name;

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

            m_emitter.Duplicate(generation.m_emitter);

            return(generation);
        }
        public MyParticleGeneration CreateInstance(MyParticleEffect effect)
        {
            MyParticleGeneration generation = MyParticlesManager.GenerationsPool.Allocate(true);

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

            generation.Start(effect);

            generation.Name = Name;

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

            generation.m_emitter.CreateInstance(m_emitter);

            return(generation);
        }
예제 #3
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
        }