// Returns a display-friendly name of an exterior cell, given a position public static string GetCellName(Vector3 position) { var coordinates = new Vector2Int(Mathf.FloorToInt(position.x / 8192), Mathf.FloorToInt(position.z / 8192)); var cell = CellRecord.GetExteriorCell(coordinates); return(string.IsNullOrEmpty(cell.Name) ? cell.Region.Name : cell.Name); }
private Dictionary <CellRecord, Scene> LoadCells() { var newCells = new Dictionary <CellRecord, Scene>(); for (var x = -cellsToLoad; x <= cellsToLoad; x++) { for (var y = -cellsToLoad; y <= cellsToLoad; y++) { var coordinates = new Vector2Int(this.coordinates.x + x, this.coordinates.y + y); var cellRecord = CellRecord.GetExteriorCell(coordinates); // Check to see if this cell is already loaded, if so, don't re-load it, just add it to the new list of loaded cells Scene scene; if (!loadedCells.TryGetValue(cellRecord, out scene)) { scene = LoadCell(cellRecord); } newCells.Add(cellRecord, scene); // If in the middle, set as current cell (Note, may be different to Unity's current cell if (x == 0 && y == 0) { currentCell = cellRecord; } } } return(newCells); }