Refactors tree spawning and rendering: - Adds seasonal color variations for trees via scripts. - Introduces `ColorStorage` to manage tree and grass colors - Removes unused code from tree spawning logic. - Adjusts ground tile color for better visual appeal. - Hides debug text on ground tiles.
53 lines
No EOL
2.1 KiB
GDScript
53 lines
No EOL
2.1 KiB
GDScript
class_name TreeDataResource
|
|
extends Resource
|
|
|
|
@export var tree_name: String = "Oak Tree"
|
|
@export var model: PackedScene
|
|
@export var icon: Texture2D
|
|
@export var growth_stages: Array[PackedScene] = []
|
|
|
|
@export_group("Biome Preferences")
|
|
@export var temperature_range: Vector2 = Vector2(0.3, 0.7) # Min/Max temperature
|
|
@export var moisture_range: Vector2 = Vector2(0.4, 0.8) # Min/Max moisture
|
|
@export var elevation_range: Vector2 = Vector2(0.0, 0.6) # Min/Max elevation
|
|
|
|
@export_group("Growth Properties")
|
|
@export var max_height: float = 15.0
|
|
@export var growth_time: float = 120.0 # Seconds to full growth
|
|
@export var spread_radius: float = 5.0
|
|
|
|
@export_group("Seasonal Behavior")
|
|
@export var seasonal_models: Array[PackedScene] = [] # Spring, Summer, Fall, Winter
|
|
@export var drops_leaves: bool = true
|
|
@export var leaf_color_variations: Array[Color] = []
|
|
|
|
@export_group("Tree Color Management")
|
|
@export var color_script: GDScript = null
|
|
|
|
@export_group("Leaf Colors")
|
|
@export var spring_leaf_color: Color = Color(0.0, 1.0, 0.0) # Green
|
|
@export var summer_leaf_color: Color = Color(0.0, 0.5, 0.0) # Darker green
|
|
@export var autumn_leaf_color: Color = Color(1.0, 0.5, 0.0) # Orange
|
|
@export var winter_leaf_color: Color = Color(0.5, 0.5, 0.5) # Gray/Brown
|
|
|
|
@export_group("Trunk Colors")
|
|
@export var spring_trunk_color: Color = Color(0.6, 0.4, 0.2) # Brown
|
|
@export var summer_trunk_color: Color = Color(0.5, 0.3, 0.1) # Darker brown
|
|
@export var autumn_trunk_color: Color = Color(0.4, 0.2, 0.1) # Darker brown
|
|
@export var winter_trunk_color: Color = Color(0.3, 0.2, 0.1) # Very dark brown
|
|
|
|
func apply_seasonal_colors(instance_model: Node3D, season: String = "summer") -> void:
|
|
if color_script == null:
|
|
return
|
|
|
|
var script_instance = color_script.new()
|
|
|
|
# Pass the tree name and season to the color script
|
|
if script_instance.has_method("set_tree_info"):
|
|
script_instance.set_tree_info(tree_name, season)
|
|
|
|
|
|
if script_instance.has_method("set_leaf_color"):
|
|
script_instance.set_leaf_color(instance_model)
|
|
if script_instance.has_method("set_trunk_color"):
|
|
script_instance.set_trunk_color(instance_model) |