Пример #1
0
        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;
        }
Пример #2
0
        void ActivateOnOneTatget(EffectApplicationData app_data, Entity target)
        {
            EffectRegistry registry = EntityUtil.GetEffectRegistry(target);

            if (registry == null)
            {
                return;
            }
            if (!registry.CanAddEffect())
            {
                return;
            }
            Effect effect = CreateEffect(target.ID);

            if (effect == null)
            {
                return;
            }
            app_data.m_target_entity_id = target.ID;
            app_data.m_generator_id     = m_generator.ID;
            app_data.m_entry_index      = m_index;
            EffectDefinitionComponent definition_cmp = effect.GetDefinitionComponent();

            definition_cmp.InitializeApplicationData(app_data);
            if (!registry.AddEffect(effect))
            {
                m_generator.GetLogicWorld().GetEffectManager().DestroyObject(effect.ID);
            }
            else
            {
                m_effect2entity[effect.ID] = target.ID;
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }