public void Deactivate() { if (m_effect2entity.Count == 0) { return; } LogicWorld logic_world = m_generator.GetLogicWorld(); EntityManager entity_manager = logic_world.GetEntityManager(); SortedDictionary <int, int> temp = m_effect2entity; m_effect2entity = null; var enumerator = temp.GetEnumerator(); while (enumerator.MoveNext()) { Entity entity = entity_manager.GetObject(enumerator.Current.Value); EffectRegistry registry = EntityUtil.GetEffectRegistry(entity); if (registry != null) { registry.RemoveEffect(enumerator.Current.Key); } } temp.Clear(); m_effect2entity = temp; }
public override void Run(LogicWorld logic_world, FixPoint current_time, FixPoint delta_time) { Entity entity = logic_world.GetEntityManager().GetObject(m_entity_id); if (entity == null) { return; } EffectRegistry registry = EntityUtil.GetEffectRegistry(entity); if (registry == null) { return; } Effect effect = registry.GetEffect(m_effect_id); if (effect == null) { return; } EffectDefinitionComponent definition_cmp = effect.GetDefinitionComponent(); if (definition_cmp.ExpirationTime > logic_world.GetCurrentTime()) { return; } registry.RemoveEffect(m_effect_id); }
public override void Run(LogicWorld logic_world, FixPoint current_time, FixPoint delta_time) { Entity entity = logic_world.GetEntityManager().GetObject(m_entity_id); if (entity == null) { return; } EffectRegistry registry = EntityUtil.GetEffectRegistry(entity); if (registry == null) { return; } registry.RemoveEffect(m_effect_id); LogicTask.Recycle(this); }
public bool AddEffect(Effect effect) { EffectDefinitionComponent definition_cmp = effect.GetDefinitionComponent(); if (definition_cmp.ExpirationTime <= effect.GetCurrentTime()) { effect.Apply(); effect.Unapply(); return(false); } int count = m_active_effects.Count; for (int i = 0; i < count;) { Effect active_effect = m_active_effects[i]; if (!AreConflicting(effect, active_effect)) { ++i; continue; } Effect rejected_effect = PickRejectedEffect(effect, active_effect); if (rejected_effect == effect) { return(false); } else { m_registry.RemoveEffect(active_effect.ID); count = m_active_effects.Count; } } m_active_effects.Add(effect); effect.Apply(); definition_cmp.StartExpirationTask(); return(true); }