separate tick steps
This commit is contained in:
parent
898a9cedc1
commit
a9aaf899a2
1 changed files with 238 additions and 193 deletions
21
TanksServer/TickSteps/MoveBullets.cs
Normal file
21
TanksServer/TickSteps/MoveBullets.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
namespace TanksServer.TickSteps;
|
||||
|
||||
internal sealed class MoveBullets(BulletManager bullets) : ITickStep
|
||||
{
|
||||
public Task TickAsync()
|
||||
{
|
||||
foreach (var bullet in bullets.GetAll())
|
||||
MoveBullet(bullet);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static void MoveBullet(Bullet bullet)
|
||||
{
|
||||
var angle = bullet.Rotation / 16 * 2 * Math.PI;
|
||||
bullet.Position = new FloatPosition(
|
||||
X: bullet.Position.X + Math.Sin(angle) * 3,
|
||||
Y: bullet.Position.Y - Math.Cos(angle) * 3
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in a new issue