diff --git a/COGITO/Components/LightzoneComponent.tscn b/COGITO/Components/LightzoneComponent.tscn index c33a587b..c68daca2 100644 --- a/COGITO/Components/LightzoneComponent.tscn +++ b/COGITO/Components/LightzoneComponent.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://ctr7n0w3hgys7"] +[gd_scene load_steps=4 format=3 uid="uid://ctr7n0w3hgys7"] [ext_resource type="Script" path="res://COGITO/Components/LightzoneComponent.gd" id="1_ga3m3"] +[ext_resource type="Script" path="res://COGITO/Components/LightzoneSwitchComponent.gd" id="2_5rlei"] [sub_resource type="SphereShape3D" id="SphereShape3D_t8ref"] radius = 1.5 @@ -11,5 +12,8 @@ script = ExtResource("1_ga3m3") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("SphereShape3D_t8ref") +[node name="LightzoneSwitchComponent" type="Node" parent="."] +script = ExtResource("2_5rlei") + [connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="body_exited" from="." to="." method="_on_body_exited"] diff --git a/COGITO/Components/LightzoneSwitchComponent.gd b/COGITO/Components/LightzoneSwitchComponent.gd new file mode 100644 index 00000000..0645ff01 --- /dev/null +++ b/COGITO/Components/LightzoneSwitchComponent.gd @@ -0,0 +1,11 @@ +extends Node + +## Sets if parent lightzone should respond to CogitoSwitch "switched" signal. +@export var switchable: bool = true + +## Connect to CogitoSwitch.gd "switched" signal to enable +func _on_switched(is_on: bool): + if switchable: + var lightzone: Area3D = get_parent() + if lightzone: + lightzone.set_monitoring(is_on) diff --git a/COGITO/PrefabScenes/ceiling_lamp.tscn b/COGITO/PrefabScenes/ceiling_lamp.tscn index d2bcc681..c777b8d5 100644 --- a/COGITO/PrefabScenes/ceiling_lamp.tscn +++ b/COGITO/PrefabScenes/ceiling_lamp.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://lsun1f1wjfxl"] +[gd_scene load_steps=8 format=3 uid="uid://lsun1f1wjfxl"] [ext_resource type="Script" path="res://COGITO/Scripts/Cogito_Switch.gd" id="1_ueccq"] [ext_resource type="AudioStream" uid="uid://0himm415mqex" path="res://COGITO/Assets/Audio/Kenney/UiAudio/switch29.ogg" id="2_bq20n"] [ext_resource type="Material" uid="uid://cprws42ycnkgk" path="res://COGITO/Assets/Materials/Lamp_Shade.tres" id="2_va873"] +[ext_resource type="PackedScene" uid="uid://ctr7n0w3hgys7" path="res://COGITO/Components/LightzoneComponent.tscn" id="4_lybt7"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_05p8f"] albedo_color = Color(1, 0.890196, 0.631373, 1) @@ -14,6 +15,10 @@ rim = 0.0 height = 0.2 radius = 0.3 +[sub_resource type="CylinderShape3D" id="CylinderShape3D_0ljm4"] +height = 2.62204 +radius = 1.0 + [node name="CeilingLamp" type="AnimatableBody3D" node_paths=PackedStringArray("nodes_to_show_when_on", "nodes_to_hide_when_on")] transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, -23.8641, 1.7, 5.40424) script = ExtResource("1_ueccq") @@ -50,3 +55,13 @@ bus = &"SFX" [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("CylinderShape3D_n08oq") + +[node name="LightzoneComponent" parent="." instance=ExtResource("4_lybt7")] + +[node name="CollisionShape3D" parent="LightzoneComponent" index="0"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.5774, 0) +shape = SubResource("CylinderShape3D_0ljm4") + +[connection signal="switched" from="." to="LightzoneComponent/LightzoneSwitchComponent" method="_on_switched"] + +[editable path="LightzoneComponent"]