merge options

This commit is contained in:
Vinzenz Schroeter 2024-04-19 13:37:28 +02:00
parent 9cf4304845
commit 043022186f
10 changed files with 28 additions and 40 deletions

View file

@ -9,4 +9,16 @@ internal sealed class GameRules
public int MaxPowerUpCount { get; set; } = int.MaxValue; public int MaxPowerUpCount { get; set; } = int.MaxValue;
public int BulletTimeoutMs { get; set; } = int.MaxValue; public int BulletTimeoutMs { get; set; } = int.MaxValue;
public double MoveSpeed { get; set; }
public double TurnSpeed { get; set; }
public double ShootDelayMs { get; set; }
public double BulletSpeed { get; set; }
public int SpawnDelayMs { get; set; }
public int IdleTimeoutMs { get; set; }
} }

View file

@ -2,7 +2,7 @@ namespace TanksServer.GameLogic;
internal sealed class MoveBullets( internal sealed class MoveBullets(
MapEntityManager entityManager, MapEntityManager entityManager,
IOptions<TanksConfiguration> config IOptions<GameRules> config
) : ITickStep ) : ITickStep
{ {
public Task TickAsync(TimeSpan delta) public Task TickAsync(TimeSpan delta)

View file

@ -2,11 +2,11 @@ namespace TanksServer.GameLogic;
internal sealed class MoveTanks( internal sealed class MoveTanks(
MapEntityManager entityManager, MapEntityManager entityManager,
IOptions<TanksConfiguration> options, IOptions<GameRules> options,
MapService map MapService map
) : ITickStep ) : ITickStep
{ {
private readonly TanksConfiguration _config = options.Value; private readonly GameRules _config = options.Value;
public Task TickAsync(TimeSpan delta) public Task TickAsync(TimeSpan delta)
{ {

View file

@ -1,8 +0,0 @@
namespace TanksServer.GameLogic;
public class PlayersConfiguration
{
public int SpawnDelayMs { get; set; }
public int IdleTimeoutMs { get; set; }
}

View file

@ -2,11 +2,11 @@ namespace TanksServer.GameLogic;
internal sealed class RotateTanks( internal sealed class RotateTanks(
MapEntityManager entityManager, MapEntityManager entityManager,
IOptions<TanksConfiguration> options, IOptions<GameRules> options,
ILogger<RotateTanks> logger ILogger<RotateTanks> logger
) : ITickStep ) : ITickStep
{ {
private readonly TanksConfiguration _config = options.Value; private readonly GameRules _config = options.Value;
public Task TickAsync(TimeSpan delta) public Task TickAsync(TimeSpan delta)
{ {

View file

@ -3,11 +3,11 @@ using System.Diagnostics;
namespace TanksServer.GameLogic; namespace TanksServer.GameLogic;
internal sealed class ShootFromTanks( internal sealed class ShootFromTanks(
IOptions<TanksConfiguration> options, IOptions<GameRules> options,
MapEntityManager entityManager MapEntityManager entityManager
) : ITickStep ) : ITickStep
{ {
private readonly TanksConfiguration _config = options.Value; private readonly GameRules _config = options.Value;
public Task TickAsync(TimeSpan _) public Task TickAsync(TimeSpan _)
{ {

View file

@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
namespace TanksServer.GameLogic; namespace TanksServer.GameLogic;
internal sealed class TankSpawnQueue( internal sealed class TankSpawnQueue(
IOptions<PlayersConfiguration> options, IOptions<GameRules> options,
MapEntityManager entityManager MapEntityManager entityManager
): ITickStep ): ITickStep
{ {

View file

@ -1,9 +0,0 @@
namespace TanksServer.GameLogic;
public class TanksConfiguration
{
public double MoveSpeed { get; set; }
public double TurnSpeed { get; set; }
public double ShootDelayMs { get; set; }
public double BulletSpeed { get; set; }
}

View file

@ -86,10 +86,6 @@ public static class Program
builder.Services.AddSingleton<IFrameConsumer, ClientScreenServer>(sp => builder.Services.AddSingleton<IFrameConsumer, ClientScreenServer>(sp =>
sp.GetRequiredService<ClientScreenServer>()); sp.GetRequiredService<ClientScreenServer>());
builder.Services.Configure<TanksConfiguration>(
builder.Configuration.GetSection("Tanks"));
builder.Services.Configure<PlayersConfiguration>(
builder.Configuration.GetSection("Players"));
builder.Services.Configure<GameRules>(builder.Configuration.GetSection("GameRules")); builder.Services.Configure<GameRules>(builder.Configuration.GetSection("GameRules"));
if (hostConfiguration.EnableServicePointDisplay) if (hostConfiguration.EnableServicePointDisplay)

View file

@ -19,24 +19,21 @@
"Hostname": "172.23.42.29", "Hostname": "172.23.42.29",
"Port": 2342 "Port": 2342
}, },
"Tanks": { "GameRules": {
"DestructibleWalls": true,
"PowerUpSpawnChance": 0.1,
"MaxPowerUpCount": 15,
"BulletTimeoutMs": 30000,
"SpawnDelayMs": 3000,
"IdleTimeoutMs": 30000,
"MoveSpeed": 37.5, "MoveSpeed": 37.5,
"TurnSpeed": 0.5, "TurnSpeed": 0.5,
"ShootDelayMs": 450, "ShootDelayMs": 450,
"BulletSpeed": 75 "BulletSpeed": 75
}, },
"GameRules": {
"DestructibleWalls": true,
"PowerUpSpawnChance": 0.1,
"MaxPowerUpCount": 15
},
"Players": {
"SpawnDelayMs": 3000,
"IdleTimeoutMs": 30000
},
"Host": { "Host": {
"EnableServicePointDisplay": true, "EnableServicePointDisplay": true,
"ServicePointDisplayMinFrameTimeMs": 25, "ServicePointDisplayMinFrameTimeMs": 28,
"ClientScreenMinFrameTime": 5 "ClientScreenMinFrameTime": 5
} }
} }