예제 #1
0
        public void DeserializeFromObjectBuilder(MyObjectBuilder_ParticleEffect builder)
        {
            m_name        = builder.Id.SubtypeName;
            m_particleID  = builder.ParticleId;
            m_length      = builder.Length;
            m_loop        = builder.Loop;
            m_durationMin = builder.DurationMin;
            m_durationMax = builder.DurationMax;
            SetRandomDuration();

            foreach (ParticleGeneration generation in builder.ParticleGenerations)
            {
                switch (generation.GenerationType)
                {
                case "CPU":
                    if (MyParticlesManager.EnableCPUGenerations)
                    {
                        MyParticleGeneration genCPU;
                        MyParticlesManager.GenerationsPool.AllocateOrCreate(out genCPU);
                        genCPU.Start(this);
                        genCPU.Init();
                        genCPU.DeserializeFromObjectBuilder(generation);
                        AddGeneration(genCPU);
                    }
                    break;

                case "GPU":
                    MyParticleGPUGeneration genGPU;
                    MyParticlesManager.GPUGenerationsPool.AllocateOrCreate(out genGPU);
                    genGPU.Start(this);
                    genGPU.Init();
                    genGPU.DeserializeFromObjectBuilder(generation);
                    AddGeneration(genGPU);
                    break;
                }
            }

            foreach (ParticleLight particleLight in builder.ParticleLights)
            {
                MyParticleLight light;
                MyParticlesManager.LightsPool.AllocateOrCreate(out light);
                light.Start(this);
                light.Init();
                light.DeserializeFromObjectBuilder(particleLight);
                AddParticleLight(light);
            }

            foreach (ParticleSound particleSound in builder.ParticleSounds)
            {
                MyParticleSound sound;
                MyParticlesManager.SoundsPool.AllocateOrCreate(out sound);
                sound.Start(this);
                sound.Init();
                sound.DeserializeFromObjectBuilder(particleSound);
                AddParticleSound(sound);
            }
        }
예제 #2
0
        public void DeserializeFromObjectBuilder(MyObjectBuilder_ParticleEffect builder)
        {
            m_name = builder.Id.SubtypeName;
            m_particleID = builder.ParticleId;
            m_length = builder.Length;
            m_loop = builder.Loop;
            m_durationMin = builder.DurationMin;
            m_durationMax = builder.DurationMax;
            SetRandomDuration();

            foreach (ParticleGeneration generation in builder.ParticleGenerations)
            {
                switch (generation.GenerationType)
                {
                    case "CPU":
                        MyParticleGeneration genCPU;
                        MyParticlesManager.GenerationsPool.AllocateOrCreate(out genCPU);
                        genCPU.Start(this);
                        genCPU.Init();
                        genCPU.DeserializeFromObjectBuilder(generation);
                        AddGeneration(genCPU);
                        break;

                    case "GPU":
                        MyParticleGPUGeneration genGPU;
                        MyParticlesManager.GPUGenerationsPool.AllocateOrCreate(out genGPU);
                        genGPU.Start(this);
                        genGPU.Init();
                        genGPU.DeserializeFromObjectBuilder(generation);
                        AddGeneration(genGPU);
                        break;
                }
            }

            foreach (ParticleLight particleLight in builder.ParticleLights)
            {
                MyParticleLight light;
                MyParticlesManager.LightsPool.AllocateOrCreate(out light);
                light.Start(this);
                light.Init();
                light.DeserializeFromObjectBuilder(particleLight);
                AddParticleLight(light);
            }

            foreach (ParticleSound particleSound in builder.ParticleSounds)
            {
                MyParticleSound sound;
                MyParticlesManager.SoundsPool.AllocateOrCreate(out sound);
                sound.Start(this);
                sound.Init();
                sound.DeserializeFromObjectBuilder(particleSound);
                AddParticleSound(sound);
            }
        }