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); }