Exemplo n.º 1
0
 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 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();
 }
Exemplo n.º 3
0
 public HostMutePlayerEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     RoomId = packet.ReadInteger();
     Minutes = packet.ReadInteger();
 }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
 public ScheduleTickEventArgs(HMessage packet,
     int burstCount, int burstLeft, bool isFinalBurst)
 {
     Packet = packet;
     BurstLeft = burstLeft;
     BurstCount = burstCount;
     IsFinalBurst = isFinalBurst;
 }
        public PlayerSendMessageEventArgs(HMessage packet)
        {
            _packet = packet;
            Header = packet.Header;

            int position = 0;
            PlayerID = _packet.ReadInt(ref position);
            Message = _packet.ReadString(ref position);
        }
Exemplo n.º 8
0
        public HSchedule(HMessage packet, int interval, int burst)
        {
            _ticker = new Timer(interval);
            _ticker.Elapsed += Ticker_Elapsed;

            _tickerLock = new object();

            Packet = packet;
            Burst = burst;
        }
        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 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);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InterceptedEventArgs"/> class.
        /// </summary>
        /// <param name="continuation">The <see cref="Func{TResult}"/> of type <see cref="Task"/> that will be invoked when <see cref="ContinueRead"/> is called.</param>
        /// <param name="step">The current count/step/order from which this data was intercepted.</param>
        /// <param name="packet">The intercepted data to read/write from.</param>
        public InterceptedEventArgs(Func<Task> continuation, int step, HMessage packet)
        {
            Executions = new List<HMessage>();

            Continuation = continuation;
            IsAsyncCapable = (Continuation != null);

            Step = step;
            Packet = packet;

            Replacement = new HMessage(
                packet.ToBytes(), packet.Destination);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
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 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 ", '/');
        }
Exemplo n.º 15
0
        public void AddSchedule(HMessage packet, int burst, int interval, string description)
        {
            if (packet.IsCorrupted)
                throw new Exception("Corrupted Packet: " + packet);

            var item = new ListViewItem(new[] { packet.ToString(),
                packet.Destination.ToString(), burst.ToString(), interval.ToString(), AutoStart ? "Running" : "Stopped" });

            var schedule = new HSchedule(packet, interval, burst);
            schedule.ScheduleTick += OnScheduleTick;

            _items.Add(schedule, item);
            _schedules.Add(item, schedule);
            _descriptions.Add(item, description);

            item.Checked = AutoStart;
            item.ToolTipText = description;

            FocusAdd(item);
        }
Exemplo n.º 16
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;
        }
Exemplo n.º 17
0
        public FurnitureDropEventArgs(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));

            Packet.ReadString();
            Packet.ReadInteger();
            Packet.ReadInteger();
            Packet.ReadString();

            IsRental = (Packet.ReadInteger() != 1);
            Packet.ReadInteger();

            OwnerId = Packet.ReadInteger();
            OwnerName = Packet.ReadString();
        }
Exemplo n.º 18
0
 public PlayerKickHostEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 { }
Exemplo n.º 19
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;
        }
Exemplo n.º 20
0
 public Task<int> SendAsync(HMessage packet)
 {
     return SendAsync(packet.ToBytes());
 }
Exemplo n.º 21
0
 public HostExitRoomEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 { }
Exemplo n.º 22
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;
        }
Exemplo n.º 23
0
        private void HandleIncoming(HMessage packet, int count)
        {
            var args = new InterceptedEventArgs(ReadIncomingAsync, count, packet);
            Triggers.HandleIncoming(args);
            OnDataIncoming(args);

            if (!args.WasContinued && IsReading)
            {
                Task readInTask = ReadIncomingAsync();
            }
        }
Exemplo n.º 24
0
 public HostClickPlayerEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger());
 }
Exemplo n.º 25
0
 public Task<int> SendToClientAsync(ushort header, params object[] chunks)
 {
     var inMessage = new HMessage(0, HMessage.Construct(header, chunks));
     return _externalContractor.SendAsync(inMessage.ToBytes());
 }
Exemplo n.º 26
0
 public PlayerGestureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Index = packet.ReadInteger();
     Gesture = (HGesture)packet.ReadInteger();
 }
Exemplo n.º 27
0
 public Task<int> SendToServerAsync(byte[] data)
 {
     var outMessage = new HMessage(1, data);
     return _externalContractor.SendAsync(outMessage.ToBytes());
 }
Exemplo n.º 28
0
 public HostWalkEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Tile = new HPoint(packet.ReadInteger(0),
         packet.ReadInteger(4));
 }
Exemplo n.º 29
0
        private void STCreateBtn_Click(object sender, EventArgs e)
        {
            var destination = ((HDestination)MainUI.STDestinationTxt.SelectedIndex);
            var packet = new HMessage(MainUI.STPacketTxt.Text, destination);

            if (packet.IsCorrupted)
            {
                MessageBox.Show("The given data seems corrupted, the schedule will not be created.",
                    "Tanji ~ Alert!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MainUI.STSchedulerVw.AddSchedule(packet,
                    (int)MainUI.STIntervalTxt.Value, (int)MainUI.STBurstTxt.Value);

                UpdateSchedulesActiveLabel();
            }
        }
Exemplo n.º 30
0
 public SKoreConstructView()
 {
     _packet = new HMessage(0);
 }
Exemplo n.º 31
0
 public HSchedule(HMessage Packet, uint Interval, uint Bu)
 {
 }