TerrainUtils

Utilities View source
TerrainUtils

Source on GitHub

Tuples

tile

public tuple tile(int id)

represents a single terrain tile can also be used as vec2 <-> int conversion

Functions

setWaterBaseColor

public function setWaterBaseColor(colorA color)

tile

public function tile(int x, int y) returns tile

tile

public function tile(real x, real y) returns tile

Extension Functions

vec2.setTerrainType

public function vec2.setTerrainType(int ttype, int variation, int area, int shape)

vec2.getTerrainType

public function vec2.getTerrainType() returns int

vec2.getTerrainVariance

public function vec2.getTerrainVariance() returns int

vec2.addTerrainHeight

public function vec2.addTerrainHeight(real val) returns terraindeformation

Applies a single terrain deformation to closest tile. Is not immediate. Reports shows that this may cause desync with Mac players.

vec2.setTerrainPathable

public function vec2.setTerrainPathable(pathingtype ttype, bool flag)

Fills 32x32 rect around vec2 with given pathing type

vec2.isTerrainPathable

public function vec2.isTerrainPathable(pathingtype ttype) returns bool

Returns if a specific pathingtype is set at the location. Note: Returns true if the pathingtype is not set, false if it is set.

vec2.toTileCenter

public function vec2.toTileCenter() returns vec2

Returns center of the Tile which given vec2 belongs to.

vec2.getTerrainNormal

public function vec2.getTerrainNormal(real sampleRadius) returns vec3

Returns the (not normalised) terrain-normal at the given point

vec2.isTerrainDeepWater

public function vec2.isTerrainDeepWater() returns boolean

vec2.isTerrainShallowWater

public function vec2.isTerrainShallowWater() returns boolean

vec2.isTerrainLand

public function vec2.isTerrainLand() returns boolean

vec2.isTerrainPlatform

public function vec2.isTerrainPlatform() returns boolean

vec2.isTerrainWalkable

public function vec2.isTerrainWalkable() returns boolean

tile.getX

public function tile.getX() returns real

tile.getY

public function tile.getY() returns real

vec2.getTile

public function vec2.getTile() returns tile

Returns the tile which given vec2 belongs to.

tile.toVec2

public function tile.toVec2() returns vec2

tile.setType

public function tile.setType(int ttype, int variation)

tile.setType

public function tile.setType(int ttype)

tile.getHeight

public function tile.getHeight() returns real

tile.addHeight

public function tile.addHeight(real val) returns terraindeformation

tile.getType

public function tile.getType() returns int

tile.getVariance

public function tile.getVariance() returns int

tile.setPathing

public function tile.setPathing(pathingtype ttype, bool flag)

Fills the entire tile (128x128 rect around tile pos) with given type

Constants

TILES_X

public constant TILES_X = (boundMax.x - boundMin.x).toInt() div 128 + 1

TILES_Y

public constant TILES_Y = (boundMax.y - boundMin.y).toInt() div 128 + 1

TILES_COUNT

public constant TILES_COUNT = TILES_X * TILES_Y