mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-11 06:40:39 +00:00
fix #609
This commit is contained in:
parent
b0da02b52a
commit
ec478d2aac
@ -3,6 +3,7 @@ using QSB.DeathSync.Messages;
|
|||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.Player;
|
using QSB.Player;
|
||||||
using QSB.Player.TransformSync;
|
using QSB.Player.TransformSync;
|
||||||
|
using QSB.TimeSync;
|
||||||
using QSB.Utility;
|
using QSB.Utility;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -32,7 +33,7 @@ internal class ServerStateManager : MonoBehaviour
|
|||||||
QSBSceneManager.OnPostSceneLoad += OnPostSceneLoad;
|
QSBSceneManager.OnPostSceneLoad += OnPostSceneLoad;
|
||||||
GlobalMessenger.AddListener("TriggerSupernova", OnTriggerSupernova);
|
GlobalMessenger.AddListener("TriggerSupernova", OnTriggerSupernova);
|
||||||
|
|
||||||
Delay.RunWhen(() => PlayerTransformSync.LocalInstance != null,
|
Delay.RunWhen(() => PlayerTransformSync.LocalInstance != null && WakeUpSync.LocalInstance != null,
|
||||||
() => new ServerStateMessage(ForceGetCurrentState()).Send());
|
() => new ServerStateMessage(ForceGetCurrentState()).Send());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ internal class ServerStateManager : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new ServerStateMessage(ServerState.InSolarSystem).Send();
|
new ServerStateMessage(ServerState.NotLoaded).Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -118,7 +119,11 @@ internal class ServerStateManager : MonoBehaviour
|
|||||||
switch (currentScene)
|
switch (currentScene)
|
||||||
{
|
{
|
||||||
case OWScene.SolarSystem:
|
case OWScene.SolarSystem:
|
||||||
|
if (WakeUpSync.LocalInstance.HasWokenUp)
|
||||||
|
{
|
||||||
return ServerState.InSolarSystem;
|
return ServerState.InSolarSystem;
|
||||||
|
}
|
||||||
|
return ServerState.NotLoaded;
|
||||||
case OWScene.EyeOfTheUniverse:
|
case OWScene.EyeOfTheUniverse:
|
||||||
return ServerState.InEye;
|
return ServerState.InEye;
|
||||||
default:
|
default:
|
||||||
|
@ -35,7 +35,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
private float _sendTimer;
|
private float _sendTimer;
|
||||||
private float _serverTime;
|
private float _serverTime;
|
||||||
private int _serverLoopCount;
|
private int _serverLoopCount;
|
||||||
private bool _hasWokenUp;
|
public bool HasWokenUp;
|
||||||
|
|
||||||
public void OnDisconnect()
|
public void OnDisconnect()
|
||||||
{
|
{
|
||||||
@ -75,10 +75,11 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
DebugLog.DebugWrite($"OnWakeUp", MessageType.Info);
|
DebugLog.DebugWrite($"OnWakeUp", MessageType.Info);
|
||||||
if (QSBCore.IsHost)
|
if (QSBCore.IsHost)
|
||||||
{
|
{
|
||||||
|
new ServerStateMessage(ServerState.InSolarSystem).Send();
|
||||||
RespawnOnDeath.Instance.Init();
|
RespawnOnDeath.Instance.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
_hasWokenUp = true;
|
HasWokenUp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
@ -89,12 +90,12 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
|
|
||||||
private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse)
|
private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse)
|
||||||
{
|
{
|
||||||
_hasWokenUp = false;
|
HasWokenUp = false;
|
||||||
if (isInUniverse)
|
if (isInUniverse)
|
||||||
{
|
{
|
||||||
if (newScene == OWScene.EyeOfTheUniverse)
|
if (newScene == OWScene.EyeOfTheUniverse)
|
||||||
{
|
{
|
||||||
_hasWokenUp = true;
|
HasWokenUp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalInstance = this;
|
LocalInstance = this;
|
||||||
@ -124,7 +125,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// dont bother sleeping, just wake up
|
// dont bother sleeping, just wake up
|
||||||
if (!_hasWokenUp)
|
if (!HasWokenUp)
|
||||||
{
|
{
|
||||||
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady, WakeUp);
|
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady, WakeUp);
|
||||||
}
|
}
|
||||||
@ -178,7 +179,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// should only happen from Init so we gotta wait
|
// should only happen from Init so we gotta wait
|
||||||
if (!_hasWokenUp)
|
if (!HasWokenUp)
|
||||||
{
|
{
|
||||||
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady, WakeUp);
|
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady, WakeUp);
|
||||||
}
|
}
|
||||||
@ -248,7 +249,7 @@ public class WakeUpSync : MonoBehaviour, IAddComponentOnStart
|
|||||||
|
|
||||||
QSBInputManager.Instance.SetInputsEnabled(true);
|
QSBInputManager.Instance.SetInputsEnabled(true);
|
||||||
|
|
||||||
if (!_hasWokenUp)
|
if (!HasWokenUp)
|
||||||
{
|
{
|
||||||
WakeUp();
|
WakeUp();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user