2023-07-08 14:08:32 +10:00
|
|
|
|
using System.Numerics;
|
|
|
|
|
|
using Robust.Shared.Map;
|
2022-11-22 13:12:04 +11:00
|
|
|
|
using Robust.Shared.Map.Components;
|
2020-09-06 16:11:53 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Shared.Coordinates
|
2020-09-06 16:11:53 +02:00
|
|
|
|
{
|
|
|
|
|
|
public static class EntityCoordinatesExtensions
|
|
|
|
|
|
{
|
2022-10-23 00:46:28 +02:00
|
|
|
|
public static EntityCoordinates ToCoordinates(this EntityUid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new EntityCoordinates(id, new Vector2(0, 0));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-09-06 16:11:53 +02:00
|
|
|
|
public static EntityCoordinates ToCoordinates(this EntityUid id, Vector2 offset)
|
|
|
|
|
|
{
|
2022-10-23 00:46:28 +02:00
|
|
|
|
return new EntityCoordinates(id, offset);
|
2020-09-06 16:11:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static EntityCoordinates ToCoordinates(this EntityUid id, float x, float y)
|
|
|
|
|
|
{
|
2022-10-23 00:46:28 +02:00
|
|
|
|
return new EntityCoordinates(id, x, y);
|
2020-09-06 16:11:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-22 13:12:04 +11:00
|
|
|
|
public static EntityCoordinates ToCoordinates(this MapGridComponent grid, Vector2 offset)
|
2020-09-06 16:11:53 +02:00
|
|
|
|
{
|
2022-12-12 14:59:02 +11:00
|
|
|
|
return ToCoordinates(grid.Owner, offset);
|
2020-09-06 16:11:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-22 13:12:04 +11:00
|
|
|
|
public static EntityCoordinates ToCoordinates(this MapGridComponent grid, float x, float y)
|
2020-09-06 16:11:53 +02:00
|
|
|
|
{
|
2022-12-12 14:59:02 +11:00
|
|
|
|
return ToCoordinates(grid.Owner, x, y);
|
2020-09-06 16:11:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-22 13:12:04 +11:00
|
|
|
|
public static EntityCoordinates ToCoordinates(this MapGridComponent grid)
|
2020-09-06 16:11:53 +02:00
|
|
|
|
{
|
2022-12-12 14:59:02 +11:00
|
|
|
|
return ToCoordinates(grid.Owner, Vector2.Zero);
|
2020-09-06 16:11:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|