This commit is contained in:
_nebula 2023-04-26 22:10:11 +01:00
parent b0da02b52a
commit ec478d2aac
2 changed files with 16 additions and 10 deletions

View File

@ -3,6 +3,7 @@ using QSB.DeathSync.Messages;
using QSB.Messaging;
using QSB.Player;
using QSB.Player.TransformSync;
using QSB.TimeSync;
using QSB.Utility;
using System.Linq;
using UnityEngine;
@ -32,7 +33,7 @@ internal class ServerStateManager : MonoBehaviour
QSBSceneManager.OnPostSceneLoad += OnPostSceneLoad;
GlobalMessenger.AddListener("TriggerSupernova", OnTriggerSupernova);
Delay.RunWhen(() => PlayerTransformSync.LocalInstance != null,
Delay.RunWhen(() => PlayerTransformSync.LocalInstance != null && WakeUpSync.LocalInstance != null,
() => new ServerStateMessage(ForceGetCurrentState()).Send());
}
@ -77,7 +78,7 @@ internal class ServerStateManager : MonoBehaviour
}
else
{
new ServerStateMessage(ServerState.InSolarSystem).Send();
new ServerStateMessage(ServerState.NotLoaded).Send();
}
break;
@ -118,7 +119,11 @@ internal class ServerStateManager : MonoBehaviour
switch (currentScene)
{
case OWScene.SolarSystem:
return ServerState.InSolarSystem;
if (WakeUpSync.LocalInstance.HasWokenUp)
{
return ServerState.InSolarSystem;
}
return ServerState.NotLoaded;
case OWScene.EyeOfTheUniverse:
return ServerState.InEye;
default:

View File

@ -35,7 +35,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
private float _sendTimer;
private float _serverTime;
private int _serverLoopCount;
private bool _hasWokenUp;
public bool HasWokenUp;
public void OnDisconnect()
{
@ -75,10 +75,11 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
DebugLog.DebugWrite($"OnWakeUp", MessageType.Info);
if (QSBCore.IsHost)
{
new ServerStateMessage(ServerState.InSolarSystem).Send();
RespawnOnDeath.Instance.Init();
}
_hasWokenUp = true;
HasWokenUp = true;
}
public void OnDestroy()
@ -89,12 +90,12 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse)
{
_hasWokenUp = false;
HasWokenUp = false;
if (isInUniverse)
{
if (newScene == OWScene.EyeOfTheUniverse)
{
_hasWokenUp = true;
HasWokenUp = true;
}
LocalInstance = this;
@ -124,7 +125,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
else
{
// dont bother sleeping, just wake up
if (!_hasWokenUp)
if (!HasWokenUp)
{
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady, WakeUp);
}
@ -178,7 +179,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
else
{
// should only happen from Init so we gotta wait
if (!_hasWokenUp)
if (!HasWokenUp)
{
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady, WakeUp);
}
@ -248,7 +249,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
QSBInputManager.Instance.SetInputsEnabled(true);
if (!_hasWokenUp)
if (!HasWokenUp)
{
WakeUp();
}