In my current project I want to display a map grid coordinate like 'B3' instead of the vector pos directly. While searching through dlls there wasn't something like that or did I miss it?
Converting vector to map grid?
private string GetGrid(Vector3 position, bool addVector) // Credit: Jake_Rich
{
var roundedPos = new Vector2(World.Size / 2 + position.x, World.Size / 2 - position.z);
var grid = $"{NumberToLetter((int)(roundedPos.x / 150))}{(int)(roundedPos.y / 150)}";
if (addVector)
{
grid += $" {position.ToString().Replace(",", "")}";
}
return grid;
}
private string NumberToLetter(int num) // Credit: Jake_Rich
{
var num2 = Mathf.FloorToInt((float)(num / 26));
var num3 = num % 26;
var text = string.Empty;
if (num2 > 0)
{
for (var i = 0; i < num2; i++)
{
text += Convert.ToChar(65 + i);
}
}
return text + Convert.ToChar(65 + num3);
} I believe it's code for multiple characters, but now in Rust there are NO AA and etc, they just repeat Y Z A B C ..