Beispiel #1
0
        protected override void PostInitializeComponent()
        {
            Entity            owner = GetOwnerEntity();
            PositionComponent position_component = owner.GetComponent(PositionComponent.ID) as PositionComponent;

            if (position_component == null)
            {
                return;
            }

            EffectManager effect_manager = GetLogicWorld().GetEffectManager();

            if (m_enter_generator_cfgid > 0)
            {
                m_enter_generator = effect_manager.CreateGenerator(m_enter_generator_cfgid, owner);
            }
            if (m_period_generator_cfgid > 0)
            {
                m_period_generator = effect_manager.CreateGenerator(m_period_generator_cfgid, owner);
            }

            m_region = GetLogicWorld().GetRegionCallbackManager().CreateRegion();
            m_region.Construct(this, owner);
            m_region.SetUpdateInterval(m_region_update_interval);
            m_region.SetTargetGatheringParam(m_target_gathering_param);
            m_region.Activate();

            if (m_period_generator != null)
            {
                m_task = LogicTask.Create <ComponentCommonTask>();
                m_task.Construct(this);
                var schedeler = GetLogicWorld().GetTaskScheduler();
                schedeler.Schedule(m_task, GetCurrentTime(), m_period, m_period);
            }
        }
Beispiel #2
0
        protected override void OnDestruct()
        {
            EffectManager effect_manager = GetLogicWorld().GetEffectManager();

            if (m_enter_generator != null)
            {
                effect_manager.DestroyGenerator(m_enter_generator.ID, GetOwnerEntityID());
                m_enter_generator = null;
            }
            if (m_period_generator != null)
            {
                effect_manager.DestroyGenerator(m_period_generator.ID, GetOwnerEntityID());
                m_period_generator = null;
            }
            if (m_region != null)
            {
                m_region.Destruct();
                m_region = null;
            }
            if (m_task != null)
            {
                m_task.Cancel();
                LogicTask.Recycle(m_task);
                m_task = null;
            }
        }
        protected override void OnDestruct()
        {
            if (m_die_task != null)
            {
                m_die_task.Cancel();
                LogicTask.Recycle(m_die_task);
                m_die_task = null;
            }
            EffectManager effect_manager = GetLogicWorld().GetEffectManager();

            if (m_born_generator != null)
            {
                effect_manager.DestroyGenerator(m_born_generator.ID, GetOwnerEntityID());
                m_born_generator = null;
            }
            if (m_die_generator != null)
            {
                effect_manager.DestroyGenerator(m_die_generator.ID, GetOwnerEntityID());
                m_die_generator = null;
            }
            if (m_killer_generator != null)
            {
                effect_manager.DestroyGenerator(m_killer_generator.ID, GetOwnerEntityID());
                m_killer_generator = null;
            }
        }
Beispiel #4
0
 public void Reset()
 {
     m_generator = null;
     m_data      = null;
     m_index     = -1;
     m_effect2entity.Clear();
     ClearTargets();
 }
 protected override void OnActionEnter()
 {
     if (m_generator == null)
     {
         SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
         m_generator = GetLogicWorld().GetEffectManager().CreateGenerator(m_generator_cfgid, skill_component.GetOwnerEntity());
     }
 }
 protected override void ResetRuntimeData()
 {
     if (m_generator != null)
     {
         SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
         GetLogicWorld().GetEffectManager().DestroyGenerator(m_generator.ID, skill_component.GetOwnerEntityID());
         m_generator = null;
     }
 }
        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 override void InitializeComponent()
 {
     if (m_generator_cfgid != 0)
     {
         m_generator = GetLogicWorld().GetEffectManager().CreateGenerator(m_generator_cfgid, GetOwnerEntity());
     }
     if (m_combo_type_crc == 0)
     {
         m_combo_type_crc = ComboType_Time;
     }
 }
 public override void InitializeComponent()
 {
     if (m_collision_target_generator_cfgid != 0)
     {
         m_collision_target_generator = GetLogicWorld().GetEffectManager().CreateGenerator(m_collision_target_generator_cfgid, GetOwnerEntity());
     }
     if (m_collision_target_generator != null)
     {
         m_collided_targets = new List <int>();
     }
 }
 protected override void OnDestruct()
 {
     if (m_collision_target_generator != null)
     {
         GetLogicWorld().GetEffectManager().DestroyGenerator(m_collision_target_generator.ID, GetOwnerEntityID());
         m_collision_target_generator = null;
     }
     if (m_task != null)
     {
         m_task.Cancel();
         LogicTask.Recycle(m_task);
         m_task = null;
     }
 }
Beispiel #11
0
        public override void Destruct()
        {
            m_generator_id_generator = null;
            var enumerator = m_generators.GetEnumerator();

            while (enumerator.MoveNext())
            {
                EffectGenerator generator = enumerator.Current.Value;
                RecyclableObject.Recycle(generator);
            }
            m_generators.Clear();

            base.Destruct();
        }
        public override void InitializeComponent()
        {
            ObjectProtoData proto_data = ParentObject.GetCreationContext().m_proto_data;

            if (proto_data == null)
            {
                return;
            }
            var dic = proto_data.m_component_variables;

            if (dic == null)
            {
                return;
            }
            string value;

            if (dic.TryGetValue("born_generator_id", out value))
            {
                m_born_generator_cfgid = int.Parse(value);
            }
            if (dic.TryGetValue("die_generator_id", out value))
            {
                m_die_generator_cfgid = int.Parse(value);
            }
            if (dic.TryGetValue("killer_generator_id", out value))
            {
                m_killer_generator_cfgid = int.Parse(value);
            }
            if (dic.TryGetValue("life_time", out value))
            {
                m_life_time = FixPoint.Parse(value);
            }
            SetLifeTime(m_life_time);

            EffectManager effect_manager = GetLogicWorld().GetEffectManager();

            if (m_born_generator_cfgid != 0)
            {
                m_born_generator = effect_manager.CreateGenerator(m_born_generator_cfgid, GetOwnerEntity());
            }
            if (m_die_generator_cfgid != 0)
            {
                m_die_generator = effect_manager.CreateGenerator(m_die_generator_cfgid, GetOwnerEntity());
            }
            if (m_killer_generator_cfgid != 0)
            {
                m_killer_generator = effect_manager.CreateGenerator(m_killer_generator_cfgid, GetOwnerEntity());
            }
        }
        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);
        }
Beispiel #14
0
 protected override void OnActionEnter()
 {
     if (m_collision_target_generator_cfgid > 0 && m_collision_target_generator == null)
     {
         SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
         m_collision_target_generator = GetLogicWorld().GetEffectManager().CreateGenerator(m_collision_target_generator_cfgid, skill_component.GetOwnerEntity());
         if (m_collision_target_generator != null && m_collided_targets == null)
         {
             m_collided_targets = new List <int>();
         }
     }
     if (m_task == null)
     {
         m_task = LogicTask.Create <ComponentCommonTask>();
         m_task.Construct(this);
     }
 }
Beispiel #15
0
 protected override void ResetRuntimeData()
 {
     if (m_collision_target_generator != null)
     {
         SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
         GetLogicWorld().GetEffectManager().DestroyGenerator(m_collision_target_generator.ID, skill_component.GetOwnerEntityID());
         m_collision_target_generator = null;
     }
     if (m_collided_targets != null)
     {
         m_collided_targets.Clear();
     }
     if (m_task != null)
     {
         m_task.Cancel();
         LogicTask.Recycle(m_task);
         m_task = null;
     }
     m_remain_time = FixPoint.Zero;
 }
Beispiel #16
0
        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);
        }
        protected override void OnDestruct()
        {
            EffectGenerator generator = GetLogicWorld().GetEffectManager().GetGenerator(m_generator_id);

            if (generator == null)
            {
                return;
            }
            EffectGeneratorEntry entry = generator.GetEntry(m_entry_index);

            if (entry == null)
            {
                return;
            }
            entry.RemoveEffect(ParentObject.ID);

            if (m_task != null)
            {
                m_task.Cancel();
                LogicTask.Recycle(m_task);
                m_task = null;
            }
        }
        protected override void OnDestruct()
        {
            if (m_generator != null)
            {
                GetLogicWorld().GetEffectManager().DestroyGenerator(m_generator.ID, GetOwnerEntityID());
                m_generator = null;
            }
            if (m_delay_task != null)
            {
                m_delay_task.Cancel();
                LogicTask.Recycle(m_delay_task);
                m_delay_task = null;
            }

#if COMBAT_CLIENT
            if (m_render_delay_task != null)
            {
                m_render_delay_task.Cancel();
                LogicTask.Recycle(m_render_delay_task);
                m_render_delay_task = null;
            }
#endif
        }
Beispiel #19
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);
        }
 public void AddGenerator(EffectGenerator generator)
 {
     m_generators[generator.ID] = generator;
 }
Beispiel #21
0
 public void Construct(EffectGenerator generator, EffectGeneratorEntryData data, int index)
 {
     m_generator = generator;
     m_data      = data;
     m_index     = index;
 }
        PlayRenderEffectTask m_render_delay_task;  //纯粹为了一个不合适的特效,找不到美术改
#endif

        #region 初始化/销毁
        public override void InitializeComponent()
        {
            m_generator = GetLogicWorld().GetEffectManager().CreateGenerator(m_generator_cfgid, GetOwnerEntity());
        }