示例#1
0
        public static IReadOnlyList <HFurniture> Parse(HMessage packet)
        {
            int ownersCount = packet.ReadInteger();
            var owners      = new Dictionary <int, string>(ownersCount);

            for (int i = 0; i < ownersCount; i++)
            {
                int    ownerId   = packet.ReadInteger();
                string ownerName = packet.ReadString();

                owners.Add(ownerId, ownerName);
            }

            int furnitureCount = packet.ReadInteger();
            var furnitureList  = new List <HFurniture>(furnitureCount);

            for (int i = 0; i < furnitureList.Capacity; i++)
            {
                int id     = packet.ReadInteger();
                int typeId = packet.ReadInteger();

                int x         = packet.ReadInteger();
                int y         = packet.ReadInteger();
                var direction = (HDirection)packet.ReadInteger();
                var z         = double.Parse(packet.ReadString(), CultureInfo.InvariantCulture);

                packet.ReadString();
                packet.ReadInteger();

                int category = packet.ReadInteger();
                HStuffData.ReadStuffData(category, packet);

                packet.ReadInteger();
                packet.ReadInteger();

                int ownerId = packet.ReadInteger();
                if (typeId < 0)
                {
                    packet.ReadString();
                }

                var furniture = new HFurniture(id, typeId, ownerId,
                                               owners[ownerId], new HPoint(x, y, z), direction);

                furnitureList.Add(furniture);
            }
            return(furnitureList);
        }
示例#2
0
        public static IReadOnlyList <HItem> Parse(HMessage packet)
        {
            packet.ReadInteger();
            packet.ReadInteger();

            int itemCount = packet.ReadInteger();
            var itemList  = new List <HItem>(itemCount);

            for (int i = 0; i < itemList.Capacity; i++)
            {
                packet.ReadInteger();
                string s1 = packet.ReadString();

                int id     = packet.ReadInteger();
                int typeId = packet.ReadInteger();
                packet.ReadInteger();

                int category = packet.ReadInteger();
                HStuffData.ReadStuffData(category, packet);

                packet.ReadBoolean();
                packet.ReadBoolean();
                packet.ReadBoolean();
                packet.ReadBoolean();
                int secondsToExpiration = packet.ReadInteger();

                bool hasRentPeriodStarted = packet.ReadBoolean();
                int  roomId = packet.ReadInteger();

                var item = new HItem(id, typeId, category,
                                     secondsToExpiration, hasRentPeriodStarted, roomId);

                if (s1 == "S")
                {
                    item.SlotId = packet.ReadString();
                    packet.ReadInteger();
                }
                itemList.Add(item);
            }
            return(itemList);
        }