public HostMoveFurnitureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger());
     Direction = (HDirection)packet.ReadInteger();
 }
 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 HostMutePlayerEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     RoomId = packet.ReadInteger();
     Minutes = packet.ReadInteger();
 }
Example #4
0
        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 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 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);
        }
 public PlayerGestureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Index = packet.ReadInteger();
     Gesture = (HGesture)packet.ReadInteger();
 }
Example #8
0
        /// <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 HostClickPlayerEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger());
 }
Example #10
0
 public HostWalkEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Tile = new HPoint(packet.ReadInteger(0),
         packet.ReadInteger(4));
 }
 public HostUpdateStanceEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Stance = (HStance)packet.ReadInteger();
 }
 public HostPrivateMessageEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     Message = packet.ReadString();
 }
Example #13
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;
        }
Example #14
0
 public HostGestureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Gesture = (HGesture)packet.ReadInteger();
 }
Example #15
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;
        }
 public HostRaiseSignEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Sign = (HSign)packet.ReadInteger();
 }
 public HostNavigateRoomEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     RoomId = packet.ReadInteger();
     Password = packet.ReadString();
 }
Example #18
0
        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;
                }
            }
        }
Example #19
0
        /// <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;
        }
Example #20
0
 public HostTradeEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Index = packet.ReadInteger();
 }