extends "res://scripts/multiplayer.gd" var queued_messages = [] var queued_messages_mutex = Mutex.new() func _request_lobby_list(): var apclient = global.get_node("Archipelago") Steam.addRequestLobbyListStringFilter( "archipelago", apclient._seed, Steam.LOBBY_COMPARISON_EQUAL ) ._request_lobby_list() func _on_lobby_created(result: int, lobby_id: int) -> void: if result != Steam.RESULT_OK: return var apclient = global.get_node("Archipelago") var _ignore = Steam.setLobbyData(lobby_id, "archipelago", apclient._seed) ._on_lobby_created(result, lobby_id) func _on_lobby_joined(lobby_id: int, permissions: int, locked: bool, result: int) -> void: if result != Steam.RESULT_OK: return var apclient = global.get_node("Archipelago") Steam.setLobbyMemberData(lobby_id, "slot_name", apclient._player_name_by_slot[apclient._slot]) ._on_lobby_joined(lobby_id, permissions, locked, result) func _update_lobby_members(): ._update_lobby_members() if active_lobby_id == 0: return var lobby_size: int = Steam.getNumLobbyMembers(active_lobby_id) for i in range(0, lobby_size): var member_id: int = Steam.getLobbyMemberByIndex(active_lobby_id, i) if member_id != player_steam_id and member_id in active_lobby_members: var slot_name = Steam.getLobbyMemberData(active_lobby_id, member_id, "slot_name") active_lobby_members[member_id].steam_name = slot_name func say(text): queued_messages_mutex.lock() queued_messages.append(text) queued_messages_mutex.unlock() func _physics_process(_delta): if queued_messages_mutex.try_lock() == OK: if queued_messages.empty(): queued_messages_mutex.unlock() else: var messages = queued_messages.duplicate() queued_messages = [] queued_messages_mutex.unlock() var player = get_tree().get_root().get_node("Spatial/player") var space_state = get_tree().get_root().get_world().direct_space_state var nearby_members = [] for member_id in active_lobby_members.keys(): var other_member = active_lobby_members[member_id] var ray = space_state.intersect_ray( player.global_translation, other_member.global_translation, [player], 0b0101 ) if !("collider" in ray) or ray["collider"] == other_member: # Visible! nearby_members.append(member_id) var apclient = global.get_node("Archipelago") var player_name = apclient.get_player_name() for member_id in nearby_members: for msg in messages: _send_p2p_packet( {"solves": [{"say": msg, "from": player_name}]}, member_id, Steam.P2P_SEND_RELIABLE, true ) # I'm completely hijacking this callback, since we're in ghost mode and it won't be called normally. func _receive_solve(data): if "say" in data: get_tree().get_root().get_node("Spatial/AP_TextClient").parse_printjson( "[LOCAL] [color=#fafad2]%s[/color]: %s" % [data["from"], data["say"]] ) messages.showMessage("[color=#fafad2]%s[/color]: %s" % [data["from"], data["say"]]) func _send_hi(_discard): pass /effects.gd
blob: 1e2e3113bbd34e2b71d318d33bb68abd9e6c21e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252