public static List <RpcUpdateGameData> Deserialize(HazelBinaryReader reader) { var items = new List <RpcUpdateGameData>(); while (reader.HasBytesLeft()) { var msg = new RpcUpdateGameData(); var length = reader.ReadInt16(); var body = new HazelBinaryReader(reader.ReadBytes(length)); reader.ReadByte(); msg.playerId = body.ReadByte(); msg.name = body.ReadString(); msg.color = body.ReadByte(); msg.hat = (Hat)body.ReadByte(); msg.pet = (Pet)body.ReadByte(); msg.skin = (Skin)body.ReadByte(); msg.unknown = body.ReadByte(); items.Add(msg); } return(items); }
public override void Deserialize(HazelBinaryReader reader, bool onSpawn) { if (onSpawn) { seq = reader.ReadInt16(); position = reader.ReadLerpVector2(xyrange, xyrange); velocity = reader.ReadLerpVector2(xyrange, xyrange); return; } seq = reader.ReadInt16(); position = reader.ReadLerpVector2(xyrange, xyrange); velocity = reader.ReadLerpVector2(xyrange, xyrange); //ushort newSid = reader.ReadUInt16(); //if (!CustomNetworkTransform.SidGreaterThan(newSid, this.lastSequenceId)) //{ // return; //} //this.lastSequenceId = newSid; //this.targetSyncPosition = this.ReadVector2(reader); //this.targetSyncVelocity = this.ReadVector2(reader); //if (!base.isActiveAndEnabled) //{ // return; //} //if (Vector2.Distance(this.body.position, this.targetSyncPosition) > this.snapThreshold) //{ // if (this.body) // { // this.body.position = this.targetSyncPosition; // this.body.velocity = this.targetSyncVelocity; // } // else // { // base.transform.position = this.targetSyncPosition; // } //} //if (this.interpolateMovement == 0f && this.body) //{ // this.body.position = this.targetSyncPosition; //} }
private static List <byte[]> GetMessages(MemoryStream stream) { var buffers = new List <byte[]>(); HazelBinaryReader reader = new HazelBinaryReader(stream); var header = reader.ReadByte(); if (header == (byte)UdpSendOption.Acknowledgement || header == (byte)UdpSendOption.Ping || header == (byte)UdpSendOption.Disconnect) { return(buffers); } if (header == (byte)UdpSendOption.Hello) { Console.WriteLine("Recived Hello"); var hello = HelloHandshake.Deserialize(reader); DumpToConsole(hello); return(buffers); } if (header == (byte)SendOption.Reliable) { var ack = reader.ReadInt16(); } while (reader.HasBytesLeft()) { int length = reader.ReadInt16(); var data = reader.ReadBytes(length + 1); buffers.Add(data); } return(buffers); }
public static List <GameData> Deserialize(HazelBinaryReader reader) { var gameId = reader.ReadInt32(); var gamedatas = new List <GameData>(); while (reader.HasBytesLeft()) { var msg = new GameData(); msg.gameId = gameId; var size = reader.ReadInt16(); msg.type = reader.ReadByte(); msg.body = reader.ReadBytes(size); gamedatas.Add(msg); } return(gamedatas); }
public static GetGameListV2Response Deserialize(HazelBinaryReader reader) { var msg = new GetGameListV2Response(); var size = reader.ReadInt16(); var type = reader.ReadByte(); var body = new HazelBinaryReader(reader.ReadBytes(size)); msg.games = new List <GameListItem>(); while (body.HasBytesLeft()) { var itemsize = body.ReadInt16(); var itemtype = body.ReadByte(); var itemBody = body.ReadBytes(itemsize); var itemreader = new HazelBinaryReader(itemBody); msg.games.Add(GameListItem.Deserialize(itemreader)); } return(msg); }
public static Spawn Deserialize(HazelBinaryReader reader) { var msg = new Spawn(); msg.spawnId = reader.ReadPackedInt32(); msg.ownerId = reader.ReadPackedInt32(); msg.flags = (SpawnFlags)reader.ReadByte(); msg.children = reader.ReadList(read => { var netId = reader.ReadPackedInt32(); var size = reader.ReadInt16(); var type = reader.ReadByte(); var body = reader.ReadBytes(size); return(new SpawnChild() { netId = netId, body = body, }); }); return(msg); }