private Vector2[] BuildCenters(int[] rowHexCounts, Vector2 baseHexSize)
{
List<Vector2> centers = new();
float gap = Mathf.Max(baseHexSize.x, baseHexSize.y) * Mathf.Max(0f, _gapPercent);
float columnStep = baseHexSize.x + gap;
// Для вертикального гекса как на вашем скрине обычно нужно 0.75.
// 1.0 превращает раскладку почти в обычную прямоугольную сетку.
float rowStep = baseHexSize.y * _rowDepthStepMultiplier + gap;
float firstRowZ = -rowStep * (rowHexCounts.Length - 1) * 0.5f;
int firstRowLattice = GetCenteredRowLattice(rowHexCounts[0]);
for (int rowIndex = 0; rowIndex < rowHexCounts.Length; rowIndex++)
{
int columnCount = rowHexCounts[rowIndex];
float rowZ = firstRowZ + rowIndex * rowStep;
int desiredLattice = (firstRowLattice + rowIndex) & 1;
int currentLattice = GetCenteredRowLattice(columnCount);
float rowXOffset = desiredLattice == currentLattice
? 0f
: columnStep * _oddRowOffsetMultiplier;
float firstColumnX = -columnStep * (columnCount - 1) * 0.5f;
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
float columnX = firstColumnX + columnIndex * columnStep + rowXOffset;
centers.Add(new Vector2(columnX, rowZ));
}
}
return centers.ToArray();
}
private static int GetCenteredRowLattice(int columnCount)
{
// Нечётное количество: позиции вида -1, 0, 1
// Чётное количество: позиции вида -0.5, 0.5
return columnCount % 2 == 0 ? 1 : 0;
}