2024-04-12 18:32:10 +02:00
|
|
|
using System.Diagnostics;
|
2024-04-17 19:34:19 +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-12 18:32:10 +02:00
|
|
|
internal sealed class Tank(Player player, FloatPosition spawnPosition) : IMapEntity
|
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
|
|
|
|
|
|
|
public double Rotation
|
|
|
|
{
|
|
|
|
get => _rotation;
|
2024-04-12 18:32:10 +02:00
|
|
|
set
|
|
|
|
{
|
|
|
|
var newRotation = (value % 1d + 1d) % 1d;
|
|
|
|
Debug.Assert(newRotation is >= 0 and < 1);
|
|
|
|
_rotation = newRotation;
|
|
|
|
}
|
2024-04-07 17:17:11 +02:00
|
|
|
}
|
|
|
|
|
2024-04-07 19:05:50 +02:00
|
|
|
public DateTime NextShotAfter { get; set; }
|
2024-04-07 21:09:36 +02:00
|
|
|
|
2024-04-22 19:44:28 +02:00
|
|
|
public bool Moving { get; set; }
|
2024-04-13 14:07:14 +02:00
|
|
|
|
|
|
|
public FloatPosition Position { get; set; } = spawnPosition;
|
|
|
|
|
2024-04-17 19:34:19 +02:00
|
|
|
public PixelBounds Bounds => Position.GetBoundsForCenter(MapService.TileSize);
|
2024-04-13 14:07:14 +02:00
|
|
|
|
2024-04-13 18:35:36 +02:00
|
|
|
public int Orientation => (int)Math.Round(Rotation * 16) % 16;
|
|
|
|
|
2024-04-17 19:34:19 +02:00
|
|
|
public byte ExplosiveBullets { get; set; }
|
2024-04-13 14:07:14 +02:00
|
|
|
}
|