move stuff from OnStopClient to Uninit

This commit is contained in:
JohnCorby 2022-01-21 17:51:26 -08:00
parent bf4783a3dd
commit 5b77d341fe
6 changed files with 54 additions and 33 deletions

View File

@ -28,14 +28,6 @@ namespace QSB.Anglerfish.TransformSync
{
_instances.Remove(this);
base.OnStopClient();
if (QSBCore.IsHost)
{
netIdentity.UnregisterAuthQueue();
}
AttachedRigidbody.OnUnsuspendOWRigidbody -= OnUnsuspend;
AttachedRigidbody.OnSuspendOWRigidbody -= OnSuspend;
}
protected override float SendInterval => 1;
@ -59,6 +51,19 @@ namespace QSB.Anglerfish.TransformSync
netIdentity.SendAuthQueueMessage(AttachedRigidbody.IsSuspended() ? AuthQueueAction.Remove : AuthQueueAction.Add);
}
protected override void Uninit()
{
if (QSBCore.IsHost)
{
netIdentity.UnregisterAuthQueue();
}
AttachedRigidbody.OnUnsuspendOWRigidbody -= OnUnsuspend;
AttachedRigidbody.OnSuspendOWRigidbody -= OnSuspend;
base.Uninit();
}
private void OnUnsuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Add);
private void OnSuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Remove);

View File

@ -29,14 +29,6 @@ namespace QSB.JellyfishSync.TransformSync
{
_instances.Remove(this);
base.OnStopClient();
if (QSBCore.IsHost)
{
netIdentity.UnregisterAuthQueue();
}
AttachedRigidbody.OnUnsuspendOWRigidbody -= OnUnsuspend;
AttachedRigidbody.OnSuspendOWRigidbody -= OnSuspend;
}
protected override float SendInterval => 10;
@ -60,6 +52,19 @@ namespace QSB.JellyfishSync.TransformSync
netIdentity.SendAuthQueueMessage(AttachedRigidbody.IsSuspended() ? AuthQueueAction.Remove : AuthQueueAction.Add);
}
protected override void Uninit()
{
if (QSBCore.IsHost)
{
netIdentity.UnregisterAuthQueue();
}
AttachedRigidbody.OnUnsuspendOWRigidbody -= OnUnsuspend;
AttachedRigidbody.OnSuspendOWRigidbody -= OnSuspend;
base.Uninit();
}
private void OnUnsuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Add);
private void OnSuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Remove);

View File

@ -36,14 +36,6 @@ namespace QSB.OrbSync.TransformSync
{
_instances.Remove(this);
base.OnStopClient();
if (QSBCore.IsHost)
{
netIdentity.UnregisterAuthQueue();
}
_attachedBody.OnUnsuspendOWRigidbody -= OnUnsuspend;
_attachedBody.OnSuspendOWRigidbody -= OnSuspend;
}
protected override void Init()
@ -62,15 +54,6 @@ namespace QSB.OrbSync.TransformSync
_attachedBody = AttachedTransform.GetAttachedOWRigidbody();
SetReferenceTransform(_attachedBody.GetOrigParent());
/*
if (_attachedBody.GetOrigParent() == Locator.GetRootTransform())
{
DebugLog.DebugWrite($"{LogName} with AttachedObject {AttachedObject.name} had it's original parent as SolarSystemRoot - Disabling...");
enabled = false;
return;
}
*/
if (QSBCore.IsHost)
{
netIdentity.RegisterAuthQueue();
@ -81,6 +64,20 @@ namespace QSB.OrbSync.TransformSync
netIdentity.SendAuthQueueMessage(_attachedBody.IsSuspended() ? AuthQueueAction.Remove : AuthQueueAction.Add);
}
protected override void Uninit()
{
if (QSBCore.IsHost)
{
netIdentity.UnregisterAuthQueue();
}
_attachedBody.OnUnsuspendOWRigidbody -= OnUnsuspend;
_attachedBody.OnSuspendOWRigidbody -= OnSuspend;
_attachedBody = null;
base.Uninit();
}
private void OnUnsuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Add);
private void OnSuspend(OWRigidbody suspendedBody) => netIdentity.SendAuthQueueMessage(AuthQueueAction.Remove);
}

View File

@ -49,6 +49,12 @@ namespace QSB.Syncs.Sectored.Rigidbodies
_relativeAngularVelocity = reader.ReadVector3();
}
protected override void Uninit()
{
base.Uninit();
AttachedRigidbody = null;
}
protected override void GetFromAttached()
{
GetFromSector();

View File

@ -172,6 +172,8 @@ namespace QSB.Syncs
Destroy(AttachedTransform.gameObject);
}
AttachedTransform = null;
ReferenceTransform = null;
IsInitialized = false;
}

View File

@ -49,6 +49,12 @@ namespace QSB.Syncs.Unsectored.Rigidbodies
_relativeAngularVelocity = reader.ReadVector3();
}
protected override void Uninit()
{
base.Uninit();
AttachedRigidbody = null;
}
protected override void GetFromAttached()
{
transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition());