Click or drag to resize

API

Grids is a big library. Many of the classes are a bit obscure, and the general user won't need them. This guide will point you to the most useful classes for general usage.

One important pattern that we use a lot in grids is to hide concrete implementations of certain classes, and provide static methods to generate instances of these classes. For example, you will always work with IMap, IExplicitShape, IImplicitShape, but to create instances of these you will use the static methods in Map, ExplicitShape, ImplicitShape. The static classes also define manipulations of these classes - often through extension methods.

(The same pattern is used in the Extensions Library for generators: you work with IGenerator, but use the static methods in Generator to create generators.)

We do this, because the implementation of these types require dozens of support classes that differ only on the inside - they all look the same on the outside, and you don't need to know the difference.

For grids, you generally work with the IGrid interface. However, we do expose the three concrete implementations Grid1, Grid2, and Grid3 (for 1D, 2D and 3D grids respectively).

GridPoint2

Represents 2D grid locations, and defines the methods for point arithmetic. Points are how cells in a grid are identified, and form the basic element of grid algorithms.

Note that the same point type is used for rect grids, hex grids, and indeed other 2D grids which allows a uniform coordinate structure. There are some methods and constants that are specific to points depending on whether the point is used in a hex grid or rect grid. These are provided in static classes RectPoint and PointyHexPoint.

For 3D grids, there is GridPoint3 (with some static methods and constants provided in BlockPoint for grids with cubes as cells). No special class is needed for 1D grids: we simply use int. There are some static methods and constants provided for 1D grid points (integers) in GridPoint1.

IGridTPoint, TCell

This interface is generally how you work with grids. There are concrete implementations, but in general, you should work with this interface instead, and most algorithms are defined in terms of this interface. For example, a 2D grid of integers is IGrid{GridPoint2, int}.

In advanced usages of grids, you may also want to provide your own implementation of this interface.

Algorithms

This class contains various algorithms that operate on grids, such as path finding, connected shapes, and range finding. Usually, these algorithms require knowledge of the cells (that is, the data in the grid). Algorithms that only work on the grid shape is contained in either IImplicitShapeTPoint or IExplicitShapeTPoint.

Map

This class defines methods for creating and manipulating maps in code. Generally, you would only use this class if you create grids in code. For grids created with grid builders, maps are built from the node-based space maps and the round map setting in the grid builder.

See also Space Maps

IMapTInput, TOutput

This is the type of maps (space maps, round maps, and other maps). As a general rule, the library hides the concrete implementations, and provides the Map class above for getting instances of IMaps.

ExplicitShape

This class provides methods for creating and transforming explicit shapes in code. For grids built using grid builders, you will normally not need this class, since the shape is built using the node-based editor.

IExplicitShapeTPoint

This is the type of explicit shapes, and what you use to work with them once they are created.

ImplicitShape

This class provides methods for creating and transforming implicit shapes in code. For grids built using grid builders, you will normally not need this class, since the shape is built using the node-based editor.

IImplicitShapeTPoint

This is the type of implicit shapes, and what you use to work with them once they are created.

See Also

Other Resources