CellString Class

public class CellString

The only ICellString implementation you should ever need. Can handle 3D/2D worlds and LODs that utilize multi chunking. This class is responsible for taking in a Streamable Grid Cell Index and Chunk Index and outputting a correctly formatted string that can be used as a key to load the chunk in question. It utilizes the naming convention used by each LOD, as well as any extra data to prepend or append to the generated string.

Properties

Name Type Description
AppendLoadStringData bool

Returns the data to append when generating load strings for this CellString object, or "" if there is no append data.

BaseName string

The base name of the Cell String. This should match the base name of the object group associated with your World.

ChunkLoadKey

Gets a string that can be used to load the chunk associated with the Streamable Grid Cell and chunk passed into the last MatchStringToCell method call. This string takes into account any data to prepend or append that might have been passed into the Cell String's constructor or UpdateCellString method. It should not be used for naming objects, as the name should not include prepend/append data.

ChunkName string

Gets the name of the chunk associated with the Streamable Grid Cell and chunk passed into the last MatchStringToCell method call. This can and should only be used for naming your objects. It should not be used for actually loading your objects, as it does not take into account any data to prepend or append that you may have passed into the Cell String's constructor. For that, you should use the ChunkLoadKey property, which combines this ChunkName string with data to prepend and append.

This property can be accessed repeatedly without generating garbage.

GetChunkNameAndLoadKey_MultithreadingSupported GetChunkInfoDel delegate

Gets a method for retrieving the Chunk Name and Chunk Load Key given a Cell and chunk number.

The difference between this method and MatchStringToCell is that this method does not store the Chunk Name and Chunk Load Key that is generated, and as such you cannot use the ChunkName, ChunkLoadKey, or IsEqualTo method. The advantage is because nothing is stored, the method should be safe to use in multithreaded code.

The first argument for this method is the Streamable Grid Index of the World Cell. The second is the 1 based index of the chunk you are trying to match the string to.

PrependLoadStringData bool

Returns the data to prepend when generating load strings for this CellString object, or "" if there is no prepend data.

Constructors

CellString(string, INamingConvention, bool, bool, [string], [string])

public CellString(string baseName, INamingConvention namingConvention, bool is3DCellString, bool useMultiChunkNaming, string dataToPrependWhenGeneratingLoadString = null, string dataToAppendWhenGeneratingLoadString = null)

Creates a Cell String object.

Parameters

Name Type Description
baseName string

The base name shared among all cells.

namingConvention INamingConvention

The naming convention that details how the cell string should be constructed.

is3DCellString bool

Is the cell string going to be used with a 3D world?

useMultiChunkNaming bool

Is the cell string going to be used with LODs that utilize multi chunking?

dataToPrependWhenGeneratingLoadString [string]

Optional data to prepend to every ChunkLoadKey string generated by this Cell String object. Using this data (or dataToAppendWhenGeneratingLoadString) does result in two strings being produced everytime MatchStringToCell is used, however in some instances this cannot be helped.

dataToAppendWhenGeneratingLoadString [string]

Optional data to append to every ChunkLoadKey string generated by this Cell String object. Using this data (or dataToPrependWhenGeneratingLoadString) does result in two strings being produced everytime MatchStringToCell is used, however in some instances this cannot be helped.

Methods

IsEqualTo(string)

public abstract bool IsEqualTo(string str)

Checks whether the provided string (str) matches the Chunk Name String.

Parameters

Name Type Description
str string

The string to compare the Cell String to.

Returns

bool
A bool indicating whether the input string matches the Cell String.


MatchStringToCell(Cell, int)

public void MatchStringToCell(Cell cell, int chunkIndex)

After calling this method, ChunkName will be set to a string that represents the file name of whatever asset is associated with the input Streamable Grid Cell and chunk index, and ChunkLoadKey will return a string that can be used to load this object.

If you are trying to generate the ChunkName and ChunkLoadKey in multithreaded code, use the GetChunkNameAndLoadKey_MultithreadingSupported method instead.

Parameters

Name Type Description
cell Cell

The Streamable Grid Index of the World Cell to match the string to.

chunkIndex int

The 1 based index of the chunk to match the string to.


TryGetCellDataFromChunkName(string, out int, out int, out int, out int)

public bool TryGetCellDataFromChunkName(string chunkName, out int row, out int column, out int layer, out int chunkIndex)

Attempts to get cell data from the chunk named passed in. This can also be used as a way to validate that a specific object belongs to a specific World and World Grouping, assuming the CellString has been configured correctly for that World and World Grouping. Note that it is a computationally expensive method, so generally should not be called multiple times in a single frame in game.

Parameters

Name Type Description
chunkName string

The name of the object associated with the cell. This name must contain the Group Name associated with the CellString or else the method will return false.

row int

The row of the cell which the chunk belongs to.

column int

The column of the cell which the chunk belongs to.

layer int

The layer of the cell which the chunk belongs to. Will always be 1 if the chunk belongs to a 2D World Grouping.

chunkIndex int

The chunk index of the chunk. Will always be 1 if the chunk belongs to a World Grouping that does not use multi chunking.

Returns

bool
True if the data was retrieved, false otherwise. Will only return true if the format of the name matches what's expected.


UpdateCellString(string, INamingConvention, bool, bool, [string], [string])

public void UpdateCellString(string baseName, INamingConvention namingConvention, bool is3DCellString, bool useMultiChunkNaming, string dataToPrependWhenGeneratingLoadString = null, string dataToAppendWhenGeneratingLoadString = null)

Updates a Cell String object to use a new base name and naming convention. This allows you to reuse the Cell String object to represent different assets. Do note that this method is not without garbage generation, so it is best not to abuse it.

Parameters

Name Type Description
baseName string

The base name shared among all cells.

namingConvention INamingConvention

The naming convention that details how the cell string should be constructed.

is3DCellString bool

Is the cell string going to be used with a 3D world?

useMultiChunkNaming bool

Is the cell string going to be used with LODs that utilize multi chunking?

dataToPrependWhenGeneratingLoadString [string]

Optional data to prepend to every ChunkLoadKey string generated by this Cell String object. Using this data (or dataToAppendWhenGeneratingLoadString) does result in two strings being produced everytime MatchStringToCell is used, however in some instances this cannot be helped.

dataToAppendWhenGeneratingLoadString [string]

Optional data to append to every ChunkLoadKey string generated by this Cell String object. Using this data (or dataToPrependWhenGeneratingLoadString) does result in two strings being produced everytime MatchStringToCell is used, however in some instances this cannot be helped.