about summary refs log tree commit diff stats
path: root/apworld/client/client.gd
diff options
context:
space:
mode:
Diffstat (limited to 'apworld/client/client.gd')
-rw-r--r--apworld/client/client.gd65
1 files changed, 59 insertions, 6 deletions
diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 62d7fd8..c149482 100644 --- a/apworld/client/client.gd +++ b/apworld/client/client.gd
@@ -25,6 +25,8 @@ var _slot_data = {}
25var _accessible_locations = [] 25var _accessible_locations = []
26var _accessible_worldports = [] 26var _accessible_worldports = []
27var _goal_accessible = false 27var _goal_accessible = false
28var _latched_doors = []
29var _hinted_locations = []
28 30
29signal could_not_connect 31signal could_not_connect
30signal connect_status 32signal connect_status
@@ -34,10 +36,13 @@ signal location_scout_received(location_id, item_name, player_name, flags, for_s
34signal text_message_received(message) 36signal text_message_received(message)
35signal item_sent_notification(message) 37signal item_sent_notification(message)
36signal hint_received(message) 38signal hint_received(message)
39signal door_latched(id)
37signal accessible_locations_updated 40signal accessible_locations_updated
38signal checked_locations_updated 41signal checked_locations_updated
42signal ignored_locations_updated(locations)
39signal checked_worldports_updated 43signal checked_worldports_updated
40signal keyboard_update_received 44signal keyboard_update_received
45signal hinted_locations_updated
41 46
42 47
43func _init(): 48func _init():
@@ -108,7 +113,7 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo
108 113
109 _checked_locations = [] 114 _checked_locations = []
110 for location in message["checked_locations"]: 115 for location in message["checked_locations"]:
111 _checked_locations.append(int(message["checked_locations"])) 116 _checked_locations.append(int(location))
112 117
113 client_connected.emit(_slot_data) 118 client_connected.emit(_slot_data)
114 119
@@ -158,11 +163,7 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo
158 elif cmd == "LocationInfo": 163 elif cmd == "LocationInfo":
159 for loc in message["locations"]: 164 for loc in message["locations"]:
160 location_scout_received.emit( 165 location_scout_received.emit(
161 int(loc["id"]), 166 int(loc["id"]), loc["item"], loc["player"], int(loc["flags"]), int(loc["self"])
162 loc["item"],
163 loc["player"],
164 int(loc["flags"]),
165 int(loc["for_self"])
166 ) 167 )
167 168
168 elif cmd == "AccessibleLocations": 169 elif cmd == "AccessibleLocations":
@@ -187,6 +188,35 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo
187 188
188 keyboard_update_received.emit(updates) 189 keyboard_update_received.emit(updates)
189 190
191 elif cmd == "PathReply":
192 var textclient = global.get_node("Textclient")
193 textclient.display_logical_path(
194 message["type"], int(message.get("id", null)), message["path"]
195 )
196
197 elif cmd == "UpdateLatches":
198 for id in message["latches"]:
199 var iid = int(id)
200 if not _latched_doors.has(iid):
201 _latched_doors.append(iid)
202
203 door_latched.emit(iid)
204
205 elif cmd == "SetIgnoredLocations":
206 var locs = []
207 for id in message["locations"]:
208 locs.append(int(id))
209
210 ignored_locations_updated.emit(locs)
211
212 elif cmd == "UpdateHintedLocations":
213 for id in message["locations"]:
214 var iid = int(id)
215 if !_hinted_locations.has(iid):
216 _hinted_locations.append(iid)
217
218 hinted_locations_updated.emit()
219
190 220
191func connectToServer(server, un, pw): 221func connectToServer(server, un, pw):
192 sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) 222 sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}])
@@ -253,6 +283,29 @@ func checkWorldport(port_id):
253 sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}]) 283 sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}])
254 284
255 285
286func latchDoor(id):
287 if not _latched_doors.has(id):
288 _latched_doors.append(id)
289
290 sendMessage([{"cmd": "LatchDoor", "door": id}])
291
292
293func getLogicalPath(object_type, object_id):
294 var msg = {"cmd": "GetPath", "type": object_type}
295 if object_id != null:
296 msg["id"] = object_id
297
298 sendMessage([msg])
299
300
301func addIgnoredLocation(loc_id):
302 sendMessage([{"cmd": "IgnoreLocation", "id": loc_id}])
303
304
305func removeIgnoredLocation(loc_id):
306 sendMessage([{"cmd": "UnignoreLocation", "id": loc_id}])
307
308
256func sendQuit(): 309func sendQuit():
257 sendMessage([{"cmd": "Quit"}]) 310 sendMessage([{"cmd": "Quit"}])
258 311