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

The 2D procedurally generated world of blocks More...

Inheritance diagram for TerrainEngine2D.World:
TerrainEngine2D.MonoBehaviourSingleton< World >

Public Member Functions

delegate void WorldGeneration ()
 Actions invoked by World Generation More...
 
delegate void DayCycle (int dayCount)
 Actions invoked when the day count changes More...
 
delegate void BlockModifiedAction (int x, int y, byte layer, byte blockType)
 Actions invoked when a block is placed More...
 
void GenerateVariation (int x, int y, int layer)
 Randomly set the block variation at a specific point in a layer More...
 
bool AddBlock (int x, int y, byte blockType, byte selectedLayer, bool replaceBlock=false)
 Adds a block to the specified coordinate More...
 
byte RemoveBlock (int x, int y, byte selectedLayer)
 Removes a block from the specified coordinate More...
 
int GetBlockDistanceFromAir (int x, int y)
 Get the distance from air at a specific coordinate More...
 
BlockLayer GetBlockLayer (int layer)
 Get the specified block layer More...
 

Public Attributes

const int LIGHT_SYSTEM_Z_ORDER = 1
 
const int GRID_SELECTOR_Z_ORDER = 2
 Render order of the GridSelector Used to set the z position of the GridSelector's image More...
 
const int UI_Z_ORDER = 9
 Z order of world space UI elemnts More...
 
const int CAMERA_Z_ORDER = 10
 Z order of the Camera Used to set the z position of the Camera More...
 
string Name = "World"
 The name of the World More...
 
bool LoadWorld
 Whether to load the World from file More...
 
bool SaveWorld
 Whether to save the World data More...
 
bool OverlapBlendSquares
 Whether to Overlap Blend Squares over block edges when generating an Overlap Block mesh, or replace them (optimization) More...
 
bool DoNotGenerateHiddenBlocks = true
 Whether to generate blocks which are hidden behind other layers More...
 

Protected Member Functions

override void Awake ()
 

Properties

ChunkLoader ChunkLoader [set]
 Reference to the ChunkLoader for updating Chunks More...
 
FluidDynamics FluidDynamics [set]
 Reference to the FluidDynamics for updating the FluidBlocks More...
 
FallingBlockSimulation FallingBlockSimulation [set]
 Reference to the FluidDynamics for updating the FluidBlocks More...
 
TerrainData TerrainData [set]
 Reference to the TerrainData script for generating the terrain data More...
 
LightSystem LightSystem [set]
 Reference to the LightSystem for updating the shadow mask More...
 
AdvancedLightSystem AdvancedLightSystem [set]
 Reference to the AdvancedLightSystem More...
 
AmbientLight AmbientLight [set]
 Reference to the ambient lighting More...
 
int WorldWidth [get, set]
 /The width of the world in blocks More...
 
int WorldHeight [get, set]
 The height of the world in blocks More...
 
int Seed [get, set]
 A number used to procedurally generate the terrain data More...
 
byte FluidLayer [get, set]
 The layer which fluid is placed More...
 
bool RenderFluidTexture [get]
 Whether to render the fluid simulation in a texture, or in chunks of meshes More...
 
byte LightLayer [get, set]
 The layer the light data maps to More...
 
byte AmbientLightLayer [get, set]
 The layer the ambient light data maps to More...
 
byte FallingBlockLayer [get, set]
 The layer containing falling blocks More...
 
bool FluidDisabled [get]
 Whether the fluid simulation is disabled More...
 
bool FallingBlockDisable [get]
 Whether the falling block simulation is disabled More...
 
bool LightingDisabled [get]
 Whether lighting is disabled More...
 
bool BasicLighting [get]
 Whether using basic or advanced lighting More...
 
int PixelsPerBlock [get]
 The number of pixels per block (Unity units) - should be the same as the pixels per unit of the tileset textures More...
 
float ZBlockDistance [get]
 The z distance between different block types (for render order) More...
 
int ZLayerFactor [get]
 The z distance factor between layers Layers will be positioned at a distance of zBlockDistance * zLayerFactor away from eachother More...
 
float EndZPoint [get]
 The z coordinate for the furthest block from the origin (used for setting z order of GameObjects that are in front of the world) More...
 
byte [] ColliderLayers [get]
 List of all the layers which have colliders More...
 
BlockLayer [] BlockLayers [get]
 All the block layers that makeup the terrain More...
 
int NumBlockLayers [get]
 The number of block layers More...
 
string WorldDirectory [get, set]
 Selected path to the World directory More...
 
float TimeOfDay [get]
 The current time of day More...
 
int TimeFactor [get]
 The factor used to determine how fast time will go by in the game (a time factor of 1 is realtime) More...
 
int DayCount [get]
 The amount of days that have gone by More...
 
bool PauseTime [get, set]
 Whether to pause the current time/day cycle More...
 
- Properties inherited from TerrainEngine2D.MonoBehaviourSingleton< World >
static T Instance [get]
 

Events

static WorldGeneration OnWorldGenerated
 Event called when the world is finished loading More...
 
static DayCycle OnNewDay
 Event called when a new day starts More...
 
static BlockModifiedAction OnBlockPlaced
 Event called when blocks have been added More...
 
static BlockModifiedAction OnBlockRemoved
 Event called when blocks have been removed More...
 

Detailed Description

The 2D procedurally generated world of blocks

Member Function Documentation

◆ AddBlock()

bool TerrainEngine2D.World.AddBlock ( int  x,
int  y,
byte  blockType,
byte  selectedLayer,
bool  replaceBlock = false 
)

Adds a block to the specified coordinate

Parameters
xX coordinate
yY coordinate
blockTypeThe type of block
selectedLayerThe layer to place the block in
replaceBlockWhether to replace the current block in that position (optional)
Returns
Returns true if a block is successfully added

◆ Awake()

override void TerrainEngine2D.World.Awake ( )
protectedvirtual

◆ BlockModifiedAction()

delegate void TerrainEngine2D.World.BlockModifiedAction ( int  x,
int  y,
byte  layer,
byte  blockType 
)

Actions invoked when a block is placed

◆ DayCycle()

delegate void TerrainEngine2D.World.DayCycle ( int  dayCount)

Actions invoked when the day count changes

Parameters
dayCountThe current day count

◆ GenerateVariation()

void TerrainEngine2D.World.GenerateVariation ( int  x,
int  y,
int  layer 
)

Randomly set the block variation at a specific point in a layer

Parameters
xX coordinate of point
yY coordinate of point
layerThe block layer

◆ GetBlockDistanceFromAir()

int TerrainEngine2D.World.GetBlockDistanceFromAir ( int  x,
int  y 
)

Get the distance from air at a specific coordinate

Parameters
xX coordinate
yY coordinate
Returns
Return the distance from air in blocks (Unity units)

◆ GetBlockLayer()

BlockLayer TerrainEngine2D.World.GetBlockLayer ( int  layer)

Get the specified block layer

Parameters
layerThe block layer index
Returns
Returns the block layer

◆ RemoveBlock()

byte TerrainEngine2D.World.RemoveBlock ( int  x,
int  y,
byte  selectedLayer 
)

Removes a block from the specified coordinate

Parameters
xX coordinate
yY coordinate
selectedLayerList of layers to remove blocks from
Returns
Returns the blocktype of the removed block

◆ WorldGeneration()

delegate void TerrainEngine2D.World.WorldGeneration ( )

Actions invoked by World Generation

Member Data Documentation

◆ CAMERA_Z_ORDER

const int TerrainEngine2D.World.CAMERA_Z_ORDER = 10

Z order of the Camera Used to set the z position of the Camera

◆ DoNotGenerateHiddenBlocks

bool TerrainEngine2D.World.DoNotGenerateHiddenBlocks = true

Whether to generate blocks which are hidden behind other layers

◆ GRID_SELECTOR_Z_ORDER

const int TerrainEngine2D.World.GRID_SELECTOR_Z_ORDER = 2

Render order of the GridSelector Used to set the z position of the GridSelector's image

◆ LIGHT_SYSTEM_Z_ORDER

const int TerrainEngine2D.World.LIGHT_SYSTEM_Z_ORDER = 1

◆ LoadWorld

bool TerrainEngine2D.World.LoadWorld

Whether to load the World from file

◆ Name

string TerrainEngine2D.World.Name = "World"

The name of the World

◆ OverlapBlendSquares

bool TerrainEngine2D.World.OverlapBlendSquares

Whether to Overlap Blend Squares over block edges when generating an Overlap Block mesh, or replace them (optimization)

◆ SaveWorld

bool TerrainEngine2D.World.SaveWorld

Whether to save the World data

◆ UI_Z_ORDER

const int TerrainEngine2D.World.UI_Z_ORDER = 9

Z order of world space UI elemnts

Property Documentation

◆ AdvancedLightSystem

AdvancedLightSystem TerrainEngine2D.World.AdvancedLightSystem
set

Reference to the AdvancedLightSystem

◆ AmbientLight

AmbientLight TerrainEngine2D.World.AmbientLight
set

Reference to the ambient lighting

◆ AmbientLightLayer

byte TerrainEngine2D.World.AmbientLightLayer
getset

The layer the ambient light data maps to

◆ BasicLighting

bool TerrainEngine2D.World.BasicLighting
get

Whether using basic or advanced lighting

◆ BlockLayers

BlockLayer [] TerrainEngine2D.World.BlockLayers
get

All the block layers that makeup the terrain

◆ ChunkLoader

ChunkLoader TerrainEngine2D.World.ChunkLoader
set

Reference to the ChunkLoader for updating Chunks

◆ ColliderLayers

byte [] TerrainEngine2D.World.ColliderLayers
get

List of all the layers which have colliders

◆ DayCount

int TerrainEngine2D.World.DayCount
get

The amount of days that have gone by

◆ EndZPoint

float TerrainEngine2D.World.EndZPoint
get

The z coordinate for the furthest block from the origin (used for setting z order of GameObjects that are in front of the world)

◆ FallingBlockDisable

bool TerrainEngine2D.World.FallingBlockDisable
get

Whether the falling block simulation is disabled

◆ FallingBlockLayer

byte TerrainEngine2D.World.FallingBlockLayer
getset

The layer containing falling blocks

◆ FallingBlockSimulation

FallingBlockSimulation TerrainEngine2D.World.FallingBlockSimulation
set

Reference to the FluidDynamics for updating the FluidBlocks

◆ FluidDisabled

bool TerrainEngine2D.World.FluidDisabled
get

Whether the fluid simulation is disabled

◆ FluidDynamics

FluidDynamics TerrainEngine2D.World.FluidDynamics
set

Reference to the FluidDynamics for updating the FluidBlocks

◆ FluidLayer

byte TerrainEngine2D.World.FluidLayer
getset

The layer which fluid is placed

◆ LightingDisabled

bool TerrainEngine2D.World.LightingDisabled
get

Whether lighting is disabled

◆ LightLayer

byte TerrainEngine2D.World.LightLayer
getset

The layer the light data maps to

◆ LightSystem

LightSystem TerrainEngine2D.World.LightSystem
set

Reference to the LightSystem for updating the shadow mask

◆ NumBlockLayers

int TerrainEngine2D.World.NumBlockLayers
get

The number of block layers

◆ PauseTime

bool TerrainEngine2D.World.PauseTime
getset

Whether to pause the current time/day cycle

◆ PixelsPerBlock

int TerrainEngine2D.World.PixelsPerBlock
get

The number of pixels per block (Unity units) - should be the same as the pixels per unit of the tileset textures

◆ RenderFluidTexture

bool TerrainEngine2D.World.RenderFluidTexture
get

Whether to render the fluid simulation in a texture, or in chunks of meshes

◆ Seed

int TerrainEngine2D.World.Seed
getset

A number used to procedurally generate the terrain data

◆ TerrainData

TerrainData TerrainEngine2D.World.TerrainData
set

Reference to the TerrainData script for generating the terrain data

◆ TimeFactor

int TerrainEngine2D.World.TimeFactor
get

The factor used to determine how fast time will go by in the game (a time factor of 1 is realtime)

◆ TimeOfDay

float TerrainEngine2D.World.TimeOfDay
get

The current time of day

◆ WorldDirectory

string TerrainEngine2D.World.WorldDirectory
getset

Selected path to the World directory

◆ WorldHeight

int TerrainEngine2D.World.WorldHeight
getset

The height of the world in blocks

◆ WorldWidth

int TerrainEngine2D.World.WorldWidth
getset

/The width of the world in blocks

◆ ZBlockDistance

float TerrainEngine2D.World.ZBlockDistance
get

The z distance between different block types (for render order)

◆ ZLayerFactor

int TerrainEngine2D.World.ZLayerFactor
get

The z distance factor between layers Layers will be positioned at a distance of zBlockDistance * zLayerFactor away from eachother

Event Documentation

◆ OnBlockPlaced

BlockModifiedAction TerrainEngine2D.World.OnBlockPlaced
static

Event called when blocks have been added

◆ OnBlockRemoved

BlockModifiedAction TerrainEngine2D.World.OnBlockRemoved
static

Event called when blocks have been removed

◆ OnNewDay

DayCycle TerrainEngine2D.World.OnNewDay
static

Event called when a new day starts

◆ OnWorldGenerated

WorldGeneration TerrainEngine2D.World.OnWorldGenerated
static

Event called when the world is finished loading


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