This commit is contained in:
Mister_Nebula 2021-05-18 14:33:17 +01:00
parent 54297ddb17
commit 6c9e39a6bb
6 changed files with 20 additions and 25 deletions

View File

@ -178,7 +178,10 @@ namespace QSB
offset3 += _debugLineSpacing;
GUI.Label(new Rect(420, offset3, 200f, 20f), $"Ship sector : {(ship.ReferenceSector == null ? "NULL" : ship.ReferenceSector.Name)}");
offset3 += _debugLineSpacing;
GUI.Label(new Rect(420, offset3, 200f, 20f), $"Ship relative velocity : {ship.AttachedObject.GetRelativeVelocity(ship.ReferenceTransform.GetAttachedOWRigidbody())}");
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Ship relative velocity : {ship.AttachedObject.GetRelativeVelocity(ship.ReferenceTransform.GetAttachedOWRigidbody())}");
offset3 += _debugLineSpacing;
offset3 += _debugLineSpacing;
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Ship velocity mag. : {ship.GetVelocityChangeMagnitude()}");
offset3 += _debugLineSpacing;
}

View File

@ -5,6 +5,7 @@ using QSB.Syncs.RigidbodySync;
using QSB.Syncs.TransformSync;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@ -20,35 +21,23 @@ namespace QSB.SectorSync
private void OnEnable() => RepeatingManager.Repeatings.Add(this);
private void OnDisable() => RepeatingManager.Repeatings.Remove(this);
public List<ISectoredSync<Component>> SectoredSyncs = new List<ISectoredSync<Component>>();
public void Invoke()
{
foreach (var sync in SectoredTransformSync.SectoredNetworkTransformList)
foreach (var sync in SectoredSyncs)
{
if (sync.AttachedObject == null)
{
continue;
}
if (sync.HasAuthority
if ((sync as QNetworkBehaviour).HasAuthority
&& sync.AttachedObject.gameObject.activeInHierarchy
&& sync.IsReady)
{
CheckTransformSyncSector(sync);
}
}
foreach (var sync in SectoredRigidbodySync.SectoredNetworkTransformList)
{
if (sync.AttachedObject == null)
{
continue;
}
if (sync.HasAuthority
&& sync.AttachedObject.gameObject.activeInHierarchy
&& sync.IsReady)
{
CheckTransformSyncSector(sync);
}
}
}
public override void Awake()

View File

@ -57,6 +57,7 @@ namespace QSB.ShipSync.Events
? id
: uint.MaxValue;
/*
if (id == uint.MaxValue)
{
DebugLog.DebugWrite($"ShipDetector setactive {QSBCore.IsServer}");
@ -72,6 +73,7 @@ namespace QSB.ShipSync.Events
DebugLog.DebugWrite($"Disable ship detector");
Locator.GetShipDetector().SetActive(false);
}
*/
if (QSBCore.IsServer)
{

View File

@ -10,20 +10,19 @@ namespace QSB.Syncs.RigidbodySync
{
public QSBSector ReferenceSector { get; set; }
public SectorSync.SectorSync SectorSync { get; private set; }
public static List<SectoredRigidbodySync> SectoredNetworkTransformList = new List<SectoredRigidbodySync>();
public abstract TargetType Type { get; }
public override void Start()
{
SectorSync = gameObject.AddComponent<SectorSync.SectorSync>();
SectoredNetworkTransformList.Add(this);
QSBSectorManager.Instance.SectoredSyncs.Add((ISectoredSync<UnityEngine.Component>)this);
base.Start();
}
protected override void OnDestroy()
{
base.OnDestroy();
SectoredNetworkTransformList.Remove(this);
QSBSectorManager.Instance.SectoredSyncs.Remove((ISectoredSync<UnityEngine.Component>)this);
if (SectorSync != null)
{
Destroy(SectorSync);

View File

@ -177,8 +177,8 @@ namespace QSB.Syncs.RigidbodySync
return;
}
AttachedObject.SetPosition(targetPos);
AttachedObject.SetRotation(targetRot);
AttachedObject.transform.position = targetPos;
AttachedObject.transform.rotation = targetRot;
AttachedObject.SetVelocity(ReferenceTransform.GetAttachedOWRigidbody().GetVelocity() + _velocity);
AttachedObject.SetAngularVelocity(ReferenceTransform.GetAttachedOWRigidbody().GetAngularVelocity() + _angularVelocity);
}
@ -220,6 +220,9 @@ namespace QSB.Syncs.RigidbodySync
return false;
}
public float GetVelocityChangeMagnitude()
=> (_velocity - _prevVelocity).magnitude;
private void OnRenderObject()
{
if (!QSBCore.WorldObjectsReady || !QSBCore.DebugMode || !QSBCore.ShowLinesInDebug || !IsReady)

View File

@ -11,20 +11,19 @@ namespace QSB.Syncs.TransformSync
{
public QSBSector ReferenceSector { get; set; }
public SectorSync.SectorSync SectorSync { get; private set; }
public static List<SectoredTransformSync> SectoredNetworkTransformList = new List<SectoredTransformSync>();
public abstract TargetType Type { get; }
public override void Start()
{
SectorSync = gameObject.AddComponent<SectorSync.SectorSync>();
SectoredNetworkTransformList.Add(this);
QSBSectorManager.Instance.SectoredSyncs.Add((ISectoredSync<UnityEngine.Component>)this);
base.Start();
}
protected override void OnDestroy()
{
base.OnDestroy();
SectoredNetworkTransformList.Remove(this);
QSBSectorManager.Instance.SectoredSyncs.Remove((ISectoredSync<UnityEngine.Component>)this);
if (SectorSync != null)
{
Destroy(SectorSync);