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

Base class for procedurally generating world block data More...

Inheritance diagram for TerrainEngine2D.TerrainData:
TerrainDataTemplate

Public Member Functions

virtual void GenerateData ()
 Procedurally generates world block data using random and pseudo-random functions More...
 

Protected Types

enum  Fluid { Fluid.Empty, Fluid.Solid, Fluid.Full }
 

Protected Member Functions

int PerlinNoise (int x, int y, float scale, float mag, float exp)
 Perlin Noise Function for generating block height data More...
 
void AddBlock (int x, int y, byte layer, byte blockType, float probability=100f)
 Sets the world block data of a specified layer to a specific block More...
 
bool DoAddBlock (double probability)
 Checks if block should be set based on probability More...
 
void RemoveBlock (int x, int y, byte layer)
 Removes blocks from a specified layer and coordinate More...
 
void RemoveAllBlocks (int x, int y)
 Removes blocks from all layers at a coordinate More...
 
bool IsBlockAt (int x, int y, byte layer, int width=1, int height=1)
 Checks if there is a block at a specific coordinate or area in the layer More...
 
void SetFluidType (int x, int y, Fluid fluidType)
 Set fluid type at a specified coordinate More...
 
void AddFluid (int x, int y, float weight)
 Add fluid to a block at a coordinate More...
 
void RemoveFluid (int x, int y, int width=1, int height=1)
 Remove fluid from an area More...
 
void GeneratePool (int x, int y, float weight, int maxY, Vector2 key, bool newPool=true)
 Recursive function for generating a pool of fluid below a threshold, previously set fluid blocks will be overwritten More...
 
void ClearFluid (int x, int y, int maxY)
 Recursive function for removing fluid below a threshold More...
 

Protected Attributes

World world
 
FluidDynamics fluidDynamics
 
Vector2 [,] fluidKey
 
int seed
 
System.Random random
 

Detailed Description

Base class for procedurally generating world block data

Member Enumeration Documentation

◆ Fluid

enum TerrainEngine2D.TerrainData.Fluid
strongprotected
Enumerator
Empty 
Solid 
Full 

Member Function Documentation

◆ AddBlock()

void TerrainEngine2D.TerrainData.AddBlock ( int  x,
int  y,
byte  layer,
byte  blockType,
float  probability = 100f 
)
protected

Sets the world block data of a specified layer to a specific block

Parameters
xBlock x coordinate
yBlock y coordinate
layerLayer to set the block data
blockTypeThe block type which is being set
probabilityPercent chance of setting block (0 - 100)

◆ AddFluid()

void TerrainEngine2D.TerrainData.AddFluid ( int  x,
int  y,
float  weight 
)
protected

Add fluid to a block at a coordinate

Parameters
xX coordinate
yY coordinate
weightAmount of fluid to add

◆ ClearFluid()

void TerrainEngine2D.TerrainData.ClearFluid ( int  x,
int  y,
int  maxY 
)
protected

Recursive function for removing fluid below a threshold

Parameters
xFluid block x coordinate
yFluid block y coordinate
maxYHeighest fluid point

◆ DoAddBlock()

bool TerrainEngine2D.TerrainData.DoAddBlock ( double  probability)
protected

Checks if block should be set based on probability

Parameters
probabilityThe odds of setting the block
Returns
Returns true if block should be set

◆ GenerateData()

virtual void TerrainEngine2D.TerrainData.GenerateData ( )
virtual

Procedurally generates world block data using random and pseudo-random functions

Parameters
worldReference to the world to access block arrays

Reimplemented in TerrainDataTemplate.

◆ GeneratePool()

void TerrainEngine2D.TerrainData.GeneratePool ( int  x,
int  y,
float  weight,
int  maxY,
Vector2  key,
bool  newPool = true 
)
protected

Recursive function for generating a pool of fluid below a threshold, previously set fluid blocks will be overwritten

Parameters
xFluid block x coordinate
yFluid block y coordinate
weightAmount of fluid added to the block
maxYHeighest fluid point
keyThe starting coordinate
newPoolWhether this is the

◆ IsBlockAt()

bool TerrainEngine2D.TerrainData.IsBlockAt ( int  x,
int  y,
byte  layer,
int  width = 1,
int  height = 1 
)
protected

Checks if there is a block at a specific coordinate or area in the layer

Parameters
xX coordinate
yY coordinate
layerLayer to be checked
widthThe width of the area (in blocks)
heightThe height of the area (in blocks)
Returns
Returns true if there is a block

◆ PerlinNoise()

int TerrainEngine2D.TerrainData.PerlinNoise ( int  x,
int  y,
float  scale,
float  mag,
float  exp 
)
protected

Perlin Noise Function for generating block height data

Parameters
xBlock x coordinate
yBlock y coordinate
scaleScaling; lower values gives more varying height output
magMagnitdue; higher values produce a larger height output
expExponential; greatly increases height output
Returns
Returns the noise value

◆ RemoveAllBlocks()

void TerrainEngine2D.TerrainData.RemoveAllBlocks ( int  x,
int  y 
)
protected

Removes blocks from all layers at a coordinate

Parameters
xX coordinate
yY coordinate

◆ RemoveBlock()

void TerrainEngine2D.TerrainData.RemoveBlock ( int  x,
int  y,
byte  layer 
)
protected

Removes blocks from a specified layer and coordinate

Parameters
xX coordinate
yY coordinate
layerLayer to remove the block from

◆ RemoveFluid()

void TerrainEngine2D.TerrainData.RemoveFluid ( int  x,
int  y,
int  width = 1,
int  height = 1 
)
protected

Remove fluid from an area

Parameters
xX coordinate of area
yY coordinate of area
widthWidth of area
heightHeight of area

◆ SetFluidType()

void TerrainEngine2D.TerrainData.SetFluidType ( int  x,
int  y,
Fluid  fluidType 
)
protected

Set fluid type at a specified coordinate

Parameters
xFluid block x coordinate
yFluid block y coordinate
fluidTypeThe fluid type which is being set

Member Data Documentation

◆ fluidDynamics

FluidDynamics TerrainEngine2D.TerrainData.fluidDynamics
protected

◆ fluidKey

Vector2 [,] TerrainEngine2D.TerrainData.fluidKey
protected

◆ random

System.Random TerrainEngine2D.TerrainData.random
protected

◆ seed

int TerrainEngine2D.TerrainData.seed
protected

◆ world

World TerrainEngine2D.TerrainData.world
protected

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