2026-01-21 22:46:46 +00:00
|
|
|
extends Control
|
2026-01-22 10:02:58 +00:00
|
|
|
## An interactive sequence (mostly in UI space) that can be play()ed.
|
2026-01-17 11:11:21 +00:00
|
|
|
class_name Playable
|
|
|
|
|
|
2026-01-22 10:02:58 +00:00
|
|
|
|
2026-01-18 20:01:20 +00:00
|
|
|
func _ready() -> void:
|
2026-01-22 10:02:58 +00:00
|
|
|
prints("playable.gd", "_ready()", self)
|
2026-01-18 20:23:37 +00:00
|
|
|
hide()
|
2026-01-22 10:02:58 +00:00
|
|
|
# HACK: Lets us debug playables more easily
|
|
|
|
|
if get_parent() == get_tree().root: _debug_mode()
|
2026-01-18 20:01:20 +00:00
|
|
|
|
2026-01-21 21:35:35 +00:00
|
|
|
|
2026-01-17 11:11:21 +00:00
|
|
|
## Awaitable that encapsulates the core interaction with this Playable
|
|
|
|
|
func play() -> void:
|
2026-01-18 18:37:11 +00:00
|
|
|
push_warning("Playeable[base].play() not overridden")
|
2026-01-17 11:11:21 +00:00
|
|
|
await get_tree().process_frame # Dummy wait so this is a coroutine
|
2026-01-18 09:48:03 +00:00
|
|
|
|
2026-01-18 18:37:11 +00:00
|
|
|
func handle_hover(_area: Draggable):
|
|
|
|
|
#prints("Playable[base].handle_hover", _area, _area.name)
|
2026-01-18 16:32:31 +00:00
|
|
|
pass
|
2026-01-18 20:23:37 +00:00
|
|
|
|
2026-01-18 20:53:19 +00:00
|
|
|
const TRANSPARENT_BLACK := Color(0,0,0,0)
|
|
|
|
|
|
2026-01-18 20:23:37 +00:00
|
|
|
func appear():
|
2026-01-18 20:53:19 +00:00
|
|
|
self.modulate = TRANSPARENT_BLACK
|
2026-01-18 20:23:37 +00:00
|
|
|
show()
|
|
|
|
|
var tween := create_tween().set_ease(Tween.EASE_IN)
|
2026-01-18 20:53:19 +00:00
|
|
|
tween.tween_property(self, "modulate", Color.WHITE, 0.3)
|
2026-01-18 20:23:37 +00:00
|
|
|
await tween.finished
|
2026-01-21 22:46:46 +00:00
|
|
|
|
2026-01-18 20:23:37 +00:00
|
|
|
func vanish():
|
|
|
|
|
var tween := create_tween().set_ease(Tween.EASE_OUT)
|
2026-01-18 20:53:19 +00:00
|
|
|
tween.tween_property(self, "modulate", TRANSPARENT_BLACK, 0.3)
|
2026-01-18 20:23:37 +00:00
|
|
|
await tween.finished
|
|
|
|
|
hide()
|
2026-01-22 10:02:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Override this (and call super._debug_mode()) if you want to initialize some data
|
|
|
|
|
## for running this playable standalone ("play current scene")
|
|
|
|
|
func _debug_mode():
|
|
|
|
|
push_warning("playable.gd: DEBUG MODE - ", self)
|
|
|
|
|
await get_tree().create_timer(1).timeout
|
|
|
|
|
play()
|