From ea3c4a2d2a1633223f494cb14d1486abecaf8cf9 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Tue, 13 Feb 2024 11:15:27 +0300 Subject: [PATCH] refactor: Removed Network Code From Paddle --- Game/Behaviours/PaddleBehaviour.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Game/Behaviours/PaddleBehaviour.cs b/Game/Behaviours/PaddleBehaviour.cs index 82e732a..391316f 100644 --- a/Game/Behaviours/PaddleBehaviour.cs +++ b/Game/Behaviours/PaddleBehaviour.cs @@ -12,7 +12,7 @@ using Syntriax.Engine.Network.Abstract; namespace Pong.Behaviours; -public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : NetworkBehaviour +public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : BehaviourOverride { private Keys Up { get; } = Up; private Keys Down { get; } = Down; @@ -41,20 +41,13 @@ public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Sp private void MovePaddle(Vector2D vectorToAdd) { - if (!LocalAssigned && !IsServer) - return; - GameObject.Transform.Position += vectorToAdd; - - NetDataWriter dataWriter = communicator.GetMessageWriter(this); - dataWriter.Put(Transform.Position); - communicator.Manager.SendToAll(dataWriter, LiteNetLib.DeliveryMethod.Unreliable); } protected override void OnFirstActiveFrame() { - if (!BehaviourController.TryGetBehaviour>(out var behaviourResult)) - inputs = behaviourResult ?? BehaviourController.AddBehaviour(); + BehaviourController.TryGetBehaviour>(out var behaviourResult); + inputs = behaviourResult ?? throw new Exception($"{nameof(IButtonInputs)} is missing on {GameObject.Name}."); if (!GameObject.GameManager.TryFindBehaviour(out INetworkCommunicator? foundCommunicator)) throw new Exception($"{nameof(INetworkCommunicator)} is missing on GameManager.");