Core Types & Enums

advanced scripting

Terrain Grid System 2 · Scripting Support (C#)

Note: This is an exhaustive index of public members for this API area. Signatures may vary by version; rely on your IDE/autocomplete and the source if needed.

API Reference

Cell Type

Cell(Vector2 center)

Performs cell.

Cell()

Performs cell.

Cell Fields

Vector2 betterCentroid

Better centroid.

bool[] blocksLOS

Used by specify if LOS is blocked across cell sides.

bool canCross

If this cell blocks path finding.

bool canCross

Can cross.

Vector2 centroid

Centroid.

Point centroid

Centroid.

byte clearance

Distance to nearest blocking cell

ushort row, column

Column.

int column

Column.

coordinates

Description not found in source.

float[] crossCost

Used by pathfinding in Cell mode. Cost for crossing a cell for each side. Defaults to 1.

float crossCost; // all sides public float[] crossSidesCost; // per side public Vector2 textureScale, textureOffset

Cross cost.

bool customized

Customized.

int group

Group for this cell. A different group can be assigned to use along with FindPath cellGroupMask argument.

int index

The index of the cell in the cells array

bool visible

Visible.

bool visible

Returns the actual visibility state of the cell. The setter will set only visibleSelf and not visibleByRules or visibleAlways.

bool visible

Visible.

bool visibleAlways

Gets or sets whether the cell is always visible, regardless of other rules.

bool visibleAlways

Visible always.

bool visibleByRules

Gets or sets the visibility of the cell based on rules.

bool visibleSelf

Gets or sets whether the cell is visible. If true, the cell will be visible if visibleByRules is also visible. Use "visible" to determine the actual visibility state.

Region Type

class Region
Region(IAdmin entity, bool isBox)

Performs region.

Region Fields

List<Renderer> childrenSurfaces

If the gameobject contains one or more children surfaces with name splitSurface due to having +65000 vertices

GameObject customBorderGameObject

Reference to a custom border drawn using CellDrawBorder or TerritoryDrawFrontier

GameObject customFrontiersGameObject

The reference to custom territory borders if drawn (not interior; interior borders are stored in each region)

bool customIsCanvasTexture

Custom is canvas texture.

Material customMaterial

Custom material.

bool customRotateInLocalSpace

Custom rotate in local space.

customTextureOffset

Description not found in source.

float customTextureRotation

Custom texture rotation.

IAdmin entity

Entity.

Color fillColor

Fill color.

Territory Type

Territory(string name)

Performs territory.

Territory Fields

List<Cell> cells

Cells in this region.

List<Cell> cells

Cells.

VoronoiCell[] cells

Cells.

List<Cell> cells

Complete array of states and cells and the territory name they belong to.

frontierColor

Description not found in source.

Shared Fields

GameObject interiorBorderGameObject

Reference to a custom border drawn using TerritoryDrawInteriorBorder

bool isEmpty

Is empty.

bool isFlat

Determines if this region should be rendered flat to the terrain

int iteration

Used internally to optimize certain algorithms

string name

Optional territory name.

List<Cell> neighbors

Cells adjacent to this cell

List<Territory> neighbors

List of other territories sharing some border with this territory

bool neutral

A neutral territory doesn't show conflicting borders with adjacent territories

List<Vector2> points

Points coordinates with applied grid offset and scale

List<Point> points

Points.

Polygon polygon

Polygon.

Rect rect2D

Scaled rect (rect with grid offset and scale applied)

float rect2DArea

Rect d area.

double rect2DArea

Rect d area.

Region region

Physical surface-related data

List<Region> regions

List of physical regions. Usually territories have only one region, but they can be split by assigning cells to other territories

Renderer renderer

Renderer.

MeshRenderer renderer

Renderer.

int renderingOrder

Used internally to ensure smaller territory surfaces are rendered before others

List<Segment> segments

Original grid segments. Segments coordinates are not scaled.

List <Segment> segments

Segments.

int sortIndex

Used internally to keep territory regions list order during updates

GameObject surfaceGameObject

Surface game object.

short territoryIndex

The territory to which this cell belongs to. You can change it using CellSetTerritory method. WARNING: do not change this value directly, use CellSetTerritory instead.

int territoryIndex

Territory index.

int territoryIndex

Territory index.

int territoryIndex

Territory index.

int usedFlag, usedFlag2

Used for performance optimizations.

partial class Cell : AdminEntity
partial class Territory: AdminEntity
bool isEmpty

Returns true if thi territory has no regions

Types & Enums

enum CELL_DIRECTION
enum CELL_SIDE
void ClearPointData()

Clears point data.

Region Clone()

Returns an exact copy of this region

Contour Clone()

Performs clone.

Polygon Clone()

Performs clone.

Region CloneWithoutPointData()

Returns a copy of this region without point/polygon data

ContainsFunction Contains

Contains.

bool Contains(GameObject gameObject)

Performs contains.

bool Contains(GameObject gameObject)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(T value)

Performs contains.

bool Contains(bool value)

Performs contains.

bool Contains(Point2D p)

Performs contains.

bool Contains(double x, double y)

Returns whether the coordinate is inside the bounding box. Note that this will return false if the point is ON the edge of the bounding box. If you want to test for whether the point is inside OR on the rect, use ContainsInclusive

bool Contains(Point2D p)

Performs contains.

bool Contains(Rect2D r)

Performs contains.

bool Contains(Vector3 position)

Returns true if a given position lies within this grid on the X/Z plane

bool ContainsRegion(Region otherRegion)

Performs contains region.

void DestroySurface(bool keepCustomMaterial = false)

Destroys surface.

void Enlarge(float amount)

Performs enlarge.

Vector2 GetBetterCentroid()

Returns the centroid of the territory using a more accurate algorithm. The centroid always lays inside the polygon whereas the center is the geometric center of the enclosing rectangle and could fall outside an irregular polygon.

Vector2 GetBetterCentroid(int regionIndex = 0)

Returns a better centroid of the territory.

Vector2 GetCentroid()

Returns the centroid of the territory. The centroid always lays inside the polygon whereas the center is the geometric center of the enclosing rectangle and could fall outside an irregular polygon.

Vector2 GetCentroid(int regionIndex = 0)

Returns the centroid of the territory. A centroid is a better center for a polygon.

Point2D GetCentroid()

Gets the centroid.

bool GetSideBlocksLOS(CELL_SIDE side)

Returns true if side is blocking LOS (from outside to inside cell)

float GetSideCrossCost(CELL_SIDE side)

Gets the side cross cost.

Returns: The side cross cost.

float GetSidesCost()

Returns the highest crossing cost of all side of a cell

bool Intersects(Region other)

Performs intersects.

bool Intersects(Rectangle o)

Performs intersects.

bool Intersects(Rect2D r)

Performs intersects.

void SetAllSidesCost(float cost)

Sets the same crossing cost for all sides of the hexagon.

void SetPoints(List<Vector2> points)

Sets points.

void SetPoints(List<Point> points)

Sets points.

void SetSideBlocksLOS(CELL_SIDE side, bool blocks)

Specifies if LOS is blocked through this side (from outside to inside cell)

void SetSideCrossCost(CELL_SIDE side, float cost)

Assigns a crossing cost for a given hexagonal side

void UpdateBounds()

Updates bounds.

Delegates

delegate bool ContainsFunction(float x, float y)
Was this page helpful?