# Hurry Curry! - a game about cooking # Copyright 2024 metamuffin # Copyright 2024 tpart # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, version 3 of the License only. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # class_name SceneTransition extends Control @onready var anim: AnimationPlayer = $AnimationPlayer var s_current = false var s_target = false var fading = false func _ready(): $ColorRect.visible = true func next(): while fading: await anim.animation_finished if s_target == s_current: return fading = true if s_target: anim.play_backwards("fade") await anim.animation_finished self.mouse_filter = Control.MOUSE_FILTER_IGNORE s_current = true else: self.mouse_filter = Control.MOUSE_FILTER_STOP anim.play("fade") await anim.animation_finished s_current = false fading = false await next() func fade_in(): s_target = true await next() func fade_out(): s_target = false await next() func _exit_tree(): if fading: push_error("SceneTransition destroyed while fading")