49 lines
1.6 KiB
GDScript
49 lines
1.6 KiB
GDScript
@tool
|
|
|
|
extends Control
|
|
class_name Card
|
|
var compatible_postits: Array[PostIt] = []
|
|
var own_postits: Array[PostIt] = []
|
|
|
|
@export var text: String = "" :
|
|
set (value):
|
|
text = value
|
|
if is_inside_tree() or Engine.is_editor_hint():
|
|
$Label.text = value
|
|
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
|
if is_inside_tree():
|
|
$BackgroundSprite.void_active = value == ""
|
|
@export var voice_line: AudioStream = null
|
|
|
|
func _ready():
|
|
if not Engine.is_editor_hint() and is_inside_tree():
|
|
for postit in self.get_children():
|
|
if postit is PostIt: self.own_postits.append(postit as PostIt)
|
|
|
|
for postit in get_tree().get_nodes_in_group(name):
|
|
if postit is PostIt: self.compatible_postits.append(postit as PostIt)
|
|
|
|
compatible_postits.append_array(own_postits)
|
|
|
|
if own_postits.size() == 2:
|
|
own_postits[0].sibling = own_postits[1]
|
|
own_postits[1].sibling = own_postits[0]
|
|
|
|
$BackgroundSprite.frame = randi() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
|
$Label.text = self.text
|
|
|
|
func _process(delta: float) -> void:
|
|
pass
|
|
|
|
func replace_with(card: Card):
|
|
self.text = card.text
|
|
self.compatible_postits = card.compatible_postits
|
|
self.own_postits = card.own_postits
|
|
self.voice_line = card.voice_line
|
|
|
|
func _on_focus_entered():
|
|
print(self, "is focused")
|
|
|
|
func _on_focus_exited():
|
|
print(self, "is not focused")
|