Code cleanup
This commit is contained in:
parent
2fb395a8d4
commit
391b5569a4
@ -123,9 +123,8 @@ public struct PongGameState {
|
||||
public PongPaddleDirection Direction;
|
||||
public int Score;
|
||||
|
||||
public static void Update(ref PongPaddleState state) {
|
||||
state.Height = Math.Clamp(state.Height + ((int)state.Direction) * PADDLE_SPEED, PADDLE_HALF_LENGTH, HEIGHT - PADDLE_HALF_LENGTH);
|
||||
}
|
||||
public static void Update(ref PongPaddleState state)
|
||||
=> state.Height = Math.Clamp(state.Height + ((int)state.Direction) * PADDLE_SPEED, PADDLE_HALF_LENGTH, HEIGHT - PADDLE_HALF_LENGTH);
|
||||
|
||||
public RectangleF GetCollider(float x) => new(x - PADDLE_WIDTH / 2, Height - PADDLE_HALF_LENGTH, PADDLE_WIDTH, PADDLE_LENGTH);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class PongHub : Hub<IPongClient> {
|
||||
|
||||
public Task RequestUsernameChange(string username) {
|
||||
// TOOD: check this
|
||||
Logger.LogInformation($"Player {Player} requested username change to [{username}]");
|
||||
Logger.LogInformation("Player {Player} requested username change to [{username}]", Player, username);
|
||||
Player.Username = username;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace PongGame.Hubs;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class PongRoom {
|
||||
_ = Task.Run(PlayersChanged);
|
||||
}
|
||||
|
||||
private BackgroundWorker gameWorker = new() {
|
||||
private readonly BackgroundWorker gameWorker = new() {
|
||||
WorkerSupportsCancellation = true
|
||||
};
|
||||
|
||||
@ -87,11 +87,11 @@ public class PongRoom {
|
||||
public void MovePaddle(PongPlayer player, PongPaddleDirection direction) {
|
||||
if (Player1 == player) {
|
||||
State.Paddle1.Direction = direction;
|
||||
Logger.LogInformation(DIRECTION_LOG_TEMPLATE, ID, 1, player, direction);
|
||||
Logger.LogDebug(DIRECTION_LOG_TEMPLATE, ID, 1, player, direction);
|
||||
return;
|
||||
} else if (Player2 == player) {
|
||||
State.Paddle2.Direction = direction;
|
||||
Logger.LogInformation(DIRECTION_LOG_TEMPLATE, ID, 2, player, direction);
|
||||
Logger.LogDebug(DIRECTION_LOG_TEMPLATE, ID, 2, player, direction);
|
||||
return;
|
||||
}
|
||||
throw new InvalidOperationException("Player is not in this room, but moved! Assumably players room wasn't deleted.");
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace PongGame.Pages;
|
||||
public class PongModel : PageModel {
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace PongGame.Pages;
|
||||
public class PrivacyModel : PageModel {
|
||||
|
@ -1,4 +1,3 @@
|
||||
using MessagePack;
|
||||
using PongGame.Hubs;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
Loading…
Reference in New Issue
Block a user