2025-01-05 11:25:13 +00:00
|
|
|
@tool
|
2025-01-03 08:07:35 +00:00
|
|
|
class_name Ground2D extends Node2D
|
2024-12-25 12:24:34 +00:00
|
|
|
|
|
|
|
@export var scene_config: SceneConfig
|
2025-01-05 11:25:13 +00:00
|
|
|
@export var reload := false:
|
|
|
|
set(new_val):
|
|
|
|
reload = false
|
|
|
|
load_config()
|
2024-12-25 12:24:34 +00:00
|
|
|
|
2025-01-05 11:25:13 +00:00
|
|
|
@onready var directional_light := %DirectionalLight2D as DirectionalLight2D
|
2024-12-25 12:24:34 +00:00
|
|
|
@onready var foreground = %ParallaxForeground as ParallaxBackground
|
|
|
|
|
2024-12-27 13:32:12 +00:00
|
|
|
var footstep_audio = RandomAudioStreamPlayer.new()
|
2024-12-25 12:24:34 +00:00
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
foreground.layer = GlobalConfig.CANVAS_LAYER_FG
|
2025-01-03 13:29:22 +00:00
|
|
|
# %ColorRectTop.visible = true
|
|
|
|
# %ColorRectBottom.visible = true
|
2024-12-27 13:32:12 +00:00
|
|
|
add_child(footstep_audio)
|
2025-01-05 11:25:13 +00:00
|
|
|
load_config()
|
2024-12-25 12:24:34 +00:00
|
|
|
|
|
|
|
|
2025-01-05 11:25:13 +00:00
|
|
|
func load_config():
|
2024-12-25 12:24:34 +00:00
|
|
|
if not scene_config:
|
|
|
|
return
|
|
|
|
var type = scene_config.footstep_type
|
2025-01-05 11:25:13 +00:00
|
|
|
# foot step sound
|
2024-12-25 12:24:34 +00:00
|
|
|
footstep_audio.audio_collections.clear()
|
2025-01-05 11:25:13 +00:00
|
|
|
if type != "none":
|
|
|
|
var audio = SceneConfig.FOOTSTEP_AUDIO[type] as AudioStreamCollection
|
|
|
|
footstep_audio.audio_collections.append(audio)
|
|
|
|
# light color
|
|
|
|
# directional_light.color = scene_config.light_color
|
2024-12-25 12:24:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
func play_footstep_sound() -> void:
|
2024-12-27 13:32:12 +00:00
|
|
|
if not footstep_audio.audio_collections.is_empty():
|
2024-12-25 12:24:34 +00:00
|
|
|
footstep_audio.play_random()
|