5.0 KiB
Class: chunk
Represents a chunk in the world
Table of contents
Constructors
Methods
- add_texture
- apply
- apply_all
- apply_heightmap
- apply_textures
- apply_vertex_color
- clear_colors
- clear_textures
- get_area_id
- get_effect
- get_tex
- get_texture
- get_texture_count
- get_vert
- remove_texture
- set_area_id
- set_effect
- set_hole
- set_impassable
- to_selection
Constructors
constructor
+ new chunk(): chunk
Returns: chunk
Methods
add_texture
▸ add_texture(texture: string, effect: number): number
Adds a new texture at the current topmost layer.
note A chunk can hold at most 4 texture layers.
Parameters:
| Name | Type | Description |
|---|---|---|
texture |
string | |
effect |
number | effect id to add - -2 (default): does not change effect - -1: clears current effect index - 0+: change to this effect index |
Returns: number
texture index added to
apply
▸ apply(): void
Same as apply_all
Returns: void
apply_all
▸ apply_all(): void
Applies all changes in this chunk
Returns: void
apply_heightmap
▸ apply_heightmap(): void
Applies all changes to the heightmap in this chunk
Returns: void
apply_textures
▸ apply_textures(): void
Applies all changes to texture alphamaps in this chunk
Returns: void
apply_vertex_color
▸ apply_vertex_color(): void
Applies all changes to vertex colors in this chunk
Returns: void
clear_colors
▸ clear_colors(): void
Removes all vertex colors in this chunk
Returns: void
clear_textures
▸ clear_textures(): void
Removes all texture layers in this chunk
Returns: void
get_area_id
▸ get_area_id(): number
Returns the area id of a chunk
Returns: number
get_effect
▸ get_effect(layer: number): number
Returns the effect id at a texture layer
Parameters:
| Name | Type |
|---|---|
layer |
number |
Returns: number
get_tex
▸ get_tex(index: number): tex
Returns a texel by index in this chunk
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number | valid in range [0-4095] |
Returns: tex
get_texture
▸ get_texture(index: number): string
Returns the name of the texture at the specified layer.
Parameters:
| Name | Type |
|---|---|
index |
number |
Returns: string
get_texture_count
▸ get_texture_count(): number
Returns the amount of textures on this chunk
Returns: number
get_vert
▸ get_vert(index: number): vert
Returns a vertex by index in this chunk
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number | valid in range [0-144] |
Returns: vert
remove_texture
▸ remove_texture(index: number): void
Removes a texture layer from this chunk and decreases the texture ids of all higher layers by 1
Parameters:
| Name | Type |
|---|---|
index |
number |
Returns: void
set_area_id
▸ set_area_id(value: number): void
Changes the area id of a chunk
Parameters:
| Name | Type |
|---|---|
value |
number |
Returns: void
set_effect
▸ set_effect(layer: number, effect: number): any
Changes the effect id at a texture layer
Parameters:
| Name | Type | Description |
|---|---|---|
layer |
number | |
effect |
number | effect id to set (-1 to remove effects) |
Returns: any
set_hole
▸ set_hole(hole: boolean): void
Creates or removes a hole in this chunk
Parameters:
| Name | Type |
|---|---|
hole |
boolean |
Returns: void
set_impassable
▸ set_impassable(impassable: boolean): void
Sets whether this chunk should be impassable for players or not
Parameters:
| Name | Type |
|---|---|
impassable |
boolean |
Returns: void
to_selection
▸ to_selection(): selection
Returns a selection spanning this chunk
note - iterating will include border vert/texels
Returns: selection