Пример #1
0
        void Retarget()
        {
            TargetGatheringManager manager = GetLogicWorld().GetTargetGatheringManager();

            manager.BuildTargetList(GetOwnerEntity(), m_target_gathering_param, m_targets);
            if (m_targets.Count == 0)
            {
                return;
            }
            Entity new_enemy = m_targets[0].GetEntity(GetLogicWorld());

            ClearTargets();
            if (new_enemy == m_current_enemy)
            {
                return;
            }
            if (m_current_enemy != null)
            {
                m_current_enemy.RemoveListener(SignalType.Die, m_listener_context.ID);
                m_current_enemy = null;
            }
            m_current_enemy = new_enemy;
            m_current_enemy.AddListener(SignalType.Die, m_listener_context);
            m_targeting_component.StartTargeting(m_current_enemy);
        }
Пример #2
0
        bool HandleEntityTarget(EntityTargetCommand cmd)
        {
            Entity entity = m_logic_world.GetEntityManager().GetObject(cmd.m_entity_id);

            if (entity == null)
            {
                return(false);
            }
            Entity target = m_logic_world.GetEntityManager().GetObject(cmd.m_target_entity_id);

            if (target == null)
            {
                return(false);
            }
            TargetingComponent targeting_component = entity.GetComponent(TargetingComponent.ID) as TargetingComponent;

            if (targeting_component == null)
            {
                return(false);
            }
            targeting_component.StartTargeting(target);
            return(true);
        }