tasty little switch refactoring and an extra dessert :) :3 :3

This commit is contained in:
Haze Weathers 2023-03-25 00:50:31 -04:00
parent 5684e5b3a0
commit a8e187a150
3 changed files with 19 additions and 6 deletions

View file

@ -1,3 +1,4 @@
tool
extends "res://objects/environment/switches/switch.gd"
var pressed = false

View file

@ -1,8 +1,19 @@
tool
extends Node2D
export var switch_index = 1
export var type = "switch"
export (String) var target_group = ""
func activate():
for object in get_tree().get_nodes_in_group(str(type) + str(switch_index)):
for object in get_tree().get_nodes_in_group(target_group):
object.switch_action()
func _process(delta):
# redraw lines every frame to account for things changing
if Engine.editor_hint and Engine.get_frames_drawn() % 10 == 0:
update()
func _draw():
if Engine.editor_hint:
for node in get_tree().get_nodes_in_group(target_group):
if node is Node2D:
draw_line(Vector2.ZERO, to_local(node.global_position), Color(0.2, 1.0, 0.0, 0.5), 1.5)