FoliageCell

Package: Libraries.Game.Graphics.Worlds · Inherits from: Libraries.Language.Object

A FoliageCell holds the copies of one foliage asset standing in one square cell of a terrain. TerrainFoliage splits each region into cells, so a cell can be drawn, hidden and culled as one piece, and saved with its region. Each copy is six numbers: where it stands (x, y and z, in world units), its turn about the up axis in degrees, its scale, and its shade (1 is the asset's own color, less is darker). A cell holds two kinds of copies. Copies worked out from the asset's coverage, which TerrainFoliage replaces whenever the coverage or the asset's settings change (SetGenerated), and copies a program placed itself with Add, which stay. Copies are numbered with the placed ones first.

Example Code

use Libraries.Game.Graphics.Worlds.FoliageCell

FoliageCell cell
cell:Set(0, 3, 4, 32)
cell:Add(100, 2.5, 140, 45, 1.1, 0.95)
output cell:GetCount()

Variables

  • integer VALUES_PER_COPY: How many numbers each copy takes.

Actions

Add(number x, number y, number z, number turn, number scale, number shade)

This action adds a copy that a program placed itself. It stays when the copies worked out from coverage are replaced.

Parameters

  • x number: Where it stands along x, in world units.
  • y number: Its height, in world units.
  • z number: Where it stands along z, in world units.
  • turn number: Its turn about the up axis, in degrees.
  • scale number: Its scale.
  • shade number: Its shade, 1 for the asset's own color.

Empty()

This action removes every copy, placed and worked out.

GetAsset()

This action returns the asset's number in the foliage list.

Returns

integer: The number.

GetCellSize()

This action returns how wide the cell is, in world units.

Returns

number: The width.

GetCellX()

This action returns the cell's place along x, in cells from the origin.

Returns

integer: The place.

GetCellZ()

This action returns the cell's place along z, in cells from the origin.

Returns

integer: The place.

GetCount()

This action returns how many copies the cell holds.

Returns

integer: The count.

GetGeneratedCount()

This action returns how many copies were worked out from coverage.

Returns

integer: The count.

GetHighestY()

This action returns the highest height of any copy, or 0 when empty.

Returns

number: The height, in world units.

GetLowestY()

This action returns the lowest height of any copy, or 0 when empty.

Returns

number: The height, in world units.

GetPlacedCount()

This action returns how many copies a program placed.

Returns

integer: The count.

GetScale(integer index)

This action returns a copy's scale.

Parameters

  • index integer: The copy, from 0.

Returns

number: The scale.

GetShade(integer index)

This action returns a copy's shade.

Parameters

  • index integer: The copy, from 0.

Returns

number: The shade, 1 for the asset's own color.

GetTurn(integer index)

This action returns a copy's turn about the up axis.

Parameters

  • index integer: The copy, from 0.

Returns

number: The turn, in degrees.

GetX(integer index)

This action returns where a copy stands along x.

Parameters

  • index integer: The copy, from 0.

Returns

number: The x, in world units.

GetY(integer index)

This action returns a copy's height.

Parameters

  • index integer: The copy, from 0.

Returns

number: The y, in world units.

GetZ(integer index)

This action returns where a copy stands along z.

Parameters

  • index integer: The copy, from 0.

Returns

number: The z, in world units.

IsEmpty()

This action returns true if the cell holds no copies.

Returns

boolean: True when empty.

RemoveNear(number x, number z, number radius)

This action removes the copies whose middles are within a distance of a point, measured across the ground (x and z). Copies worked out from coverage come back the next time the cell is worked out, unless the coverage there is lowered.

Parameters

  • x number: The point along x, in world units.
  • z number: The point along z, in world units.
  • radius number: The distance, in world units.

Returns

integer: How many copies were removed.

Set(integer assetNumber, integer x, integer z, number size)

This action sets which asset the cell holds and where the cell is.

Parameters

  • assetNumber integer: The asset's number in the foliage list.
  • x integer: The cell's place along x, in cells from the origin.
  • z integer: The cell's place along z, in cells from the origin.
  • size number: How wide a cell is, in world units.

SetAsset(integer assetNumber)

This action changes which asset number the cell holds, such as after the list's assets were reordered.

Parameters

  • assetNumber integer: The new number.

SetGenerated(Libraries.Containers.Array<number> numbers)

This action replaces the copies worked out from coverage, keeping the placed ones. TerrainFoliage calls it.

Parameters

SetY(integer index, number y)

This action moves a copy up or down, such as after the ground under it was sculpted.

Parameters

  • index integer: The copy, from 0.
  • y number: Its new height, in world units.

Inherited Actions

3 actions from Libraries.Language.Object