Terrain Engine 2D  1.10
A 2D Block Engine
TerrainEngine2D.BlockLayer Class Reference

A layer holding block type info and block data for the world More...

Public Member Functions

void InitializeBlockLayer (int worldWidth, int worldHeight, int pixelsPerBlock, float zBlockDistance, int zLayerFactor, BlockLayer prevLayer)
 Sets up the block layer info and allocates storage for data More...
 
int GetNumBlockTypes ()
 Get the number of block types More...
 
BlockInfo GetBlockInfo (int blockType)
 Get the info for a block by blockType More...
 
BlockInfo GetBlockInfo (int x, int y)
 Get the info for a block at a specific coordinate More...
 
void SetBitmask (int x, int y, byte bitmask)
 Sets the bitmask at a specific coordinate More...
 
byte GetBitmask (int x, int y)
 Get the bitmask at a specific coordinate More...
 
void SetVariation (int x, int y, byte variation)
 Set the block variation at a specific coordinate More...
 
byte GetVariation (int x, int y)
 Get the block variation at a specific coordinate More...
 
bool IsRenderblock (int x, int y)
 Determines if the block at the coordinate should be rendered More...
 
byte GetBlockType (int x, int y)
 Get the block type at a specific coordinate More...
 
bool AddBlock (int x, int y, byte blockType)
 Adds a block to a specific coordinate More...
 
Vector2 RemoveBlock (int x, int y)
 Removes a block from a specific coordinate More...
 
bool IsBlockAt (int x, int y)
 Checks to see if there is a block at a specific coordinate More...
 

Public Attributes

const int BLOCK_INDEX_OFFSET = 1
 Offset for getting block info using the block type as index More...
 
const int AIR_BLOCK = 0
 The value representing the block type of a air/null block More...
 

Properties

bool ColliderLayer [get]
 Colliders will be generated for this layer More...
 
string Name [get]
 Name of the layer More...
 
Material Material [get, set]
 Tileset material for the layer More...
 
float ZLayerOrder [get]
 The z position origin of the layer (for render order) More...
 
float ZLayerOrderEnd [get]
 The z position of the final block of that layer (for render order) More...
 
byte [,] BlockType [get, set]
 The block type at each grid position More...
 
bool [,] RenderBlock [get, set]
 Whether block should be rendered (for multi-tile blocks) More...
 

Detailed Description

A layer holding block type info and block data for the world

Member Function Documentation

◆ AddBlock()

bool TerrainEngine2D.BlockLayer.AddBlock ( int  x,
int  y,
byte  blockType 
)

Adds a block to a specific coordinate

Parameters
xX coordinate
yY coordinate
blockTypeThe block type to be set
Returns
Returns true if the block was added

◆ GetBitmask()

byte TerrainEngine2D.BlockLayer.GetBitmask ( int  x,
int  y 
)

Get the bitmask at a specific coordinate

Parameters
xX coordinate
yY coordinate
Returns
Returns the bitmask

◆ GetBlockInfo() [1/2]

BlockInfo TerrainEngine2D.BlockLayer.GetBlockInfo ( int  blockType)

Get the info for a block by blockType

Parameters
blockTypeThe type of block
Returns
Returns the block info

◆ GetBlockInfo() [2/2]

BlockInfo TerrainEngine2D.BlockLayer.GetBlockInfo ( int  x,
int  y 
)

Get the info for a block at a specific coordinate

Parameters
xX coordinate
yY coordinate
Returns
Returns the block info

◆ GetBlockType()

byte TerrainEngine2D.BlockLayer.GetBlockType ( int  x,
int  y 
)

Get the block type at a specific coordinate

Parameters
xX coordinate
yY coordinate
Returns
Returns the block type

◆ GetNumBlockTypes()

int TerrainEngine2D.BlockLayer.GetNumBlockTypes ( )

Get the number of block types

Returns
Returns the number of block types

◆ GetVariation()

byte TerrainEngine2D.BlockLayer.GetVariation ( int  x,
int  y 
)

Get the block variation at a specific coordinate

Parameters
xX coordinate
yY coordinate
Returns
The block variation

◆ InitializeBlockLayer()

void TerrainEngine2D.BlockLayer.InitializeBlockLayer ( int  worldWidth,
int  worldHeight,
int  pixelsPerBlock,
float  zBlockDistance,
int  zLayerFactor,
BlockLayer  prevLayer 
)

Sets up the block layer info and allocates storage for data

Parameters
worldWidthWidth of the world
worldHeightHeight of the world
pixelsPerBlockNumber of pixels per block (unit)
zBlockDistanceThe z distance between blocks
zLayerFactorThe z distance factor between layers
prevLayerThe previous layer that was initialized

◆ IsBlockAt()

bool TerrainEngine2D.BlockLayer.IsBlockAt ( int  x,
int  y 
)

Checks to see if there is a block at a specific coordinate

Parameters
xX coordinate
yY coordinate
Returns
Returns true if a block exists

◆ IsRenderblock()

bool TerrainEngine2D.BlockLayer.IsRenderblock ( int  x,
int  y 
)

Determines if the block at the coordinate should be rendered

Parameters
xX coordinate
yY coordinate
Returns
Returns if the block should be rendered

◆ RemoveBlock()

Vector2 TerrainEngine2D.BlockLayer.RemoveBlock ( int  x,
int  y 
)

Removes a block from a specific coordinate

Parameters
xX coordinate
yY coordinate
Returns
Returns the render position

◆ SetBitmask()

void TerrainEngine2D.BlockLayer.SetBitmask ( int  x,
int  y,
byte  bitmask 
)

Sets the bitmask at a specific coordinate

Parameters
xX coordinate
yY coordinate
bitmaskThe bitmask value to be set

◆ SetVariation()

void TerrainEngine2D.BlockLayer.SetVariation ( int  x,
int  y,
byte  variation 
)

Set the block variation at a specific coordinate

Parameters
xX coordinate
yY coordinate
variationThe variation to be set

Member Data Documentation

◆ AIR_BLOCK

const int TerrainEngine2D.BlockLayer.AIR_BLOCK = 0

The value representing the block type of a air/null block

◆ BLOCK_INDEX_OFFSET

const int TerrainEngine2D.BlockLayer.BLOCK_INDEX_OFFSET = 1

Offset for getting block info using the block type as index

Property Documentation

◆ BlockType

byte [,] TerrainEngine2D.BlockLayer.BlockType
getset

The block type at each grid position

◆ ColliderLayer

bool TerrainEngine2D.BlockLayer.ColliderLayer
get

Colliders will be generated for this layer

◆ Material

Material TerrainEngine2D.BlockLayer.Material
getset

Tileset material for the layer

◆ Name

string TerrainEngine2D.BlockLayer.Name
get

Name of the layer

◆ RenderBlock

bool [,] TerrainEngine2D.BlockLayer.RenderBlock
getset

Whether block should be rendered (for multi-tile blocks)

◆ ZLayerOrder

float TerrainEngine2D.BlockLayer.ZLayerOrder
get

The z position origin of the layer (for render order)

◆ ZLayerOrderEnd

float TerrainEngine2D.BlockLayer.ZLayerOrderEnd
get

The z position of the final block of that layer (for render order)


The documentation for this class was generated from the following file: