add base isready

This commit is contained in:
Mister_Nebula 2021-07-17 09:51:47 +01:00
parent 8591e2136c
commit 60371f5381
4 changed files with 18 additions and 24 deletions

View File

@ -83,7 +83,7 @@ namespace QSB.Player.TransformSync
protected override Component InitLocalTransform()
{
SectorSync.Init(Locator.GetPlayerSectorDetector(), this);
QSBCore.UnityEvents.RunWhen(() => WorldObjectManager.AllReady, () => SectorSync.Init(Locator.GetPlayerSectorDetector(), this));
// player body
var player = Locator.GetPlayerTransform();
@ -237,14 +237,8 @@ namespace QSB.Player.TransformSync
visible.localRotation = QuaternionHelper.SmoothDamp(visible.localRotation, network.localRotation, ref rotationVelocity, SmoothTime);
}
public override bool IsReady
=> Locator.GetPlayerTransform() != null
&& Player != null
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
&& Player.PlayerStates.IsReady
&& NetId.Value != uint.MaxValue
&& NetId.Value != 0U
&& WorldObjectManager.AllReady;
public override bool IsReady
=> Locator.GetPlayerTransform() != null;
public static PlayerTransformSync LocalInstance { get; private set; }

View File

@ -1,6 +1,5 @@
using OWML.Common;
using OWML.Utils;
using QSB.Player;
using QSB.SectorSync;
using QSB.Syncs.TransformSync;
using QSB.Tools;
@ -23,7 +22,7 @@ namespace QSB.ProbeSync.TransformSync
protected override Component InitLocalTransform()
{
SectorSync.Init(Locator.GetProbe().GetSectorDetector(), this);
QSBCore.UnityEvents.RunWhen(() => WorldObjectManager.AllReady, () => SectorSync.Init(Locator.GetProbe().GetSectorDetector(), this));
var body = Locator.GetProbe().transform;
Player.ProbeBody = body.gameObject;
@ -101,12 +100,6 @@ namespace QSB.ProbeSync.TransformSync
return true;
}
public override bool IsReady => Locator.GetProbe() != null
&& Player != null
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
&& Player.PlayerStates.IsReady
&& NetId.Value != uint.MaxValue
&& NetId.Value != 0U
&& WorldObjectManager.AllReady;
public override bool IsReady => Locator.GetProbe() != null;
}
}

View File

@ -12,8 +12,7 @@ namespace QSB.ShipSync.TransformSync
public static ShipTransformSync LocalInstance { get; private set; }
public override bool IsReady
=> Locator.GetShipBody() != null
&& WorldObjectManager.AllReady;
=> Locator.GetShipBody() != null;
public override void Start()
{
@ -26,7 +25,7 @@ namespace QSB.ShipSync.TransformSync
protected override OWRigidbody GetRigidbody()
{
SectorSync.Init(Locator.GetShipDetector().GetComponent<SectorDetector>(), this);
QSBCore.UnityEvents.RunWhen(() => WorldObjectManager.AllReady, () => SectorSync.Init(Locator.GetShipDetector().GetComponent<SectorDetector>(), this));
return Locator.GetShipBody();
}

View File

@ -1,6 +1,7 @@
using OWML.Common;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET.Components;
using UnityEngine;
@ -39,7 +40,12 @@ namespace QSB.Syncs
}
public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId);
private bool _baseIsReady => QSBPlayerManager.PlayerExists(PlayerId)
&& Player != null
&& Player.PlayerStates.IsReady
&& NetId.Value != uint.MaxValue
&& NetId.Value != 0U
&& WorldObjectManager.AllReady;
public abstract bool IsReady { get; }
public abstract bool UseInterpolation { get; }
public abstract bool IgnoreDisabledAttachedObject { get; }
@ -77,11 +83,13 @@ namespace QSB.Syncs
public override void Update()
{
if (!_isInitialized && IsReady)
if (!_isInitialized && IsReady && _baseIsReady)
{
Init();
base.Update();
return;
}
else if (_isInitialized && !IsReady)
else if (_isInitialized && (!IsReady || !_baseIsReady))
{
_isInitialized = false;
base.Update();