Exemplo n.º 1
0
        /// <summary>
        /// Finds first packet by type.
        /// </summary>
        /// <param name="serial">Serial to find by.</param>
        /// <param name="type">Type to find by.</param>
        /// <returns>Ultima packet.</returns>
        public UltimaPacket FindFirstPacket(uint serial, Type type = null)
        {
            if (type != null)
            {
                foreach (UltimaPacket packet in Packets)
                {
                    if (!packet.Definition.IsDefault)
                    {
                        IUltimaEntity entity = packet as IUltimaEntity;

                        if (entity != null && entity.Serial == serial && packet.GetType() == type)
                        {
                            return(packet);
                        }
                    }
                }
            }
            else
            {
                foreach (UltimaPacket packet in Packets)
                {
                    if (!packet.Definition.IsDefault)
                    {
                        IUltimaEntity entity = packet as IUltimaEntity;

                        if (entity != null && entity.Serial == serial)
                        {
                            return(packet);
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        private void SpyHelper_OnPacket(UltimaPacket relative)
        {
            if (Packet == null)
            {
                return;
            }

            IUltimaEntity packet = Packet as IUltimaEntity;
            IUltimaEntity entity = relative as IUltimaEntity;

            if (packet != null && entity != null && packet.Serial == entity.Serial)
            {
                Relatives.Add(relative);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Finds all entities with specific serial.
        /// </summary>
        /// <param name="serial">Serial to find by.</param>
        /// <returns>Collection of entities.</returns>
        public ObservableCollection <UltimaPacket> FindEntities(uint serial)
        {
            ObservableCollection <UltimaPacket> packets = new ObservableCollection <UltimaPacket>();

            foreach (UltimaPacket packet in Packets)
            {
                IUltimaEntity entity = packet as IUltimaEntity;

                if (entity != null && entity.Serial == serial)
                {
                    packets.Add(packet);
                }
            }

            return(packets);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Finds packets by type.
        /// </summary>
        /// <param name="serial">Serial to find by.</param>
        /// <param name="type">Type to find by.</param>
        /// <returns>List of ultima packets.</returns>
        public List <UltimaPacket> FindPackets(uint serial, Type type = null)
        {
            List <UltimaPacket> list = new List <UltimaPacket>();

            if (type != null)
            {
                foreach (UltimaPacket packet in Packets)
                {
                    if (packet.Definition != null && !packet.Definition.IsDefault)
                    {
                        IUltimaEntity entity = packet as IUltimaEntity;

                        if (entity.Serial == serial && packet.GetType() == type)
                        {
                            list.Add(packet);
                        }
                    }
                }
            }
            else
            {
                foreach (UltimaPacket packet in Packets)
                {
                    if (packet.Definition != null && !packet.Definition.IsDefault)
                    {
                        IUltimaEntity entity = packet as IUltimaEntity;

                        if (entity.Serial == serial)
                        {
                            list.Add(packet);
                        }
                    }
                }
            }

            return(list);
        }
Exemplo n.º 5
0
        private void FindRelatives_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ShowLoading();

            try
            {
                if (e.Parameter is UltimaPacket && e.Parameter is IUltimaEntity)
                {
                    IUltimaEntity entity = (IUltimaEntity)e.Parameter;

                    RelativesWindow window = new RelativesWindow();
                    window.Packet    = (UltimaPacket)e.Parameter;
                    window.Relatives = _SpyHelper.FindEntities(entity.Serial);
                    window.WireEvents(_SpyHelper);
                    window.Show();
                }
            }
            catch (Exception ex)
            {
                ShowNotification(NotificationType.Error, ex);
            }

            HideLoading();
        }