35 lines
1.3 KiB
GDScript

extends Node3D
@export var day_length := 120.0 # seconds for full rotation
@export var start_light_angle := -90.0
@export var show_spawn_dialog := true
@export_multiline var spawn_dialog_text := "Welcome to Promiscuity.\n\nPress E to close this message."
@export var spawn_dialog_auto_close_seconds := 4.0
var end_light_angle = start_light_angle + 360.0
var start_radians = start_light_angle * PI / 180
var time := 0.0
@onready var sun := $DirectionalLight3D
func _ready() -> void:
if show_spawn_dialog and DialogSystem and DialogSystem.has_method("show_text"):
await get_tree().process_frame
DialogSystem.show_text(spawn_dialog_text)
if spawn_dialog_auto_close_seconds > 0.0:
await get_tree().create_timer(spawn_dialog_auto_close_seconds).timeout
if DialogSystem and DialogSystem.has_method("close_if_text"):
DialogSystem.close_if_text(spawn_dialog_text)
func _process(delta):
time = fmod((time + delta), day_length)
var t = time / day_length
# Rotate sun around X axis
var angle = lerp(start_light_angle, end_light_angle, t) # sunrise → sunset → night → sunrise
sun.rotation_degrees.x = angle
# Adjust intensity
var curSin = -sin((t * TAU) + start_radians)
var energy = clamp((curSin * 1.0) + 0.2, 0.0, 1.2)
sun.light_energy = energy