immersive-home/app/content/ui/onboarding/onboarding.gd

44 lines
1.3 KiB
GDScript3
Raw Normal View History

2024-03-17 18:05:45 +02:00
extends Node3D
@onready var getting_started_button = $GettingStartedButton
@onready var close_button = $CloseButton
2024-04-26 15:42:30 +03:00
var next_new_position = null
2024-03-17 18:05:45 +02:00
func _ready():
2024-04-26 15:42:30 +03:00
next_new_position = global_position
2024-03-17 18:05:45 +02:00
if Store.settings.is_loaded() == false:
await Store.settings.on_loaded
2024-04-09 18:46:59 +03:00
if (Store.settings.state.url != ""&&Store.settings.state.url != null)||Store.settings.state.onboarding_complete:
2024-03-17 18:05:45 +02:00
close()
return
getting_started_button.on_button_down.connect(func():
OS.shell_open("https://docs.immersive-home.org/")
)
close_button.on_button_down.connect(func():
close()
)
EventSystem.on_slow_tick.connect(_slow_tick)
func close():
2024-04-09 18:46:59 +03:00
Store.settings.state.onboarding_complete = true
2024-03-17 18:05:45 +02:00
Store.settings.save_local()
queue_free()
func _slow_tick(delta):
2024-05-22 19:38:28 +03:00
var new_position = App.camera.global_position + App.camera.global_transform.basis.z * - 0.5
2024-03-17 18:05:45 +02:00
if next_new_position.distance_to(new_position) > 0.2:
next_new_position = new_position
2024-05-22 19:38:28 +03:00
var new_direction = Basis.looking_at((App.camera.global_position - new_position) * - 1)
2024-03-17 18:05:45 +02:00
var tween = create_tween()
tween.set_parallel(true)
tween.set_trans(Tween.TransitionType.TRANS_QUAD)
tween.tween_property(self, "global_position", new_position, 0.6)
tween.tween_property(self, "global_transform:basis", new_direction, 0.6)