servicepoint-tanks/TanksServer/Models/Tank.cs

34 lines
798 B
C#
Raw Normal View History

2024-04-10 19:25:45 +02:00
using TanksServer.GameLogic;
2024-04-07 21:09:36 +02:00
2024-04-07 13:02:49 +02:00
namespace TanksServer.Models;
2024-04-07 17:17:11 +02:00
internal sealed class Tank(Player player, FloatPosition spawnPosition)
2024-04-07 13:02:49 +02:00
{
2024-04-07 17:17:11 +02:00
private double _rotation;
2024-04-07 18:18:26 +02:00
2024-04-07 13:02:49 +02:00
public Player Owner { get; } = player;
2024-04-07 17:17:11 +02:00
2024-04-07 18:18:26 +02:00
/// <summary>
/// Bounds: 0 (inclusive) .. 16 (exclusive)
/// </summary>
2024-04-07 17:17:11 +02:00
public double Rotation
{
get => _rotation;
2024-04-07 18:18:26 +02:00
set => _rotation = (value + 16d) % 16d;
2024-04-07 17:17:11 +02:00
}
public FloatPosition Position { get; set; } = spawnPosition;
2024-04-07 21:09:36 +02:00
public DateTime NextShotAfter { get; set; }
2024-04-07 21:09:36 +02:00
2024-04-07 19:52:16 +02:00
public bool Moved { get; set; }
2024-04-07 21:09:36 +02:00
public (FloatPosition TopLeft, FloatPosition BottomRight) GetBounds()
{
return (
2024-04-07 21:16:41 +02:00
Position,
new FloatPosition(Position.X + MapService.TileSize , Position.Y + MapService.TileSize )
2024-04-07 21:09:36 +02:00
);
}
2024-04-07 13:02:49 +02:00
}