From 0ca6a91a7e836693f92f8cd57f1fbbb4d40f97e6 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Wed, 10 Apr 2024 19:25:45 +0200 Subject: [PATCH] separate folders per functionality --- .../{Services => GameLogic}/BulletManager.cs | 4 +-- .../CollideBulletsWithMap.cs | 6 +---- .../CollideBulletsWithTanks.cs | 5 +--- .../{Services => GameLogic}/GameTickWorker.cs | 4 +-- .../{TickSteps => GameLogic}/ITickStep.cs | 2 +- .../{Services => GameLogic}/MapService.cs | 4 +-- .../{TickSteps => GameLogic}/MoveBullets.cs | 5 +--- .../{TickSteps => GameLogic}/MoveTanks.cs | 9 +++---- .../{TickSteps => GameLogic}/RotateTanks.cs | 5 +--- .../ShootFromTanks.cs | 5 +--- .../{TickSteps => GameLogic}/SpawnNewTanks.cs | 5 +--- .../SpawnQueueProvider.cs | 4 +-- .../{Services => GameLogic}/TankManager.cs | 4 +-- TanksServer/GlobalUsings.cs | 2 ++ .../{DrawSteps => Graphics}/BulletDrawer.cs | 5 ++-- .../DrawStateToFrame.cs | 5 ++-- .../{DrawSteps => Graphics}/IDrawStep.cs | 2 +- .../LastFinishedFrameProvider.cs | 2 +- .../{DrawSteps => Graphics}/MapDrawer.cs | 6 ++--- .../{DrawSteps => Graphics}/TankDrawer.cs | 5 ++-- .../AppSerializerContext.cs | 3 +-- .../ByteChannelWebSocket.cs | 3 +-- .../ClientScreenServer.cs | 4 +-- .../ControlsServer.cs | 7 ++--- .../PlayerServer.cs | 6 ++--- .../SendToClientScreen.cs | 6 ++--- .../{Helpers => Models}/PositionHelpers.cs | 12 +++------ TanksServer/Models/Tank.cs | 2 +- TanksServer/Program.cs | 8 +++--- .../ServicePointDisplay/DisplayBufferView.cs | 2 -- .../PixelDisplayBufferView.cs | 3 --- .../SendToServicePointDisplay.cs | 26 ++++++++++--------- .../ServicePointDisplay/TextDisplayBuffer.cs | 2 -- 33 files changed, 60 insertions(+), 113 deletions(-) rename TanksServer/{Services => GameLogic}/BulletManager.cs (84%) rename TanksServer/{TickSteps => GameLogic}/CollideBulletsWithMap.cs (76%) rename TanksServer/{TickSteps => GameLogic}/CollideBulletsWithTanks.cs (91%) rename TanksServer/{Services => GameLogic}/GameTickWorker.cs (94%) rename TanksServer/{TickSteps => GameLogic}/ITickStep.cs (62%) rename TanksServer/{Services => GameLogic}/MapService.cs (96%) rename TanksServer/{TickSteps => GameLogic}/MoveBullets.cs (85%) rename TanksServer/{TickSteps => GameLogic}/MoveTanks.cs (91%) rename TanksServer/{TickSteps => GameLogic}/RotateTanks.cs (85%) rename TanksServer/{TickSteps => GameLogic}/ShootFromTanks.cs (92%) rename TanksServer/{TickSteps => GameLogic}/SpawnNewTanks.cs (92%) rename TanksServer/{Services => GameLogic}/SpawnQueueProvider.cs (64%) rename TanksServer/{Services => GameLogic}/TankManager.cs (87%) rename TanksServer/{DrawSteps => Graphics}/BulletDrawer.cs (77%) rename TanksServer/{TickSteps => Graphics}/DrawStateToFrame.cs (85%) rename TanksServer/{DrawSteps => Graphics}/IDrawStep.cs (78%) rename TanksServer/{Services => Graphics}/LastFinishedFrameProvider.cs (91%) rename TanksServer/{DrawSteps => Graphics}/MapDrawer.cs (88%) rename TanksServer/{DrawSteps => Graphics}/TankDrawer.cs (95%) rename TanksServer/{Helpers => Interactivity}/AppSerializerContext.cs (72%) rename TanksServer/{Helpers => Interactivity}/ByteChannelWebSocket.cs (97%) rename TanksServer/{Servers => Interactivity}/ClientScreenServer.cs (97%) rename TanksServer/{Servers => Interactivity}/ControlsServer.cs (96%) rename TanksServer/{Servers => Interactivity}/PlayerServer.cs (89%) rename TanksServer/{TickSteps => Interactivity}/SendToClientScreen.cs (80%) rename TanksServer/{Helpers => Models}/PositionHelpers.cs (77%) diff --git a/TanksServer/Services/BulletManager.cs b/TanksServer/GameLogic/BulletManager.cs similarity index 84% rename from TanksServer/Services/BulletManager.cs rename to TanksServer/GameLogic/BulletManager.cs index 5e72db5..4827e02 100644 --- a/TanksServer/Services/BulletManager.cs +++ b/TanksServer/GameLogic/BulletManager.cs @@ -1,6 +1,4 @@ -using TanksServer.Models; - -namespace TanksServer.Services; +namespace TanksServer.GameLogic; internal sealed class BulletManager { diff --git a/TanksServer/TickSteps/CollideBulletsWithMap.cs b/TanksServer/GameLogic/CollideBulletsWithMap.cs similarity index 76% rename from TanksServer/TickSteps/CollideBulletsWithMap.cs rename to TanksServer/GameLogic/CollideBulletsWithMap.cs index 7f4882f..b0c0221 100644 --- a/TanksServer/TickSteps/CollideBulletsWithMap.cs +++ b/TanksServer/GameLogic/CollideBulletsWithMap.cs @@ -1,8 +1,4 @@ -using TanksServer.Helpers; -using TanksServer.Models; -using TanksServer.Services; - -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; internal sealed class CollideBulletsWithMap(BulletManager bullets, MapService map) : ITickStep { diff --git a/TanksServer/TickSteps/CollideBulletsWithTanks.cs b/TanksServer/GameLogic/CollideBulletsWithTanks.cs similarity index 91% rename from TanksServer/TickSteps/CollideBulletsWithTanks.cs rename to TanksServer/GameLogic/CollideBulletsWithTanks.cs index 4f6b185..837a5e8 100644 --- a/TanksServer/TickSteps/CollideBulletsWithTanks.cs +++ b/TanksServer/GameLogic/CollideBulletsWithTanks.cs @@ -1,7 +1,4 @@ -using TanksServer.Models; -using TanksServer.Services; - -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; internal sealed class CollideBulletsWithTanks( BulletManager bullets, TankManager tanks, SpawnQueueProvider spawnQueueProvider diff --git a/TanksServer/Services/GameTickWorker.cs b/TanksServer/GameLogic/GameTickWorker.cs similarity index 94% rename from TanksServer/Services/GameTickWorker.cs rename to TanksServer/GameLogic/GameTickWorker.cs index 9a775c4..1a3abea 100644 --- a/TanksServer/Services/GameTickWorker.cs +++ b/TanksServer/GameLogic/GameTickWorker.cs @@ -1,9 +1,7 @@ using System.Diagnostics; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using TanksServer.TickSteps; -namespace TanksServer.Services; +namespace TanksServer.GameLogic; internal sealed class GameTickWorker( IEnumerable steps, diff --git a/TanksServer/TickSteps/ITickStep.cs b/TanksServer/GameLogic/ITickStep.cs similarity index 62% rename from TanksServer/TickSteps/ITickStep.cs rename to TanksServer/GameLogic/ITickStep.cs index 960c06e..fb74f23 100644 --- a/TanksServer/TickSteps/ITickStep.cs +++ b/TanksServer/GameLogic/ITickStep.cs @@ -1,4 +1,4 @@ -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; public interface ITickStep { diff --git a/TanksServer/Services/MapService.cs b/TanksServer/GameLogic/MapService.cs similarity index 96% rename from TanksServer/Services/MapService.cs rename to TanksServer/GameLogic/MapService.cs index 25606e7..cfff6c4 100644 --- a/TanksServer/Services/MapService.cs +++ b/TanksServer/GameLogic/MapService.cs @@ -1,6 +1,4 @@ -using TanksServer.Models; - -namespace TanksServer.Services; +namespace TanksServer.GameLogic; internal sealed class MapService { diff --git a/TanksServer/TickSteps/MoveBullets.cs b/TanksServer/GameLogic/MoveBullets.cs similarity index 85% rename from TanksServer/TickSteps/MoveBullets.cs rename to TanksServer/GameLogic/MoveBullets.cs index 78dc921..950cb5a 100644 --- a/TanksServer/TickSteps/MoveBullets.cs +++ b/TanksServer/GameLogic/MoveBullets.cs @@ -1,7 +1,4 @@ -using TanksServer.Models; -using TanksServer.Services; - -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; internal sealed class MoveBullets(BulletManager bullets) : ITickStep { diff --git a/TanksServer/TickSteps/MoveTanks.cs b/TanksServer/GameLogic/MoveTanks.cs similarity index 91% rename from TanksServer/TickSteps/MoveTanks.cs rename to TanksServer/GameLogic/MoveTanks.cs index 6da4eef..3c289e3 100644 --- a/TanksServer/TickSteps/MoveTanks.cs +++ b/TanksServer/GameLogic/MoveTanks.cs @@ -1,10 +1,9 @@ -using TanksServer.Models; -using TanksServer.Services; - -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; internal sealed class MoveTanks( - TankManager tanks, IOptions options, MapService map + TankManager tanks, + IOptions options, + MapService map ) : ITickStep { private readonly TanksConfiguration _config = options.Value; diff --git a/TanksServer/TickSteps/RotateTanks.cs b/TanksServer/GameLogic/RotateTanks.cs similarity index 85% rename from TanksServer/TickSteps/RotateTanks.cs rename to TanksServer/GameLogic/RotateTanks.cs index 52eccf2..b36af8b 100644 --- a/TanksServer/TickSteps/RotateTanks.cs +++ b/TanksServer/GameLogic/RotateTanks.cs @@ -1,7 +1,4 @@ -using TanksServer.Models; -using TanksServer.Services; - -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; internal sealed class RotateTanks(TankManager tanks, IOptions options) : ITickStep { diff --git a/TanksServer/TickSteps/ShootFromTanks.cs b/TanksServer/GameLogic/ShootFromTanks.cs similarity index 92% rename from TanksServer/TickSteps/ShootFromTanks.cs rename to TanksServer/GameLogic/ShootFromTanks.cs index d4ec192..04beb3e 100644 --- a/TanksServer/TickSteps/ShootFromTanks.cs +++ b/TanksServer/GameLogic/ShootFromTanks.cs @@ -1,7 +1,4 @@ -using TanksServer.Models; -using TanksServer.Services; - -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; internal sealed class ShootFromTanks( TankManager tanks, diff --git a/TanksServer/TickSteps/SpawnNewTanks.cs b/TanksServer/GameLogic/SpawnNewTanks.cs similarity index 92% rename from TanksServer/TickSteps/SpawnNewTanks.cs rename to TanksServer/GameLogic/SpawnNewTanks.cs index 2ab5761..b6e93e0 100644 --- a/TanksServer/TickSteps/SpawnNewTanks.cs +++ b/TanksServer/GameLogic/SpawnNewTanks.cs @@ -1,7 +1,4 @@ -using TanksServer.Models; -using TanksServer.Services; - -namespace TanksServer.TickSteps; +namespace TanksServer.GameLogic; internal sealed class SpawnNewTanks(TankManager tanks, MapService map, SpawnQueueProvider queueProvider) : ITickStep { diff --git a/TanksServer/Services/SpawnQueueProvider.cs b/TanksServer/GameLogic/SpawnQueueProvider.cs similarity index 64% rename from TanksServer/Services/SpawnQueueProvider.cs rename to TanksServer/GameLogic/SpawnQueueProvider.cs index 57be6e3..c45b13a 100644 --- a/TanksServer/Services/SpawnQueueProvider.cs +++ b/TanksServer/GameLogic/SpawnQueueProvider.cs @@ -1,6 +1,4 @@ -using TanksServer.Models; - -namespace TanksServer.Services; +namespace TanksServer.GameLogic; internal sealed class SpawnQueueProvider { diff --git a/TanksServer/Services/TankManager.cs b/TanksServer/GameLogic/TankManager.cs similarity index 87% rename from TanksServer/Services/TankManager.cs rename to TanksServer/GameLogic/TankManager.cs index 100ebb4..a8cd345 100644 --- a/TanksServer/Services/TankManager.cs +++ b/TanksServer/GameLogic/TankManager.cs @@ -1,8 +1,6 @@ using System.Collections; -using Microsoft.Extensions.Logging; -using TanksServer.Models; -namespace TanksServer.Services; +namespace TanksServer.GameLogic; internal sealed class TankManager(ILogger logger) : IEnumerable { diff --git a/TanksServer/GlobalUsings.cs b/TanksServer/GlobalUsings.cs index d98adb0..7dab1c6 100644 --- a/TanksServer/GlobalUsings.cs +++ b/TanksServer/GlobalUsings.cs @@ -4,4 +4,6 @@ global using System.Collections.Generic; global using System.Linq; global using System.Threading; global using System.Threading.Tasks; +global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Options; +global using TanksServer.Models; diff --git a/TanksServer/DrawSteps/BulletDrawer.cs b/TanksServer/Graphics/BulletDrawer.cs similarity index 77% rename from TanksServer/DrawSteps/BulletDrawer.cs rename to TanksServer/Graphics/BulletDrawer.cs index 16412fb..b70d852 100644 --- a/TanksServer/DrawSteps/BulletDrawer.cs +++ b/TanksServer/Graphics/BulletDrawer.cs @@ -1,8 +1,7 @@ -using TanksServer.Helpers; +using TanksServer.GameLogic; using TanksServer.ServicePointDisplay; -using TanksServer.Services; -namespace TanksServer.DrawSteps; +namespace TanksServer.Graphics; internal sealed class BulletDrawer(BulletManager bullets): IDrawStep { diff --git a/TanksServer/TickSteps/DrawStateToFrame.cs b/TanksServer/Graphics/DrawStateToFrame.cs similarity index 85% rename from TanksServer/TickSteps/DrawStateToFrame.cs rename to TanksServer/Graphics/DrawStateToFrame.cs index 3c34c8e..a793322 100644 --- a/TanksServer/TickSteps/DrawStateToFrame.cs +++ b/TanksServer/Graphics/DrawStateToFrame.cs @@ -1,8 +1,7 @@ -using TanksServer.DrawSteps; +using TanksServer.GameLogic; using TanksServer.ServicePointDisplay; -using TanksServer.Services; -namespace TanksServer.TickSteps; +namespace TanksServer.Graphics; internal sealed class DrawStateToFrame( IEnumerable drawSteps, LastFinishedFrameProvider lastFrameProvider diff --git a/TanksServer/DrawSteps/IDrawStep.cs b/TanksServer/Graphics/IDrawStep.cs similarity index 78% rename from TanksServer/DrawSteps/IDrawStep.cs rename to TanksServer/Graphics/IDrawStep.cs index b9fa0d5..9366adf 100644 --- a/TanksServer/DrawSteps/IDrawStep.cs +++ b/TanksServer/Graphics/IDrawStep.cs @@ -1,6 +1,6 @@ using TanksServer.ServicePointDisplay; -namespace TanksServer.DrawSteps; +namespace TanksServer.Graphics; internal interface IDrawStep { diff --git a/TanksServer/Services/LastFinishedFrameProvider.cs b/TanksServer/Graphics/LastFinishedFrameProvider.cs similarity index 91% rename from TanksServer/Services/LastFinishedFrameProvider.cs rename to TanksServer/Graphics/LastFinishedFrameProvider.cs index 80dd26a..70c101d 100644 --- a/TanksServer/Services/LastFinishedFrameProvider.cs +++ b/TanksServer/Graphics/LastFinishedFrameProvider.cs @@ -1,6 +1,6 @@ using TanksServer.ServicePointDisplay; -namespace TanksServer.Services; +namespace TanksServer.Graphics; internal sealed class LastFinishedFrameProvider { diff --git a/TanksServer/DrawSteps/MapDrawer.cs b/TanksServer/Graphics/MapDrawer.cs similarity index 88% rename from TanksServer/DrawSteps/MapDrawer.cs rename to TanksServer/Graphics/MapDrawer.cs index c5f5ade..c1e9ebd 100644 --- a/TanksServer/DrawSteps/MapDrawer.cs +++ b/TanksServer/Graphics/MapDrawer.cs @@ -1,9 +1,7 @@ -using TanksServer.Helpers; -using TanksServer.Models; +using TanksServer.GameLogic; using TanksServer.ServicePointDisplay; -using TanksServer.Services; -namespace TanksServer.DrawSteps; +namespace TanksServer.Graphics; internal sealed class MapDrawer(MapService map) : IDrawStep { diff --git a/TanksServer/DrawSteps/TankDrawer.cs b/TanksServer/Graphics/TankDrawer.cs similarity index 95% rename from TanksServer/DrawSteps/TankDrawer.cs rename to TanksServer/Graphics/TankDrawer.cs index 0046b97..e21bccd 100644 --- a/TanksServer/DrawSteps/TankDrawer.cs +++ b/TanksServer/Graphics/TankDrawer.cs @@ -1,10 +1,9 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; -using TanksServer.Helpers; +using TanksServer.GameLogic; using TanksServer.ServicePointDisplay; -using TanksServer.Services; -namespace TanksServer.DrawSteps; +namespace TanksServer.Graphics; internal sealed class TankDrawer : IDrawStep { diff --git a/TanksServer/Helpers/AppSerializerContext.cs b/TanksServer/Interactivity/AppSerializerContext.cs similarity index 72% rename from TanksServer/Helpers/AppSerializerContext.cs rename to TanksServer/Interactivity/AppSerializerContext.cs index c048633..98153bf 100644 --- a/TanksServer/Helpers/AppSerializerContext.cs +++ b/TanksServer/Interactivity/AppSerializerContext.cs @@ -1,7 +1,6 @@ using System.Text.Json.Serialization; -using TanksServer.Models; -namespace TanksServer.Helpers; +namespace TanksServer.Interactivity; [JsonSerializable(typeof(Player))] internal sealed partial class AppSerializerContext: JsonSerializerContext; diff --git a/TanksServer/Helpers/ByteChannelWebSocket.cs b/TanksServer/Interactivity/ByteChannelWebSocket.cs similarity index 97% rename from TanksServer/Helpers/ByteChannelWebSocket.cs rename to TanksServer/Interactivity/ByteChannelWebSocket.cs index d6051c5..0408fc0 100644 --- a/TanksServer/Helpers/ByteChannelWebSocket.cs +++ b/TanksServer/Interactivity/ByteChannelWebSocket.cs @@ -1,9 +1,8 @@ using System.Diagnostics; using System.Net.WebSockets; using System.Threading.Channels; -using Microsoft.Extensions.Logging; -namespace TanksServer.Helpers; +namespace TanksServer.Interactivity; /// /// Hacky class for easier semantics diff --git a/TanksServer/Servers/ClientScreenServer.cs b/TanksServer/Interactivity/ClientScreenServer.cs similarity index 97% rename from TanksServer/Servers/ClientScreenServer.cs rename to TanksServer/Interactivity/ClientScreenServer.cs index d0893b0..7c8c1db 100644 --- a/TanksServer/Servers/ClientScreenServer.cs +++ b/TanksServer/Interactivity/ClientScreenServer.cs @@ -2,11 +2,9 @@ using System.Diagnostics; using System.Net.WebSockets; using System.Threading.Channels; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using TanksServer.Helpers; using TanksServer.ServicePointDisplay; -namespace TanksServer.Servers; +namespace TanksServer.Interactivity; internal sealed class ClientScreenServer( ILogger logger, diff --git a/TanksServer/Servers/ControlsServer.cs b/TanksServer/Interactivity/ControlsServer.cs similarity index 96% rename from TanksServer/Servers/ControlsServer.cs rename to TanksServer/Interactivity/ControlsServer.cs index 38058bd..eb6752a 100644 --- a/TanksServer/Servers/ControlsServer.cs +++ b/TanksServer/Interactivity/ControlsServer.cs @@ -1,15 +1,12 @@ using System.Net.WebSockets; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using TanksServer.Helpers; -using TanksServer.Models; -namespace TanksServer.Servers; +namespace TanksServer.Interactivity; internal sealed class ControlsServer(ILogger logger, ILoggerFactory loggerFactory) : IHostedLifecycleService { - private readonly List _connections = new(); + private readonly List _connections = []; public Task HandleClient(WebSocket ws, Player player) { diff --git a/TanksServer/Servers/PlayerServer.cs b/TanksServer/Interactivity/PlayerServer.cs similarity index 89% rename from TanksServer/Servers/PlayerServer.cs rename to TanksServer/Interactivity/PlayerServer.cs index 46f2a96..aa28529 100644 --- a/TanksServer/Servers/PlayerServer.cs +++ b/TanksServer/Interactivity/PlayerServer.cs @@ -1,9 +1,7 @@ using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Logging; -using TanksServer.Models; -using TanksServer.Services; +using TanksServer.GameLogic; -namespace TanksServer.Servers; +namespace TanksServer.Interactivity; internal sealed class PlayerServer(ILogger logger, SpawnQueueProvider spawnQueueProvider) { diff --git a/TanksServer/TickSteps/SendToClientScreen.cs b/TanksServer/Interactivity/SendToClientScreen.cs similarity index 80% rename from TanksServer/TickSteps/SendToClientScreen.cs rename to TanksServer/Interactivity/SendToClientScreen.cs index 2c136c9..8256906 100644 --- a/TanksServer/TickSteps/SendToClientScreen.cs +++ b/TanksServer/Interactivity/SendToClientScreen.cs @@ -1,7 +1,7 @@ -using TanksServer.Servers; -using TanksServer.Services; +using TanksServer.GameLogic; +using TanksServer.Graphics; -namespace TanksServer.TickSteps; +namespace TanksServer.Interactivity; internal sealed class SendToClientScreen( ClientScreenServer clientScreenServer, diff --git a/TanksServer/Helpers/PositionHelpers.cs b/TanksServer/Models/PositionHelpers.cs similarity index 77% rename from TanksServer/Helpers/PositionHelpers.cs rename to TanksServer/Models/PositionHelpers.cs index 0a644a8..e0985b0 100644 --- a/TanksServer/Helpers/PositionHelpers.cs +++ b/TanksServer/Models/PositionHelpers.cs @@ -1,15 +1,11 @@ using System.Diagnostics; -using TanksServer.Models; -using TanksServer.Services; +using TanksServer.GameLogic; -namespace TanksServer.Helpers; +namespace TanksServer.Models; internal static class PositionHelpers { - public static int ToPixelIndex(this PixelPosition position) - { - return position.Y * MapService.PixelsPerRow + position.X; - } + public static int ToPixelIndex(this PixelPosition position) => position.Y * MapService.PixelsPerRow + position.X; public static PixelPosition GetPixelRelative(this TilePosition position, byte subX, byte subY) { @@ -31,4 +27,4 @@ internal static class PositionHelpers X: position.X / MapService.TileSize, Y: position.Y / MapService.TileSize ); -} +} \ No newline at end of file diff --git a/TanksServer/Models/Tank.cs b/TanksServer/Models/Tank.cs index c7549ba..eb472a8 100644 --- a/TanksServer/Models/Tank.cs +++ b/TanksServer/Models/Tank.cs @@ -1,4 +1,4 @@ -using TanksServer.Services; +using TanksServer.GameLogic; namespace TanksServer.Models; diff --git a/TanksServer/Program.cs b/TanksServer/Program.cs index 1f163b6..b8b87ca 100644 --- a/TanksServer/Program.cs +++ b/TanksServer/Program.cs @@ -4,12 +4,10 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; -using TanksServer.DrawSteps; -using TanksServer.Helpers; -using TanksServer.Servers; +using TanksServer.GameLogic; +using TanksServer.Graphics; +using TanksServer.Interactivity; using TanksServer.ServicePointDisplay; -using TanksServer.Services; -using TanksServer.TickSteps; namespace TanksServer; diff --git a/TanksServer/ServicePointDisplay/DisplayBufferView.cs b/TanksServer/ServicePointDisplay/DisplayBufferView.cs index a28ea60..8d1dde8 100644 --- a/TanksServer/ServicePointDisplay/DisplayBufferView.cs +++ b/TanksServer/ServicePointDisplay/DisplayBufferView.cs @@ -1,5 +1,3 @@ -using TanksServer.Models; - namespace TanksServer.ServicePointDisplay; internal class DisplayBufferView(byte[] data) diff --git a/TanksServer/ServicePointDisplay/PixelDisplayBufferView.cs b/TanksServer/ServicePointDisplay/PixelDisplayBufferView.cs index d11e0cc..6da0f76 100644 --- a/TanksServer/ServicePointDisplay/PixelDisplayBufferView.cs +++ b/TanksServer/ServicePointDisplay/PixelDisplayBufferView.cs @@ -1,6 +1,3 @@ -using TanksServer.Helpers; -using TanksServer.Services; - namespace TanksServer.ServicePointDisplay; internal sealed class PixelDisplayBufferView : DisplayBufferView diff --git a/TanksServer/ServicePointDisplay/SendToServicePointDisplay.cs b/TanksServer/ServicePointDisplay/SendToServicePointDisplay.cs index 69027c2..acb0f29 100644 --- a/TanksServer/ServicePointDisplay/SendToServicePointDisplay.cs +++ b/TanksServer/ServicePointDisplay/SendToServicePointDisplay.cs @@ -1,10 +1,9 @@ using System.Diagnostics; using System.Net; using System.Net.Sockets; -using Microsoft.Extensions.Logging; -using TanksServer.Servers; -using TanksServer.Services; -using TanksServer.TickSteps; +using TanksServer.GameLogic; +using TanksServer.Graphics; +using TanksServer.Interactivity; namespace TanksServer.ServicePointDisplay; @@ -34,16 +33,19 @@ internal sealed class SendToServicePointDisplay : ITickStep, IDisposable ? new UdpClient(options.Value.Hostname, options.Value.Port) : null; - _scoresBuffer = new(new(MapService.TilesPerRow, 0), 12, 20); - _scoresBuffer.Rows[0] = "== TANKS! =="; - _scoresBuffer.Rows[1] = "-- scores --"; - - _scoresBuffer.Rows[17] = "-- join --"; - var localIp = GetLocalIp(options.Value.Hostname, options.Value.Port).Split('.'); Debug.Assert(localIp.Length == 4); // were talking legacy ip - _scoresBuffer.Rows[18] = string.Join('.', localIp[..2]); - _scoresBuffer.Rows[19] = string.Join('.', localIp[2..]); + _scoresBuffer = new TextDisplayBuffer(new TilePosition(MapService.TilesPerRow, 0), 12, 20) + { + Rows = + { + [0] = "== TANKS! ==", + [1] = "-- scores --", + [17] = "-- join --", + [18] = string.Join('.', localIp[..2]), + [19] = string.Join('.', localIp[2..]) + } + }; } private static string GetLocalIp(string host, int port) diff --git a/TanksServer/ServicePointDisplay/TextDisplayBuffer.cs b/TanksServer/ServicePointDisplay/TextDisplayBuffer.cs index 2f7a269..ace76a7 100644 --- a/TanksServer/ServicePointDisplay/TextDisplayBuffer.cs +++ b/TanksServer/ServicePointDisplay/TextDisplayBuffer.cs @@ -1,5 +1,3 @@ -using TanksServer.Models; - namespace TanksServer.ServicePointDisplay; internal sealed class TextDisplayBuffer : DisplayBufferView