34 lines
749 B
GDScript
34 lines
749 B
GDScript
extends Node3D
|
|
|
|
signal incremented
|
|
signal decremented
|
|
signal switchUpdated
|
|
|
|
@export var State = 0
|
|
@export var isLoopingUpdate : bool = false
|
|
|
|
func _interact_press(is_alt_click: bool = false) -> void:
|
|
if is_alt_click:
|
|
if State != 0:
|
|
State -= 1
|
|
$Sound.play()
|
|
emit_signal("decremented")
|
|
emit_signal("switchUpdated")
|
|
else:
|
|
if State != 2:
|
|
State += 1
|
|
$Sound.play()
|
|
emit_signal("incremented")
|
|
emit_signal("switchUpdated")
|
|
|
|
func _process(delta: float) -> void:
|
|
if State == 0:
|
|
$StaticBody3D.rotation_degrees = Vector3(0, 45, 0)
|
|
elif State == 1:
|
|
$StaticBody3D.rotation_degrees = Vector3(0, 0, 0)
|
|
elif State == 2:
|
|
$StaticBody3D.rotation_degrees = Vector3(0, -45, 0)
|
|
|
|
if isLoopingUpdate:
|
|
emit_signal("switchUpdated")
|