Skip to content

Commit

Permalink
feat: convert MapToWorldCoord to float
Browse files Browse the repository at this point in the history
  • Loading branch information
xCykrix committed Jul 18, 2024
1 parent 6a4c547 commit ff1ef16
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Utilities/Helpers/MapHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace DalamudSystem.Utilities.Helpers
{
public static class MapHelper
{
public static (int X, int Y) MapToWorldCoordinates(Vector2 pos, uint mapId)
public static (float X, float Y) MapToWorldCoordinates(Vector2 pos, uint mapId)
{
ushort scale = ICoreManager.DataManager.GetExcelSheet<Map>()?.GetRow(mapId)?.SizeFactor ?? 100;
float num = scale / 100f;
float x = (float)(((pos.X - 1.0) * num / 41.0 * 2048.0) - 1024.0) / num * 1000f;
float y = (float)(((pos.Y - 1.0) * num / 41.0 * 2048.0) - 1024.0) / num * 1000f;
x = (int)(MathF.Round(x, 3, MidpointRounding.AwayFromZero) * 1000) * 0.001f / 1000f;
y = (int)(MathF.Round(y, 3, MidpointRounding.AwayFromZero) * 1000) * 0.001f / 1000f;
return ((int)x, (int)y);
x = (MathF.Round(x, 1, MidpointRounding.AwayFromZero) * 1000) * 0.001f / 1000f;
y = (MathF.Round(y, 1, MidpointRounding.AwayFromZero) * 1000) * 0.001f / 1000f;
return (x, y);
}
}
}

0 comments on commit ff1ef16

Please sign in to comment.