From ace887b1d8d735b701790c5137ef7113393ed06f Mon Sep 17 00:00:00 2001 From: betalars Date: Sun, 28 May 2023 15:41:25 +0200 Subject: [PATCH] update void card so it can be used generally --- src/logic-scenes/board/card.gd | 2 ++ src/logic-scenes/board/void_card.tscn | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/logic-scenes/board/card.gd b/src/logic-scenes/board/card.gd index fb8ac44..abfac60 100644 --- a/src/logic-scenes/board/card.gd +++ b/src/logic-scenes/board/card.gd @@ -10,6 +10,8 @@ var own_postits: Array[PostIt] = [] if is_inside_tree() or Engine.is_editor_hint(): $Label.text = value $BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation) + + $BackgroundSprite.void_active = text == "" text = value @export var voice_line: AudioStream = null diff --git a/src/logic-scenes/board/void_card.tscn b/src/logic-scenes/board/void_card.tscn index 3e59a36..ed78f9b 100644 --- a/src/logic-scenes/board/void_card.tscn +++ b/src/logic-scenes/board/void_card.tscn @@ -56,10 +56,17 @@ script/source = "extends AnimatedSprite2D @onready var initial_position = position var noise_position = randf() var noise: Noise = FastNoiseLite.new() - +var void_active: + set(become_void): + if not (void_active == become_void): + if is_inside_tree(): + $GPUParticles2D.is_void = become_void + $GPUParticles2D.emitting = become_void + $Sprite2D.is_void = become_void + void_active = become_void func _process(delta): - if not State.reduce_motion: + if void_active and not State.reduce_motion: noise_position += delta * 10 var random_position = Vector2(noise.get_noise_1d(noise_position*2), noise.get_noise_1d(-noise_position)) @@ -119,15 +126,19 @@ attractor_interaction_enabled = false [sub_resource type="GDScript" id="GDScript_vjwk7"] script/source = "extends GPUParticles2D +var is_void:bool = false + func _process(_delta): - self.visible = !State.reduce_motion + self.visible = !State.reduce_motion and is_void " [sub_resource type="GDScript" id="GDScript_tgc0b"] script/source = "extends Sprite2D +var is_void:bool = false + func _process(_delta): - self.visible = State.reduce_motion + self.visible = State.reduce_motion and is_void " [node name="card" type="Control"] @@ -139,7 +150,6 @@ offset_right = 150.0 offset_bottom = 110.0 focus_mode = 2 script = ExtResource("1_6ceun") -compatible_postits = Array[Resource("res://logic-scenes/board/post-it.gd")]([null, null, null]) [node name="BackgroundSprite" type="AnimatedSprite2D" parent="."] clip_children = 2