generated from krampus/template-godot4
52 lines
1.2 KiB
GDScript3
52 lines
1.2 KiB
GDScript3
|
extends Level
|
||
|
|
||
|
@export var game_environment: Environment
|
||
|
@export var debug_environment: Environment
|
||
|
|
||
|
@onready var world_environment: WorldEnvironment = %WorldEnvironment
|
||
|
@onready var post_processing: ColorRect = %PostProcessing
|
||
|
|
||
|
@onready var props: Node3D = %Props
|
||
|
@onready var vending_machine: MeshInstance3D = %VendingMachine
|
||
|
|
||
|
|
||
|
func _clean_tree(node: Node) -> void:
|
||
|
if node is GunkBody:
|
||
|
(node as GunkBody).clear_all()
|
||
|
else:
|
||
|
for child: Node in node.get_children():
|
||
|
_clean_tree(child)
|
||
|
|
||
|
|
||
|
func clean_all_props() -> void:
|
||
|
print("Cleaning all props in the scene...")
|
||
|
_clean_tree(props)
|
||
|
|
||
|
|
||
|
func reset_level() -> void:
|
||
|
print("Reloading world with current scene...")
|
||
|
(
|
||
|
Game
|
||
|
. instance
|
||
|
. queue_load(
|
||
|
World.instance.current_level_scene.resource_path, ResourceLoader.CACHE_MODE_REPLACE_DEEP
|
||
|
)
|
||
|
. then(LoadingTools._load_world)
|
||
|
)
|
||
|
|
||
|
|
||
|
func toggle_vending_machine() -> void:
|
||
|
vending_machine.set("powered", not vending_machine.get("powered"))
|
||
|
|
||
|
|
||
|
func set_game_environment() -> void:
|
||
|
world_environment.environment = game_environment
|
||
|
|
||
|
|
||
|
func set_debug_environment() -> void:
|
||
|
world_environment.environment = debug_environment
|
||
|
|
||
|
|
||
|
func toggle_postprocessing() -> void:
|
||
|
post_processing.visible = not post_processing.visible
|