Adds procedural ground tile generation with chunking for improved performance. Includes: - Ground tile entity with debug text and cell information - Grass and tree placement based on cell data - Ground shader for visual representation - Chunk loading and unloading system based on player position
29 lines
710 B
GDScript
29 lines
710 B
GDScript
# GroundTile.gd
|
|
class_name GroundTile
|
|
extends Node3D
|
|
|
|
@onready var debug_text: Label = $DebugText/DebugTextViewport/DebugTextLabel
|
|
var grid_x: int
|
|
var grid_z: int
|
|
var cell_info: CellDataResource = null:
|
|
set(value):
|
|
cell_info = value
|
|
if cell_info != null:
|
|
cell_info_updated.emit(value)
|
|
|
|
var rng: RandomClass = RandomClass.new()
|
|
|
|
signal cell_info_updated(value)
|
|
|
|
func _ready() -> void:
|
|
if cell_info != null:
|
|
update_text_label()
|
|
rng.set_seed(cell_info.cell_seed)
|
|
|
|
func set_grid_location(x, z) -> void:
|
|
grid_x = x
|
|
grid_z = z
|
|
cell_info = MapData.get_map_data(grid_x, grid_z)
|
|
|
|
func update_text_label() -> void:
|
|
debug_text.text = str(grid_x) + ', ' + str(grid_z) + ', ' + str(cell_info.cell_seed)
|