Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
Lobby.cs
Go to the documentation of this file.
1using System;
3using Steamworks;
4
6
7public class Lobby
8{
10
11 private byte[] _messageBuffer = new byte[1024];
12
13 public CSteamID Id = CSteamID.Nil;
14
15 public CSteamID Owner = CSteamID.Nil;
16
18
20
22
24
26
27 public Lobby()
28 {
29 //IL_001c: Unknown result type (might be due to invalid IL or missing references)
30 //IL_0021: Unknown result type (might be due to invalid IL or missing references)
31 //IL_0027: Unknown result type (might be due to invalid IL or missing references)
32 //IL_002c: Unknown result type (might be due to invalid IL or missing references)
35 }
36
38 {
39 //IL_000c: Unknown result type (might be due to invalid IL or missing references)
40 //IL_0011: Unknown result type (might be due to invalid IL or missing references)
41 //IL_001f: Unknown result type (might be due to invalid IL or missing references)
42 SteamAPICall_t val = SteamMatchmaking.CreateLobby((ELobbyType)(!inviteOnly), 256);
45 State = LobbyState.Creating;
46 }
47
48 public void OpenInviteOverlay()
49 {
50 //IL_0019: Unknown result type (might be due to invalid IL or missing references)
51 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
52 if (State == LobbyState.Inactive)
53 {
54 SteamFriends.ActivateGameOverlayInviteDialog(new CSteamID(Main.LobbyId));
55 }
56 else
57 {
58 SteamFriends.ActivateGameOverlayInviteDialog(Id);
59 }
60 }
61
63 {
64 //IL_0017: Unknown result type (might be due to invalid IL or missing references)
65 //IL_0018: Unknown result type (might be due to invalid IL or missing references)
66 //IL_001d: Unknown result type (might be due to invalid IL or missing references)
67 //IL_0024: Unknown result type (might be due to invalid IL or missing references)
68 if (State == LobbyState.Inactive)
69 {
70 State = LobbyState.Connecting;
74 }
75 }
76
77 public byte[] GetMessage(int index)
78 {
79 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
80 CSteamID val = default(CSteamID);
82 int lobbyChatEntry = SteamMatchmaking.GetLobbyChatEntry(Id, index, ref val, _messageBuffer, _messageBuffer.Length, ref val2);
83 byte[] array = new byte[lobbyChatEntry];
85 return array;
86 }
87
88 public int GetUserCount()
89 {
90 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
91 return SteamMatchmaking.GetNumLobbyMembers(Id);
92 }
93
94 public CSteamID GetUserByIndex(int index)
95 {
96 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
97 //IL_0007: Unknown result type (might be due to invalid IL or missing references)
98 return SteamMatchmaking.GetLobbyMemberByIndex(Id, index);
99 }
100
101 public bool SendMessage(byte[] data)
102 {
103 return SendMessage(data, data.Length);
104 }
105
106 public bool SendMessage(byte[] data, int length)
107 {
108 //IL_000c: Unknown result type (might be due to invalid IL or missing references)
109 if (State != LobbyState.Active)
110 {
111 return false;
112 }
113 return SteamMatchmaking.SendLobbyChatMsg(Id, data, length);
114 }
115
116 public void Set(CSteamID lobbyId)
117 {
118 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
119 //IL_0002: Unknown result type (might be due to invalid IL or missing references)
120 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
121 //IL_0010: Unknown result type (might be due to invalid IL or missing references)
122 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
123 Id = lobbyId;
124 State = LobbyState.Active;
125 Owner = SteamMatchmaking.GetLobbyOwner(lobbyId);
126 }
127
128 public void SetPlayedWith(CSteamID userId)
129 {
130 //IL_0006: Unknown result type (might be due to invalid IL or missing references)
131 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
132 //IL_001b: Unknown result type (might be due to invalid IL or missing references)
134 {
135 SteamFriends.SetPlayedWith(userId);
137 }
138 }
139
140 public void Leave()
141 {
142 //IL_000a: Unknown result type (might be due to invalid IL or missing references)
143 if (State == LobbyState.Active)
144 {
145 SteamMatchmaking.LeaveLobby(Id);
146 }
147 State = LobbyState.Inactive;
149 }
150
151 private void OnLobbyEntered(LobbyEnter_t result, bool failure)
152 {
153 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
154 //IL_0024: Unknown result type (might be due to invalid IL or missing references)
155 //IL_0029: Unknown result type (might be due to invalid IL or missing references)
156 //IL_0030: Unknown result type (might be due to invalid IL or missing references)
157 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
158 //IL_003a: Unknown result type (might be due to invalid IL or missing references)
159 //IL_0045: Unknown result type (might be due to invalid IL or missing references)
160 if (State == LobbyState.Connecting)
161 {
162 if (failure)
163 {
164 State = LobbyState.Inactive;
165 }
166 else
167 {
168 State = LobbyState.Active;
169 }
170 Id = new CSteamID(result.m_ulSteamIDLobby);
171 Owner = SteamMatchmaking.GetLobbyOwner(Id);
172 _lobbyEnterExternalCallback.Invoke(result, failure);
173 }
174 }
175
176 private void OnLobbyCreated(LobbyCreated_t result, bool failure)
177 {
178 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
179 //IL_0024: Unknown result type (might be due to invalid IL or missing references)
180 //IL_0029: Unknown result type (might be due to invalid IL or missing references)
181 //IL_0030: Unknown result type (might be due to invalid IL or missing references)
182 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
183 //IL_003a: Unknown result type (might be due to invalid IL or missing references)
184 //IL_0045: Unknown result type (might be due to invalid IL or missing references)
185 if (State == LobbyState.Creating)
186 {
187 if (failure)
188 {
189 State = LobbyState.Inactive;
190 }
191 else
192 {
193 State = LobbyState.Active;
194 }
195 Id = new CSteamID(result.m_ulSteamIDLobby);
196 Owner = SteamMatchmaking.GetLobbyOwner(Id);
197 _lobbyCreatedExternalCallback.Invoke(result, failure);
198 }
199 }
200}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void ICollection< T >. Add(T item)
Definition HashSet.cs:225
static ulong LobbyId
Definition Main.cs:389
void Join(CSteamID lobbyId, APIDispatchDelegate< LobbyEnter_t > callResult)
Definition Lobby.cs:62
byte[] GetMessage(int index)
Definition Lobby.cs:77
CallResult< LobbyEnter_t > _lobbyEnter
Definition Lobby.cs:19
void OnLobbyEntered(LobbyEnter_t result, bool failure)
Definition Lobby.cs:151
HashSet< CSteamID > _usersSeen
Definition Lobby.cs:9
APIDispatchDelegate< LobbyEnter_t > _lobbyEnterExternalCallback
Definition Lobby.cs:21
bool SendMessage(byte[] data)
Definition Lobby.cs:101
CSteamID GetUserByIndex(int index)
Definition Lobby.cs:94
bool SendMessage(byte[] data, int length)
Definition Lobby.cs:106
APIDispatchDelegate< LobbyCreated_t > _lobbyCreatedExternalCallback
Definition Lobby.cs:25
CallResult< LobbyCreated_t > _lobbyCreated
Definition Lobby.cs:23
void Set(CSteamID lobbyId)
Definition Lobby.cs:116
void OnLobbyCreated(LobbyCreated_t result, bool failure)
Definition Lobby.cs:176
void Create(bool inviteOnly, APIDispatchDelegate< LobbyCreated_t > callResult)
Definition Lobby.cs:37
void SetPlayedWith(CSteamID userId)
Definition Lobby.cs:128