mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-12-11 20:15:10 +01:00
Fix #671
This commit is contained in:
parent
ada70a41de
commit
7aba6bb2a8
@ -50,6 +50,8 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
|||||||
|
|
||||||
private GameObject _choicePopupPrefab;
|
private GameObject _choicePopupPrefab;
|
||||||
|
|
||||||
|
public bool WillBeHost;
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
@ -606,6 +608,7 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
|||||||
private void Host(bool newMultiplayerSave)
|
private void Host(bool newMultiplayerSave)
|
||||||
{
|
{
|
||||||
QSBCore.IsInMultiplayer = true;
|
QSBCore.IsInMultiplayer = true;
|
||||||
|
WillBeHost = true;
|
||||||
|
|
||||||
if (newMultiplayerSave)
|
if (newMultiplayerSave)
|
||||||
{
|
{
|
||||||
@ -648,7 +651,11 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
|||||||
LoadGame(PlayerData.GetWarpedToTheEye());
|
LoadGame(PlayerData.GetWarpedToTheEye());
|
||||||
// wait until scene load and then wait until Start has ran
|
// wait until scene load and then wait until Start has ran
|
||||||
// why is this done? GameStateMessage etc works on title screen since nonhost has to deal with that
|
// why is this done? GameStateMessage etc works on title screen since nonhost has to deal with that
|
||||||
Delay.RunWhen(() => TimeLoop._initialized, QSBNetworkManager.singleton.StartHost);
|
Delay.RunWhen(() => TimeLoop._initialized, () =>
|
||||||
|
{
|
||||||
|
QSBNetworkManager.singleton.StartHost();
|
||||||
|
Delay.RunWhen(() => NetworkServer.active, () => WillBeHost = false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenInfoPopup(string.Format(QSBLocalization.Current.CopySteamIDToClipboard, steamId)
|
OpenInfoPopup(string.Format(QSBLocalization.Current.CopySteamIDToClipboard, steamId)
|
||||||
@ -660,7 +667,11 @@ public class MenuManager : MonoBehaviour, IAddComponentOnStart
|
|||||||
LoadGame(PlayerData.GetWarpedToTheEye());
|
LoadGame(PlayerData.GetWarpedToTheEye());
|
||||||
// wait until scene load and then wait until Start has ran
|
// wait until scene load and then wait until Start has ran
|
||||||
// why is this done? GameStateMessage etc works on title screen since nonhost has to deal with that
|
// why is this done? GameStateMessage etc works on title screen since nonhost has to deal with that
|
||||||
Delay.RunWhen(() => TimeLoop._initialized, QSBNetworkManager.singleton.StartHost);
|
Delay.RunWhen(() => TimeLoop._initialized, () =>
|
||||||
|
{
|
||||||
|
QSBNetworkManager.singleton.StartHost();
|
||||||
|
Delay.RunWhen(() => NetworkServer.active, () => WillBeHost = false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public class QSBCore : ModBehaviour
|
|||||||
public static AssetBundle NetworkAssetBundle { get; private set; }
|
public static AssetBundle NetworkAssetBundle { get; private set; }
|
||||||
public static AssetBundle ConversationAssetBundle { get; private set; }
|
public static AssetBundle ConversationAssetBundle { get; private set; }
|
||||||
public static AssetBundle HUDAssetBundle { get; private set; }
|
public static AssetBundle HUDAssetBundle { get; private set; }
|
||||||
public static bool IsHost => NetworkServer.active;
|
public static bool IsHost => NetworkServer.active || (IsInMultiplayer && MenuManager.Instance.WillBeHost);
|
||||||
public static bool IsInMultiplayer;
|
public static bool IsInMultiplayer;
|
||||||
public static string QSBVersion => Helper.Manifest.Version;
|
public static string QSBVersion => Helper.Manifest.Version;
|
||||||
public static string GameVersion =>
|
public static string GameVersion =>
|
||||||
|
|||||||
@ -66,6 +66,11 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
|
|
||||||
public float GetTimeDifference()
|
public float GetTimeDifference()
|
||||||
{
|
{
|
||||||
|
if (QSBCore.IsHost)
|
||||||
|
{
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
var myTime = Time.timeSinceLevelLoad;
|
var myTime = Time.timeSinceLevelLoad;
|
||||||
return myTime - _serverTime;
|
return myTime - _serverTime;
|
||||||
}
|
}
|
||||||
@ -114,6 +119,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
CurrentState = State.Loaded;
|
CurrentState = State.Loaded;
|
||||||
if (QSBCore.IsHost)
|
if (QSBCore.IsHost)
|
||||||
{
|
{
|
||||||
|
_serverTime = Time.timeSinceLevelLoad;
|
||||||
SendServerTime();
|
SendServerTime();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -160,8 +166,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var myTime = Time.timeSinceLevelLoad;
|
var diff = GetTimeDifference();
|
||||||
var diff = myTime - _serverTime;
|
|
||||||
|
|
||||||
if (ServerStateManager.Instance.GetServerState() is not (ServerState.InSolarSystem or ServerState.InEye))
|
if (ServerStateManager.Instance.GetServerState() is not (ServerState.InSolarSystem or ServerState.InEye))
|
||||||
{
|
{
|
||||||
@ -188,6 +193,12 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
|
|
||||||
private void StartFastForwarding(FastForwardReason reason)
|
private void StartFastForwarding(FastForwardReason reason)
|
||||||
{
|
{
|
||||||
|
if (QSBCore.IsHost)
|
||||||
|
{
|
||||||
|
DebugLog.ToConsole($"Tried to fast-forward as server??? What???? _serverTime = {_serverTime}, GetTimeDifference() = {GetTimeDifference()}", MessageType.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (CurrentState == State.FastForwarding)
|
if (CurrentState == State.FastForwarding)
|
||||||
{
|
{
|
||||||
TimeSyncUI.TargetTime = _serverTime;
|
TimeSyncUI.TargetTime = _serverTime;
|
||||||
@ -276,13 +287,11 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
|
|
||||||
if (ServerStateManager.Instance == null)
|
if (ServerStateManager.Instance == null)
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"Warning - ServerStateManager.Instance is null!", MessageType.Warning);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QSBPlayerManager.LocalPlayer == null)
|
if (QSBPlayerManager.LocalPlayer == null)
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"Warning - LocalPlayer is null!", MessageType.Warning);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ using QSB.TimeSync;
|
|||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using QSB.Menus;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace QSB.Utility;
|
namespace QSB.Utility;
|
||||||
@ -108,7 +109,7 @@ public class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteLine(1, $"IsHost : {QSBCore.IsHost}");
|
WriteLine(1, $"IsHost : {QSBCore.IsHost} (WillBeHost : {(MenuManager.Instance != null ? MenuManager.Instance.WillBeHost : "MenuManager null")})");
|
||||||
WriteLine(1, $"HasWokenUp : {QSBWorldSync.AllObjectsReady}");
|
WriteLine(1, $"HasWokenUp : {QSBWorldSync.AllObjectsReady}");
|
||||||
if (WakeUpSync.LocalInstance != null)
|
if (WakeUpSync.LocalInstance != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user