wip client "secret"

This commit is contained in:
Vinzenz Schroeter 2024-04-13 18:35:36 +02:00
commit b192cd7da0

View file

@ -1,6 +1,10 @@
namespace TanksServer.GameLogic;
internal sealed class RotateTanks(TankManager tanks, IOptions<TanksConfiguration> options) : ITickStep
internal sealed class RotateTanks(
TankManager tanks,
IOptions<TanksConfiguration> options,
ILogger<RotateTanks> logger
) : ITickStep
{
private readonly TanksConfiguration _config = options.Value;
@ -10,10 +14,20 @@ internal sealed class RotateTanks(TankManager tanks, IOptions<TanksConfiguration
{
var player = tank.Owner;
if (player.Controls.TurnLeft)
tank.Rotation -= _config.TurnSpeed / 16d;
if (player.Controls.TurnRight)
tank.Rotation += _config.TurnSpeed / 16d;
switch (player.Controls)
{
case { TurnRight: true, TurnLeft: true }:
case { TurnRight: false, TurnLeft: false }:
continue;
case { TurnLeft: true }:
tank.Rotation -= _config.TurnSpeed;
break;
case { TurnRight: true }:
tank.Rotation += _config.TurnSpeed;
break;
}
logger.LogTrace("rotated tank to {}", tank.Rotation);
}
return Task.CompletedTask;