frame-of-mind/src/logic-scenes/board/card.gd

49 lines
1.6 KiB
GDScript3
Raw Normal View History

2023-04-19 16:53:24 +00:00
@tool
extends Control
class_name Card
var compatible_postits: Array[PostIt] = []
var own_postits: Array[PostIt] = []
2023-04-19 16:53:24 +00:00
@export var text: String = "" :
set (value):
2023-05-28 14:18:26 +00:00
text = value
2023-04-19 16:53:24 +00:00
if is_inside_tree() or Engine.is_editor_hint():
$Label.text = value
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
2023-05-28 14:18:26 +00:00
if is_inside_tree():
$BackgroundSprite.void_active = value == ""
2023-04-19 16:53:24 +00:00
@export var voice_line: AudioStream = null
func _ready():
2023-04-19 16:53:24 +00:00
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)
2023-04-19 16:53:24 +00:00
$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
2023-04-19 16:53:24 +00:00
func _on_focus_entered():
print(self, "is focused")
func _on_focus_exited():
print(self, "is not focused")