This repository has been archived on 2026-07-13. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
servicepoint-tanks/TanksServer/GameLogic/RotateTanks.cs
Vinzenz Schroeter b192cd7da0 wip client "secret"
2024-04-13 18:35:36 +02:00

35 lines
949 B
C#

namespace TanksServer.GameLogic;
internal sealed class RotateTanks(
TankManager tanks,
IOptions<TanksConfiguration> options,
ILogger<RotateTanks> logger
) : ITickStep
{
private readonly TanksConfiguration _config = options.Value;
public Task TickAsync()
{
foreach (var tank in 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;
break;
case { TurnRight: true }:
tank.Rotation += _config.TurnSpeed;
break;
}
logger.LogTrace("rotated tank to {}", tank.Rotation);
}
return Task.CompletedTask;
}
}