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/TickSteps/RotateTanks.cs
2024-04-07 20:16:22 +02:00

24 lines
621 B
C#

using TanksServer.Models;
using TanksServer.Services;
namespace TanksServer.TickSteps;
internal sealed class RotateTanks(TankManager tanks, IOptions<TanksConfiguration> options) : ITickStep
{
private readonly TanksConfiguration _config = options.Value;
public Task TickAsync()
{
foreach (var tank in tanks)
{
var player = tank.Owner;
if (player.Controls.TurnLeft)
tank.Rotation -= _config.TurnSpeed;
if (player.Controls.TurnRight)
tank.Rotation += _config.TurnSpeed;
}
return Task.CompletedTask;
}
}