separate folders per functionality
This commit is contained in:
parent
7f00160780
commit
0ca6a91a7e
|
@ -1,6 +1,4 @@
|
|||
using TanksServer.Models;
|
||||
|
||||
namespace TanksServer.Services;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class BulletManager
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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
|
|
@ -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<ITickStep> steps,
|
|
@ -1,4 +1,4 @@
|
|||
namespace TanksServer.TickSteps;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
public interface ITickStep
|
||||
{
|
|
@ -1,6 +1,4 @@
|
|||
using TanksServer.Models;
|
||||
|
||||
namespace TanksServer.Services;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class MapService
|
||||
{
|
|
@ -1,7 +1,4 @@
|
|||
using TanksServer.Models;
|
||||
using TanksServer.Services;
|
||||
|
||||
namespace TanksServer.TickSteps;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class MoveBullets(BulletManager bullets) : ITickStep
|
||||
{
|
|
@ -1,10 +1,9 @@
|
|||
using TanksServer.Models;
|
||||
using TanksServer.Services;
|
||||
|
||||
namespace TanksServer.TickSteps;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class MoveTanks(
|
||||
TankManager tanks, IOptions<TanksConfiguration> options, MapService map
|
||||
TankManager tanks,
|
||||
IOptions<TanksConfiguration> options,
|
||||
MapService map
|
||||
) : ITickStep
|
||||
{
|
||||
private readonly TanksConfiguration _config = options.Value;
|
|
@ -1,7 +1,4 @@
|
|||
using TanksServer.Models;
|
||||
using TanksServer.Services;
|
||||
|
||||
namespace TanksServer.TickSteps;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class RotateTanks(TankManager tanks, IOptions<TanksConfiguration> options) : ITickStep
|
||||
{
|
|
@ -1,7 +1,4 @@
|
|||
using TanksServer.Models;
|
||||
using TanksServer.Services;
|
||||
|
||||
namespace TanksServer.TickSteps;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class ShootFromTanks(
|
||||
TankManager tanks,
|
|
@ -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
|
||||
{
|
|
@ -1,6 +1,4 @@
|
|||
using TanksServer.Models;
|
||||
|
||||
namespace TanksServer.Services;
|
||||
namespace TanksServer.GameLogic;
|
||||
|
||||
internal sealed class SpawnQueueProvider
|
||||
{
|
|
@ -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<TankManager> logger) : IEnumerable<Tank>
|
||||
{
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
{
|
|
@ -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<IDrawStep> drawSteps, LastFinishedFrameProvider lastFrameProvider
|
|
@ -1,6 +1,6 @@
|
|||
using TanksServer.ServicePointDisplay;
|
||||
|
||||
namespace TanksServer.DrawSteps;
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal interface IDrawStep
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
using TanksServer.ServicePointDisplay;
|
||||
|
||||
namespace TanksServer.Services;
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class LastFinishedFrameProvider
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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;
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Hacky class for easier semantics
|
|
@ -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<ClientScreenServer> logger,
|
|
@ -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<ControlsServer> logger, ILoggerFactory loggerFactory)
|
||||
: IHostedLifecycleService
|
||||
{
|
||||
private readonly List<ControlsServerConnection> _connections = new();
|
||||
private readonly List<ControlsServerConnection> _connections = [];
|
||||
|
||||
public Task HandleClient(WebSocket ws, Player player)
|
||||
{
|
|
@ -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<PlayerServer> logger, SpawnQueueProvider spawnQueueProvider)
|
||||
{
|
|
@ -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,
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using TanksServer.Services;
|
||||
using TanksServer.GameLogic;
|
||||
|
||||
namespace TanksServer.Models;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
using TanksServer.Models;
|
||||
|
||||
namespace TanksServer.ServicePointDisplay;
|
||||
|
||||
internal class DisplayBufferView(byte[] data)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
using TanksServer.Helpers;
|
||||
using TanksServer.Services;
|
||||
|
||||
namespace TanksServer.ServicePointDisplay;
|
||||
|
||||
internal sealed class PixelDisplayBufferView : DisplayBufferView
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
using TanksServer.Models;
|
||||
|
||||
namespace TanksServer.ServicePointDisplay;
|
||||
|
||||
internal sealed class TextDisplayBuffer : DisplayBufferView
|
||||
|
|
Loading…
Reference in a new issue