doors are now assigned via door script

This commit is contained in:
derek
2024-11-07 17:00:50 -06:00
parent a31e420330
commit f4be67996a
2 changed files with 22 additions and 17 deletions

View File

@@ -1943,9 +1943,8 @@ transform = Transform3D(0.015, -7.86969e-07, 2.74274e-07, 7.86945e-07, 0.015, 1.
mesh = SubResource("ArrayMesh_dt3jf")
skeleton = NodePath("")
[node name="Switch 1" type="Node" parent="." node_paths=PackedStringArray("door")]
[node name="Switch 1" type="Node" parent="."]
script = ExtResource("32_dncpy")
door = NodePath("Door1")
[node name="Door1" type="MeshInstance3D" parent="Switch 1" node_paths=PackedStringArray("anim_player")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 28.5934, 14.0814)

View File

@@ -1,8 +1,7 @@
extends Node
@export var door : Node
var switches = []
var doors = []
var switch_override : Node
# Called when the node enters the scene tree for the first time.
@@ -17,6 +16,8 @@ func _ready() -> void:
switch_override = i
else:
switches.append(i)
if i.is_in_group("door"):
doors.append(i)
#print("switches " + str(switches))
#print("override switches " + str(switch_override))
@@ -34,27 +35,32 @@ func _on_switch_changed() -> void:
print("null check passed")
if switch_override.switched_on:
print("switched on")
if door.door_open == false:
door.open()
else:
if door.door_open == true:
door.close()
for i in doors:
if i.door_open == false:
i.open()
else:
if i.door_open == false:
i.open()
#Otherwise follow standard switches
elif switches_on == switches_needed:
print("switch check run with " + str(switches_on) + "switches on")
if door.door_open == false:
door.open()
for i in doors:
if i.door_open == false:
i.open()
else:
print("switch check run with " + str(switches_on) + "switches on")
if door.door_open == true:
door.close()
for i in doors:
if i.door_open == true:
i.close()
#Otherwise follow standard switches
elif switches_on == switches_needed:
print("switch check run with " + str(switches_on) + "switches on")
if door.door_open == false:
door.open()
for i in doors:
if i.door_open == false:
i.open()
else:
print("switch check run with " + str(switches_on) + "switches on")
if door.door_open == true:
door.close()
for i in doors:
if i.door_open == true:
i.close()