NetworkIdentity.DirtyMasks: syntax simplified

This commit is contained in:
mischa 2024-07-14 10:14:09 +02:00
parent 54b78251ad
commit f730b61cb9

View File

@ -844,9 +844,9 @@ internal void OnStopLocalPlayer()
for (int i = 0; i < components.Length; ++i) for (int i = 0; i < components.Length; ++i)
{ {
NetworkBehaviour component = components[i]; NetworkBehaviour component = components[i];
ulong nthBit = (1u << i);
bool dirty = component.IsDirty(); bool dirty = component.IsDirty();
ulong nthBit = (1u << i);
// owner needs to be considered for both SyncModes, because // owner needs to be considered for both SyncModes, because
// Observers mode always includes the Owner. // Observers mode always includes the Owner.
@ -888,11 +888,13 @@ ulong ClientDirtyMask()
// on client, only consider owned components with SyncDirection to server // on client, only consider owned components with SyncDirection to server
NetworkBehaviour component = components[i]; NetworkBehaviour component = components[i];
ulong nthBit = (1u << i);
if (isOwned && component.syncDirection == SyncDirection.ClientToServer) if (isOwned && component.syncDirection == SyncDirection.ClientToServer)
{ {
// set the n-th bit if dirty // set the n-th bit if dirty
// shifting from small to large numbers is varint-efficient. // shifting from small to large numbers is varint-efficient.
if (component.IsDirty()) mask |= (1u << i); if (component.IsDirty()) mask |= nthBit;
} }
} }