infinite map

This commit is contained in:
Vinzenz Schroeter 2024-04-12 18:32:10 +02:00
commit 461a9139c2

View file

@ -1,20 +1,23 @@
using System.Diagnostics;
using TanksServer.GameLogic;
namespace TanksServer.Models;
internal sealed class Tank(Player player, FloatPosition spawnPosition): IMapEntity
internal sealed class Tank(Player player, FloatPosition spawnPosition) : IMapEntity
{
private double _rotation;
public Player Owner { get; } = player;
/// <summary>
/// Bounds: 0 (inclusive) .. 16 (exclusive)
/// </summary>
public double Rotation
{
get => _rotation;
set => _rotation = (value + 16d) % 16d;
set
{
var newRotation = (value % 1d + 1d) % 1d;
Debug.Assert(newRotation is >= 0 and < 1);
_rotation = newRotation;
}
}
public FloatPosition Position { get; set; } = spawnPosition;
@ -22,12 +25,4 @@ internal sealed class Tank(Player player, FloatPosition spawnPosition): IMapEnti
public DateTime NextShotAfter { get; set; }
public bool Moved { get; set; }
public (FloatPosition TopLeft, FloatPosition BottomRight) GetBounds()
{
return (
Position,
new FloatPosition(Position.X + MapService.TileSize , Position.Y + MapService.TileSize )
);
}
}
}