changement du scene manager, amélioration du cockpit et autres

* refonte du scene manager
* refonte du audio manager
* premier rework des plantes
* nettoyage des dossiers/fichiers
* renommage de planète en region
* fix des run
This commit is contained in:
2026-01-23 18:06:27 +01:00
parent 62b34473b6
commit 83d462f2f4
247 changed files with 2964 additions and 3159 deletions

View File

@@ -0,0 +1,13 @@
[gd_scene load_steps=8 format=3 uid="uid://dac5wte80dwj0"]
[ext_resource type="Script" uid="uid://bb44144ckt2w7" path="res://common/scene_manager/scripts/scene_manager.gd" id="1_1c0qu"]
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="2_c1lr7"]
[ext_resource type="Resource" uid="uid://bvksiaiocwob5" path="res://common/scene_manager/scenes/cockpit.tres" id="3_e28ni"]
[ext_resource type="Resource" uid="uid://bvgdq43fpl1xs" path="res://common/scene_manager/scenes/intro.tres" id="4_msho1"]
[ext_resource type="Resource" uid="uid://boqgwjyxyb45r" path="res://common/scene_manager/scenes/region.tres" id="5_ytog4"]
[ext_resource type="Resource" uid="uid://c27wenetitwm" path="res://common/scene_manager/scenes/region_selection.tres" id="6_chs32"]
[ext_resource type="Resource" uid="uid://diro74w272onp" path="res://common/scene_manager/scenes/title.tres" id="7_ol3d5"]
[node name="SceneManager" type="Node"]
script = ExtResource("1_1c0qu")
scenes = Array[ExtResource("2_c1lr7")]([ExtResource("3_e28ni"), ExtResource("4_msho1"), ExtResource("5_ytog4"), ExtResource("6_chs32"), ExtResource("7_ol3d5")])

View File

@@ -0,0 +1,10 @@
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://bvksiaiocwob5"]
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_tkiq8"]
[resource]
script = ExtResource("1_tkiq8")
scene_id = "COCKPIT"
scene_path = "res://stages/cockpit/cockpit.tscn"
mouse_captured = true
metadata/_custom_type_script = "uid://1ejbvr3431ac"

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://bvgdq43fpl1xs"]
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_6ws88"]
[resource]
script = ExtResource("1_6ws88")
scene_id = "INTRO"
scene_path = "res://stages/intro/intro.tscn"
metadata/_custom_type_script = "uid://1ejbvr3431ac"

View File

@@ -0,0 +1,10 @@
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://boqgwjyxyb45r"]
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_10qbh"]
[resource]
script = ExtResource("1_10qbh")
scene_id = "REGION"
scene_path = "res://stages/terrain/region/region.tscn"
need_terrain_generated = true
metadata/_custom_type_script = "uid://1ejbvr3431ac"

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://c27wenetitwm"]
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_smjh0"]
[resource]
script = ExtResource("1_smjh0")
scene_id = "REGION_SELECTION"
scene_path = "res://stages/region_selection/region_selection.tscn"
metadata/_custom_type_script = "uid://1ejbvr3431ac"

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://diro74w272onp"]
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_48g2j"]
[resource]
script = ExtResource("1_48g2j")
scene_id = "TITLE"
scene_path = "res://stages/title_screen/title_screen.tscn"
metadata/_custom_type_script = "uid://1ejbvr3431ac"

View File

@@ -0,0 +1,7 @@
extends Resource
class_name Scene
@export var scene_id : String
@export_file_path() var scene_path : String
@export var mouse_captured := false
@export var need_terrain_generated := false

View File

@@ -0,0 +1 @@
uid://1ejbvr3431ac

View File

@@ -1,25 +1,39 @@
extends Node
const TITLE_SCREEN = "res://stages/title_screen/title_screen.tscn"
const PLANET_SCENE = "res://stages/terrain/planet/planet.tscn"
const TRUCK_SCENE = "res://stages/terrain/truck/truck.tscn"
const INTRO_SCENE = "res://stages/intro/intro.tscn"
const COCKPIT_SCENE = "res://stages/cockpit/cockpit.tscn"
const REGION_SELECTION_SCREEN = "res://stages/region_selection/region_selection.tscn"
@export var scenes : Array[Scene]
signal scene_loaded
signal scene_node_ready
signal scene_loaded(scene : Scene)
signal scene_node_ready(scene : Scene)
var loading_scene = false
var generating_node = false
var scene_to_load := ""
var actual_scene : Scene = null
var next_scene_node : Node
@onready var current_scene_node : Node = get_tree().root.get_children().back()
func change_scene(scene_path : String, with_loading = true):
func search_scenes(scene_id : String) -> Scene:
var scene_pos : int = scenes.find_custom(
func (s : Scene):
return s.scene_id == scene_id
)
if scene_pos == -1:
return null
else :
return scenes[scene_pos]
func change_scene(scene_id : String, with_loading = true):
if loading_scene or generating_node:
await scene_node_ready
var scene = search_scenes(scene_id)
if not scene:
printerr("Scene %s not found" % scene_id)
return
actual_scene = scene
loading_scene = true
scene_to_load = scene_path
ResourceLoader.load_threaded_request(scene_to_load)
var scene_path_to_load = scene.scene_path
ResourceLoader.load_threaded_request(scene_path_to_load)
LoadingScreen.loading_text = "LOADING_SCENE"
var scene_to_hide = current_scene_node
if with_loading:
@@ -31,16 +45,16 @@ func change_scene(scene_path : String, with_loading = true):
if loading_scene:
await scene_loaded
next_scene_node = ResourceLoader.load_threaded_get(scene_to_load).instantiate()
next_scene_node = ResourceLoader.load_threaded_get(scene_path_to_load).instantiate()
if next_scene_node.has_method("hide"):
next_scene_node.hide()
get_tree().root.add_child(next_scene_node)
generating_node = true
if next_scene_node is Planet:
if scene.need_terrain_generated:
LoadingScreen.loading_text = "GENERATING_TERRAIN"
if generating_node:
await scene_node_ready
await scene_node_ready
if current_scene_node:
current_scene_node.queue_free()
@@ -48,23 +62,27 @@ func change_scene(scene_path : String, with_loading = true):
if current_scene_node.has_method("show"):
current_scene_node.show()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if scene.mouse_captured else Input.MOUSE_MODE_VISIBLE
if with_loading:
LoadingScreen.hide_loading_screen()
func _process(_delta):
if loading_scene:
var progress = []
var load_status := ResourceLoader.load_threaded_get_status(scene_to_load, progress)
var load_status := ResourceLoader.load_threaded_get_status(actual_scene.scene_path, progress)
LoadingScreen.loading_value = progress[0]
if load_status == ResourceLoader.THREAD_LOAD_LOADED:
loading_scene = false
scene_loaded.emit()
scene_loaded.emit(actual_scene)
if load_status == ResourceLoader.THREAD_LOAD_FAILED or load_status == ResourceLoader.THREAD_LOAD_INVALID_RESOURCE:
printerr()
elif generating_node:
if next_scene_node is Planet:
if next_scene_node is Region:
LoadingScreen.loading_value = next_scene_node.generated_value
if next_scene_node.is_generated:
generating_node = false
scene_node_ready.emit()
elif next_scene_node.is_node_ready():
generating_node = false
scene_node_ready.emit()
scene_node_ready.emit(actual_scene)