public PlayerUpdateEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Index = packet.ReadInteger(); FigureId = packet.ReadString(); Gender = SKore.ToGender(packet.ReadString()); Motto = packet.ReadString(); }
public HostBanPlayerEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Id = packet.ReadInteger(); RoomId = packet.ReadInteger(); Ban = SKore.ToBan(packet.ReadString()); }
public HostSayEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Message = packet.ReadString(); // TODO: Find the chunks before Theme and read them. Theme = (HTheme)packet.ReadInteger(packet.Length - 10); }
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; }
public PlayerSendMessageEventArgs(HMessage packet) { _packet = packet; Header = packet.Header; int position = 0; PlayerID = _packet.ReadInt(ref position); Message = _packet.ReadString(ref position); }
public PlayerActionEventArgs(HMessage packet) { _packet = packet; Header = _packet.Header; int x, y; string z, actionTxt; int position = 0; PlayerCount = _packet.ReadInt(ref position); PlayerIndex = _packet.ReadInt(ref position); x = _packet.ReadInt(ref position); y = _packet.ReadInt(ref position); z = _packet.ReadString(ref position); Tile = new HPoint(x, y, z); HeadDirection = (HDirection)_packet.ReadInt(ref position); BodyDirection = (HDirection)_packet.ReadInt(ref position); actionTxt = _packet.ReadString(ref position); actionTxt = actionTxt.GetChild("//mv ", '/'); }
public PlayerWhisperEventArgs(HMessage packet) { _packet = packet; Header = _packet.Header; int position = 0; PlayerIndex = _packet.ReadInt(ref position); Message = _packet.ReadString(ref position); _packet.ReadInt(ref position); Theme = (HTheme)_packet.ReadInt(ref position); }
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; }
public PlayerSpeakEventArgs(HMessage packet, HSpeech speech) { _packet = packet; Header = _packet.Header; Speech = speech; int position = 0; PlayerIndex = _packet.ReadInt(ref position); Message = _packet.ReadString(ref position); _packet.ReadInt(ref position); Theme = (HTheme)_packet.ReadInt(ref position); }
public FurnitureMoveEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Id = packet.ReadInteger(); TypeId = packet.ReadInteger(); int x = packet.ReadInteger(); int y = packet.ReadInteger(); Direction = (HDirection)packet.ReadInteger(); Tile = new HPoint(x, y, double.Parse(packet.ReadString(), CultureInfo.InvariantCulture)); // TODO: Find the chunks before OwnerId and read them. OwnerId = packet.ReadInteger(packet.Length - 6); }
/// <summary> /// Returns a <see cref="IReadOnlyList{T}"/> of type <see cref="HEntityAction"/> found in the <see cref="HMessage"/>. /// </summary> /// <param name="packet">The <see cref="HMessage"/> that contains the <see cref="HEntityAction"/> data to parse.</param> /// <returns></returns> public static IReadOnlyList<HEntityAction> Parse(HMessage packet) { int entityActionCount = packet.ReadInteger(); var entityActionList = new List<HEntityAction>(entityActionCount); for (int i = 0; i < entityActionList.Capacity; i++) { int index = packet.ReadInteger(); int x = packet.ReadInteger(); int y = packet.ReadInteger(); var z = double.Parse(packet.ReadString(), CultureInfo.InvariantCulture); var headDirection = (HDirection)packet.ReadInteger(); var bodyDirection = (HDirection)packet.ReadInteger(); string actionString = packet.ReadString(); string[] actionData = actionString.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); HSign sign = HSign.One; HAction action = HAction.None; HStance stance = HStance.Stand; double movingToZ = 0.0; bool isEmpowered = false; int movingToX = 0, movingToY = 0; foreach (string actionInfo in actionData) { string[] actionValues = actionInfo.Split(' '); if (actionValues.Length < 2) continue; if (string.IsNullOrWhiteSpace(actionValues[0])) continue; #region Switch Statement: actionValues[] switch (actionValues[0]) { case "flatctrl": { isEmpowered = true; break; } case "mv": { string[] movingToValues = actionValues[1].Split(','); if (movingToValues.Length >= 3) { movingToX = int.Parse(movingToValues[0]); movingToY = int.Parse(movingToValues[1]); movingToZ = double.Parse(movingToValues[2], CultureInfo.InvariantCulture); } action = HAction.Move; break; } case "sit": { action = HAction.Sit; stance = HStance.Sit; break; } case "lay": { action = HAction.Lay; stance = HStance.Lay; break; } case "sign": { sign = (HSign)int.Parse(actionValues[1]); action = HAction.Sign; break; } } #endregion } var entityAction = new HEntityAction(isEmpowered, index, new HPoint(x, y, z), new HPoint(movingToX, movingToY, movingToZ), sign, stance, headDirection, bodyDirection, action); entityActionList.Add(entityAction); } return entityActionList; }
/// <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; }
public static void ReadStuffData(int category, HMessage packet) { switch (category & 0xff) { case 0: { packet.ReadString(); break; } case 1: /* MapStuffData */ { int count = packet.ReadInteger(); for (int j = 0; j < count; j++) { packet.ReadString(); packet.ReadString(); } break; } case 2: /* StringArrayStuffData */ { int count = packet.ReadInteger(); for (int j = 0; j < count; j++) { packet.ReadString(); } break; } case 3: { packet.ReadString(); packet.ReadInteger(); break; } case 5: /* IntArrayStuffData */ { int count = packet.ReadInteger(); for (int j = 0; j < count; j++) { packet.ReadInteger(); } break; } case 6: /* HighScoreStuffData */ { packet.ReadString(); packet.ReadInteger(); packet.ReadInteger(); int count = packet.ReadInteger(); for (int j = 0; j < count; j++) { int score = packet.ReadInteger(); int subCount = packet.ReadInteger(); for (int k = 0; k < subCount; k++) { packet.ReadString(); } } break; } case 7: { packet.ReadString(); packet.ReadInteger(); packet.ReadInteger(); break; } } }
public HostNavigateRoomEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { RoomId = packet.ReadInteger(); Password = packet.ReadString(); }
public HostUpdateClothesEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Gender = SKore.ToGender(packet.ReadString()); FigureId = packet.ReadString(); }
private void OnPlayerChangeData(HMessage obj) { try { #region Some Parsing int position = 0; obj.ReadInt(ref position); obj.ReadString(ref position); HGender Gender = SKore.ToGender(obj.ReadString(ref position)); string Motto = obj.ReadString(ref position); #endregion var args = new PlayerChangeDataEventArgs(obj); foreach (PDU PData in _loadedPlayers.Values) { if (PData.PlayerIndex == args.PlayerIndex) { PData.Update(Motto, Gender, args.FigureId); } } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public HostPrivateMessageEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Id = packet.ReadInteger(); Message = packet.ReadString(); }
public HostUpdateMottoEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Motto = packet.ReadString(); }