move backend to subfolder

This commit is contained in:
Vinzenz Schroeter 2024-04-21 12:38:03 +02:00
parent d4d1f2f981
commit 8d09663eff
80 changed files with 98 additions and 88 deletions

View file

@ -0,0 +1,35 @@
namespace TanksServer.GameLogic;
internal sealed class RotateTanks(
MapEntityManager entityManager,
IOptions<GameRules> options,
ILogger<RotateTanks> logger
) : ITickStep
{
private readonly GameRules _config = options.Value;
public Task TickAsync(TimeSpan delta)
{
foreach (var tank in entityManager.Tanks)
{
var player = tank.Owner;
switch (player.Controls)
{
case { TurnRight: true, TurnLeft: true }:
case { TurnRight: false, TurnLeft: false }:
continue;
case { TurnLeft: true }:
tank.Rotation -= _config.TurnSpeed * delta.TotalSeconds;
break;
case { TurnRight: true }:
tank.Rotation += _config.TurnSpeed * delta.TotalSeconds;
break;
}
logger.LogTrace("rotated tank to {}", tank.Rotation);
}
return Task.CompletedTask;
}
}