From ef7f856ec315cb0a2025623c470f87e7fa826106 Mon Sep 17 00:00:00 2001 From: Tusharjamdade Date: Thu, 29 Jan 2026 18:37:36 +0000 Subject: [PATCH 1/2] feat: Add sink availability indicator with blinking light Signed-off-by: Tusharjamdade --- Scenes/sink.tscn | 18 ++++++++++++++++-- Scripts/sink.gd | 23 +++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Scenes/sink.tscn b/Scenes/sink.tscn index 28c867d..6b62b67 100644 --- a/Scenes/sink.tscn +++ b/Scenes/sink.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://whu4rwgsyl8u"] +[gd_scene load_steps=6 format=3 uid="uid://whu4rwgsyl8u"] [ext_resource type="Texture2D" uid="uid://cgnmmfc1l4d5d" path="res://2D Assets/sinks/sink.png" id="1_0ywo5"] [ext_resource type="Script" path="res://Scripts/SinkClick.gd" id="2_16xt0"] @@ -7,6 +7,13 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_7l3ci"] size = Vector2(443.333, 408.333) +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_circle"] +bg_color = Color(0, 1, 0, 1) +corner_radius_top_left = 50 +corner_radius_top_right = 50 +corner_radius_bottom_right = 50 +corner_radius_bottom_left = 50 + [node name="Sink" type="Sprite2D"] position = Vector2(946.667, 863.333) texture = ExtResource("1_0ywo5") @@ -20,4 +27,11 @@ script = ExtResource("2_16xt0") position = Vector2(0, -5.83331) shape = SubResource("RectangleShape2D_7l3ci") -[connection signal="area_entered" from="Area2D" to="Area2D" method="_on_area_entered"] +[node name="IndicatorLight" type="Panel" parent="."] +offset_left = -25.0 +offset_top = -25.0 +offset_right = 25.0 +offset_bottom = 25.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_circle") + +[connection signal="area_entered" from="Area2D" to="Area2D" method="_on_area_entered"] \ No newline at end of file diff --git a/Scripts/sink.gd b/Scripts/sink.gd index 4939319..65e9ed0 100644 --- a/Scripts/sink.gd +++ b/Scripts/sink.gd @@ -2,12 +2,23 @@ extends Sprite2D @export var expectedType: String +var _available := true -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. +@export var available: bool = true: + set(value): + _available = value + if indicator_light: + indicator_light.visible = value + get: + return _available + +@onready var indicator_light: Control = $IndicatorLight +func _ready() -> void: + if indicator_light: + indicator_light.visible = available -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass +func _process(_delta: float) -> void: + if available and indicator_light: + var time = Time.get_ticks_msec() / 200.0 + indicator_light.modulate.a = 0.6 + sin(time) * 0.4 From 6cec238bc3712120d935a14a9f89995145c4245e Mon Sep 17 00:00:00 2001 From: Tusharjamdade Date: Thu, 29 Jan 2026 18:47:57 +0000 Subject: [PATCH 2/2] bug fix Signed-off-by: Tusharjamdade --- Scenes/sink.tscn | 1 + Scripts/sink.gd | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Scenes/sink.tscn b/Scenes/sink.tscn index 6b62b67..9dc7e48 100644 --- a/Scenes/sink.tscn +++ b/Scenes/sink.tscn @@ -32,6 +32,7 @@ offset_left = -25.0 offset_top = -25.0 offset_right = 25.0 offset_bottom = 25.0 +mouse_filter = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_circle") [connection signal="area_entered" from="Area2D" to="Area2D" method="_on_area_entered"] \ No newline at end of file diff --git a/Scripts/sink.gd b/Scripts/sink.gd index 65e9ed0..1283476 100644 --- a/Scripts/sink.gd +++ b/Scripts/sink.gd @@ -2,15 +2,11 @@ extends Sprite2D @export var expectedType: String -var _available := true - @export var available: bool = true: set(value): - _available = value + available = value if indicator_light: indicator_light.visible = value - get: - return _available @onready var indicator_light: Control = $IndicatorLight @@ -21,4 +17,4 @@ func _ready() -> void: func _process(_delta: float) -> void: if available and indicator_light: var time = Time.get_ticks_msec() / 200.0 - indicator_light.modulate.a = 0.6 + sin(time) * 0.4 + indicator_light.modulate.a = 0.6 + (sin(time) * 0.4) \ No newline at end of file