Implements bush and flower spawning on ground tiles based on vegetation density. Adds new assets for bushes and flowers, and introduces multi-mesh rendering for optimized performance. Introduces seasonal color variations for vegetation using a shader for bushes and materials for flowers and grass. Refactors material application into a MaterialManager to handle material assignments over multiple frames. Moves ground tile scripts into a subfolder. Adds floating particles to test scene.
36 lines
908 B
GDScript
36 lines
908 B
GDScript
# GrassController.gd
|
|
extends Node3D
|
|
class_name BushController
|
|
|
|
@onready var bush_multimesh: MultiMeshInstance3D = $BushMultimesh
|
|
var parent_node: GroundTile = null
|
|
var bush_density: float = 0.5
|
|
var bush_instance_range: int = 10
|
|
|
|
func _ready() -> void:
|
|
parent_node = get_parent() as GroundTile
|
|
|
|
func spawn_bushes_for_cell(value):
|
|
if value == null:
|
|
return
|
|
|
|
bush_density = value.vegetation_density
|
|
update_bush_density()
|
|
|
|
if bush_multimesh and bush_multimesh.has_method("setup_multimesh"):
|
|
bush_multimesh.setup_multimesh()
|
|
|
|
func update_bush_density() -> void:
|
|
if parent_node == null:
|
|
return
|
|
|
|
var rng = parent_node.get_rng()
|
|
|
|
if bush_density > 0.8:
|
|
bush_instance_range = rng.randi_range(5, 10)
|
|
elif bush_density > 0.6:
|
|
bush_instance_range = rng.randi_range(2, 7)
|
|
elif bush_density > 0.3:
|
|
bush_instance_range = rng.randi_range(0, 1)
|
|
else:
|
|
bush_instance_range = rng.randi_range(0, 0)
|