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
xnumber: Where it stands along x, in world units.ynumber: Its height, in world units.znumber: Where it stands along z, in world units.turnnumber: Its turn about the up axis, in degrees.scalenumber: Its scale.shadenumber: 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
indexinteger: The copy, from 0.
Returns
number: The scale.
GetShade(integer index)
This action returns a copy's shade.
Parameters
indexinteger: 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
indexinteger: The copy, from 0.
Returns
number: The turn, in degrees.
GetX(integer index)
This action returns where a copy stands along x.
Parameters
indexinteger: The copy, from 0.
Returns
number: The x, in world units.
GetY(integer index)
This action returns a copy's height.
Parameters
indexinteger: The copy, from 0.
Returns
number: The y, in world units.
GetZ(integer index)
This action returns where a copy stands along z.
Parameters
indexinteger: 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
xnumber: The point along x, in world units.znumber: The point along z, in world units.radiusnumber: 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
assetNumberinteger: The asset's number in the foliage list.xinteger: The cell's place along x, in cells from the origin.zinteger: The cell's place along z, in cells from the origin.sizenumber: 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
assetNumberinteger: 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
numbersLibraries.Containers.Array<number>: The copies, six numbers each, as Add takes them.
SetY(integer index, number y)
This action moves a copy up or down, such as after the ground under it was sculpted.
Parameters
indexinteger: The copy, from 0.ynumber: Its new height, in world units.