Skip to content

Commit df60ea7

Browse files
committed
Addressed Standards check complains
1 parent 2a7db89 commit df60ea7

17 files changed

Lines changed: 165 additions & 165 deletions

File tree

com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,14 +2152,14 @@ private bool GetReadMethodForParameter(TypeReference paramType, out MethodRefere
21522152
}
21532153
else
21542154
#endif
2155-
if (paramType.Resolve().FullName == "Unity.Collections.NativeArray`1")
2156-
{
2157-
typeMethod = GetFastBufferReaderReadMethod(k_ReadValueTempMethodName, paramType);
2158-
}
2159-
else
2160-
{
2161-
typeMethod = GetFastBufferReaderReadMethod(k_ReadValueMethodName, paramType);
2162-
}
2155+
if (paramType.Resolve().FullName == "Unity.Collections.NativeArray`1")
2156+
{
2157+
typeMethod = GetFastBufferReaderReadMethod(k_ReadValueTempMethodName, paramType);
2158+
}
2159+
else
2160+
{
2161+
typeMethod = GetFastBufferReaderReadMethod(k_ReadValueMethodName, paramType);
2162+
}
21632163
if (typeMethod != null)
21642164
{
21652165
methodRef = m_MainModule.ImportReference(typeMethod);

com.unity.netcode.gameobjects/Editor/NetworkManagerHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ public bool NotifyUserOfNestedNetworkManager(NetworkManager networkManager, bool
196196
return isParented;
197197
}
198198
else // If we are no longer a child, then we can remove ourself from this list
199-
if (transform.root == gameObject.transform)
200-
{
201-
s_LastKnownNetworkManagerParents.Remove(networkManager);
202-
}
199+
if (transform.root == gameObject.transform)
200+
{
201+
s_LastKnownNetworkManagerParents.Remove(networkManager);
202+
}
203203
}
204204
if (!EditorApplication.isUpdating && isParented)
205205
{

com.unity.netcode.gameobjects/Runtime/Components/Interpolator/BufferedLinearInterpolator.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -468,19 +468,19 @@ internal T Update(float deltaTime, double tickLatencyAsTime, double minDeltaTime
468468
}
469469
}
470470
else // If the target is reached and we have no more state updates, we want to check to see if we need to reset.
471-
if (m_BufferQueue.Count == 0)
472-
{
473-
// When the delta between the time sent and the current tick latency time-window is greater than the max delta time
474-
// plus the minimum delta time (a rough estimate of time to wait before we consider rate of change equal to zero),
475-
// we will want to reset the interpolator with the current known value. This prevents the next received state update's
476-
// time to be calculated against the last calculated time which if there is an extended period of time between the two
477-
// it would cause a large delta time period between the two states (i.e. it stops moving for a second or two and then
478-
// starts moving again).
479-
if ((tickLatencyAsTime - InterpolateState.Target.Value.TimeSent) > InterpolateState.MaxDeltaTime + minDeltaTime)
471+
if (m_BufferQueue.Count == 0)
480472
{
481-
InterpolateState.Reset(InterpolateState.CurrentValue);
473+
// When the delta between the time sent and the current tick latency time-window is greater than the max delta time
474+
// plus the minimum delta time (a rough estimate of time to wait before we consider rate of change equal to zero),
475+
// we will want to reset the interpolator with the current known value. This prevents the next received state update's
476+
// time to be calculated against the last calculated time which if there is an extended period of time between the two
477+
// it would cause a large delta time period between the two states (i.e. it stops moving for a second or two and then
478+
// starts moving again).
479+
if ((tickLatencyAsTime - InterpolateState.Target.Value.TimeSent) > InterpolateState.MaxDeltaTime + minDeltaTime)
480+
{
481+
InterpolateState.Reset(InterpolateState.CurrentValue);
482+
}
482483
}
483-
}
484484
}
485485
m_NbItemsReceivedThisFrame = 0;
486486
return InterpolateState.CurrentValue;
@@ -594,19 +594,19 @@ public T Update(float deltaTime, double renderTime, double serverTime)
594594
InterpolateState.TargetReached = IsApproximately(InterpolateState.CurrentValue, InterpolateState.Target.Value.Item, GetPrecision());
595595
}
596596
else // If the target is reached and we have no more state updates, we want to check to see if we need to reset.
597-
if (InterpolateState.TargetReached && m_BufferQueue.Count == 0)
598-
{
599-
// When the delta between the time sent and the current tick latency time-window is greater than the max delta time
600-
// plus the minimum delta time (a rough estimate of time to wait before we consider rate of change equal to zero),
601-
// we will want to reset the interpolator with the current known value. This prevents the next received state update's
602-
// time to be calculated against the last calculated time which if there is an extended period of time between the two
603-
// it would cause a large delta time period between the two states (i.e. it stops moving for a second or two and then
604-
// starts moving again).
605-
if ((renderTime - InterpolateState.Target.Value.TimeSent) > 0.3f) // If we haven't recevied anything within 300ms, assume we stopped motion.
597+
if (InterpolateState.TargetReached && m_BufferQueue.Count == 0)
606598
{
607-
InterpolateState.Reset(InterpolateState.CurrentValue);
599+
// When the delta between the time sent and the current tick latency time-window is greater than the max delta time
600+
// plus the minimum delta time (a rough estimate of time to wait before we consider rate of change equal to zero),
601+
// we will want to reset the interpolator with the current known value. This prevents the next received state update's
602+
// time to be calculated against the last calculated time which if there is an extended period of time between the two
603+
// it would cause a large delta time period between the two states (i.e. it stops moving for a second or two and then
604+
// starts moving again).
605+
if ((renderTime - InterpolateState.Target.Value.TimeSent) > 0.3f) // If we haven't recevied anything within 300ms, assume we stopped motion.
606+
{
607+
InterpolateState.Reset(InterpolateState.CurrentValue);
608+
}
608609
}
609-
}
610610
m_NbItemsReceivedThisFrame = 0;
611611
return InterpolateState.CurrentValue;
612612
}

com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,25 +1181,25 @@ internal void CheckForAnimatorChanges()
11811181
SendAnimStateRpc(m_AnimationMessage);
11821182
}
11831183
else
1184-
if (!IsServer && IsOwner)
1185-
{
1186-
SendServerAnimStateRpc(m_AnimationMessage);
1187-
}
1188-
else
1189-
{
1190-
// Just notify all remote clients and not the local server
1191-
m_TargetGroup.Clear();
1192-
foreach (var clientId in LocalNetworkManager.ConnectionManager.ConnectedClientIds)
1184+
if (!IsServer && IsOwner)
1185+
{
1186+
SendServerAnimStateRpc(m_AnimationMessage);
1187+
}
1188+
else
11931189
{
1194-
if (clientId == LocalNetworkManager.LocalClientId || !NetworkObject.Observers.Contains(clientId))
1190+
// Just notify all remote clients and not the local server
1191+
m_TargetGroup.Clear();
1192+
foreach (var clientId in LocalNetworkManager.ConnectionManager.ConnectedClientIds)
11951193
{
1196-
continue;
1194+
if (clientId == LocalNetworkManager.LocalClientId || !NetworkObject.Observers.Contains(clientId))
1195+
{
1196+
continue;
1197+
}
1198+
m_TargetGroup.Add(clientId);
11971199
}
1198-
m_TargetGroup.Add(clientId);
1200+
m_RpcParams.Send.Target = m_TargetGroup.Target;
1201+
SendClientAnimStateRpc(m_AnimationMessage, m_RpcParams);
11991202
}
1200-
m_RpcParams.Send.Target = m_TargetGroup.Target;
1201-
SendClientAnimStateRpc(m_AnimationMessage, m_RpcParams);
1202-
}
12031203
}
12041204
}
12051205

@@ -1347,24 +1347,24 @@ private unsafe void WriteParameters(ref FastBufferWriter writer)
13471347
}
13481348
}
13491349
else
1350-
if (cacheValue.Type == AnimationParamEnumWrapper.AnimatorControllerParameterBool)
1351-
{
1352-
var valueBool = m_Animator.GetBool(hash);
1353-
fixed (void* value = cacheValue.Value)
1350+
if (cacheValue.Type == AnimationParamEnumWrapper.AnimatorControllerParameterBool)
13541351
{
1355-
UnsafeUtility.WriteArrayElement(value, 0, valueBool);
1356-
BytePacker.WriteValuePacked(writer, valueBool);
1352+
var valueBool = m_Animator.GetBool(hash);
1353+
fixed (void* value = cacheValue.Value)
1354+
{
1355+
UnsafeUtility.WriteArrayElement(value, 0, valueBool);
1356+
BytePacker.WriteValuePacked(writer, valueBool);
1357+
}
13571358
}
1358-
}
1359-
else if (cacheValue.Type == AnimationParamEnumWrapper.AnimatorControllerParameterFloat)
1360-
{
1361-
var valueFloat = m_Animator.GetFloat(hash);
1362-
fixed (void* value = cacheValue.Value)
1359+
else if (cacheValue.Type == AnimationParamEnumWrapper.AnimatorControllerParameterFloat)
13631360
{
1364-
UnsafeUtility.WriteArrayElement(value, 0, valueFloat);
1365-
BytePacker.WriteValuePacked(writer, valueFloat);
1361+
var valueFloat = m_Animator.GetFloat(hash);
1362+
fixed (void* value = cacheValue.Value)
1363+
{
1364+
UnsafeUtility.WriteArrayElement(value, 0, valueFloat);
1365+
BytePacker.WriteValuePacked(writer, valueFloat);
1366+
}
13661367
}
1367-
}
13681368
}
13691369
}
13701370

com.unity.netcode.gameobjects/Runtime/Components/NetworkTransform.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,23 +2516,23 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, bool is
25162516
}
25172517
}
25182518
else // Just apply the full local scale when synchronizing
2519-
if (SynchronizeScale)
2520-
{
2521-
var localScale = CachedTransform.localScale;
2522-
if (!UseHalfFloatPrecision)
2519+
if (SynchronizeScale)
25232520
{
2521+
var localScale = CachedTransform.localScale;
2522+
if (!UseHalfFloatPrecision)
2523+
{
25242524

2525-
networkState.ScaleX = localScale.x;
2526-
networkState.ScaleY = localScale.y;
2527-
networkState.ScaleZ = localScale.z;
2528-
}
2529-
else
2530-
{
2531-
networkState.Scale = localScale;
2525+
networkState.ScaleX = localScale.x;
2526+
networkState.ScaleY = localScale.y;
2527+
networkState.ScaleZ = localScale.z;
2528+
}
2529+
else
2530+
{
2531+
networkState.Scale = localScale;
2532+
}
2533+
flagStates.MarkChanged(AxialType.Scale, true);
2534+
isScaleDirty = true;
25322535
}
2533-
flagStates.MarkChanged(AxialType.Scale, true);
2534-
isScaleDirty = true;
2535-
}
25362536
isDirty |= isPositionDirty || isRotationDirty || isScaleDirty;
25372537

25382538
if (isDirty)
@@ -3489,11 +3489,11 @@ private void NonAuthorityFinalizeSynchronization()
34893489
}
34903490
}
34913491
else // Otherwise, just run through standard synchronization of this instance
3492-
if (!CanCommitToTransform)
3493-
{
3494-
ApplySynchronization();
3495-
InternalInitialization();
3496-
}
3492+
if (!CanCommitToTransform)
3493+
{
3494+
ApplySynchronization();
3495+
InternalInitialization();
3496+
}
34973497
}
34983498
}
34993499

com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -968,18 +968,18 @@ internal void ProcessClientsToDisconnect()
968968
return (true, playerPrefabHash.Value);
969969
}
970970
else
971-
if (NetworkManager.NetworkConfig.PlayerPrefab != null)
972-
{
973-
var networkObject = NetworkManager.NetworkConfig.PlayerPrefab.GetComponent<NetworkObject>();
974-
if (networkObject != null)
971+
if (NetworkManager.NetworkConfig.PlayerPrefab != null)
975972
{
976-
return (true, networkObject.GlobalObjectIdHash);
977-
}
978-
else
979-
{
980-
NetworkManager.Log.Error(new Logging.Context(LogLevel.Error, $"Player prefab {NetworkManager.NetworkConfig.PlayerPrefab.name} has no {nameof(NetworkObject)}!"));
973+
var networkObject = NetworkManager.NetworkConfig.PlayerPrefab.GetComponent<NetworkObject>();
974+
if (networkObject != null)
975+
{
976+
return (true, networkObject.GlobalObjectIdHash);
977+
}
978+
else
979+
{
980+
NetworkManager.Log.Error(new Logging.Context(LogLevel.Error, $"Player prefab {NetworkManager.NetworkConfig.PlayerPrefab.name} has no {nameof(NetworkObject)}!"));
981+
}
981982
}
982-
}
983983
return (false, 0);
984984
}
985985

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,25 +2564,25 @@ internal bool ApplyNetworkParenting(bool removeParent = false, bool ignoreNotSpa
25642564
return true;
25652565
}
25662566
else // If the parent still isn't spawned add this to the orphaned children and return false
2567-
if (!parentNetworkObject.IsSpawned)
2568-
{
2569-
OrphanChildren.Add(this);
2570-
return false;
2571-
}
2572-
else
2573-
{
2574-
// If we made it this far, go ahead and set the network parenting values
2575-
// with the WorldPoisitonSays value set to false
2576-
// Note: Since in-scene placed NetworkObjects are parented in the scene
2577-
// the default "assumption" is that children are parenting local space
2578-
// relative.
2579-
SetNetworkParenting(parentNetworkObject.NetworkObjectId, false);
2567+
if (!parentNetworkObject.IsSpawned)
2568+
{
2569+
OrphanChildren.Add(this);
2570+
return false;
2571+
}
2572+
else
2573+
{
2574+
// If we made it this far, go ahead and set the network parenting values
2575+
// with the WorldPoisitonSays value set to false
2576+
// Note: Since in-scene placed NetworkObjects are parented in the scene
2577+
// the default "assumption" is that children are parenting local space
2578+
// relative.
2579+
SetNetworkParenting(parentNetworkObject.NetworkObjectId, false);
25802580

2581-
// Set the cached parent
2582-
SetCachedParent(parentNetworkObject.transform);
2581+
// Set the cached parent
2582+
SetCachedParent(parentNetworkObject.transform);
25832583

2584-
return true;
2585-
}
2584+
return true;
2585+
}
25862586
}
25872587

25882588
// If we are removing the parent or our latest parent is not set, then remove the parent.
@@ -3548,16 +3548,16 @@ internal void SceneChangedUpdate(Scene scene, bool notify = false)
35483548
}
35493549
}
35503550
else // Otherwise, the client did not find the client to server scene handle
3551-
if (NetworkManagerOwner.LogLevel <= LogLevel.Developer)
3552-
{
3553-
// There could be a scenario where a user has some client-local scene loaded that they migrate the NetworkObject
3554-
// into, but that scenario seemed very edge case and under most instances a user should be notified that this
3555-
// server - client scene handle mismatch has occurred. It also seemed pertinent to make the message replicate to
3556-
// the server-side too.
3557-
NetworkLog.LogWarningServer($"[Client-{NetworkManagerOwner.LocalClientId}][{name}] Server - " +
3558-
$"client scene mismatch detected! Client-side scene handle ({SceneOriginHandle}) for scene ({gameObject.scene.name})" +
3559-
$"has no associated server side (network) scene handle!");
3560-
}
3551+
if (NetworkManagerOwner.LogLevel <= LogLevel.Developer)
3552+
{
3553+
// There could be a scenario where a user has some client-local scene loaded that they migrate the NetworkObject
3554+
// into, but that scenario seemed very edge case and under most instances a user should be notified that this
3555+
// server - client scene handle mismatch has occurred. It also seemed pertinent to make the message replicate to
3556+
// the server-side too.
3557+
NetworkLog.LogWarningServer($"[Client-{NetworkManagerOwner.LocalClientId}][{name}] Server - " +
3558+
$"client scene mismatch detected! Client-side scene handle ({SceneOriginHandle}) for scene ({gameObject.scene.name})" +
3559+
$"has no associated server side (network) scene handle!");
3560+
}
35613561
OnMigratedToNewScene?.Invoke();
35623562

35633563
// Only the authority side will notify clients of non-parented NetworkObject scene changes

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/CreateObjectMessage.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ internal static void CreateObject(ref NetworkManager networkManager, ulong sende
190190
NetworkLog.LogErrorServer($"[{nameof(CreateObjectMessage)}][Duplicate-Broadcast] Detected duplicated object creation for {serializedObject.NetworkObjectId}!");
191191
}
192192
else // Trap to make sure the owner is not receiving any messages it sent
193-
if (networkManager.CMBServiceConnection && networkManager.LocalClientId == networkObject.OwnerClientId)
194-
{
195-
NetworkLog.LogWarning($"[{nameof(CreateObjectMessage)}][Client-{networkManager.LocalClientId}][Duplicate-CreateObjectMessage][Client Is Owner] Detected duplicated object creation for {networkObject.name}-{serializedObject.NetworkObjectId}!");
196-
}
193+
if (networkManager.CMBServiceConnection && networkManager.LocalClientId == networkObject.OwnerClientId)
194+
{
195+
NetworkLog.LogWarning($"[{nameof(CreateObjectMessage)}][Client-{networkManager.LocalClientId}][Duplicate-CreateObjectMessage][Client Is Owner] Detected duplicated object creation for {networkObject.name}-{serializedObject.NetworkObjectId}!");
196+
}
197197
}
198198
else
199199
{

0 commit comments

Comments
 (0)