wip client "secret"
This commit is contained in:
parent
698271ae9f
commit
b192cd7da0
1 changed files with 117 additions and 71 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Reference in a new issue