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(); }
public HostMutePlayerEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Id = packet.ReadInteger(); RoomId = packet.ReadInteger(); Minutes = packet.ReadInteger(); }
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 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); }
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); }
/// <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); }
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 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 ", '/'); }
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); }
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 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(); }
public PlayerKickHostEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { }
/// <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 Task<int> SendAsync(HMessage packet) { return SendAsync(packet.ToBytes()); }
public HostExitRoomEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { }
/// <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; }
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(); } }
public HostClickPlayerEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Id = packet.ReadInteger(); Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger()); }
public Task<int> SendToClientAsync(ushort header, params object[] chunks) { var inMessage = new HMessage(0, HMessage.Construct(header, chunks)); return _externalContractor.SendAsync(inMessage.ToBytes()); }
public PlayerGestureEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Index = packet.ReadInteger(); Gesture = (HGesture)packet.ReadInteger(); }
public Task<int> SendToServerAsync(byte[] data) { var outMessage = new HMessage(1, data); return _externalContractor.SendAsync(outMessage.ToBytes()); }
public HostWalkEventArgs(Func<Task> continuation, int step, HMessage packet) : base(continuation, step, packet) { Tile = new HPoint(packet.ReadInteger(0), packet.ReadInteger(4)); }
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(); } }
public SKoreConstructView() { _packet = new HMessage(0); }
public HSchedule(HMessage Packet, uint Interval, uint Bu) { }