make syncbase not generic :(

This commit is contained in:
Mister_Nebula 2021-07-07 23:54:09 +01:00
parent f350123c07
commit 3af11df2ff
9 changed files with 27 additions and 27 deletions

View File

@ -49,8 +49,8 @@ namespace QSB.OrbSync.TransformSync
return QSBWorldSync.OldOrbList[_index].transform;
}
protected override Transform InitLocalTransform() => GetTransform();
protected override Transform InitRemoteTransform() => GetTransform();
protected override Component InitLocalTransform() => GetTransform();
protected override Component InitRemoteTransform() => GetTransform();
public override bool IsReady => QSBCore.WorldObjectsReady;
public override bool UseInterpolation => false;

View File

@ -58,7 +58,7 @@ namespace QSB.Player.TransformSync
}
}
protected override Transform InitLocalTransform()
protected override Component InitLocalTransform()
{
SectorSync.Init(Locator.GetPlayerSectorDetector(), this);
@ -89,7 +89,7 @@ namespace QSB.Player.TransformSync
return player;
}
protected override Transform InitRemoteTransform()
protected override Component InitRemoteTransform()
{
/*
* CREATE PLAYER STRUCTURE

View File

@ -18,7 +18,7 @@ namespace QSB.ProbeSync.TransformSync
LocalInstance = this;
}
protected override Transform InitLocalTransform()
protected override Component InitLocalTransform()
{
SectorSync.Init(Locator.GetProbe().GetSectorDetector(), this);
@ -37,7 +37,7 @@ namespace QSB.ProbeSync.TransformSync
return body;
}
protected override Transform InitRemoteTransform()
protected override Component InitRemoteTransform()
{
var probe = Locator.GetProbe().transform;

View File

@ -19,8 +19,8 @@ namespace QSB.SectorSync
private void OnEnable() => RepeatingManager.Repeatings.Add(this);
private void OnDisable() => RepeatingManager.Repeatings.Remove(this);
public List<SyncBase<Transform>> SectoredTransformSyncs = new List<SyncBase<Transform>>();
public List<SyncBase<OWRigidbody>> SectoredRigidbodySyncs = new List<SyncBase<OWRigidbody>>();
public List<SyncBase> SectoredTransformSyncs = new List<SyncBase>();
public List<SyncBase> SectoredRigidbodySyncs = new List<SyncBase>();
public void Invoke()
{
@ -88,7 +88,7 @@ namespace QSB.SectorSync
private void CheckTransformSyncSector<T>(ISectoredSync<T> transformSync)
where T : Component
{
var attachedObject = (transformSync as SyncBase<T>).AttachedObject;
var attachedObject = (transformSync as SyncBase).AttachedObject;
var closestSector = transformSync.SectorSync.GetClosestSector(attachedObject.transform);
if (closestSector == default(QSBSector))
{

View File

@ -2,6 +2,7 @@ using QSB.Player;
using QSB.SectorSync;
using QSB.Syncs.RigidbodySync;
using QSB.Utility;
using UnityEngine;
namespace QSB.ShipSync.TransformSync
{
@ -19,8 +20,8 @@ namespace QSB.ShipSync.TransformSync
LocalInstance = this;
}
protected override OWRigidbody InitLocalTransform() => throw new System.NotImplementedException();
protected override OWRigidbody InitRemoteTransform() => throw new System.NotImplementedException();
protected override Component InitLocalTransform() => throw new System.NotImplementedException();
protected override Component InitRemoteTransform() => throw new System.NotImplementedException();
protected override OWRigidbody GetRigidbody()
{

View File

@ -6,7 +6,7 @@ using UnityEngine;
namespace QSB.Syncs.RigidbodySync
{
public abstract class UnparentedBaseRigidbodySync : SyncBase<OWRigidbody>
public abstract class UnparentedBaseRigidbodySync : SyncBase
{
protected Vector3 _relativeVelocity;
protected Vector3 _relativeAngularVelocity;
@ -113,7 +113,7 @@ namespace QSB.Syncs.RigidbodySync
_intermediaryTransform.EncodePosition(AttachedObject.transform.position);
_intermediaryTransform.EncodeRotation(AttachedObject.transform.rotation);
_relativeVelocity = GetRelativeVelocity();
_relativeAngularVelocity = AttachedObject.GetRelativeAngularVelocity(ReferenceTransform.GetAttachedOWRigidbody());
_relativeAngularVelocity = (AttachedObject as OWRigidbody).GetRelativeAngularVelocity(ReferenceTransform.GetAttachedOWRigidbody());
return;
}
@ -127,21 +127,21 @@ namespace QSB.Syncs.RigidbodySync
if (UseInterpolation)
{
AttachedObject.SetPosition(SmartSmoothDamp(AttachedObject.transform.position, targetPos));
AttachedObject.SetRotation(QuaternionHelper.SmoothDamp(AttachedObject.transform.rotation, targetRot, ref _rotationSmoothVelocity, SmoothTime));
(AttachedObject as OWRigidbody).SetPosition(SmartSmoothDamp(AttachedObject.transform.position, targetPos));
(AttachedObject as OWRigidbody).SetRotation(QuaternionHelper.SmoothDamp(AttachedObject.transform.rotation, targetRot, ref _rotationSmoothVelocity, SmoothTime));
}
else
{
AttachedObject.SetPosition(targetPos);
AttachedObject.SetRotation(targetRot);
(AttachedObject as OWRigidbody).SetPosition(targetPos);
(AttachedObject as OWRigidbody).SetRotation(targetRot);
}
var currentVelocity = GetRelativeVelocity();
var targetVelocity = ReferenceTransform.GetAttachedOWRigidbody().GetPointVelocity(targetPos) + _relativeVelocity;
var adjustedTarget = targetVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameWorldVelocity();
SetVelocity(AttachedObject, targetVelocity);
AttachedObject.SetAngularVelocity(ReferenceTransform.GetAttachedOWRigidbody().GetAngularVelocity() + _relativeAngularVelocity);
SetVelocity((AttachedObject as OWRigidbody), targetVelocity);
(AttachedObject as OWRigidbody).SetAngularVelocity(ReferenceTransform.GetAttachedOWRigidbody().GetAngularVelocity() + _relativeAngularVelocity);
}
private void SetVelocity(OWRigidbody rigidbody, Vector3 relativeVelocity)
@ -231,7 +231,7 @@ namespace QSB.Syncs.RigidbodySync
}
var pointVelocity = attachedRigid.GetPointVelocity(AttachedObject.transform.position);
return AttachedObject.GetVelocity() - pointVelocity;
return (AttachedObject as OWRigidbody).GetVelocity() - pointVelocity;
}
}
}

View File

@ -6,8 +6,7 @@ using UnityEngine;
namespace QSB.Syncs
{
public abstract class SyncBase<T> : QNetworkTransform
where T : Component
public abstract class SyncBase : QNetworkTransform
{
public uint AttachedNetId
{
@ -44,7 +43,7 @@ namespace QSB.Syncs
public abstract bool IsReady { get; }
public abstract bool UseInterpolation { get; }
public T AttachedObject { get; set; }
public Component AttachedObject { get; set; }
public Transform ReferenceTransform { get; set; }
protected string _logName => $"{PlayerId}.{GetType().Name}";
@ -56,8 +55,8 @@ namespace QSB.Syncs
protected IntermediaryTransform _intermediaryTransform;
protected bool _isInitialized;
protected abstract T InitLocalTransform();
protected abstract T InitRemoteTransform();
protected abstract Component InitLocalTransform();
protected abstract Component InitRemoteTransform();
protected abstract void UpdateTransform();
protected abstract void Init();

View File

@ -15,7 +15,7 @@ namespace QSB.Syncs.TransformSync
* God has cursed me for my hubris, and my work is never finished.
*/
public abstract class BaseTransformSync : SyncBase<Transform>
public abstract class BaseTransformSync : SyncBase
{
private readonly static Dictionary<PlayerInfo, Dictionary<Type, BaseTransformSync>> _storedTransformSyncs = new Dictionary<PlayerInfo, Dictionary<Type, BaseTransformSync>>();

View File

@ -7,7 +7,7 @@ using UnityEngine;
namespace QSB.Syncs.TransformSync
{
public abstract class UnparentedBaseTransformSync : SyncBase<Transform>
public abstract class UnparentedBaseTransformSync : SyncBase
{
public virtual void Start()
{