diff options
Diffstat (limited to 'apworld/client/client.gd')
| -rw-r--r-- | apworld/client/client.gd | 65 |
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 = {} | |||
| 25 | var _accessible_locations = [] | 25 | var _accessible_locations = [] |
| 26 | var _accessible_worldports = [] | 26 | var _accessible_worldports = [] |
| 27 | var _goal_accessible = false | 27 | var _goal_accessible = false |
| 28 | var _latched_doors = [] | ||
| 29 | var _hinted_locations = [] | ||
| 28 | 30 | ||
| 29 | signal could_not_connect | 31 | signal could_not_connect |
| 30 | signal connect_status | 32 | signal connect_status |
| @@ -34,10 +36,13 @@ signal location_scout_received(location_id, item_name, player_name, flags, for_s | |||
| 34 | signal text_message_received(message) | 36 | signal text_message_received(message) |
| 35 | signal item_sent_notification(message) | 37 | signal item_sent_notification(message) |
| 36 | signal hint_received(message) | 38 | signal hint_received(message) |
| 39 | signal door_latched(id) | ||
| 37 | signal accessible_locations_updated | 40 | signal accessible_locations_updated |
| 38 | signal checked_locations_updated | 41 | signal checked_locations_updated |
| 42 | signal ignored_locations_updated(locations) | ||
| 39 | signal checked_worldports_updated | 43 | signal checked_worldports_updated |
| 40 | signal keyboard_update_received | 44 | signal keyboard_update_received |
| 45 | signal hinted_locations_updated | ||
| 41 | 46 | ||
| 42 | 47 | ||
| 43 | func _init(): | 48 | func _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 | ||
| 191 | func connectToServer(server, un, pw): | 221 | func 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 | ||
| 286 | func latchDoor(id): | ||
| 287 | if not _latched_doors.has(id): | ||
| 288 | _latched_doors.append(id) | ||
| 289 | |||
| 290 | sendMessage([{"cmd": "LatchDoor", "door": id}]) | ||
| 291 | |||
| 292 | |||
| 293 | func 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 | |||
| 301 | func addIgnoredLocation(loc_id): | ||
| 302 | sendMessage([{"cmd": "IgnoreLocation", "id": loc_id}]) | ||
| 303 | |||
| 304 | |||
| 305 | func removeIgnoredLocation(loc_id): | ||
| 306 | sendMessage([{"cmd": "UnignoreLocation", "id": loc_id}]) | ||
| 307 | |||
| 308 | |||
| 256 | func sendQuit(): | 309 | func sendQuit(): |
| 257 | sendMessage([{"cmd": "Quit"}]) | 310 | sendMessage([{"cmd": "Quit"}]) |
| 258 | 311 | ||
