infinite map
This commit is contained in:
parent
7213318838
commit
461a9139c2
1 changed files with 101 additions and 69 deletions
|
|
@ -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 )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in a new issue