Exemple #1
0
        public void OnEntityEnter(int entity_id)
        {
            Entity owner = GetOwnerEntity();

            if (ObjectUtil.IsDead(owner))
            {
                return;
            }
            if (m_enter_generator == null)
            {
                return;
            }
            Entity entity = GetLogicWorld().GetEntityManager().GetObject(entity_id);

            if (entity == null)
            {
                return;
            }
            if (ObjectUtil.IsDead(entity))
            {
                return;
            }
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = ParentObject.ID;
            app_data.m_source_entity_id   = ParentObject.ID;
            m_enter_generator.Activate(app_data, entity);
            RecyclableObject.Recycle(app_data);
        }
Exemple #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 void CopyFrom(EffectApplicationData rhs)
 {
     m_original_entity_id = rhs.m_original_entity_id;
     m_source_entity_id   = rhs.m_source_entity_id;
     m_target_entity_id   = rhs.m_target_entity_id;
     m_generator_id       = rhs.m_generator_id;
     m_entry_index        = rhs.m_entry_index;
 }
        void ApplyGenerator(EffectGenerator generator)
        {
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = ParentObject.ID;
            app_data.m_source_entity_id   = ParentObject.ID;
            generator.Activate(app_data, GetOwnerEntity());
            RecyclableObject.Recycle(app_data);
        }
 public void Activate(EffectApplicationData app_data, Entity target)
 {
     Deactivate();
     for (int i = 0; i < m_entries.Count; ++i)
     {
         m_entries[i].Activate(app_data, target);
     }
     m_is_active = true;
 }
        public void KillOwner(int killer_id)
        {
            //ZZWTODO Resurrect

            if (m_die_task != null)
            {
                m_die_task.Cancel();
            }
            LogicWorld logic_world = GetLogicWorld();

            Entity killer = logic_world.GetEntityManager().GetObject(killer_id);

            if (!DieSilently && killer_id != ParentObject.ID && m_killer_generator != null && killer != null)
            {
                EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();
                app_data.m_original_entity_id = ParentObject.ID;
                app_data.m_source_entity_id   = ParentObject.ID;
                m_killer_generator.Activate(app_data, killer);
                RecyclableObject.Recycle(app_data);
            }

            var schedeler = logic_world.GetTaskScheduler();

            if (DieSilently)
            {
                logic_world.AddSimpleRenderMessage(RenderMessageType.Hide, ParentObject.ID);
            }
            else
            {
                HideEntityTask hide_task = LogicTask.Create <HideEntityTask>();
                hide_task.Construct(ParentObject.ID);
                schedeler.Schedule(hide_task, GetCurrentTime(), m_hide_delay);
            }

            ParentObject.DeletePending = true;
            ParentObject.SendSignal(SignalType.Die);
            logic_world.AddSimpleRenderMessage(RenderMessageType.Die, ParentObject.ID);

            StateComponent state_component = ParentObject.GetComponent(StateComponent.ID) as StateComponent;

            if (state_component != null)
            {
                state_component.AddState(StateSystem.DEAD_STATE, 0);
            }

            if (!m_can_resurrect)
            {
                DeleteEntityTask delete_task = LogicTask.Create <DeleteEntityTask>();
                delete_task.Construct(ParentObject.ID);
                schedeler.Schedule(delete_task, GetCurrentTime(), m_delete_delay);
            }

            logic_world.OnKillEntity(killer, GetOwnerEntity());
        }
Exemple #7
0
 public void Activate(EffectApplicationData app_data, Entity target)
 {
     if (m_data.m_target_gathering_param.m_type == TargetGatheringType.Default || m_data.m_target_gathering_param.m_type == 0)
     {
         ActivateOnOneTatget(app_data, target);
     }
     else
     {
         GatherTargetsAndActivate(app_data);
     }
 }
        void ApplyGenerator(Entity entity)
        {
            LogicWorld      logic_world = GetLogicWorld();
            EffectGenerator generator   = logic_world.GetEffectManager().GetGenerator(m_param.m_generator_id);

            if (generator == null)
            {
                return;
            }
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = m_param.m_source_entity_id;
            app_data.m_source_entity_id   = GetOwnerEntityID();
            generator.Activate(app_data, entity);
            RecyclableObject.Recycle(app_data);
        }
        public void InitializeApplicationData(EffectApplicationData app_data)
        {
            m_original_entity_id = app_data.m_original_entity_id;
            m_source_entity_id   = app_data.m_source_entity_id;
            m_target_entity_id   = app_data.m_target_entity_id;
            m_generator_id       = app_data.m_generator_id;
            m_entry_index        = app_data.m_entry_index;
            FixPoint duration = m_duration.Evaluate(this);

            if (duration < 0)
            {
                m_expiration_time = FixPoint.MaxValue;
            }
            else
            {
                m_expiration_time = ParentObject.CreationTime + duration;
            }
        }
Exemple #10
0
 public void Activate(EffectApplicationData app_data, List <Target> default_targets)
 {
     if (m_data.m_target_gathering_param.m_type == TargetGatheringType.Default || m_data.m_target_gathering_param.m_type == 0)
     {
         LogicWorld logic_world = m_generator.GetLogicWorld();
         for (int i = 0; i < default_targets.Count; ++i)
         {
             Entity entity = default_targets[i].GetEntity(logic_world);
             if (entity != null)
             {
                 ActivateOnOneTatget(app_data, entity);
             }
         }
     }
     else
     {
         GatherTargetsAndActivate(app_data);
     }
 }
Exemple #11
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);
        }
Exemple #12
0
        void DetectCollision(ISpacePartition partition, Vector3FP position, FixPoint radius)
        {
            if (partition == null)
            {
                return;
            }
            SkillComponent           skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
            Skill                    skill           = skill_component.GetOwnerSkill();
            List <PositionComponent> list            = partition.CollectEntity_SurroundingRing(position, radius, FixPoint.Zero, skill.GetOwnerEntityID());

            if (list.Count == 0)
            {
                return;
            }
            for (int i = 0; i < list.Count; ++i)
            {
                PositionComponent position_component = list[i];
                Entity            entity             = position_component.GetOwnerEntity();
                if (m_collided_targets.Contains(entity.ID))
                {
                    continue;
                }
                m_collided_targets.Add(entity.ID);
                if (position_component.Height <= FixPoint.Zero) //ZZWTODO
                {
                    continue;
                }
                if (!FactionRelation.IsFactionSatisfied(skill.GetOwnerPlayer().GetFaction(entity.GetOwnerPlayerID()), FactionRelation.NotAlly))
                {
                    continue;
                }
                Entity current_target = entity;
                skill_component.CurrentTarget = current_target;
                EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();
                app_data.m_original_entity_id = skill.GetOwnerEntityID();
                app_data.m_source_entity_id   = app_data.m_original_entity_id;
                m_collision_target_generator.Activate(app_data, entity);
                RecyclableObject.Recycle(app_data);
            }
            skill_component.CurrentTarget = null;
        }
        protected override void OnActionUpdate(FixPoint delta_time)
        {
            if (m_generator == null)
            {
                return;
            }
            SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
            Skill          skill           = skill_component.GetOwnerSkill();
            List <Target>  targets         = skill.GetTargets();

            if (targets.Count == 0)
            {
                return;
            }
            Entity caster = skill.GetOwnerEntity();
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = caster.ID;
            app_data.m_source_entity_id   = caster.ID;
            m_generator.Activate(app_data, targets);
            RecyclableObject.Recycle(app_data);
        }
Exemple #14
0
        void GatherTargetsAndActivate(EffectApplicationData app_data)
        {
            LogicWorld logic_world   = m_generator.GetLogicWorld();
            Entity     source_entity = logic_world.GetEntityManager().GetObject(app_data.m_source_entity_id);

            if (source_entity == null)
            {
                return;
            }
            if (m_targets == null)
            {
                m_targets = new List <Target>();
            }
            m_generator.GetLogicWorld().GetTargetGatheringManager().BuildTargetList(source_entity, m_data.m_target_gathering_param, m_targets);
            for (int i = 0; i < m_targets.Count; ++i)
            {
                Entity entity = m_targets[i].GetEntity(logic_world);
                if (entity != null)
                {
                    ActivateOnOneTatget(app_data, entity);
                }
            }
            ClearTargets();
        }
Exemple #15
0
        public void OnTaskService(FixPoint delta_time)
        {
            List <int> ids = m_region.GetCurrentEnteredObjects();

            if (ids.Count == 0)
            {
                return;
            }
            EntityManager         entity_manager = GetLogicWorld().GetEntityManager();
            EffectApplicationData app_data       = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = ParentObject.ID;
            app_data.m_source_entity_id   = ParentObject.ID;
            for (int i = 0; i < ids.Count; ++i)
            {
                Entity entity = entity_manager.GetObject(ids[i]);
                if (entity == null)
                {
                    continue;
                }
                m_period_generator.Activate(app_data, entity);
            }
            RecyclableObject.Recycle(app_data);
        }
        void Impact()
        {
            Skill skill = GetOwnerSkill();

            if (!skill.GetDefinitionComponent().NeedGatherTargets)
            {
                skill.BuildSkillTargets();
            }
            List <Target>         targets  = skill.GetTargets();
            Entity                caster   = GetOwnerEntity();
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = caster.ID;
            app_data.m_source_entity_id   = caster.ID;
            m_generator.Activate(app_data, targets);
            m_current_target = null;
            RecyclableObject.Recycle(app_data);
#if COMBAT_CLIENT
            if (m_render_effect_cfgid > 0 && m_render_delay_time <= FixPoint.Zero)
            {
                PlayRenderEffect();
            }
#endif
        }
Exemple #17
0
        public static Entity CreateEntityForSkillAndEffect(Component caller_component, Entity owner_entity, Target projectile_target, Vector3FP position_offset, FixPoint angle_offset, int object_type_id, int object_proto_id, FixPoint object_life_time, EffectGenerator attached_generator)
        {
            LogicWorld      logic_world = owner_entity.GetLogicWorld();
            IConfigProvider config      = logic_world.GetConfigProvider();
            ObjectTypeData  type_data   = config.GetObjectTypeData(object_type_id);

            if (type_data == null)
            {
                return(null);
            }

            PositionComponent owner_position_cmp = owner_entity.GetComponent(PositionComponent.ID) as PositionComponent;
            Vector3FP         source_pos         = owner_position_cmp.CurrentPosition;

            Vector2FP xz_facing;
            FixPoint  angle;
            Vector3FP facing;

            if (projectile_target == null)
            {
                xz_facing = owner_position_cmp.Facing2D;
                angle     = owner_position_cmp.FacingAngle;
                facing.x  = xz_facing.x;
                facing.y  = FixPoint.Zero;
                facing.z  = xz_facing.z;
            }
            else
            {
                Vector3FP target_pos = projectile_target.GetPosition(logic_world);
                xz_facing.x = target_pos.x - source_pos.x;
                xz_facing.z = target_pos.z - source_pos.z;
                xz_facing.Normalize();
                angle  = xz_facing.ToDegree();
                facing = target_pos - source_pos;
                facing.Normalize();
            }
            Vector2FP side      = xz_facing.Perpendicular();
            Vector2FP xz_offset = xz_facing * position_offset.z + side * position_offset.x;

            if (angle_offset != FixPoint.Zero)
            {
                angle += angle_offset;
                FixPoint radian = FixPoint.Degree2Radian(-angle);
                facing.x = FixPoint.Cos(radian);
                facing.z = FixPoint.Sin(radian);
            }

            Vector3FP         birth_position = new Vector3FP(source_pos.x + xz_offset.x, source_pos.y + position_offset.y, source_pos.z + xz_offset.z);
            BirthPositionInfo birth_info     = new BirthPositionInfo(birth_position.x, birth_position.y, birth_position.z, angle, owner_position_cmp.GetCurrentSceneSpace());

            ProjectileComponent owner_entity_projectile_component = owner_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent;

            if (owner_entity_projectile_component != null)
            {
                Entity original_owner = logic_world.GetEntityManager().GetObject(owner_entity_projectile_component.SourceEntityID);
                if (original_owner != null)
                {
                    owner_entity = original_owner;
                }
            }

            Player owner_player = owner_entity.GetOwnerPlayer();
            ObjectCreationContext object_context = new ObjectCreationContext();

            object_context.m_object_proxy_id = owner_player.ProxyID;
            object_context.m_object_type_id  = object_type_id;
            object_context.m_object_proto_id = object_proto_id;
            object_context.m_birth_info      = birth_info;
            object_context.m_type_data       = type_data;
            object_context.m_proto_data      = config.GetObjectProtoData(object_proto_id);
            object_context.m_logic_world     = logic_world;
            object_context.m_owner_id        = owner_player.ID;
            object_context.m_is_ai           = true;
            object_context.m_is_local        = owner_player.IsLocal;

            Entity created_entity = logic_world.GetEntityManager().CreateObject(object_context);

            DeathComponent death_component = created_entity.GetComponent(DeathComponent.ID) as DeathComponent;

            if (death_component != null && object_life_time > FixPoint.Zero)
            {
                death_component.SetLifeTime(object_life_time);
            }

            SummonedEntityComponent summoned_component = created_entity.GetComponent(SummonedEntityComponent.ID) as SummonedEntityComponent;

            if (summoned_component != null)
            {
                summoned_component.SetMaster(owner_entity);
            }

            ProjectileComponent projectile_component = created_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent;

            if (projectile_component != null)
            {
                ProjectileParameters param = RecyclableObject.Create <ProjectileParameters>();
                param.m_start_time       = logic_world.GetCurrentTime();
                param.m_life_time        = object_life_time;
                param.m_source_entity_id = owner_entity.ID;
                param.m_start_position   = birth_position;
                param.m_fixed_facing     = facing;
                if (projectile_target != null)
                {
                    param.m_target_entity_id = projectile_target.GetEntityID();
                    param.m_target_position  = projectile_target.GetPosition(logic_world);
                }
                else
                {
                    Skill          owner_skill     = null;
                    SkillComponent skill_componnet = caller_component as SkillComponent;
                    if (skill_componnet != null)
                    {
                        owner_skill = skill_componnet.GetOwnerSkill();
                    }
                    if (owner_skill != null && owner_skill.GetDefinitionComponent().ExternalDataType == SkillDefinitionComponent.NeedExternalTarget)
                    {
                        param.m_target_entity_id = 0;
                        FixPoint range = owner_skill.GetDefinitionComponent().MaxRange;
                        if (range <= 0)
                        {
                            range = FixPoint.Ten;  //ZZWTODO
                        }
                        if (projectile_component.Speed > FixPoint.Zero)
                        {
                            param.m_life_time = range / projectile_component.Speed;
                        }
                        param.m_target_position = param.m_start_position + param.m_fixed_facing * range;
                    }
                }
                param.m_generator_id = attached_generator == null ? 0 : attached_generator.ID;
                projectile_component.InitParam(param);
            }
            else if (attached_generator != null)
            {
                EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();
                app_data.m_original_entity_id = owner_entity.ID;
                app_data.m_source_entity_id   = owner_entity.ID;
                attached_generator.Activate(app_data, created_entity);
                RecyclableObject.Recycle(app_data);
            }
            return(created_entity);
        }