void Game_OnGameProcessPacket(GamePacketEventArgs args)
        {
            if (!IsActive())
            {
                return;
            }

            var reader = new BinaryReader(new MemoryStream(args.PacketData));

            byte packetId = reader.ReadByte();

            if (packetId == Packet.S2C.Ping.Header)
            {
                Packet.S2C.Ping.Struct ping = Packet.S2C.Ping.Decoded(args.PacketData);
                Obj_AI_Hero            hero = ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(ping.SourceNetworkId);
                if (hero != null && hero.IsValid)
                {
                    pingInfo.Add(new PingInfo(hero.ChampionName, new Vector2(ping.X, ping.Y), Game.Time + 2));
                }
            }
        }
Esempio n. 2
0
        private void Game_OnGameProcessPacket(GamePacketEventArgs args)
        {
            try
            {
                if (args.PacketData[0] == Packet.S2C.Ping.Header)
                {
                    Packet.S2C.Ping.Struct decoded   = Packet.S2C.Ping.Decoded(args.PacketData);
                    GameObject             srcObject = ObjectManager.GetUnitByNetworkId <GameObject>(decoded.SourceNetworkId);
                    Obj_AI_Hero            src       = srcObject as Obj_AI_Hero;
                    if (src == null)
                    {
                        return;
                    }
                    MenuItem blockItem = _menu.Item(src.Name);
                    if (blockItem != null && blockItem.GetValue <bool>())
                    {
                        args.Process = false;
                        return;
                    }
                    GameObject target = ObjectManager.GetUnitByNetworkId <GameObject>(decoded.TargetNetworkId);
                    if (decoded.Type == Packet.PingType.OnMyWay || !src.IsValid)
                    {
                        return;
                    }
                    Color c = Color.White;
                    switch (decoded.Type)
                    {
                    case Packet.PingType.Fallback:
                    case Packet.PingType.EnemyMissing:
                        c = Color.LightYellow;
                        break;

                    case Packet.PingType.AssistMe:
                        c = Color.LightBlue;
                        break;

                    case Packet.PingType.Danger:
                        c = new Color(255, 204, 203);
                        break;
                    }

                    int    selectedIndex = _menu.Item("print").GetValue <StringList>().SelectedIndex;
                    String name;
                    switch (selectedIndex)
                    {
                    case 0:
                        name = src.ChampionName;
                        break;

                    case 1:
                        name = src.Name;
                        break;

                    default:
                        name = src.Name + " (" + src.ChampionName + ")";
                        break;
                    }
                    _pings.Add(new Ping(name, Game.ClockTime + 2f, decoded.X, decoded.Y, target, c));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }