public void Depacketize(IReadablePacket packet) { var attributeCount = packet.ReadInt32(); for (var i = 0; i < attributeCount; i++) { var type = (AttributeType)packet.ReadByte(); var value = packet.ReadSingle(); Attributes.Add(type, value); } Projectiles = packet.ReadPacketizables <ProjectileFactory>(); }
/// <summary>Reads a Manifold value.</summary> /// <param name="packet">The packet.</param> /// <returns>The read value.</returns> /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception> public static Manifold ReadManifold(this IReadablePacket packet) { var result = new Manifold(); packet .Read(out result.Points.Item1) .Read(out result.Points.Item2) .Read(out result.LocalNormal) .Read(out result.LocalPoint); result.Type = (Manifold.ManifoldType)packet.ReadByte(); packet.Read(out result.PointCount); return(result); }
public void Depacketize(IReadablePacket packet) { _currentBehaviors.Clear(); var behaviorCount = packet.ReadInt32(); for (var i = 0; i < behaviorCount; i++) { _currentBehaviors.Push((BehaviorType)packet.ReadByte()); } foreach (var behaviorType in _behaviors.Keys) { var behavior = _behaviors[behaviorType]; packet.ReadPacketizableInto(behavior); } }
public static IReadablePacket Read(this IReadablePacket packet, out byte data) { data = packet.ReadByte(); return(packet); }