diff --git a/maps/rust.tscn b/maps/rust.tscn index 08d524b..6461952 100644 --- a/maps/rust.tscn +++ b/maps/rust.tscn @@ -133,18 +133,19 @@ scale = Vector2( 1, 6 ) [node name="Button" parent="Environment" instance=ExtResource( 15 )] position = Vector2( 80, 113 ) +target_group = "button1" [node name="Button2" parent="Environment" instance=ExtResource( 15 )] position = Vector2( 728, 168 ) -switch_index = 3 +target_group = "button3" [node name="Button4" parent="Environment" instance=ExtResource( 15 )] position = Vector2( 272, 168 ) -switch_index = 4 +target_group = "button4" [node name="Button3" parent="Environment" instance=ExtResource( 15 )] position = Vector2( 520, 16 ) -switch_index = 2 +target_group = "button2" [node name="Barrier2" parent="Environment" instance=ExtResource( 22 )] position = Vector2( 332, 63 ) diff --git a/objects/environment/switches/button.gd b/objects/environment/switches/button.gd index 9cde8ca..7b15d53 100644 --- a/objects/environment/switches/button.gd +++ b/objects/environment/switches/button.gd @@ -1,3 +1,4 @@ +tool extends "res://objects/environment/switches/switch.gd" var pressed = false diff --git a/objects/environment/switches/switch.gd b/objects/environment/switches/switch.gd index 94091c1..41b2742 100644 --- a/objects/environment/switches/switch.gd +++ b/objects/environment/switches/switch.gd @@ -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)