Skip to content

Commit

Permalink
Merge pull request #88 from kk1201/switchable-lightzone
Browse files Browse the repository at this point in the history
Lightzone Switch component
  • Loading branch information
Phazorknight authored Feb 28, 2024
2 parents d9807ac + 3556053 commit 84ae70d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
6 changes: 5 additions & 1 deletion COGITO/Components/LightzoneComponent.tscn
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
11 changes: 11 additions & 0 deletions COGITO/Components/LightzoneSwitchComponent.gd
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 16 additions & 1 deletion COGITO/PrefabScenes/ceiling_lamp.tscn
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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")
Expand Down Expand Up @@ -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"]

0 comments on commit 84ae70d

Please sign in to comment.