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
        }
示例#2
0
        public static void KillEntity(Entity entity, int killer_id)
        {
            DeathComponent death_component = entity.GetComponent(DeathComponent.ID) as DeathComponent;

            if (death_component != null)
            {
                death_component.KillOwner(killer_id);
            }
            else
            {
                //Player player = entity.GetOwnerPlayer();
                //Entity killer = entity.GetLogicWorld().GetEntityManager().GetObject(killer_id);
                //player.OnEntityBeKilled(killer, entity);
                //if (killer != null)
                //{
                //    Player killer_player = killer.GetOwnerPlayer();
                //    killer_player.OnKillEntity(killer, entity);
                //}

                //没有死亡组件的就从简了
                entity.SendSignal(SignalType.Die);
                entity.GetLogicWorld().AddSimpleRenderMessage(RenderMessageType.Die, entity.ID);
                entity.DeletePending = true;
                var schedeler = entity.GetLogicWorld().GetTaskScheduler();
                DeleteEntityTask delete_task = LogicTask.Create <DeleteEntityTask>();
                delete_task.Construct(entity.ID);
                schedeler.Schedule(delete_task, entity.GetCurrentTime(), ms_death_delay);
            }
        }
示例#3
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);
            }
        }
        public void Impact()
        {
            m_remain_attack_cnt = m_combo_attack_cnt;
            if (m_combo_type_crc == ComboType_Time)
            {
                CreateOneObject(0);
                if (m_combo_attack_cnt > 1)
                {
                    if (m_task == null)
                    {
                        m_task = LogicTask.Create <ComponentCommonTask>();
                        m_task.Construct(this);
                    }
                    var schedeler = GetLogicWorld().GetTaskScheduler();
                    schedeler.Schedule(m_task, GetCurrentTime(), m_combo_interval, m_combo_interval);
                }
            }
            else if (m_combo_type_crc == ComboType_Angle || m_combo_type_crc == ComboType_Circle)
            {
                for (int i = 0; i < m_combo_attack_cnt; ++i)
                {
                    CreateOneObject(i);
                }
            }

#if COMBAT_CLIENT
            if (m_render_effect_cfgid > 0)
            {
                PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>();
                msg.ConstructAsPlay(GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne);
                GetLogicWorld().AddRenderMessage(msg);
            }
#endif
        }
        public override void Inflict(FixPoint start_time)
        {
            if (m_generator == null)
            {
                return;
            }
            if (m_delay_time == FixPoint.Zero)
            {
                Impact();
            }
            else
            {
                if (m_delay_task == null)
                {
                    m_delay_task = LogicTask.Create <ComponentCommonTask>();
                    m_delay_task.Construct(this);
                }
                var schedeler = GetLogicWorld().GetTaskScheduler();
                schedeler.Schedule(m_delay_task, GetCurrentTime(), m_delay_time);
            }

#if COMBAT_CLIENT
            if (m_render_effect_cfgid > 0 && m_render_delay_time > FixPoint.Zero)
            {
                if (m_render_delay_task == null)
                {
                    m_render_delay_task = LogicTask.Create <PlayRenderEffectTask>();
                    m_render_delay_task.Construct(this);
                }
                var schedeler = GetLogicWorld().GetTaskScheduler();
                schedeler.Schedule(m_render_delay_task, GetCurrentTime(), m_render_delay_time);
            }
#endif
        }
        public void InitParam(ProjectileParameters param)
        {
            m_param = param;
            if (m_trajectory_type == TrajectoryTypeBezier)
            {
                m_param.m_bezier_b    = (m_param.m_start_position + m_param.m_target_position) / FixPoint.Two;
                m_param.m_bezier_b.y += m_extra_hight;
            }
            if (m_param.m_life_time <= FixPoint.Zero)
            {
                m_param.m_life_time = m_life_time;
            }

            PositionComponent position_component = ParentObject.GetComponent(PositionComponent.ID) as PositionComponent;
            GridGraph         grid_graph         = position_component.GetGridGraph();
            GridNode          node = grid_graph.Position2Node(position_component.CurrentPosition);

            m_previous_walkable = (node != null && node.Walkable);

            if (m_task == null)
            {
                m_task = LogicTask.Create <UpdateProjectileTask>();
            }
            m_task.Construct(this, m_param.m_life_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(ParentObject.ID, true);
            GetLogicWorld().AddRenderMessage(msg);
#endif
        }
示例#7
0
        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());
        }
示例#8
0
        void Schedule()
        {
            if (m_task == null)
            {
                m_task = LogicTask.Create <ComponentCommonTask>();
                m_task.Construct(this);
            }
            var schedeler = GetLogicWorld().GetTaskScheduler();

            schedeler.Schedule(m_task, GetCurrentTime(), FixPoint.One, FixPoint.One);
        }
        public void ScheduleTargeting(FixPoint delay)
        {
            if (m_task == null)
            {
                m_task = LogicTask.Create <ComponentCommonTask>();
                m_task.Construct(this);
            }
            LogicWorld logic_world    = GetLogicWorld();
            var        task_scheduler = logic_world.GetTaskScheduler();

            task_scheduler.Schedule(m_task, logic_world.GetCurrentTime(), delay);
        }
示例#10
0
 public void Construct(LogicWorld logic_world)
 {
     if (m_context == null)
     {
         BTContext context = RecyclableObject.Create <BTContext>();
         context.Construct(logic_world, this);
         SetContext(context);
     }
     if (m_task == null)
     {
         m_task = LogicTask.Create <BehaviorTreeTask>();
         m_task.Construct(this);
     }
 }
 public override void Apply()
 {
     ApplyDamage();
     if (m_period > FixPoint.Zero)
     {
         if (m_period_task == null)
         {
             m_period_task = LogicTask.Create <ComponentCommonTask>();
             m_period_task.Construct(this);
         }
         var schedeler = GetLogicWorld().GetTaskScheduler();
         schedeler.Schedule(m_period_task, GetCurrentTime(), m_period, m_period);
     }
 }
 public override void Apply()
 {
     m_remain_count = m_object_count;
     CreateOneObject();
     if (m_object_count > 1 || m_object_count == -1)
     {
         if (m_task == null)
         {
             m_task = LogicTask.Create <ComponentCommonTask>();
             m_task.Construct(this);
         }
         var schedeler = GetLogicWorld().GetTaskScheduler();
         schedeler.Schedule(m_task, GetCurrentTime(), m_interval, m_interval);
     }
 }
示例#13
0
 public void RealInflict()
 {
     m_remain_attack_cnt = m_combo_attack_cnt;
     Impact();
     if (m_combo_attack_cnt > 1)
     {
         if (m_combo_task == null)
         {
             m_combo_task = LogicTask.Create <ComboAttackTask>();
             m_combo_task.Construct(this);
         }
         var schedeler = GetLogicWorld().GetTaskScheduler();
         schedeler.Schedule(m_combo_task, GetCurrentTime(), m_combo_interval, m_combo_interval);
     }
 }
示例#14
0
        void StartMoving(bool from_command = true)
        {
            if (m_task == null)
            {
                m_task = LogicTask.Create <ComponentCommonTask>();
                m_task.Construct(this);
            }
            var schedeler = GetLogicWorld().GetTaskScheduler();

            schedeler.Schedule(m_task, GetCurrentTime(), LOGIC_UPDATE_INTERVAL, LOGIC_UPDATE_INTERVAL);
            if (!m_is_moving)
            {
                m_is_moving = true;
                OnMovementStarted(from_command);
            }
        }
示例#15
0
        void StartLocomotorSpeedRateTask()
        {
            if (m_update_locomotor_speed_rate_task != null)
            {
                return;
            }
            var schedeler = GetLogicWorld().GetTaskScheduler();

            if (schedeler == null)
            {
                return; //ZZWTOOD 世界销毁的时候
            }
            m_update_locomotor_speed_rate_task = LogicTask.Create <UpdateLocomotorSpeedRateTask>();
            m_update_locomotor_speed_rate_task.Construct(this);
            schedeler.Schedule(m_update_locomotor_speed_rate_task, GetCurrentTime(), FixPoint.PrecisionFP);
        }
示例#16
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);
     }
 }
        public void StartExpirationTask()
        {
            if (m_expiration_time == FixPoint.MaxValue)
            {
                return;
            }
            if (m_task == null)
            {
                m_task = LogicTask.Create <EffectExpireTask>();
                m_task.Construct(GetOwnerEntityID(), ParentObject.ID);
            }
            FixPoint current_time = GetCurrentTime();
            var      schedeler    = GetLogicWorld().GetTaskScheduler();
            FixPoint delay        = m_expiration_time - current_time;

            schedeler.Schedule(m_task, current_time, delay);
        }
示例#18
0
        public void DeactivateOnOneTarget(Entity target)
        {
            var enumerator = m_effect2entity.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Current.Value != target.ID)
                {
                    continue;
                }
                RemoveEffectTask task = LogicTask.Create <RemoveEffectTask>();
                task.Construct(target.ID, enumerator.Current.Key);
                LogicWorld logic_world = m_generator.GetLogicWorld();
                var        schedeler   = logic_world.GetTaskScheduler();
                schedeler.Schedule(task, logic_world.GetCurrentTime(), FixPoint.Zero);
            }
        }
示例#19
0
        private void ScheduleTimers()
        {
            FixPoint time_remaining = m_definition_component.GetLowestCountdownTimerRemaining();

            if (time_remaining <= FixPoint.Zero)
            {
                time_remaining = FixPoint.PrecisionFP;
            }
            var task_scheduler = GetLogicWorld().GetTaskScheduler();

            if (m_task == null)
            {
                m_task = LogicTask.Create <SkillCountdownTask>();
                m_task.Construct(this);
            }
            task_scheduler.Schedule(m_task, GetCurrentTime(), time_remaining);
        }
示例#20
0
 public override void Inflict(FixPoint start_time)
 {
     if (m_delay_time == FixPoint.Zero)
     {
         RealInflict();
     }
     else
     {
         if (m_delay_task == null)
         {
             m_delay_task = LogicTask.Create <ComponentCommonTask>();
             m_delay_task.Construct(this);
         }
         var schedeler = GetLogicWorld().GetTaskScheduler();
         schedeler.Schedule(m_delay_task, GetCurrentTime(), m_delay_time);
     }
 }
示例#21
0
        protected override void PostInitializeComponent()
        {
            ResetSpawnAreaRange();
            if (m_update_interval < FixPoint.One)
            {
                m_update_interval = FixPoint.One;
            }
            m_listener_context = SignalListenerContext.CreateForEntityComponent(GetLogicWorld().GenerateSignalListenerID(), ParentObject.ID, m_component_type_id);
            m_task             = LogicTask.Create <ComponentCommonTask>();
            m_task.Construct(this);
            var schedeler = GetLogicWorld().GetTaskScheduler();

            schedeler.Schedule(m_task, GetCurrentTime(), m_update_interval, m_update_interval);
            for (int i = 0; i < m_init_count; ++i)
            {
                SpawnOneObject();
            }
        }
示例#22
0
 public void SetLifeTime(FixPoint life_time)
 {
     m_life_time = life_time;
     if (m_die_task != null)
     {
         m_die_task.Cancel();
     }
     if (m_life_time > FixPoint.Zero)
     {
         if (m_die_task == null)
         {
             m_die_task = LogicTask.Create <ComponentCommonTask>();
             m_die_task.Construct(this);
         }
         var schedeler = GetLogicWorld().GetTaskScheduler();
         schedeler.Schedule(m_die_task, GetCurrentTime(), m_life_time);
     }
 }
示例#23
0
 public override void Apply()
 {
     if (m_generator == null)
     {
         return;
     }
     m_remain_count = m_combo_count;
     ApplyOnce();
     if (m_combo_count > 1 || m_combo_count == -1)
     {
         if (m_combo_task == null)
         {
             m_combo_task = LogicTask.Create <ComponentCommonTask>();
             m_combo_task.Construct(this);
         }
         var schedeler = GetLogicWorld().GetTaskScheduler();
         schedeler.Schedule(m_combo_task, GetCurrentTime(), m_combo_interval, m_combo_interval);
     }
 }
        public override void Inflict(FixPoint start_time)
        {
            Skill owner_skill = GetOwnerSkill();
            SkillDefinitionComponent definition_component = owner_skill.GetDefinitionComponent();

            m_actual_distance = m_distance;
            if (m_distance == FixPoint.Zero)
            {
                if (definition_component.ExternalDataType == SkillDefinitionComponent.NeedExternalOffset)
                {
                    m_actual_distance = definition_component.ExternalVector.Length();
                }
            }
            m_actual_time = m_time;
            if (definition_component.NormalAttack)
            {
                m_actual_time = m_time / owner_skill.GetSkillManagerComponent().AttackSpeedRate;
            }

            if (m_task == null)
            {
                m_task = LogicTask.Create <ComponentCommonTaskWithLastingTime>();
            }
            m_task.Construct(this, m_actual_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

            if (m_enable_hide)
            {
                GetLogicWorld().AddSimpleRenderMessage(RenderMessageType.Hide, GetOwnerEntityID());
            }
        }