refactor: string id to IConnection parameters for sending network packets

This commit is contained in:
2025-06-22 20:35:00 +03:00
parent bc6aaa865a
commit 5cfed3ba56
4 changed files with 20 additions and 14 deletions

View File

@@ -32,7 +32,7 @@ public class BallBehaviour : Behaviour2D, IFirstFrameUpdate, IPhysicsUpdate, INe
{
ResetBall();
RigidBody.Velocity = launchDirection * Speed;
networkServer?.SendToClient("*", new BallUpdatePacket(this));
networkServer?.SendToAll(new BallUpdatePacket(this));
}
public void ResetBall()
@@ -41,7 +41,7 @@ public class BallBehaviour : Behaviour2D, IFirstFrameUpdate, IPhysicsUpdate, INe
tweenManager.CancelTween(networkTween);
Transform.Position = Vector2D.Zero;
RigidBody.Velocity = Vector2D.Zero;
networkServer?.SendToClient("*", new BallResetPacket());
networkServer?.SendToAll(new BallResetPacket());
}
public void PhysicsUpdate(float delta)
@@ -59,7 +59,7 @@ public class BallBehaviour : Behaviour2D, IFirstFrameUpdate, IPhysicsUpdate, INe
RigidBody.Velocity = information.Detected.Transform.Position.FromTo(information.Detector.Transform.Position).Normalized * RigidBody.Velocity.Magnitude;
else
RigidBody.Velocity = RigidBody.Velocity.Reflect(information.Normal);
networkServer?.SendToClient("*", new BallUpdatePacket(this));
networkServer?.SendToAll(new BallUpdatePacket(this));
}
public BallBehaviour() { }

View File

@@ -75,7 +75,7 @@ public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Sp
isUpPressed = packet.IsUpPressed;
isDownPressed = packet.IsDownPressed;
networkServer?.SendToClient("*", new PaddleKeyStatePacket(this));
networkServer?.SendToAll(new PaddleKeyStatePacket(this));
}
public void OnClientPacketArrived(IConnection sender, PaddleKeyStatePacket packet)