Пример #1
0
        public IMyParticleGeneration Duplicate(MyParticleEffect effect)
        {
            MyParticleGPUGeneration generation = MyParticlesManager.GPUGenerationsPool.Allocate();

            generation.Start(effect);

            generation.Name = Name;

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

            return(generation);
        }
Пример #2
0
        public IMyParticleGeneration CreateInstance(MyParticleEffect effect)
        {
            MyParticleGPUGeneration generation = MyParticlesManager.GPUGenerationsPool.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];
            }

            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
        }