summaryrefslogtreecommitdiff
path: root/Game/Selection
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-06 22:35:04 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-06 22:35:04 +0100
commit63d2a59042fb9d90a586ad85d8364de7c38aea8e (patch)
treef4c648b39313f10f44898d0216a9147dfb4ba491 /Game/Selection
parentf20b3a48a14f34def41d823fabb476981ef7055e (diff)
next commit
Diffstat (limited to 'Game/Selection')
-rw-r--r--Game/Selection/SelectionManager.gd24
-rw-r--r--Game/Selection/SelectionManager.tscn6
2 files changed, 30 insertions, 0 deletions
diff --git a/Game/Selection/SelectionManager.gd b/Game/Selection/SelectionManager.gd
index c58dc69..49cb319 100644
--- a/Game/Selection/SelectionManager.gd
+++ b/Game/Selection/SelectionManager.gd
@@ -2,5 +2,29 @@ class_name SelectionManager
extends Node
+var selection_groups := {}
+
+signal selected_group_changed
+var selected_group := "":
+ set(value):
+ selected_group = value
+ selected_group_changed.emit()
+
+
func _ready() -> void:
pass
+
+
+func change_selection_group_id(towers: Array[Tower], previous_id: String, new_id: String) -> void:
+ if new_id not in selection_groups:
+ selection_groups[new_id] = []
+
+ selection_groups[new_id].append_array(towers)
+
+ for tower in towers:
+ selection_groups[previous_id].erase(tower)
+
+ if selection_groups[previous_id].is_empty():
+ selection_groups.erase(previous_id)
+ if previous_id == selected_group:
+ selected_group = new_id
diff --git a/Game/Selection/SelectionManager.tscn b/Game/Selection/SelectionManager.tscn
new file mode 100644
index 0000000..e89880f
--- /dev/null
+++ b/Game/Selection/SelectionManager.tscn
@@ -0,0 +1,6 @@
+[gd_scene load_steps=2 format=3 uid="uid://mgm4npqeybbr"]
+
+[ext_resource type="Script" path="res://Game/Selection/SelectionManager.gd" id="1_1w5l7"]
+
+[node name="SelectionManager" type="Node"]
+script = ExtResource("1_1w5l7")