diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-13 18:09:30 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-13 18:09:30 -0400 |
commit | 617e31fce21eb18d1ffccdc9c377d25535157351 (patch) | |
tree | c1fbcee75a67062663a0fe1ff00f4be1db382be1 /Archipelago/client.gd | |
parent | 679bba3b46ea30a329c617b3cc47645d540a261f (diff) | |
download | lingo-archipelago-617e31fce21eb18d1ffccdc9c377d25535157351.tar.gz lingo-archipelago-617e31fce21eb18d1ffccdc9c377d25535157351.tar.bz2 lingo-archipelago-617e31fce21eb18d1ffccdc9c377d25535157351.zip |
It WORKS!
You can send checks and receive door items!
Diffstat (limited to 'Archipelago/client.gd')
-rw-r--r-- | Archipelago/client.gd | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 74fe6e9..cbddf89 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -16,12 +16,21 @@ var _location_name_to_id = {} | |||
16 | 16 | ||
17 | const uuid_util = preload("user://maps/Archipelago/vendor/uuid.gd") | 17 | const uuid_util = preload("user://maps/Archipelago/vendor/uuid.gd") |
18 | 18 | ||
19 | # TODO: caching per MW/slot, reset between connections | ||
19 | var _authenticated = false | 20 | var _authenticated = false |
20 | var _team = 0 | 21 | var _team = 0 |
21 | var _slot = 0 | 22 | var _slot = 0 |
22 | var _players = [] | 23 | var _players = [] |
23 | var _checked_locations = [] | 24 | var _checked_locations = [] |
24 | var _slot_data = {} | 25 | var _slot_data = {} |
26 | var _door_ids_by_item = {} | ||
27 | var _mentioned_doors = [] | ||
28 | var _painting_ids_by_item = {} | ||
29 | var _mentioned_paintings = [] | ||
30 | var _panel_ids_by_location = {} | ||
31 | |||
32 | var _map_loaded = false | ||
33 | var _held_items = [] | ||
25 | 34 | ||
26 | signal client_connected | 35 | signal client_connected |
27 | 36 | ||
@@ -104,12 +113,36 @@ func _on_data(): | |||
104 | _checked_locations = message["checked_locations"] | 113 | _checked_locations = message["checked_locations"] |
105 | _slot_data = message["slot_data"] | 114 | _slot_data = message["slot_data"] |
106 | 115 | ||
116 | if _slot_data.has("door_ids_by_item_id"): | ||
117 | _door_ids_by_item = _slot_data["door_ids_by_item_id"] | ||
118 | |||
119 | _mentioned_doors = [] | ||
120 | for item in _door_ids_by_item.values(): | ||
121 | for door in item: | ||
122 | _mentioned_doors.append(door) | ||
123 | if _slot_data.has("painting_ids_by_item_id"): | ||
124 | _painting_ids_by_item = _slot_data["painting_ids_by_item_id"] | ||
125 | |||
126 | _mentioned_paintings = [] | ||
127 | for item in _painting_ids_by_item.values(): | ||
128 | for painting in item: | ||
129 | _mentioned_paintings.append(painting) | ||
130 | if _slot_data.has("panel_ids_by_location_id"): | ||
131 | _panel_ids_by_location = _slot_data["panel_ids_by_location_id"] | ||
132 | |||
107 | emit_signal("client_connected") | 133 | emit_signal("client_connected") |
108 | 134 | ||
109 | elif cmd == "ConnectionRefused": | 135 | elif cmd == "ConnectionRefused": |
110 | global._print("Connection to AP refused") | 136 | global._print("Connection to AP refused") |
111 | global._print(message) | 137 | global._print(message) |
112 | 138 | ||
139 | elif cmd == "ReceivedItems": | ||
140 | for item in message["items"]: | ||
141 | if _map_loaded: | ||
142 | processItem(item["item"]) | ||
143 | else: | ||
144 | _held_items.append(item["item"]) | ||
145 | |||
113 | 146 | ||
114 | func _process(_delta): | 147 | func _process(_delta): |
115 | if _should_process: | 148 | if _should_process: |
@@ -170,3 +203,40 @@ func connectToRoom(): | |||
170 | } | 203 | } |
171 | ] | 204 | ] |
172 | ) | 205 | ) |
206 | |||
207 | |||
208 | func sendLocation(loc_id): | ||
209 | sendMessage([{"cmd": "LocationChecks", "locations": [loc_id]}]) | ||
210 | |||
211 | |||
212 | func mapFinishedLoading(): | ||
213 | if !_map_loaded: | ||
214 | _map_loaded = true | ||
215 | |||
216 | for item in _held_items: | ||
217 | processItem(item) | ||
218 | |||
219 | _held_items = [] | ||
220 | |||
221 | |||
222 | func processItem(item): | ||
223 | global._print(item) | ||
224 | |||
225 | var stringified = String(item) | ||
226 | if _door_ids_by_item.has(stringified): | ||
227 | var doorsNode = get_tree().get_root().get_node("Spatial/Doors") | ||
228 | for door_id in _door_ids_by_item[stringified]: | ||
229 | doorsNode.get_node(door_id).openDoor() | ||
230 | |||
231 | if _painting_ids_by_item.has(stringified): | ||
232 | var paintingsNode = get_tree().get_root().get_node("Spatial/Decorations/Paintings") | ||
233 | for painting_id in _painting_ids_by_item[stringified]: | ||
234 | paintingsNode.get_node(painting_id).movePainting() | ||
235 | |||
236 | |||
237 | func doorIsVanilla(door): | ||
238 | return !_mentioned_doors.has(door) | ||
239 | |||
240 | |||
241 | func paintingIsVanilla(painting): | ||
242 | return !_mentioned_paintings.has(painting) | ||