public void DestroyGenerator(int generator_id, int owner_entity_id) { EffectGenerator generator; if (!m_generators.TryGetValue(generator_id, out generator)) { return; } if (generator.RemoveBySelf && !generator.RemoveSelfWhenIdle) { generator.RemoveSelfWhenIdle = true; } else { generator.ForceDeactivate(); m_generators.Remove(generator_id); Entity owner = m_logic_world.GetEntityManager().GetObject(owner_entity_id); EffectGeneratorRegistry registry = EntityUtil.GetEffectGeneratorRegistry(owner); if (registry != null) { registry.RemoveGenerator(generator_id); } RecyclableObject.Recycle(generator); } }
public EffectGenerator CreateGenerator(int generator_id, Entity owner) { IConfigProvider config_provider = m_logic_world.GetConfigProvider(); EffectGeneratorData data = config_provider.GetEffectGeneratorData(generator_id); if (data == null) { return(null); } int id = m_generator_id_generator.GenID(); EffectGenerator generator = RecyclableObject.Create <EffectGenerator>(); generator.Construct(m_logic_world, id, data); m_generators[id] = generator; EffectGeneratorRegistry registry = EntityUtil.GetEffectGeneratorRegistry(owner); if (registry != null) { registry.AddGenerator(generator); } return(generator); }