Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Lobby.cs
Go to the documentation of this file.
1using System;
2using rail;
3
5
6public class Lobby
7{
8 private RailCallBackHelper _callbackHelper = new RailCallBackHelper();
9
11
13
14 private IRailGameServer _gameServer;
15
16 public Action<RailID> _lobbyCreatedExternalCallback;
17
18 private RailID _server_id;
19
20 private IRailGameServer RailServerHelper
21 {
22 get
23 {
25 {
26 return _gameServer;
27 }
28 return null;
29 }
30 set
31 {
33 }
34 }
35
36 private IRailGameServerHelper GetRailServerHelper()
37 {
38 return rail_api.RailFactory().RailGameServerHelper();
39 }
40
42 {
43 //IL_001a: Unknown result type (might be due to invalid IL or missing references)
44 //IL_0024: Expected O, but got Unknown
45 if (_callbackHelper != null)
46 {
47 _callbackHelper.RegisterCallback((RAILEventID)3002, new RailEventCallBackHandler(OnRailEvent));
48 }
49 }
50
51 public void OnRailEvent(RAILEventID id, EventBase data)
52 {
53 //IL_0038: Unknown result type (might be due to invalid IL or missing references)
54 //IL_003e: Invalid comparison between Unknown and I4
55 //IL_0042: Unknown result type (might be due to invalid IL or missing references)
56 //IL_004c: Expected O, but got Unknown
57 WeGameHelper.WriteDebugString("OnRailEvent,id=" + ((object)(RAILEventID)(ref id)).ToString() + " ,result=" + ((object)(RailResult)(ref data.result)).ToString());
58 if ((int)id == 3002)
59 {
60 OnGameServerCreated((CreateGameServerResult)data);
61 }
62 }
63
64 private void OnGameServerCreated(CreateGameServerResult result)
65 {
66 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
67 if ((int)((EventBase)result).result == 0)
68 {
70 _lobbyCreatedExternalCallback(result.game_server_id);
71 _server_id = result.game_server_id;
72 }
73 }
74
75 public void Create(bool inviteOnly)
76 {
77 //IL_0018: Unknown result type (might be due to invalid IL or missing references)
78 //IL_001e: Expected O, but got Unknown
79 if (State == LobbyState.Inactive)
80 {
82 }
83 IRailGameServerHelper obj = rail_api.RailFactory().RailGameServerHelper();
84 CreateGameServerOptions val = new CreateGameServerOptions();
85 val.has_password = false;
86 val.enable_team_voice = false;
87 IRailGameServer railServerHelper = obj.AsyncCreateGameServer(val, "terraria", "terraria");
88 RailServerHelper = railServerHelper;
89 State = LobbyState.Creating;
90 }
91
92 public void OpenInviteOverlay()
93 {
94 //IL_0021: Unknown result type (might be due to invalid IL or missing references)
95 WeGameHelper.WriteDebugString("OpenInviteOverlay by wegame");
96 rail_api.RailFactory().RailFloatingWindow().AsyncShowRailFloatingWindow((EnumRailWindowType)10, "");
97 }
98
99 public void Join(RailID local_peer, RailID remote_peer)
100 {
101 if (State != 0)
102 {
103 WeGameHelper.WriteDebugString("Lobby connection attempted while already in a lobby. This should never happen?");
104 }
105 else
106 {
107 State = LobbyState.Connecting;
108 }
109 }
110
111 public byte[] GetMessage(int index)
112 {
113 return null;
114 }
115
116 public int GetUserCount()
117 {
118 return 0;
119 }
120
121 public RailID GetUserByIndex(int index)
122 {
123 return null;
124 }
125
126 public bool SendMessage(byte[] data)
127 {
128 return SendMessage(data, data.Length);
129 }
130
131 public bool SendMessage(byte[] data, int length)
132 {
133 return false;
134 }
135
136 public void Set(RailID lobbyId)
137 {
138 }
139
140 public void SetPlayedWith(RailID userId)
141 {
142 }
143
144 public void Leave()
145 {
146 State = LobbyState.Inactive;
147 }
148
149 public IRailGameServer GetServer()
150 {
151 return RailServerHelper;
152 }
153}
RailCallBackHelper _callbackHelper
Definition Lobby.cs:8
RailID GetUserByIndex(int index)
Definition Lobby.cs:121
IRailGameServer _gameServer
Definition Lobby.cs:14
void OnRailEvent(RAILEventID id, EventBase data)
Definition Lobby.cs:51
IRailGameServerHelper GetRailServerHelper()
Definition Lobby.cs:36
void Create(bool inviteOnly)
Definition Lobby.cs:75
void OnGameServerCreated(CreateGameServerResult result)
Definition Lobby.cs:64
byte[] GetMessage(int index)
Definition Lobby.cs:111
Action< RailID > _lobbyCreatedExternalCallback
Definition Lobby.cs:16
IRailGameServer RailServerHelper
Definition Lobby.cs:21
void SetPlayedWith(RailID userId)
Definition Lobby.cs:140
void Join(RailID local_peer, RailID remote_peer)
Definition Lobby.cs:99
bool SendMessage(byte[] data)
Definition Lobby.cs:126
IRailGameServer GetServer()
Definition Lobby.cs:149
void Set(RailID lobbyId)
Definition Lobby.cs:136
bool SendMessage(byte[] data, int length)
Definition Lobby.cs:131
static void WriteDebugString(string format, params object[] args)