This commit is contained in:
Mister_Nebula 2020-12-07 20:47:07 +00:00
parent 6ec83dac94
commit c56b23b34c
7 changed files with 189 additions and 2115 deletions

View File

@ -170,12 +170,6 @@ namespace QuantumUNET
return true;
}
public void Connect(MatchInfo matchInfo)
{
PrepareForConnect();
ConnectWithRelay(matchInfo);
}
public bool ReconnectToNewHost(string serverIp, int serverPort)
{
bool result;

View File

@ -8,62 +8,62 @@ namespace QuantumUNET
{
private void Awake()
{
this.manager = base.GetComponent<QSBNetworkManagerUNET>();
manager = GetComponent<QSBNetworkManagerUNET>();
}
private void OnGUI()
{
if (this.showGUI)
if (showGUI)
{
int num = 10 + this.offsetX;
int num2 = 40 + this.offsetY;
bool flag = this.manager.client == null || this.manager.client.connection == null || this.manager.client.connection.connectionId == -1;
if (!this.manager.IsClientConnected() && !QSBNetworkServer.active && this.manager.matchMaker == null)
var num = 10 + offsetX;
var num2 = 40 + offsetY;
var flag = manager.client == null || manager.client.connection == null || manager.client.connection.connectionId == -1;
if (!manager.IsClientConnected() && !QSBNetworkServer.active)
{
if (flag)
{
if (Application.platform != RuntimePlatform.WebGLPlayer)
{
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "LAN Host(H)"))
if (GUI.Button(new Rect(num, num2, 200f, 20f), "Host"))
{
this.manager.StartHost();
manager.StartHost();
}
num2 += 24;
}
if (GUI.Button(new Rect((float)num, (float)num2, 105f, 20f), "LAN Client(C)"))
if (GUI.Button(new Rect(num, num2, 105f, 20f), "Connect"))
{
this.manager.StartClient();
manager.StartClient();
}
this.manager.networkAddress = GUI.TextField(new Rect((float)(num + 100), (float)num2, 95f, 20f), this.manager.networkAddress);
manager.networkAddress = GUI.TextField(new Rect(num + 100, num2, 95f, 20f), manager.networkAddress);
num2 += 24;
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
GUI.Box(new Rect((float)num, (float)num2, 200f, 25f), "( WebGL cannot be server )");
GUI.Box(new Rect(num, num2, 200f, 25f), "( WebGL cannot be server )");
num2 += 24;
}
else
{
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "LAN Server Only(S)"))
if (GUI.Button(new Rect(num, num2, 200f, 20f), "LAN Server Only"))
{
this.manager.StartServer();
manager.StartServer();
}
num2 += 24;
}
}
else
{
GUI.Label(new Rect((float)num, (float)num2, 200f, 20f), string.Concat(new object[]
GUI.Label(new Rect(num, num2, 200f, 20f), string.Concat(new object[]
{
"Connecting to ",
this.manager.networkAddress,
manager.networkAddress,
":",
this.manager.networkPort,
manager.networkPort,
".."
}));
num2 += 24;
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Cancel Connection Attempt"))
if (GUI.Button(new Rect(num, num2, 200f, 20f), "Cancel Connection Attempt"))
{
this.manager.StopClient();
manager.StopClient();
}
}
}
@ -71,31 +71,25 @@ namespace QuantumUNET
{
if (QSBNetworkServer.active)
{
string text = "Server: port=" + this.manager.networkPort;
if (this.manager.useWebSockets)
var text = $"Hosting on port {manager.networkPort}";
if (manager.useWebSockets)
{
text += " (Using WebSockets)";
text += " (using WebSockets)";
}
GUI.Label(new Rect((float)num, (float)num2, 300f, 20f), text);
GUI.Label(new Rect(num, num2, 300f, 20f), text);
num2 += 24;
}
if (this.manager.IsClientConnected())
if (manager.IsClientConnected())
{
GUI.Label(new Rect((float)num, (float)num2, 300f, 20f), string.Concat(new object[]
{
"Client: address=",
this.manager.networkAddress,
" port=",
this.manager.networkPort
}));
GUI.Label(new Rect(num, num2, 300f, 20f), $"Connected to {manager.networkAddress}, port {manager.networkPort}");
num2 += 24;
}
}
if (this.manager.IsClientConnected() && !QSBClientScene.ready)
if (manager.IsClientConnected() && !QSBClientScene.ready)
{
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Client Ready"))
if (GUI.Button(new Rect(num, num2, 200f, 20f), "Client Ready"))
{
QSBClientScene.Ready(this.manager.client.connection);
QSBClientScene.Ready(manager.client.connection);
if (QSBClientScene.localPlayers.Count == 0)
{
QSBClientScene.AddPlayer(0);
@ -103,102 +97,20 @@ namespace QuantumUNET
}
num2 += 24;
}
if (QSBNetworkServer.active || this.manager.IsClientConnected())
if (QSBNetworkServer.active || manager.IsClientConnected())
{
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Stop (X)"))
if (GUI.Button(new Rect(num, num2, 200f, 20f), "Stop"))
{
this.manager.StopHost();
manager.StopHost();
}
num2 += 24;
}
if (!QSBNetworkServer.active && !this.manager.IsClientConnected() && flag)
if (!QSBNetworkServer.active && !manager.IsClientConnected() && flag)
{
num2 += 10;
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
GUI.Box(new Rect((float)(num - 5), (float)num2, 220f, 25f), "(WebGL cannot use Match Maker)");
}
else if (this.manager.matchMaker == null)
{
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Enable Match Maker (M)"))
{
this.manager.StartMatchMaker();
}
num2 += 24;
}
else
{
if (this.manager.matchInfo == null)
{
if (this.manager.matches == null)
{
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Create Internet Match"))
{
this.manager.matchMaker.CreateMatch(this.manager.matchName, this.manager.matchSize, true, "", "", "", 0, 0, new NetworkMatch.DataResponseDelegate<MatchInfo>(this.manager.OnMatchCreate));
}
num2 += 24;
GUI.Label(new Rect((float)num, (float)num2, 100f, 20f), "Room Name:");
this.manager.matchName = GUI.TextField(new Rect((float)(num + 100), (float)num2, 100f, 20f), this.manager.matchName);
num2 += 24;
num2 += 10;
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Find Internet Match"))
{
this.manager.matchMaker.ListMatches(0, 20, "", false, 0, 0, new NetworkMatch.DataResponseDelegate<List<MatchInfoSnapshot>>(this.manager.OnMatchList));
}
num2 += 24;
}
else
{
for (int i = 0; i < this.manager.matches.Count; i++)
{
MatchInfoSnapshot matchInfoSnapshot = this.manager.matches[i];
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Join Match:" + matchInfoSnapshot.name))
{
this.manager.matchName = matchInfoSnapshot.name;
this.manager.matchMaker.JoinMatch(matchInfoSnapshot.networkId, "", "", "", 0, 0, new NetworkMatch.DataResponseDelegate<MatchInfo>(this.manager.OnMatchJoined));
}
num2 += 24;
}
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Back to Match Menu"))
{
this.manager.matches = null;
}
num2 += 24;
}
}
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Change MM server"))
{
this.m_ShowServer = !this.m_ShowServer;
}
if (this.m_ShowServer)
{
num2 += 24;
if (GUI.Button(new Rect((float)num, (float)num2, 100f, 20f), "Local"))
{
this.manager.SetMatchHost("localhost", 1337, false);
this.m_ShowServer = false;
}
num2 += 24;
if (GUI.Button(new Rect((float)num, (float)num2, 100f, 20f), "Internet"))
{
this.manager.SetMatchHost("mm.unet.unity3d.com", 443, true);
this.m_ShowServer = false;
}
num2 += 24;
if (GUI.Button(new Rect((float)num, (float)num2, 100f, 20f), "Staging"))
{
this.manager.SetMatchHost("staging-mm.unet.unity3d.com", 443, true);
this.m_ShowServer = false;
}
}
num2 += 24;
GUI.Label(new Rect((float)num, (float)num2, 300f, 20f), "MM Uri: " + this.manager.matchMaker.baseUri);
num2 += 24;
if (GUI.Button(new Rect((float)num, (float)num2, 200f, 20f), "Disable Match Maker"))
{
this.manager.StopMatchMaker();
}
num2 += 24;
GUI.Box(new Rect(num - 5, num2, 220f, 25f), "(WebGL cannot use Match Maker)");
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +0,0 @@
using UnityEngine.Networking;
namespace QuantumUNET
{
public class QSBPeerAuthorityMessage : QSBMessageBase
{
public override void Deserialize(QSBNetworkReader reader)
{
this.connectionId = (int)reader.ReadPackedUInt32();
this.netId = reader.ReadNetworkId();
this.authorityState = reader.ReadBoolean();
}
public override void Serialize(QSBNetworkWriter writer)
{
writer.WritePackedUInt32((uint)this.connectionId);
writer.Write(this.netId);
writer.Write(this.authorityState);
}
public int connectionId;
public NetworkInstanceId netId;
public bool authorityState;
}
}

View File

@ -1,32 +0,0 @@
namespace QuantumUNET
{
public class QSBPeerListMessage : QSBMessageBase
{
public override void Deserialize(QSBNetworkReader reader)
{
this.oldServerConnectionId = (int)reader.ReadPackedUInt32();
int num = (int)reader.ReadUInt16();
this.peers = new QSBPeerInfoMessage[num];
for (int i = 0; i < this.peers.Length; i++)
{
QSBPeerInfoMessage peerInfoMessage = new QSBPeerInfoMessage();
peerInfoMessage.Deserialize(reader);
this.peers[i] = peerInfoMessage;
}
}
public override void Serialize(QSBNetworkWriter writer)
{
writer.WritePackedUInt32((uint)this.oldServerConnectionId);
writer.Write((ushort)this.peers.Length);
for (int i = 0; i < this.peers.Length; i++)
{
this.peers[i].Serialize(writer);
}
}
public QSBPeerInfoMessage[] peers;
public int oldServerConnectionId;
}
}

View File

@ -120,7 +120,6 @@
<Compile Include="QSBNetworkMessage.cs" />
<Compile Include="QSBNetworkMessageDelegate.cs" />
<Compile Include="QSBNetworkMessageHandlers.cs" />
<Compile Include="QSBNetworkMigrationManager.cs" />
<Compile Include="QSBNetworkReader.cs" />
<Compile Include="QSBNetworkScene.cs" />
<Compile Include="QSBNetworkServer.cs" />
@ -133,10 +132,8 @@
<Compile Include="QSBObjectSpawnMessage.cs" />
<Compile Include="QSBObjectSpawnSceneMessage.cs" />
<Compile Include="QSBOwnerMessage.cs" />
<Compile Include="QSBPeerAuthorityMessage.cs" />
<Compile Include="QSBPeerInfoMessage.cs" />
<Compile Include="QSBPeerInfoPlayer.cs" />
<Compile Include="QSBPeerListMessage.cs" />
<Compile Include="QSBPlayerController.cs" />
<Compile Include="QSBReadyMessage.cs" />
<Compile Include="QSBReconnectMessage.cs" />