move backend to subfolder
This commit is contained in:
parent
d4d1f2f981
commit
8d09663eff
80 changed files with 98 additions and 88 deletions
35
tanks-backend/TanksServer/GameLogic/RotateTanks.cs
Normal file
35
tanks-backend/TanksServer/GameLogic/RotateTanks.cs
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue