public override void Read(NetBuffer msg) { worldZoneId = msg.ReadUInt64(); sceneBuildIndex = msg.ReadInt32(); ip = msg.ReadString(); port = msg.ReadInt32(); }
private void ReadFieldState(NetBuffer msg, Field field) { int bitsForPlayerIndex = NetUtility.BitsToHoldUInt((uint)(field.GetPlayers().GetCount() - 1)); FieldCellSlot[] slots = field.GetCells().slots; for (int i = 0; i < slots.Length; ++i) { FieldCellSlot slot = slots[i]; bool hasStaticCell = msg.ReadBoolean(); if (hasStaticCell) { byte type = msg.ReadByte(BITS_FOR_STATIC_CELL); switch (type) { case CELL_BRICK: { Debug.Assert(slot.ContainsBrick()); break; } case CELL_POWERUP: { int powerup = msg.ReadInt32(BITS_FOR_POWERUP); if (slot.staticCell == null) { field.AddCell(new PowerupCell(powerup, slot.cx, slot.cy)); } else if (!slot.staticCell.IsPowerup()) { field.RemoveCell(slot.staticCell); field.AddCell(new PowerupCell(powerup, slot.cx, slot.cy)); } break; } case CELL_FLAME: { int playerIndex = msg.ReadInt32(bitsForPlayerIndex); if (slot.staticCell == null) { Player player = field.GetPlayers().Get(playerIndex); field.AddCell(new FlameCell(player, slot.cx, slot.cy)); } else if (!slot.staticCell.IsFlame()) { Player player = field.GetPlayers().Get(playerIndex); field.RemoveCell(slot.staticCell); field.AddCell(new FlameCell(player, slot.cx, slot.cy)); } break; } } } else if (slot.staticCell != null && !slot.staticCell.IsSolid()) { field.RemoveCell(slot.staticCell); } } }
public void Unpack(NetBuffer netBuffer) { Client.ServiceLocator.GetService <LightManagerService>().Component.Lights.Clear(); this.Dark = netBuffer.ReadBoolean(); if (this.Dark) { Client.ServiceLocator.GetService <LightManagerService>().Component.AmbientColor = new Color(100, 100, 100, 20); } else { Client.ServiceLocator.GetService <LightManagerService>().Component.AmbientColor = Color.White; } int layerCount = netBuffer.ReadInt32(); for (int i = 0; i < layerCount; i++) { string layerName = netBuffer.ReadString(); int lIndex = netBuffer.ReadInt32(); var layer = new Layer(this.Dimensions, lIndex, layerName); layer.Unpack(netBuffer); _layers.Add(layerName, layer); } }
public void Read(NetBuffer buffer) { SendTime = buffer.ReadSingle(); CurrentRTT = buffer.ReadInt32(); RemoteTime = buffer.ReadSingle(); RemoteTick = buffer.ReadInt32(); }
public static Point ReadPoint32(this NetBuffer buffer) { int x = buffer.ReadInt32(); int y = buffer.ReadInt32(); return(new Point(x, y)); }
public static Point3D ReadPoint3D(this NetBuffer msg) { int x = msg.ReadInt32(); int y = msg.ReadInt32(); int z = msg.ReadInt32(); return(new Point3D(x, y, z)); }
public void Read(NetBuffer buffer) { Scope = (ChatScope)buffer.ReadByte(); Message = buffer.ReadString(); Name = buffer.ReadString(); ClientIndex = buffer.ReadInt32(); SupporterLevel = buffer.ReadInt32(); }
public void Read(NetBuffer buffer) { EntityId = buffer.ReadInt32(); EntityTypeId = buffer.ReadByte(); ChangedTick = buffer.ReadInt32(); ChangedTime = buffer.ReadSingle(); PropDataSize = buffer.ReadInt32(); PropData = buffer.ReadBytes(PropDataSize); }
/* the server reads data from a client */ protected ClientPacket ReadClientPacket(NetBuffer msg) { ClientPacket packet; packet.id = msg.ReadInt32(); packet.lastAckServerPacketId = msg.ReadInt32(); packet.actions = msg.ReadInt32((int)PlayerAction.Count); return(packet); }
public override void Read(NetBuffer im) { base.Read(im); int c = im.ReadInt32(); for (int i = 0; i < c; ++i) { int id = im.ReadInt32(); FollowerId.Add(id); } }
public void Read(NetBuffer im) { MessagePacketId = im.ReadInt64(); Number = im.ReadInt32(); int length = im.ReadInt32(); if (length != 0) { Bytes = im.ReadBytes(length); } }
public static MapObject Unpack(NetBuffer netBuffer) { // can we view it? if (!netBuffer.ReadBoolean()) { return(null); } var textureName = Path.ChangeExtension(netBuffer.ReadString(), null); var sourceRectangle = new Rectangle(netBuffer.ReadInt32(), netBuffer.ReadInt32(), netBuffer.ReadInt32(), netBuffer.ReadInt32()); var color = new Color(new Vector4(netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte())); var position = new Vector2(netBuffer.ReadFloat(), netBuffer.ReadFloat()); var animated = netBuffer.ReadBoolean(); float zIndex = netBuffer.ReadSingle(); var frameTime = netBuffer.ReadInt32(); var sprite = new AnimatedSprite(Client.ServiceLocator.GetService <ContentManagerService>().ContentManager.LoadTexture2D( Constants.FILEPATH_ROOT + textureName)) { SourceRectangle = sourceRectangle, Color = color, Position = position, LayerDepth = zIndex }; var mapObject = new MapObject(sprite, animated) { FrameTime = frameTime }; // is it a light source? if (netBuffer.ReadBoolean() == true) { var lightColor = new Color(new Vector4(netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte())); var radius = netBuffer.ReadFloat(); PointLight pointLight = new PointLight { Position = position, Scale = new Vector2(radius), Color = lightColor, Intensity = .7f, }; Client.ServiceLocator.GetService <LightManagerService>().Component.Lights.Add(pointLight); mapObject.Light = pointLight; } return(mapObject); }
public override void Read(NetBuffer im) { base.Read(im); int c = im.ReadInt32(); for (int i = 0; i < c; ++i) { int objId = im.ReadInt32(); int folId = im.ReadInt32(); Followers.Add(new KeyValuePair <int, int>(objId, folId)); } }
public void Read(NetBuffer buffer) { Fields.HostTime = buffer.ReadSingle(); Fields.PacketId = buffer.ReadInt32(); Fields.ClientIndex = buffer.ReadInt32(); Fields.Buttons = (InputActions)buffer.ReadInt32(); Fields.Origin = buffer.ReadVector3(); Fields.Angles = buffer.ReadVector3(); Fields.Velocity = buffer.ReadVector3(); Fields.BaseVelocity = buffer.ReadVector3(); Fields.MousePosition = buffer.ReadVector3(); Fields.HoveredEntity = buffer.ReadInt32(); }
public void Read(NetBuffer buffer) { DamageInfo.WeaponId = buffer.ReadInt32(); DamageInfo.AttackerEntityId = buffer.ReadInt32(); DamageInfo.VictimEntityId = buffer.ReadInt32(); DamageInfo.Amount = buffer.ReadInt32(); DamageInfo.ResultedInDeath = buffer.ReadBoolean(); DamageInfo.HitNormal = buffer.ReadVector3(); DamageInfo.HitPoint = buffer.ReadVector3(); DamageInfo.Viewpunch = buffer.ReadSingle(); DamageInfo.HitArea = (HitboxArea)buffer.ReadByte(); DamageInfo.DamageType = (DamageType)buffer.ReadByte(); }
public void Read(NetBuffer buffer) { Files.Clear(); SyncType = (FileSyncType)buffer.ReadByte(); if (SyncType == FileSyncType.Manifest) { DownloadUrl = buffer.ReadString(); } if (SyncType == FileSyncType.Manifest || SyncType == FileSyncType.Request) { var fileCount = buffer.ReadInt32(); for (int i = 0; i < fileCount; i++) { var fi = new FSFileInfo(); fi.RelativePath = buffer.ReadString(); fi.WorkshopId = buffer.ReadUInt64(); if (SyncType == FileSyncType.Manifest) { fi.Hash = buffer.ReadBytes(16); } Files.Add(fi); } } }
public void Deserialize(NetBuffer pPacketReader) { name = pPacketReader.ReadString(); subspace = pPacketReader.ReadInt32(); clock = pPacketReader.ReadDouble(); unk = pPacketReader.ReadBool(); }
public void Read(NetBuffer buffer) { EventType = (PlayerEventType)buffer.ReadByte(); ClientIndex = buffer.ReadInt32(); TeamNumber = buffer.ReadByte(); Latency = buffer.ReadInt32(); DisplayName = buffer.ReadString(); SteamID = buffer.ReadUInt64(); switch (EventType) { case PlayerEventType.Spectate: SpecTarget = buffer.ReadInt32(); break; } }
public void Read(NetBuffer im) { MetaData = im.ReadString(); int l = im.ReadInt32(); Data = im.ReadBytes(l); }
private static Relation _ReadRelation(NetBuffer buffer) { RelationFlags flags = (RelationFlags)buffer.ReadByte(); int value = (flags != RelationFlags.Any) ? buffer.ReadInt32() : 0; return(new Relation(flags, value)); }
public override void Read(NetBuffer m) { netid = m.ReadUInt64(); netComponentId = m.ReadByte(); originalMessageId = m.ReadInt32(); messageData = NetSerialize.ReadBytes(m); }
public void Read(NetBuffer buffer) { File = buffer.ReadString().ToLower(); TotalLength = buffer.ReadInt64(); ChunkLength = buffer.ReadInt32(); Data = buffer.ReadBytes(ChunkLength); Temporary = buffer.ReadBoolean(); }
internal LocalHostData(NetBuffer buffer) { gameType = buffer.ReadString(); gameName = buffer.ReadString(); gameMode = buffer.ReadString(); gameLevel = buffer.ReadString(); connectedPlayers = buffer.ReadInt32(); playerLimit = buffer.ReadInt32(); passwordProtected = (buffer.ReadByte() == 1); dedicatedServer = (buffer.ReadByte() == 1); useNat = (buffer.ReadByte() == 1); useProxy = (buffer.ReadByte() == 1); comment = buffer.ReadString(); platform = buffer.ReadString(); timestamp = DateTime.FromBinary(buffer.ReadInt64()); internalEndpoint = buffer.ReadEndPoint(); }
public void Read(NetBuffer buffer) { DataEntries.Clear(); Label = buffer.ReadString(); byte entryCount = buffer.ReadByte(); for (int i = 0; i < entryCount; i++) { var entry = new DataEntry(); entry.Type = (DataType)buffer.ReadByte(); switch (entry.Type) { case DataType.Bool: entry.BoolValue = buffer.ReadBoolean(); break; case DataType.Int: entry.IntValue = buffer.ReadInt32(); break; case DataType.Float: entry.FloatValue = buffer.ReadSingle(); break; case DataType.Byte: entry.ByteValue = buffer.ReadByte(); break; case DataType.String: entry.StringValue = buffer.ReadString(); break; case DataType.Vector3: entry.Vector3Value = buffer.ReadVector3(); break; case DataType.Bytes: var byteCount = buffer.ReadInt32(); entry.BytesValue = buffer.ReadBytes(byteCount); break; } DataEntries.Add(entry); } }
public override void Read(NetBuffer im) { base.Read(im); int c = im.ReadInt32(); for (int i = 0; i < c; ++i) { var objid = im.ReadInt32(); var followerid = im.ReadInt32(); FollowerList.Add(new KeyValuePair <int, int>(objid, followerid)); } c = im.ReadInt32(); for (int i = 0; i < c; ++i) { var follower = im.ReadInt32(); FightFollowerList.Add(follower); } }
/// <inheritdoc /> public void ReadFromBuffer(NetBuffer buffer) { RoomId = buffer.ReadString(); YourPlayer = buffer.ReadInt32(); CurrentPlayer = new Guid(buffer.ReadBytes(16)); Players = new Player[buffer.ReadInt32()]; for (var i = 0; i < Players.Length; i++) { Players[i] = buffer.ReadClass <Player>(); } Board = new GamePiece[buffer.ReadInt32()]; for (var i = 0; i < Board.Length; i++) { Board[i] = buffer.ReadClass <GamePiece>(); } }
public static int ReadEntityLight(this NetBuffer message, ref CBody cBody, ref CTransform ctransform, ref string modelname, ref bool isPlayer) { int id = message.ReadInt32(); cBody.Velocity = message.ReadVector3(); ctransform.Position = message.ReadVector3(); ctransform.Rotation = message.ReadMatrix(); return(id); }
/// <summary> /// Reads a <see cref="TimeSpan"/> value from the <see cref="NetBuffer"/>. /// </summary> /// <param name="message">The buffer to write to</param> /// <param name="highPrecision"> /// Indicates whether the <see cref="TimeSpan"/> will be read using high precision (ticks) or not (milliseconds) /// </param> /// <remarks> /// High precision allows full <see cref="TimeSpan"/> range, otherwise it will be limited to "+-24.20:31:23.647" /// (+-24 days, 20 hours, 31 minutes, 23 seconds and 647 milliseconds) /// </remarks> /// <returns>A <see cref="TimeSpan"/> value</returns> public static TimeSpan ReadTimeSpan(this NetBuffer message, bool highPrecision) { if (highPrecision) { return(TimeSpan.FromTicks(message.ReadInt64())); } else { return(TimeSpan.FromMilliseconds(message.ReadInt32())); } }
public static int ReadEntity(this NetBuffer message, ref CBody cBody, ref CTransform ctransform, ref string modelname, ref bool isPlayer) { int id = message.ReadInt32(); isPlayer = message.ReadBoolean(); cBody = ReadCBody(message); ctransform = ReadCTransform(message); modelname = message.ReadString(); return(id); }
public static byte[] ReadBytes(NetBuffer buffer) { byte[] data = null; int len = buffer.ReadInt32(); if (len > 0) { data = buffer.ReadBytes(len); } return(data); }
/// <summary> /// Read a Point /// </summary> public static Point ReadPoint(NetBuffer buffer) { return new Point(buffer.ReadInt32(), buffer.ReadInt32()); }