wip move to new uniffi language binding

This commit is contained in:
Vinzenz Schroeter 2024-11-12 18:27:04 +01:00
parent f7a5d8f823
commit 53cbdd8440
30 changed files with 211 additions and 187 deletions

View file

@ -4,12 +4,12 @@ using TanksServer.GameLogic;
namespace TanksServer.Models;
[DebuggerDisplay("({X} | {Y})")]
internal readonly struct PixelPosition(int x, int y)
internal readonly struct PixelPosition(ulong x, ulong y)
{
public int X { get; } = (x + MapService.PixelsPerRow) % MapService.PixelsPerRow;
public int Y { get; } = (y + MapService.PixelsPerColumn) % MapService.PixelsPerColumn;
public ulong X { get; } = (x + MapService.PixelsPerRow) % MapService.PixelsPerRow;
public ulong Y { get; } = (y + MapService.PixelsPerColumn) % MapService.PixelsPerColumn;
public void Deconstruct(out int x, out int y)
public void Deconstruct(out ulong x, out ulong y)
{
x = X;
y = Y;

View file

@ -4,20 +4,20 @@ namespace TanksServer.Models;
internal static class PositionHelpers
{
public static PixelPosition GetPixelRelative(this PixelPosition position, short subX, short subY)
=> new(position.X + subX, position.Y + subY);
public static PixelPosition GetPixelRelative(this PixelPosition position, long subX, long subY)
=> new((ulong)((long)position.X + subX), (ulong)((long)position.Y + subY));
public static PixelPosition ToPixelPosition(this FloatPosition position)
=> new((int)Math.Round(position.X), (int)Math.Round(position.Y));
=> new((ulong)Math.Round(position.X), (ulong)Math.Round(position.Y));
public static PixelPosition ToPixelPosition(this TilePosition position) => new(
(ushort)(position.X * MapService.TileSize),
(ushort)(position.Y * MapService.TileSize)
(ulong)(position.X * MapService.TileSize),
(ulong)(position.Y * MapService.TileSize)
);
public static TilePosition ToTilePosition(this PixelPosition position) => new(
(ushort)(position.X / MapService.TileSize),
(ushort)(position.Y / MapService.TileSize)
(ulong)(position.X / MapService.TileSize),
(ulong)(position.Y / MapService.TileSize)
);
public static FloatPosition ToFloatPosition(this PixelPosition position) => new(position.X, position.Y);
@ -28,10 +28,10 @@ internal static class PositionHelpers
Math.Pow(p1.Y - p2.Y, 2)
);
public static PixelBounds GetBoundsForCenter(this FloatPosition position, ushort size)
public static PixelBounds GetBoundsForCenter(this FloatPosition position, ulong size)
{
var sub = (short)(-size / 2d);
var add = (short)(size / 2d - 1);
var sub = (long)(-(long)size / 2d);
var add = (long)(size / 2d - 1);
var pixelPosition = position.ToPixelPosition();
return new PixelBounds(
pixelPosition.GetPixelRelative(sub, sub),

View file

@ -11,7 +11,7 @@ internal enum PowerUpType
SmartBullets,
}
internal sealed class PowerUp: IMapEntity
internal sealed class PowerUp : IMapEntity
{
public required FloatPosition Position { get; init; }

View file

@ -10,7 +10,8 @@ internal sealed class Tank(Player owner, FloatPosition position) : IMapEntity
[JsonIgnore] public Player Owner { get; } = owner;
[JsonIgnore] public double Rotation
[JsonIgnore]
public double Rotation
{
get => _rotation;
set

View file

@ -4,8 +4,8 @@ using TanksServer.GameLogic;
namespace TanksServer.Models;
[DebuggerDisplay("({X} | {Y})")]
internal readonly struct TilePosition(ushort x, ushort y)
internal readonly struct TilePosition(ulong x, ulong y)
{
public ushort X { get; } = (ushort)((x + MapService.TilesPerRow) % MapService.TilesPerRow);
public ushort Y { get; } = (ushort)((y + MapService.TilesPerColumn) % MapService.TilesPerColumn);
public ulong X { get; } = (ulong)((x + MapService.TilesPerRow) % MapService.TilesPerRow);
public ulong Y { get; } = (ulong)((y + MapService.TilesPerColumn) % MapService.TilesPerColumn);
}