Cells & Grid API
advanced scriptingWorld Map Strategy Kit · Scripting Support (C#)
WMSK (namespace WorldMapStrategyKit)
Cells API
Methods and properties for working with the grid/cell system.
Properties
Cell[] cellsArray of all grid cells. Only populated when the grid is enabled.
Cell cellHighlighted { get; }The cell currently under the pointer (null if none).
int cellHighlightedIndex { get; }Index of the highlighted cell (-1 if none).
int cellLastClicked { get; }Index of the last clicked cell.
bool showGrid { get; set; }Show or hide the grid overlay.
int gridRows { get; set; }Number of grid rows. Changing this regenerates the grid.
int gridColumns { get; set; }Number of grid columns. Changing this regenerates the grid.
Color gridColor { get; set; }Color of grid lines.
bool enableCellHighlight { get; set; }Enable highlighting cells on hover.
Color cellHighlightColor { get; set; }Color for cell highlights.
bool gridCutOutBordersUse alpha when coloring parts of cells on water
bool exclusiveHighlightGets or sets the exclusive highlight.
enum HexProportionHexagon proportion options for grid generation
HexProportion hexProportionReturns the hexagon proportion setting for grid generation
float highlightFadeAmountAmount of fading ping-poing effect for highlighted cell
float gridAphaOnWaterAlpha applied to grid over water
float gridMaxDistanceMaximum distance from grid where it's visible
float gridMinDistanceMinimum distance from grid where it's visible
int cellLastClickedIndexReturns Cell index which has been clicked
Query Methods
Cell GetCell(int cellIndex)Returns a cell by index.
Cell GetCell(Vector2 localPosition)Returns the cell at a given map position.
Cell GetCell(int row, int column)Returns the cell at a specific grid row and column.
int GetCellIndex(Cell cell)Returns the index of a cell.
int GetCellIndex(Vector2 localPosition)Returns the cell index at a map position.
List<int> GetCellNeighbors(int cellIndex)Returns indices of neighboring cells (sharing an edge).
Grid Manipulation
void SetGridDimensions(int rows, int columns)Sets the grid size and regenerates all cells.
Surface & Effects
Renderer ToggleCellSurface(int cellIndex, bool visible, Color color)Toggles a cell surface. Returns the Renderer component. Also supports texture, scale, offset, and rotation in overloads.
void HideCellSurface(int cellIndex)Hides the surface of a specific cell.
void HideCellSurfaces()Hides all cell surfaces on the entire grid.
Pathfinding Integration
float GetCellPathCost(int cellIndex)Returns the pathfinding traversal cost of a cell (1.0 = normal, higher = slower, 0 = blocked).
Additional Methods
Renderer SetCellTemporaryColor(int cellIndex, Color color)Assigns a temporary color to a cell. This color can be erased calling RestoreCellMaterials(). Cell index. Color.
void RestoreCellMaterials()Restores all cells colors to their original materials. Useful when coloring cells temporarily using SetCellTemporaryColor.
void CellSetColor(int cellIndex, Color color)Colors a cell. For more options call ToggleCellSurface directly. Cell indices. Color.
void CellSetColor(List cellIndices, Color color)Colors a group of cells. Cell indices. Color.
void CellFadeOut(int cellIndex, Color color, float duration)Colors a cell and fades it out during "duration" in seconds.
void CellFadeOut(List cellIndices, Color color, float duration)Colors a group of cells and fades it out during "duration" in seconds. Cell indices. Color. Duration.
void CellBlink(int cellIndex, Color color, float duration)Colors a cell and blinks it during "duration" in seconds.
void CellBlink(List cellIndices, Color color, float duration)Colors a group of cells and blinks them during "duration" in seconds. Cell indices. Color. Duration.
void CellFlash(int cellIndex, Color color, float duration)Colors a cell and flashes it during "duration" in seconds.
void CellFlash(List cellIndices, Color color, float duration)Colors a group of cells and flashes them during "duration" in seconds. Cell indices. Color. Duration.
Vector2 GetCellPosition(int cellIndex)Gets the cell's center position in local space.
Vector3 GetCellWorldPosition(int cellIndex)Gets the cell's center position in world space.
Vector3 GetCellVertexWorldPosition(int cellIndex, int vertexIndex)Returns the world space position of the vertex
List GetCellsInCountry(int countryIndex)Returns a list of cells indices whose center belongs to a country regions.
List GetCellsInProvince(int provinceIndex)Returns a list of cells whose center belongs to a country region.
int GetCellStepsDistance(int cell1index, int cell2index)Returns the integer distance between two cells based on their row/column positions
int GetCellsWithinRadius(int cellIndex, int radius, List cellIndices)Returns a list of cells indices within a certain distance to a given cell. The cell at the center of the circle Distance to cellIndex in cell steps List where results will be returned. Must be previously initialized. The number of found cells (-1 if some index is out of range)
int GetCellsWithinDistanceKM(int cellIndex, float km, List cellIndices)Returns a list of cells indices within a certain distance to a given cell. The cell at the center of the circle Distance to cellIndex in kilometers (assuming the Earth has a radius of 6378 km List where results will be returned. Must be previously initialized. The number of found cells (-1 if some index is out of range)
int GetCellsWithinRectangle(int rowMin, int rowMax, int columnMin, int columnMax, List cellIndices)Returns a list of cells indices within a given rectangle List where results will be returned. Must be previously initialized. The number of found cells (-1 if some index is out of range)
int GetCellsWithinCone(int cellIndex, Vector2 direction, float maxDistance, float angle, List cellIndices)Returns a list of cells contained in a cone defined by a starting cell, a direction, max distance and an angle for the cone List where results will be returned. Must be previously initialized. The number of found cells (-1 if some index is out of range)
int GetCellsWithinCone(int cellIndex, int targetCellIndex, float angle, List cellIndices)Returns a list of cells contained in a cone defined by a starting cell, a target cellIndex, a max distance and an angle for the cone List where results will be returned. Must be previously initialized. The number of found cells (-1 if some index is out of range)
int GetCellCountryIndex(int cellIndex)Returns the country index to which the cell belongs.
int GetCellCountryIndex(int cellIndex, out int regionIndex)Returns the country index to which the cell belongs. It also returns the region index.
int GetCellProvinceIndex(int cellIndex)Returns the province index to which the cell belongs.
List | GetCellsByAltitude(float minAltitude, float maxAltitude)Gets a list of cells within the given altitude range (non-inclusive) The cells by altitude. Minimum altitude. Maximum altitude.
float GetCellAltitude(int cellIndex)Returns the altitude of a cell as it would be used by GetCellsByAltitude or path-finding methods
Suggest an improvement
Help us improve this documentation page.