Switches and doors are working

This commit is contained in:
Derek
2024-10-11 22:29:41 -05:00
parent fc29636ee6
commit 346a686780
7 changed files with 73 additions and 25 deletions

3
scripts/signal_bus.gd Normal file
View File

@@ -0,0 +1,3 @@
extends Node
signal switch_changed()

View File

@@ -2,18 +2,20 @@ extends Node3D
var switched_on
@export var default_setting : bool = false
@export var start_on : bool = false
@export var toggle_enabled : bool = false
@export var bullet_enabled : bool = true
@export var timer_enabled : bool = false
@export var timer_duration : float = 2.0
signal switch_on()
signal switch_off()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
add_to_group("switch")
add_to_group("interact")
switched_on = default_setting
switched_on = start_on
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -21,27 +23,18 @@ func _process(delta: float) -> void:
pass
func interact():
print("switch hit")
if toggle_enabled:
if switched_on:
if switched_on == true:
switched_on = false
SignalBus.emit_signal("switch_changed")
else:
switched_on = true
SignalBus.emit_signal("switch_changed")
else:
print("switched on")
switched_on = true
SignalBus.emit_signal("switch_changed")
func _on_static_body_3d_switch_hit() -> void:
if bullet_enabled:
print("switch hit")
if toggle_enabled:
if switched_on:
switched_on = false
else:
print("switched on")
switched_on = true
else:
print("switched on")
switched_on = true
interact()