Save game when the window is closed

master
Marc Gilleron 2021-05-02 18:10:16 +01:00
parent a3814445db
commit aa87dabbf1
1 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,7 @@
extends Node
onready var _light = $DirectionalLight
onready var _terrain = $VoxelTerrain
func _unhandled_input(event):
@ -11,3 +12,14 @@ func _unhandled_input(event):
# Toggle shadows
_light.shadow_enabled = not _light.shadow_enabled
func _notification(what: int):
match what:
NOTIFICATION_WM_QUIT_REQUEST:
# Save game when the user closes the window
_save_world()
func _save_world():
_terrain.save_modified_blocks()