From 86ef57fb6200a04838ee539947749ec2405190ce Mon Sep 17 00:00:00 2001 From: Syntriax Date: Fri, 9 Feb 2024 10:00:36 +0300 Subject: [PATCH] refactor: Folder and Namespace Restructure of Network Code --- Game/Behaviours/BallBehaviour.cs | 6 +++--- Game/Behaviours/PaddleBehaviour.cs | 4 ++-- Game/Behaviours/PongManagerBehaviour.cs | 4 ++-- Game/GamePong.cs | 2 +- Game/Network/{ => Abstract}/INetworkBehaviour.cs | 2 +- Game/Network/{ => Abstract}/INetworkClient.cs | 2 +- Game/Network/{ => Abstract}/INetworkCommunicator.cs | 4 +++- Game/Network/{ => Abstract}/INetworkServer.cs | 2 +- Game/Network/NetworkBase.cs | 3 ++- Game/Network/NetworkBehaviour.cs | 9 +++++---- Game/Network/NetworkClient.cs | 4 +++- Game/Network/NetworkExtensions.cs | 3 ++- Game/Network/NetworkServer.cs | 4 +++- 13 files changed, 29 insertions(+), 20 deletions(-) rename Game/Network/{ => Abstract}/INetworkBehaviour.cs (85%) rename Game/Network/{ => Abstract}/INetworkClient.cs (74%) rename Game/Network/{ => Abstract}/INetworkCommunicator.cs (90%) rename Game/Network/{ => Abstract}/INetworkServer.cs (83%) diff --git a/Game/Behaviours/BallBehaviour.cs b/Game/Behaviours/BallBehaviour.cs index cebf123..e795f47 100644 --- a/Game/Behaviours/BallBehaviour.cs +++ b/Game/Behaviours/BallBehaviour.cs @@ -1,15 +1,15 @@ using System; +using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using LiteNetLib; -using Pong.Network; - using Syntriax.Engine.Core; +using Syntriax.Engine.Network; +using Syntriax.Engine.Network.Abstract; using Syntriax.Engine.Physics2D; using Syntriax.Engine.Physics2D.Abstract; -using Microsoft.Xna.Framework.Audio; namespace Pong.Behaviours; diff --git a/Game/Behaviours/PaddleBehaviour.cs b/Game/Behaviours/PaddleBehaviour.cs index 684aa9f..1856c65 100644 --- a/Game/Behaviours/PaddleBehaviour.cs +++ b/Game/Behaviours/PaddleBehaviour.cs @@ -5,10 +5,10 @@ using Microsoft.Xna.Framework.Input; using LiteNetLib; using LiteNetLib.Utils; -using Pong.Network; - using Syntriax.Engine.Core; using Syntriax.Engine.Input; +using Syntriax.Engine.Network; +using Syntriax.Engine.Network.Abstract; namespace Pong.Behaviours; diff --git a/Game/Behaviours/PongManagerBehaviour.cs b/Game/Behaviours/PongManagerBehaviour.cs index a9ed86a..fbe3693 100644 --- a/Game/Behaviours/PongManagerBehaviour.cs +++ b/Game/Behaviours/PongManagerBehaviour.cs @@ -4,9 +4,9 @@ using Microsoft.Xna.Framework.Input; using LiteNetLib; -using Pong.Network; - using Syntriax.Engine.Core; +using Syntriax.Engine.Network; +using Syntriax.Engine.Network.Abstract; namespace Pong.Behaviours; diff --git a/Game/GamePong.cs b/Game/GamePong.cs index 3723b62..2f93f3f 100644 --- a/Game/GamePong.cs +++ b/Game/GamePong.cs @@ -7,7 +7,7 @@ using Microsoft.Xna.Framework.Input; using Apos.Shapes; using Pong.Behaviours; -using Pong.Network; +using Syntriax.Engine.Network; using Syntriax.Engine.Core; using Syntriax.Engine.Core.Abstract; diff --git a/Game/Network/INetworkBehaviour.cs b/Game/Network/Abstract/INetworkBehaviour.cs similarity index 85% rename from Game/Network/INetworkBehaviour.cs rename to Game/Network/Abstract/INetworkBehaviour.cs index da667bb..2bcadd0 100644 --- a/Game/Network/INetworkBehaviour.cs +++ b/Game/Network/Abstract/INetworkBehaviour.cs @@ -1,6 +1,6 @@ using Syntriax.Engine.Core.Abstract; -namespace Pong.Network; +namespace Syntriax.Engine.Network.Abstract; public interface INetworkBehaviour : IBehaviour { diff --git a/Game/Network/INetworkClient.cs b/Game/Network/Abstract/INetworkClient.cs similarity index 74% rename from Game/Network/INetworkClient.cs rename to Game/Network/Abstract/INetworkClient.cs index d19f094..957d991 100644 --- a/Game/Network/INetworkClient.cs +++ b/Game/Network/Abstract/INetworkClient.cs @@ -1,4 +1,4 @@ -namespace Pong.Network; +namespace Syntriax.Engine.Network.Abstract; public interface INetworkClient : INetworkCommunicator { diff --git a/Game/Network/INetworkCommunicator.cs b/Game/Network/Abstract/INetworkCommunicator.cs similarity index 90% rename from Game/Network/INetworkCommunicator.cs rename to Game/Network/Abstract/INetworkCommunicator.cs index 26315f5..ad9d788 100644 --- a/Game/Network/INetworkCommunicator.cs +++ b/Game/Network/Abstract/INetworkCommunicator.cs @@ -1,9 +1,11 @@ using System; + using LiteNetLib; using LiteNetLib.Utils; + using Syntriax.Engine.Core.Abstract; -namespace Pong.Network; +namespace Syntriax.Engine.Network.Abstract; public interface INetworkCommunicator { diff --git a/Game/Network/INetworkServer.cs b/Game/Network/Abstract/INetworkServer.cs similarity index 83% rename from Game/Network/INetworkServer.cs rename to Game/Network/Abstract/INetworkServer.cs index 55b8bfa..700b426 100644 --- a/Game/Network/INetworkServer.cs +++ b/Game/Network/Abstract/INetworkServer.cs @@ -1,4 +1,4 @@ -namespace Pong.Network; +namespace Syntriax.Engine.Network.Abstract; public interface INetworkServer : INetworkCommunicator { diff --git a/Game/Network/NetworkBase.cs b/Game/Network/NetworkBase.cs index 47fb41d..49a62d3 100644 --- a/Game/Network/NetworkBase.cs +++ b/Game/Network/NetworkBase.cs @@ -6,8 +6,9 @@ using LiteNetLib.Utils; using Syntriax.Engine.Core; using Syntriax.Engine.Core.Abstract; +using Syntriax.Engine.Network.Abstract; -namespace Pong.Network; +namespace Syntriax.Engine.Network; public abstract class NetworkBase : BehaviourOverride, INetworkCommunicator { diff --git a/Game/Network/NetworkBehaviour.cs b/Game/Network/NetworkBehaviour.cs index c70cf6f..2d97e6b 100644 --- a/Game/Network/NetworkBehaviour.cs +++ b/Game/Network/NetworkBehaviour.cs @@ -1,6 +1,7 @@ using Syntriax.Engine.Core; +using Syntriax.Engine.Network.Abstract; -namespace Pong.Network; +namespace Syntriax.Engine.Network; public class NetworkBehaviour : BehaviourOverride, INetworkBehaviour { @@ -20,10 +21,10 @@ public class NetworkBehaviour : BehaviourOverride, INetworkBehaviour if (NetworkCommunicator is INetworkServer server) { - IsServer = true; - LocalAssigned = true; + IsServer = true; + LocalAssigned = true; - // TODO Set and send Network Id + // TODO Set and send Network Id } else IsClient = true; diff --git a/Game/Network/NetworkClient.cs b/Game/Network/NetworkClient.cs index 2542150..524043f 100644 --- a/Game/Network/NetworkClient.cs +++ b/Game/Network/NetworkClient.cs @@ -1,4 +1,6 @@ -namespace Pong.Network; +using Syntriax.Engine.Network.Abstract; + +namespace Syntriax.Engine.Network; public class NetworkClient : NetworkBase, INetworkClient { diff --git a/Game/Network/NetworkExtensions.cs b/Game/Network/NetworkExtensions.cs index ae67a7e..79fa9b8 100644 --- a/Game/Network/NetworkExtensions.cs +++ b/Game/Network/NetworkExtensions.cs @@ -1,8 +1,9 @@ using LiteNetLib; using LiteNetLib.Utils; + using Syntriax.Engine.Core; -namespace Pong.Network; +namespace Syntriax.Engine.Network; public static class NetworkExtensions { diff --git a/Game/Network/NetworkServer.cs b/Game/Network/NetworkServer.cs index e757a1d..13f1ff9 100644 --- a/Game/Network/NetworkServer.cs +++ b/Game/Network/NetworkServer.cs @@ -1,4 +1,6 @@ -namespace Pong.Network; +using Syntriax.Engine.Network.Abstract; + +namespace Syntriax.Engine.Network; public class NetworkServer : NetworkBase, INetworkServer {