Engine-Pong/Game/Network/NetworkExtensions.cs

22 lines
569 B
C#

using LiteNetLib;
using LiteNetLib.Utils;
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Network;
public static class NetworkExtensions
{
public static Vector2D GetVector2D(this NetPacketReader reader)
=> new(reader.GetFloat(), reader.GetFloat());
public static void GetVector2D(this NetPacketReader reader, out Vector2D vector2D)
=> vector2D = new(reader.GetFloat(), reader.GetFloat());
public static void Put(this NetDataWriter writer, Vector2D vector)
{
writer.Put(vector.X);
writer.Put(vector.Y);
}
}