feat: NetworkExtensions for Vector2D Communication
This commit is contained in:
		
							
								
								
									
										17
									
								
								Game/Network/NetworkExtensions.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Game/Network/NetworkExtensions.cs
									
									
									
									
									
										Normal file
									
								
							@@ -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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user