From 78010c266e2b09bc5a42bc07721843b7d411b826 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Fri, 2 Feb 2024 12:39:04 +0300 Subject: [PATCH] feat: NetworkExtensions for Vector2D Communication --- Game/Network/NetworkExtensions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Game/Network/NetworkExtensions.cs diff --git a/Game/Network/NetworkExtensions.cs b/Game/Network/NetworkExtensions.cs new file mode 100644 index 0000000..ae67a7e --- /dev/null +++ b/Game/Network/NetworkExtensions.cs @@ -0,0 +1,17 @@ +using LiteNetLib; +using LiteNetLib.Utils; +using Syntriax.Engine.Core; + +namespace Pong.Network; + +public static class NetworkExtensions +{ + public static Vector2D GetVector2D(this NetPacketReader reader) + => new(reader.GetFloat(), reader.GetFloat()); + + public static void Put(this NetDataWriter writer, Vector2D vector) + { + writer.Put(vector.X); + writer.Put(vector.Y); + } +}