Exemplo n.º 1
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);
        }
Exemplo n.º 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;
            }
        }
        public override void Apply()
        {
            if (m_task == null)
            {
                m_task = LogicTask.Create <ComponentCommonTaskWithLastingTime>();
            }

            EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent();
            Entity entity = GetLogicWorld().GetEntityManager().GetObject(definition_component.SourceEntityID);

            if (entity != null)
            {
                PositionComponent position_component = entity.GetComponent(PositionComponent.ID) as PositionComponent;
                if (position_component != null)
                {
                    m_direction = position_component.Facing3D;
                }
            }
            m_task.Construct(this, m_time);
            var schedeler = GetLogicWorld().GetTaskScheduler();

            schedeler.Schedule(m_task, GetCurrentTime(), LOGIC_UPDATE_INTERVAL, LOGIC_UPDATE_INTERVAL);
#if COMBAT_CLIENT
            LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>();
            msg.ConstructAsStartMoving(GetOwnerEntityID(), true, LocomoteRenderMessage.NotLocomotion);
            GetLogicWorld().AddRenderMessage(msg);
#endif
        }
        bool AreConflicting(Effect effect1, Effect effect2)
        {
            EffectDefinitionComponent cmp1 = effect1.GetDefinitionComponent();
            EffectDefinitionComponent cmp2 = effect2.GetDefinitionComponent();

            if (cmp1.ConflictID == cmp2.ConflictID)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        public void RemoveEffect(int effect_id)
        {
            Effect effect;

            if (!m_effects_by_id.TryGetValue(effect_id, out effect))
            {
                return;
            }
            EffectDefinitionComponent definition_cmp = effect.GetDefinitionComponent();
            ClassifiedEffectContainer container      = GetContainer(definition_cmp.Category);

            if (container == null)
            {
                return;
            }
            container.RemoveEffect(effect);
            m_effects_by_id.Remove(effect_id);
        }
Exemplo n.º 6
0
        int AddModifier(AttributeModifierConfig modifier_config, FixPoint modifier_value)
        {
            AttributeModifier attribute_modifier = RecyclableObject.Create <AttributeModifier>();

            attribute_modifier.Construct(GetLogicWorld().GetAttributeModifierIDGenerator().GenID(), modifier_config.m_attribute_category, modifier_value);

            EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent();
            EntityManager             entity_manager       = GetLogicWorld().GetEntityManager();
            Entity    owner_entity = entity_manager.GetObject(definition_component.TargetEntityID);
            Attribute attribute    = EntityUtil.GetAttribute(owner_entity, modifier_config.m_attribute_id);

            if (attribute == null)
            {
                return(0);
            }
            attribute.AddModifier(attribute_modifier);
            return(attribute_modifier.ID);
        }
Exemplo n.º 7
0
        void ApplyOnce()
        {
            if (m_remain_count > 0)
            {
                --m_remain_count;
            }
            if (m_remain_count == 0)
            {
                CancelTask();
            }
            Entity owner = GetOwnerEntity();
            EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent();
            EffectApplicationData     app_data             = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = definition_component.OriginalEntityID;
            app_data.m_source_entity_id   = owner.ID;
            m_generator.Activate(app_data, owner);
            RecyclableObject.Recycle(app_data);
        }
Exemplo n.º 8
0
        public bool AddEffect(Effect effect)
        {
            if (!CanAddEffect())
            {
                return(false);
            }
            EffectDefinitionComponent definition_cmp = effect.GetDefinitionComponent();
            ClassifiedEffectContainer container      = GetContainer(definition_cmp.Category);

            if (container == null)
            {
                return(false);
            }
            if (!container.AddEffect(effect))
            {
                return(false);
            }
            m_effects_by_id[effect.ID] = effect;
            return(true);
        }
Exemplo n.º 9
0
        public override void Unapply()
        {
            if (m_modifier_ids == null)
            {
                return;
            }
            EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent();
            EntityManager             entity_manager       = GetLogicWorld().GetEntityManager();
            Entity owner_entity = entity_manager.GetObject(definition_component.TargetEntityID);

            for (int i = 0; i < m_modifier_ids.Length; ++i)
            {
                Attribute attribute = EntityUtil.GetAttribute(owner_entity, m_modefier_configs[i].m_attribute_id);
                if (attribute != null)
                {
                    attribute.RemoveModifier(m_modifier_ids[i]);
                    m_modifier_ids[i] = 0;
                }
            }
        }
        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);
        }
        void ApplyDamage()
        {
            EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent();
            EntityManager             entity_manager       = GetLogicWorld().GetEntityManager();
            Entity attacker = entity_manager.GetObject(definition_component.OriginalEntityID);
            Entity target   = entity_manager.GetObject(definition_component.TargetEntityID);

            DamagableComponent damageable_component = target.GetComponent(DamagableComponent.ID) as DamagableComponent;

            if (damageable_component == null)
            {
                return;
            }
            Damage damage = RecyclableObject.Create <Damage>();

            damage.m_attacker_id         = definition_component.OriginalEntityID;
            damage.m_defender_id         = definition_component.TargetEntityID;
            damage.m_damage_type         = m_damage_type_id;
            damage.m_damage_amount       = m_damage_amount.Evaluate(this);
            damage.m_damage_amount       = DamageSystem.Instance.CalculateDamageAmount(m_damage_type_id, damage.m_damage_amount, attacker, target);
            damage.m_render_effect_cfgid = m_damage_render_effect_cfgid;
            damage.m_sound_cfgid         = m_damage_sound_cfgid;
            damageable_component.TakeDamage(damage);
        }
Exemplo n.º 12
0
 protected override void OnDestruct()
 {
     m_definition_component = null;
 }
Exemplo n.º 13
0
 protected override void PostInitializeObject(ObjectCreationContext context)
 {
     m_definition_component = GetComponent(EffectDefinitionComponent.ID) as EffectDefinitionComponent;
 }