mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-17 01:13:05 +00:00
rotating elements: only do auth on first lit/last darkened
This commit is contained in:
parent
4b679746e6
commit
133639353b
@ -73,9 +73,6 @@ public static class AuthorityManager
|
||||
{
|
||||
identity.AssignClientAuthority(newConn);
|
||||
}
|
||||
|
||||
// DebugLog.DebugWrite($"{identity.NetId}:{identity.gameObject.name} - "
|
||||
// + $"set authority to {id}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -19,6 +19,7 @@ internal abstract class QSBRotatingElements<T, U> : LinkedWorldObject<T, U>
|
||||
|
||||
protected abstract IEnumerable<SingleLightSensor> LightSensors { get; }
|
||||
private QSBLightSensor[] _qsbLightSensors;
|
||||
private int _litSensors;
|
||||
|
||||
public override async UniTask Init(CancellationToken ct)
|
||||
{
|
||||
@ -45,8 +46,23 @@ internal abstract class QSBRotatingElements<T, U> : LinkedWorldObject<T, U>
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDetectLocalLight() => NetworkBehaviour.netIdentity.UpdateAuthQueue(AuthQueueAction.Add);
|
||||
private void OnDetectLocalDarkness() => NetworkBehaviour.netIdentity.UpdateAuthQueue(AuthQueueAction.Remove);
|
||||
private void OnDetectLocalLight()
|
||||
{
|
||||
_litSensors++;
|
||||
if (_litSensors == 1)
|
||||
{
|
||||
NetworkBehaviour.netIdentity.UpdateAuthQueue(AuthQueueAction.Add);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDetectLocalDarkness()
|
||||
{
|
||||
_litSensors--;
|
||||
if (_litSensors == 0)
|
||||
{
|
||||
NetworkBehaviour.netIdentity.UpdateAuthQueue(AuthQueueAction.Remove);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool SpawnWithServerAuthority => false;
|
||||
}
|
||||
|
@ -36,11 +36,8 @@ internal abstract class RotatingElementsVariableSyncer<TWorldObject> : BaseVaria
|
||||
protected override bool HasChanged()
|
||||
{
|
||||
var rotatingElements = RotatingElements;
|
||||
if (Value == null)
|
||||
{
|
||||
Value = new Quaternion[rotatingElements.Length];
|
||||
PrevValue = new Quaternion[rotatingElements.Length];
|
||||
}
|
||||
Value ??= new Quaternion[rotatingElements.Length];
|
||||
PrevValue ??= new Quaternion[rotatingElements.Length];
|
||||
|
||||
for (var i = 0; i < rotatingElements.Length; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user