WorldCell Class

public class WorldCell

Represents a tangible cell on the World.

Each World Cell is always associated with a specific Cell on a Streamable Grid and a Cell on an Endless Grid. For non endless/repeating Worlds, these two Cell values will always match, but for endless Worlds (with one or more endless Axis), these Cells may or may not match. As such, the primary identificator of a World Cell is it's CellOnEndlessGrid, as this is gauranteed to be unique across all loaded World Cells.

In 99% of cases, each World Cell will have one or more Asset Chunks stored in it, which is typically determined by the Streamable Grid Cell and active LOD of the World Cell. World Cell's can trade up or down in LODs, moving from using the Asset Chunks of a lower quality LOD Group to a higher quality LOD Group, or vice versa. When this happens, a new World Cell is used to store the new LODs Asset Chunks, and internally this new World Cell replaces the old World Cell that used the previous LODs chunks.

If the World Cell's active LOD is associated with an LOD Group that uses Unity Terrain, the World Cell will actually be a WorldCellWithTerrain object, which allows it to store Unity Terrain and perform other operations required for Terrain Neighboring to work.

Your primary interaction with World Cells will come in custom Cell Visual Transition Controllers and World Grouping Listeners, though there are several other components that interact with them as well.

Properties

Name Type Description
AllChunkAssetsMatchExpectedLOD bool

Whether every chunk asset on this World Cell matches the expected assets for its current active Level of Detail. This will be true in most cases. One situation where it might be false is if using an Addressable Streamer and an asset fails to download properly.

In this situation, a lower quality LOD asset or place holder asset may be loaded instead. If that happens, this value will return false, so long as at least one chunk is using the lower quality LOD or placeholder asset.

This is useful in situations where you are using a component (such as a Cell Visual Transition Controllers or World Grouping Listeners) which expects a specific hierarchy format for each LOD. In these cases, the component may not work properly or it may throw an exception if it tries to work with the lower quality LOD or place holder assets as if they were the assets of the World Cell's LOD.

So instead, when this property returns false, you can verify whether each chunk asset on the World Cell is a lower quality LOD asset or placeholder by checking its hierarchy (you cannot check the game object name, because all chunks are renamed to match the chunk index and World Cell index, no matter of it is a lower quality LOD or placeholder asset that is loaded for the chunk), or by another means.

Also keep in mind that the setter for this property is also public, so that the Addressable Streamers (which exist outside of the .dll) can access this property. In most instances, you should not need to set the value of this property yourself.

Finally, this property is queried any time Asset Chunks from one World Cell would be reused by another World Cell on the same LOD, to ensure that the chunks are of the correct LOD. If they are not, the chunks are not transferred, but instead passed to the Chunk Manager for processing.

BaseCellThisCellResidesIn Cell

Gets the Endless Grid Cell from the Base Grouping that this World Cell resides within. Note that it's possible that this World Cell falls within multiple Base Grouping Cell's. The value returned here is the Cell in which the CellPosition of this World Cell falls within.

BottomNeighbor WorldCell

Gets the World Cell that neighbors this WorldCell below (-Y Axis, only present for 3D Worlds).

Bounds BoundsDouble

The bounds of the World Cell in the scene, which is calculated from the CellPosition and dimensions of the cell (as set on the Streamable Grid).

This may or may not be not equivalent to the bounds of the terrain or chunks associated with the cell, so you should decide which bounds to use if implementing a culling system.

CellOnEndlessGrid Cell

Gets the cell's index on the Endless Grid associated with the World Grouping this cell belongs to.

CellOnStreamableGrid Cell

Gets the cell's index on the Streamable Grid associated with the World Grouping this cell belongs to.

CellPosition Vector3Double

Gets the position of the cell in world space (note, this may be different than the position of the chunk, since the chunk can be offset from the cell).

CellUsers int

Gets the number of users of this World Cell across all LODs. The World Cell upgrades to a higher quality LOD whenever a user is added for the higher quality LOD (where no user was present before). It downgrades when the user count for an LOD reaches 0 (and users for a lower quality LOD exists). When the total CellUsers count reaches 0, it is unloaded completely.

ChunkManager ChunkManager

Gets the chunk manager resposible for managing this World Cell.

ChunkStreamer ChunkStreamer

Gets the chunk streamer resposible for loading and removing/deactivating the Asset Chunks for this World Cell.

DoesCellHaveMultipleChunks bool

Gets a value indicating whether the cell has multiple Asset Chunks.

DoesCellHaveUsers bool

Gets a value indicating whether the World Cell currently has any users across all LODs.

EastNeighbor WorldCell

Gets the World Cell that neighbors this WorldCell to the East (+X Axis).

FlattenedStreamableGridIndex long

Gets the flattened index of the cell on the Streamable Grid it belongs to. The flattened index is the CellOnStreamableGrid value flattened to represent an index in a 1D array of size (StreamableGrid.Rows * StreamableGrid.Columns * StreamableGrid.Layers).

Note however, if you have a very large world, this value may be larger than int.MaxValue, making it unusable as an index into a real array. In such cases, it's better to use it as the key in a dictionary.

Height double

Gets the height of the cell.

Length double

Gets the length of the cell.

LevelOfDetail int

Gets the active Level of Detail of the World Cell.

NorthNeighbor WorldCell

Gets the World Cell that neighbors this WorldCell to the North (+Y for 2D XY Grids, or +Z otherwise).

NumChunks int

Gets the number of Asset Chunks this World Cell has.

PositionOfChunks bool

Gets the position that Asset Chunks should be placed at. You can position the chunks manually, or let them be automatically positioned by the World (by passing in No or Maybe for chunksPositionedCorrectlyAlready when calling AttachChunkToCell).

SouthNeighbor WorldCell

Gets the World Cell that neighbors this WorldCell to the South (-Y for 2D XY Grids, or -Z otherwise).

StreamableGrid StreamableGrid

Gets the Streamable Grid this cell was created from.

TopNeighbor WorldCell

Gets the World Cell that neighbors this WorldCell above (+Y Axis, only present for 3D Worlds).

WestNeighbor WorldCell

Gets the World Cell that neighbors this WorldCell to the West (-X axis).

Width double

Gets the width of the cell.

World World

Get the World this World Cell belongs to.

WorldGroupingIndex int

Gets the index of the World Grouping that this cell belongs to.

Methods

AttachChunkToCell(object, ChunksPositioned, int)

public void AttachChunkToCell(object chunk, ChunksPositioned chunksPositionedCorrectlyAlready, int chunkIndex)

Attaches an Asset Chunk to the cell. If creating a custom Chunk Streamer or Chunk Manager class, you should either let the World position the chunk correctly by passing in 'No' for chunksPositionedCorrectlyAlready, or position the chunks manually (or instantiate it at the correct position) and pass in 'Yes'. If you are unsure whether it's positioned correctly, you can pass in Maybe instead.

It's assumed that all chunks attached for a World Cell during a given operation will have the same value for chunksPositionedCorrectlyAlready. As such, only the value passed in for the last chunk will actually be used.

The chunks are not positioned immediately. If you require them to be positioned immediately in whatever is calling this method, you should position them manually and pass in Yes for the chunksPositionedCorrectlyAlready value.

If you have some chunks that are positioned already and others that are not, pass in Maybe to have the World evaluate all of the chunks.

Parameters

Name Type Description
chunk object

The Asset Chunk to attach to the cell. While you can pass in any object, the object should match the Chunk Type you set on the LOD Group of your Streamable Grid.

chunksPositionedCorrectlyAlready ChunksPositioned

Whether the Asset Chunks attached to the World Cell are already positioned correctly. If 'No', the chunks will be moved to PositionOfChunks (at a later time) by the World.

If you've already positioned the chunks at the correct location (PositionOfChunks), you can pass in 'Yes'.

If you are unsure whether the chunks are positioned, or are attaching a combination of positioned and non-positioned chunks, pass in 'Maybe'. Only the value passed in for the last chunk attached will always be used!

chunkIndex int

The index of the chunk. 1 should be passed in if not using multi-chunking. Cannot be larger than NumChunks.


DetachChunksFromCell(int)

public object DetachChunksFromCell(int chunkIndex)

Detaches the Asset Chunk at the specified index from the cell and returns it.

The object returned and no longer associated with the World Cell (i.e., the World Cell no longer holds a reference to it).

Parameters

Name Type Description
chunkIndex int

The index of the chunk to detatch (one based). If you are not using chunks (i.e., there is only 1 chunk), then pass in 1. Cannot be larger than NumChunks.

Returns

object
The chunk that was detached from the World Cell.


GetChunkBelongingToCell(int chunkIndex)

object GetChunkBelongingToCell(int)

Gets the Asset Chunk at chunkIndex belonging to the cell. Unlike DetachChunksFromCell, this does not disassociate the chunk from the World Cell (i.e., the World Cell will still hold a reference to the chunk after this method is called).

Parameters

Name Type Description
chunkIndex int

The index of the chunk you wish to get. If you are not using multi-chunking (i.e., there is only 1 chunk), then pass in 1. Cannot be larger than NumChunks.

Returns

object
The chunk at chunkIndex.