OpenLiberty/scripts/world.gd

45 lines
1.4 KiB
GDScript3
Raw Permalink Normal View History

2022-11-14 20:20:41 +07:00
extends Node
2022-11-14 20:58:49 +07:00
@onready var sun = $sun
@onready var moon = $moon
@onready var sky = $WorldEnvironment
2024-08-15 19:25:32 -03:00
var car := preload("res://scenes/car.tscn")
2025-03-04 19:36:02 +07:00
var map_loader: MapLoader
2022-11-19 05:06:08 +07:00
2022-11-14 20:58:49 +07:00
func _ready() -> void:
2025-03-04 19:36:02 +07:00
map_loader = MapLoader.new()
add_child(map_loader)
# Connect signals for progress updates
map_loader.loading_progress.connect(_on_loading_progress)
2025-03-05 13:10:38 +07:00
# TODO: Implement a proper loading screen before enabling threaded loading
# For now, load the map directly
var world_node := map_loader.load_map()
2025-03-05 13:10:38 +07:00
# Add world to scene and setup environment
add_child(world_node)
sky.environment = load("res://scenes/world/day.tres")
moon.visible = not moon.visible
2022-11-20 04:07:41 +07:00
2025-03-05 13:10:38 +07:00
func _on_loading_progress(progress: float) -> void:
print("Loading: %d%%" % int(progress * 100))
2022-11-20 04:07:41 +07:00
func _unhandled_input(event: InputEvent) -> void:
2024-08-15 19:25:32 -03:00
if Input.is_action_pressed("spawn"):
var car_node := car.instantiate()
add_child(car_node)
car_node.global_position = get_viewport().get_camera_3d().global_position
func _input(event):
if Input.is_action_just_pressed("full_screen"):
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
#else:
#DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
if Input.is_action_just_pressed("night_toggle"):
sky.environment = load("res://scenes/world/night.tres")
sun.visible = not sun.visible
moon.visible = not moon.visible
#if sun.visible = true
#sky.environment = load("res://scenes/world/day.tres")