public static ProjectileSpawn Read(NetPacketReader message) { var p = new ProjectileSpawn(); p.Owner = message.GetVariableInt32(); p.Gun = message.GetUInt(); p.Hardpoint = message.GetUInt(); p.Start = message.GetVector3(); p.Heading = message.GetNormal(); return(p); }
public static NetShipLoadout Read(NetPacketReader message) { var s = new NetShipLoadout(); s.ShipCRC = message.GetUInt(); var equipCount = (int)message.GetVariableUInt32(); s.Equipment = new List <NetShipEquip>(equipCount); for (int i = 0; i < equipCount; i++) { s.Equipment.Add(new NetShipEquip(message.GetUInt(), message.GetUInt(), message.GetByte())); } return(s); }
public static NetShipLoadout Read(NetPacketReader message) { var s = new NetShipLoadout(); s.ShipCRC = message.GetUInt(); s.Health = message.GetFloat(); var cargoCount = (int)message.GetVariableUInt32(); s.Items = new List <NetShipCargo>(cargoCount); for (int i = 0; i < cargoCount; i++) { s.Items.Add(new NetShipCargo(message.GetInt(), message.GetUInt(), message.GetUInt(), message.GetByte(), message.GetInt())); } return(s); }
/// <inheritdoc/> public override void Read(NetPacketReader message) { base.Read(message); try { NetworkID = message.GetUInt(); MethodID = message.GetUShort(); RPCInfo = Network.InstanceType == NetInstanceType.Server ? (RPCInfo)Network.ServerRPCLookupTable.GetRPCInfo(MethodID) : Network.ClientRPCLookupTable.GetRPCInfo(MethodID); ParametersNum = RPCInfo.ParameterTypes.Length; if (Parameters.Length < ParametersNum) { Parameters = new object[ParametersNum]; } for (int i = 0; i < ParametersNum; i++) { Parameters[i] = NetData.Read(RPCInfo.ParameterTypes[i], message); } } catch (Exception e) { throw new MalformedPacketException("Failed to read packet.", e); } }
public static object Read(NetPacketReader message) { return(new LineSpokenPacket() { Hash = message.GetUInt() }); }
private void ServerOutgoingHandler(MessageType messageType, NetPeer peer, NetPacketReader reader) { var writer = new NetDataWriter(); switch (messageType) { case MessageType.GetConcurrentUsers: GetConcurrentUsers(writer); break; case MessageType.LeaderboardsResponse: break; case MessageType.PlayerStatsResponse: writer.Put((byte)MessageType.PlayerStatsResponse); var data = reader.GetUInt(); Console.WriteLine($"{data} id received"); try { Console.WriteLine(_connectionProvider.PlayerPool.List .FirstOrDefault(x => x.AccountInfo.Id == data) ?.Statistics.Username); writer.Put(_connectionProvider.PlayerPool.List .FirstOrDefault(x => x.AccountInfo.Id == data) ?.Statistics); } catch { // ignored } break; case MessageType.GetConcurrentUsersResponse: GetConcurrentUsers(writer); break; case MessageType.UpdateProfileSettingsResponse: break; case MessageType.GetAvatarResponse: break; default: Console.WriteLine(); throw new ArgumentOutOfRangeException(); } ConnectionProvider.SendMessage(peer, writer); }
public static object Read(NetPacketReader message) { var p = new ObjectUpdatePacket(); p.Tick = message.GetUInt(); var pack = new BitReader(message.GetRemainingBytes(), 0); var updateCount = pack.GetUInt(8); p.Updates = new PackedShipUpdate[updateCount]; for (int i = 0; i < p.Updates.Length; i++) { p.Updates[i] = PackedShipUpdate.ReadFrom(ref pack); } return(p); }
public static object Read(NetPacketReader message) { var pk = new MsnDialogPacket() { Lines = new NetDlgLine[(int)message.GetVariableUInt32()] }; for (int i = 0; i < pk.Lines.Length; i++) { pk.Lines[i] = new NetDlgLine() { Voice = message.GetString(), Hash = message.GetUInt() }; } return(pk); }
protected override void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType) { switch (messageType) { // 处理房间发现请求或主机信息更新请求 case UnconnectedMessageType.Broadcast: case UnconnectedMessageType.BasicMessage: if (RoomValid && reader.GetInt() == (int)PacketType.discoveryRequest) { logger?.Log($"主机房间收到了局域网发现请求或主机信息更新请求"); NetDataWriter writer = room.Write(PacketType.discoveryResponse, reader.GetUInt()); net.SendUnconnectedMessage(writer, remoteEndPoint); } break; default: break; } }
public static NetDlgLine Read(NetPacketReader message) => new NetDlgLine() { Voice = message.GetString(), Hash = message.GetUInt() };