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; }
/// <summary> /// Returns a <see cref="IReadOnlyList{T}"/> of type <see cref="HEntity"/> found in the <see cref="HMessage"/>. /// </summary> /// <param name="packet">The <see cref="HMessage"/> that contains the <see cref="HEntity"/> data to parse.</param> /// <returns></returns> public static IReadOnlyList<HEntity> Parse(HMessage packet) { int entityCount = packet.ReadInteger(); var entityList = new List<HEntity>(entityCount); for (int i = 0; i < entityList.Capacity; i++) { int id = packet.ReadInteger(); string name = packet.ReadString(); string motto = packet.ReadString(); string figureId = packet.ReadString(); int index = packet.ReadInteger(); int x = packet.ReadInteger(); int y = packet.ReadInteger(); var z = double.Parse( packet.ReadString(), CultureInfo.InvariantCulture); packet.ReadInteger(); int type = packet.ReadInteger(); HGender gender = HGender.Unisex; string favoriteGroup = string.Empty; #region Switch Statement: type switch (type) { case 1: { gender = SKore.ToGender(packet.ReadString()); packet.ReadInteger(); packet.ReadInteger(); favoriteGroup = packet.ReadString(); packet.ReadString(); packet.ReadInteger(); packet.ReadBoolean(); break; } case 2: { packet.ReadInteger(); packet.ReadInteger(); packet.ReadString(); packet.ReadInteger(); packet.ReadBoolean(); packet.ReadBoolean(); packet.ReadBoolean(); packet.ReadBoolean(); packet.ReadBoolean(); packet.ReadBoolean(); packet.ReadInteger(); packet.ReadString(); break; } case 4: { packet.ReadString(); packet.ReadInteger(); packet.ReadString(); for (int j = packet.ReadInteger(); j > 0; j--) packet.ReadShort(); break; } } #endregion var entity = new HEntity(id, index, name, new HPoint(x, y, z), motto, gender, figureId, favoriteGroup); entityList.Add(entity); } return entityList; }