wait a frame

This commit is contained in:
Will Corby 2022-01-03 00:15:57 -08:00
parent 58e1c70c33
commit b1a4b357d5

View File

@ -180,32 +180,34 @@ namespace QSB.QuantumSync.WorldObjects
((IQSBQuantumObject)this).SendMessage(new QuantumAuthorityMessage(QSBPlayerManager.LocalPlayerId));
}
private void OnDisable(Shape s)
{
if (!IsEnabled)
private void OnDisable(Shape s) =>
// we wait a frame here in case the shapes get disabled as we switch from 1 visibility tracker to another
QSBCore.UnityEvents.FireOnNextUpdate(() =>
{
return;
}
if (!IsEnabled)
{
return;
}
if (GetAttachedShapes().Any(x => x.isActiveAndEnabled))
{
return;
}
if (GetAttachedShapes().Any(x => x.isActiveAndEnabled))
{
return;
}
IsEnabled = false;
if (!WorldObjectManager.AllObjectsReady && !QSBCore.IsHost)
{
return;
}
IsEnabled = false;
if (!WorldObjectManager.AllObjectsReady && !QSBCore.IsHost)
{
return;
}
if (ControllingPlayer != QSBPlayerManager.LocalPlayerId)
{
// not being controlled by us, don't care if we leave area
return;
}
if (ControllingPlayer != QSBPlayerManager.LocalPlayerId)
{
// not being controlled by us, don't care if we leave area
return;
}
// send event to other players that we're releasing authority
((IQSBQuantumObject)this).SendMessage(new QuantumAuthorityMessage(0u));
}
// send event to other players that we're releasing authority
((IQSBQuantumObject)this).SendMessage(new QuantumAuthorityMessage(0u));
});
}
}