mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
remove qsbnetworklobby
This commit is contained in:
parent
cc62f4db4a
commit
29a4705035
@ -230,7 +230,6 @@
|
||||
<Compile Include="ProbeSync\QSBProbeEffects.cs" />
|
||||
<Compile Include="ProbeSync\QSBProbeLantern.cs" />
|
||||
<Compile Include="ProbeSync\QSBProbeSpotlight.cs" />
|
||||
<Compile Include="QSBNetworkLobby.cs" />
|
||||
<Compile Include="Patches\QSBPatch.cs" />
|
||||
<Compile Include="Patches\QSBPatchTypes.cs" />
|
||||
<Compile Include="QSBSceneManager.cs" />
|
||||
|
@ -1,71 +0,0 @@
|
||||
using OWML.Utils;
|
||||
using QuantumUNET;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB
|
||||
{
|
||||
public class QSBNetworkLobby : QNetworkBehaviour
|
||||
{
|
||||
public bool CanEditName { get; set; }
|
||||
public string PlayerName { get; private set; }
|
||||
|
||||
// TODO : Could delete a lot of this - shouldnt be possible to not have a profile and still play
|
||||
|
||||
private readonly string[] _defaultNames = {
|
||||
"Arkose",
|
||||
"Chert",
|
||||
"Esker",
|
||||
"Hal",
|
||||
"Hornfels",
|
||||
"Feldspar",
|
||||
"Gabbro",
|
||||
"Galena",
|
||||
"Gneiss",
|
||||
"Gossan",
|
||||
"Marl",
|
||||
"Mica",
|
||||
"Moraine",
|
||||
"Porphy",
|
||||
"Riebeck",
|
||||
"Rutile",
|
||||
"Slate",
|
||||
"Spinel",
|
||||
"Tektite",
|
||||
"Tephra",
|
||||
"Tuff",
|
||||
"Jinha"
|
||||
};
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
PlayerName = GetPlayerName();
|
||||
CanEditName = true;
|
||||
}
|
||||
|
||||
private string GetPlayerName()
|
||||
{
|
||||
var profileManager = StandaloneProfileManager.SharedInstance;
|
||||
profileManager.Initialize();
|
||||
var profile = profileManager.GetValue<StandaloneProfileManager.ProfileData>("_currentProfile");
|
||||
var profileName = profile?.profileName;
|
||||
return !string.IsNullOrEmpty(profileName)
|
||||
? profileName
|
||||
: _defaultNames.OrderBy(x => Guid.NewGuid()).First();
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
GUI.Label(new Rect(10, 10, 200f, 20f), "Name:");
|
||||
if (CanEditName)
|
||||
{
|
||||
PlayerName = GUI.TextField(new Rect(60, 10, 145, 20f), PlayerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.Label(new Rect(60, 10, 145, 20f), PlayerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -34,11 +34,11 @@ namespace QSB
|
||||
public bool IsReady { get; private set; }
|
||||
public GameObject OrbPrefab { get; private set; }
|
||||
public GameObject ShipPrefab { get; private set; }
|
||||
public string PlayerName { get; private set; }
|
||||
|
||||
private const int MaxConnections = 128;
|
||||
private const int MaxBufferedPackets = 64;
|
||||
|
||||
private QSBNetworkLobby _lobby;
|
||||
private AssetBundle _assetBundle;
|
||||
private GameObject _probePrefab;
|
||||
private bool _everConnected;
|
||||
@ -48,7 +48,7 @@ namespace QSB
|
||||
base.Awake();
|
||||
Instance = this;
|
||||
|
||||
_lobby = gameObject.AddComponent<QSBNetworkLobby>();
|
||||
PlayerName = GetPlayerName();
|
||||
_assetBundle = QSBCore.NetworkAssetBundle;
|
||||
|
||||
playerPrefab = _assetBundle.LoadAsset<GameObject>("assets/NETWORK_Player_Body.prefab");
|
||||
@ -82,6 +82,15 @@ namespace QSB
|
||||
ConfigureNetworkManager();
|
||||
}
|
||||
|
||||
private string GetPlayerName()
|
||||
{
|
||||
var profileManager = StandaloneProfileManager.SharedInstance;
|
||||
profileManager.Initialize();
|
||||
var profile = profileManager.GetValue<StandaloneProfileManager.ProfileData>("_currentProfile");
|
||||
var profileName = profile.profileName;
|
||||
return profileName;
|
||||
}
|
||||
|
||||
private void SetupNetworkId(GameObject go)
|
||||
{
|
||||
var ident = go.AddComponent<QNetworkIdentity>();
|
||||
@ -163,13 +172,11 @@ namespace QSB
|
||||
QSBPatchManager.DoPatchType(specificType);
|
||||
QSBPatchManager.DoPatchType(QSBPatchTypes.OnClientConnect);
|
||||
|
||||
_lobby.CanEditName = false;
|
||||
|
||||
OnNetworkManagerReady?.SafeInvoke();
|
||||
IsReady = true;
|
||||
|
||||
QSBCore.UnityEvents.RunWhen(() => QSBEventManager.Ready && PlayerTransformSync.LocalInstance != null,
|
||||
() => QSBEventManager.FireEvent(EventNames.QSBPlayerJoin, _lobby.PlayerName));
|
||||
() => QSBEventManager.FireEvent(EventNames.QSBPlayerJoin, PlayerName));
|
||||
|
||||
if (!QSBCore.IsHost)
|
||||
{
|
||||
@ -201,8 +208,6 @@ namespace QSB
|
||||
QSBPatchManager.DoUnpatchType(QSBPatchTypes.OnClientConnect);
|
||||
}
|
||||
|
||||
_lobby.CanEditName = true;
|
||||
|
||||
IsReady = false;
|
||||
_everConnected = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user