27 lines
935 B
GDScript
27 lines
935 B
GDScript
class_name MapPopulationClass
|
|
extends Node
|
|
|
|
var map_data: Array = Global.map_data
|
|
|
|
## Generate the CellDataResource for a given cell
|
|
## Setup the X and Z
|
|
## If it's a path or water we do nothing else for now
|
|
## If it's anything else then we need to:
|
|
## Set grass density directly from the vegetation density
|
|
## Then do the following:
|
|
## Density < 0.5 - chance of spawning special stuff and nothing else
|
|
## Density > 0.6 - add trees, varying quantity from 0.6 to 1
|
|
## Density 0.1 to 0.6 - add bushes, varying quantity TBD
|
|
## Density 0.1 to 0.4 - add flowers, varying quantity TBD
|
|
|
|
static func generate_cell(x: int, z: int, density: float, path: bool = false, water: bool = false):
|
|
var cell_data = CellDataResource.new()
|
|
cell_data.x = x
|
|
cell_data.z = z
|
|
cell_data.vegetation_density = density
|
|
|
|
if not (path or water):
|
|
if density >= 0.6:
|
|
cell_data.add_trees(int(density * 10 / 3))
|
|
|
|
Global.map_data[x][z] = cell_data
|