update game_menu
This commit was merged in pull request #40.
This commit is contained in:
@@ -12,6 +12,10 @@ var environment_config: EnvironmentConfig
|
||||
@export var time_scale: float = 1.0
|
||||
@export var paused: bool = false
|
||||
|
||||
var _time_tween: Tween
|
||||
|
||||
var time_transition_duration: float = 2
|
||||
|
||||
signal time_changed(time: float)
|
||||
|
||||
var current_time: float = 0.0
|
||||
@@ -67,16 +71,30 @@ func get_time_option_index(currtime: float) -> int:
|
||||
return TIME_OPTION_DAY
|
||||
return TIME_OPTION_SUNSET
|
||||
|
||||
|
||||
|
||||
func _time_option_changed(index: int) -> void:
|
||||
var target_time: float = 0.0
|
||||
match index:
|
||||
TIME_OPTION_SUNRISE:
|
||||
set_time(environment_config.sunrise)
|
||||
target_time = environment_config.sunrise
|
||||
TIME_OPTION_DAY:
|
||||
set_time(environment_config.day)
|
||||
target_time = environment_config.day
|
||||
TIME_OPTION_SUNSET:
|
||||
set_time(environment_config.sunset)
|
||||
target_time = environment_config.sunset
|
||||
TIME_OPTION_NIGHT:
|
||||
set_time(environment_config.night)
|
||||
target_time = environment_config.night
|
||||
|
||||
if _time_tween:
|
||||
_time_tween.kill()
|
||||
|
||||
_time_tween = create_tween()
|
||||
|
||||
# Always move forward in time for a natural transition
|
||||
if target_time < current_time:
|
||||
target_time += 1.0
|
||||
|
||||
_time_tween.tween_method(set_time, current_time, target_time, time_transition_duration)
|
||||
|
||||
func _on_set_day_time(value: float) -> void:
|
||||
set_time(value)
|
||||
|
||||
Reference in New Issue
Block a user