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,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),