Skip to content

Commit 966e1d0

Browse files
committed
Standards changes
1 parent 335eb73 commit 966e1d0

11 files changed

Lines changed: 34 additions & 43 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
#if UNIFIED_NETCODE
3-
using Unity.NetCode;
43
using Unity.Netcode.Editor;
54
#endif
65
using UnityEditor;

com.unity.netcode.gameobjects/Runtime/Components/Helpers/NetworkObjectBridge.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#if UNIFIED_NETCODE
2-
using Unity.Entities;
3-
using Unity.NetCode;
42
using Unity.Transforms;
53
using UnityEngine;
64

@@ -98,7 +96,7 @@ internal static void ApplyPostTransformMatrixScale(this GhostObject ghost, Vecto
9896
var entity = ghost.Entity;
9997
if (entityManager.HasComponent<PostTransformMatrix>(entity))
10098
{
101-
entityManager.SetComponentData(entity, new PostTransformMatrix { Value = Unity.Mathematics.float4x4.Scale(scale) });
99+
entityManager.SetComponentData(entity, new PostTransformMatrix { Value = Mathematics.float4x4.Scale(scale) });
102100
}
103101
else if (Mathf.Approximately(scale.x, scale.y) && Mathf.Approximately(scale.y, scale.z))
104102
{
@@ -108,7 +106,7 @@ internal static void ApplyPostTransformMatrixScale(this GhostObject ghost, Vecto
108106
}
109107
else
110108
{
111-
entityManager.AddComponentData(entity, new PostTransformMatrix { Value = Unity.Mathematics.float4x4.Scale(scale) });
109+
entityManager.AddComponentData(entity, new PostTransformMatrix { Value = Mathematics.float4x4.Scale(scale) });
112110
}
113111
}
114112
}

com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedBootstrap.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#if UNIFIED_NETCODE
22
using System;
33
using Unity.Entities;
4-
using Unity.NetCode;
54
using UnityEngine;
65

76
namespace Unity.Netcode

com.unity.netcode.gameobjects/Runtime/Components/Helpers/UnifiedUpdateConnections.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using Unity.Collections;
44
using Unity.Entities;
5-
using Unity.NetCode;
65
using UnityEngine;
76

87
namespace Unity.Netcode.Components

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// blanket import of it competes with Unity.Netcode on every name the two happen to share. Importing
99
// only the types used here keeps that surface to exactly those names.
1010
using NetCodeConfig = Unity.Netcode.NetcodeConfig;
11-
using NetcodeWorld = Unity.Netcode.NetcodeWorld;
1211
#endif
1312
using Unity.Netcode.Components;
1413
using Unity.Netcode.GameObjects.Timing;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Unity.Netcode.Logging;
99
using Unity.Netcode.Runtime;
1010
#if UNIFIED_NETCODE
11-
using Unity.NetCode;
1211
#endif
1312

1413
#if UNITY_EDITOR

com.unity.netcode.gameobjects/Runtime/Spawning/GhostSpawnManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ internal void ProcessAllGhostsPendingSynchronization()
182182
m_GhostSynchronizationPendingRemoval.Add(networkObjectId);
183183
}
184184
else
185-
if ((ghost.Value.RegistrationTime + spawnTimeout) < Time.realtimeSinceStartup)
186-
{
187-
m_Log.Info(new Context(LogLevel.Developer, $"Registering {nameof(NetworkObject.SerializedObject)} for pending synchronization").AddInfo(nameof(NetworkObject.NetworkObjectId), networkObjectId));
185+
if ((ghost.Value.RegistrationTime + spawnTimeout) < Time.realtimeSinceStartup)
186+
{
187+
m_Log.Info(new Context(LogLevel.Developer, $"Registering {nameof(NetworkObject.SerializedObject)} for pending synchronization").AddInfo(nameof(NetworkObject.NetworkObjectId), networkObjectId));
188188

189-
// Timed out entries are removed too
190-
m_GhostSynchronizationPendingRemoval.Add(ghost.Key);
191-
}
189+
// Timed out entries are removed too
190+
m_GhostSynchronizationPendingRemoval.Add(ghost.Key);
191+
}
192192
}
193193

194194
foreach (var networkObjectId in m_GhostSynchronizationPendingRemoval)

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkPrefabHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
#if UNIFIED_NETCODE
4-
using Unity.NetCode;
54
#endif
65
using UnityEngine;
76

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -981,27 +981,27 @@ internal NetworkObject CreateLocalNetworkObject(NetworkObject.SerializedObject s
981981
}
982982
else
983983
#endif
984-
// If scene management is disabled or the NetworkObject was dynamically spawned
985-
if (!NetworkManager.NetworkConfig.EnableSceneManagement || !serializedObject.IsSceneObject)
986-
{
987-
networkObject = GetNetworkObjectToSpawn(serializedObject.Hash, serializedObject.OwnerClientId, position, rotation, serializedObject.IsSceneObject, instantiationData);
988-
}
989-
else // Get the in-scene placed NetworkObject
990-
{
991-
networkObject = NetworkManager.SceneManager.GetSceneRelativeInSceneNetworkObject(globalObjectIdHash, serializedObject.NetworkSceneHandle);
992-
if (networkObject == null)
984+
// If scene management is disabled or the NetworkObject was dynamically spawned
985+
if (!NetworkManager.NetworkConfig.EnableSceneManagement || !serializedObject.IsSceneObject)
993986
{
994-
NetworkLog.LogErrorServer(new Context(LogLevel.Error, $"{nameof(NetworkPrefab)} hash was not found! In-Scene placed {nameof(NetworkObject)} soft synchronization failure!").AddInfo(nameof(NetworkObject.GlobalObjectIdHash), globalObjectIdHash));
995-
return null;
987+
networkObject = GetNetworkObjectToSpawn(serializedObject.Hash, serializedObject.OwnerClientId, position, rotation, serializedObject.IsSceneObject, instantiationData);
996988
}
997-
998-
// Since this NetworkObject is an in-scene placed NetworkObject, if it is disabled then enable it so
999-
// NetworkBehaviours will have their OnNetworkSpawn method invoked
1000-
if (!networkObject.gameObject.activeInHierarchy)
989+
else // Get the in-scene placed NetworkObject
1001990
{
1002-
networkObject.gameObject.SetActive(true);
991+
networkObject = NetworkManager.SceneManager.GetSceneRelativeInSceneNetworkObject(globalObjectIdHash, serializedObject.NetworkSceneHandle);
992+
if (networkObject == null)
993+
{
994+
NetworkLog.LogErrorServer(new Context(LogLevel.Error, $"{nameof(NetworkPrefab)} hash was not found! In-Scene placed {nameof(NetworkObject)} soft synchronization failure!").AddInfo(nameof(NetworkObject.GlobalObjectIdHash), globalObjectIdHash));
995+
return null;
996+
}
997+
998+
// Since this NetworkObject is an in-scene placed NetworkObject, if it is disabled then enable it so
999+
// NetworkBehaviours will have their OnNetworkSpawn method invoked
1000+
if (!networkObject.gameObject.activeInHierarchy)
1001+
{
1002+
networkObject.gameObject.SetActive(true);
1003+
}
10031004
}
1004-
}
10051005
if (networkObject == null)
10061006
{
10071007
return null;

com.unity.netcode.gameobjects/Runtime/Transports/Unified/UnifiedNetcodeTransport.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Unity.Collections;
77
using Unity.Collections.LowLevel.Unsafe;
88
using Unity.Entities;
9-
using Unity.NetCode;
109
using Unity.Netcode.GameObjects.Timing;
1110
using Unity.Netcode.Transports.UTP;
1211
using UnityEngine;
@@ -165,7 +164,7 @@ protected override void OnUpdate()
165164
NetworkManager.MessageManager.ProcessSendQueues();
166165

167166
using var commandBuffer = new EntityCommandBuffer(Allocator.Temp);
168-
foreach(var (networkId, _, entity) in SystemAPI.Query<RefRO<NetworkId>, RefRO<NetworkStreamConnection>>().WithEntityAccess())
167+
foreach (var (networkId, _, entity) in SystemAPI.Query<RefRO<NetworkId>, RefRO<NetworkStreamConnection>>().WithEntityAccess())
169168
{
170169
var connectionId = networkId.ValueRO.Value;
171170
DynamicBuffer<TransportRpcData> rpcs = EntityManager.GetBuffer<TransportRpcData>(entity);
@@ -176,7 +175,7 @@ protected override void OnUpdate()
176175
{
177176
Transport.DispatchMessage(connectionId, buffer);
178177
}
179-
catch(Exception e)
178+
catch (Exception e)
180179
{
181180
Debug.LogException(e);
182181
}
@@ -273,7 +272,7 @@ public override NetworkEvent PollEvent(out ulong clientId, out ArraySegment<byte
273272
return NetworkEvent.Nothing;
274273
}
275274

276-
private void OnClientConnectedToServer(Connection connection, Unity.Netcode.NetcodeConnectionEvent connectionEvent)
275+
private void OnClientConnectedToServer(Connection connection, NetcodeConnectionEvent connectionEvent)
277276
{
278277
m_Connections[connectionEvent.Id.Value] = new ConnectionInfo
279278
{
@@ -287,7 +286,7 @@ private void OnClientConnectedToServer(Connection connection, Unity.Netcode.Netc
287286
updateSystem.EntityManager.AddBuffer<TransportRpcData>(connection.ConnectionEntity);
288287
}
289288

290-
private void OnServerNewClientConnection(Connection connection, Unity.Netcode.NetcodeConnectionEvent connectionEvent)
289+
private void OnServerNewClientConnection(Connection connection, NetcodeConnectionEvent connectionEvent)
291290
{
292291
m_Connections[connectionEvent.Id.Value] = new ConnectionInfo
293292
{
@@ -365,7 +364,7 @@ private DisconnectEvents GetDisconnectEventFromNetworkStreamDisconnectReason(Net
365364
return DisconnectEvents.Disconnected;
366365
}
367366

368-
private void OnClientDisconnectFromServer(Connection connection, Unity.Netcode.NetcodeConnectionEvent connectionEvent)
367+
private void OnClientDisconnectFromServer(Connection connection, NetcodeConnectionEvent connectionEvent)
369368
{
370369
SetDisconnectEvent(
371370
GetDisconnectEventFromNetworkStreamDisconnectReason(connectionEvent.DisconnectReason),
@@ -374,12 +373,12 @@ private void OnClientDisconnectFromServer(Connection connection, Unity.Netcode.N
374373
InvokeOnTransportEvent(NetworkEvent.Disconnect, (ulong)connectionEvent.Id.Value, default, m_RealTimeProvider.RealTimeSinceStartup);
375374
}
376375

377-
private void OnServerClientDisconnected(Connection connection, Unity.Netcode.NetcodeConnectionEvent connectionEvent)
376+
private void OnServerClientDisconnected(Connection connection, NetcodeConnectionEvent connectionEvent)
378377
{
379378
InvokeOnTransportEvent(NetworkEvent.Disconnect, (ulong)connectionEvent.Id.Value, default, m_RealTimeProvider.RealTimeSinceStartup);
380379
}
381380

382-
private void OnClientConnectionEvent(Connection connection, Unity.Netcode.NetcodeConnectionEvent connectionEvent)
381+
private void OnClientConnectionEvent(Connection connection, NetcodeConnectionEvent connectionEvent)
383382
{
384383
switch (connectionEvent.State)
385384
{
@@ -392,7 +391,7 @@ private void OnClientConnectionEvent(Connection connection, Unity.Netcode.Netcod
392391
}
393392
}
394393

395-
private void OnServerConnectionEvent(Connection connection, Unity.Netcode.NetcodeConnectionEvent connectionEvent)
394+
private void OnServerConnectionEvent(Connection connection, NetcodeConnectionEvent connectionEvent)
396395
{
397396
switch (connectionEvent.State)
398397
{

0 commit comments

Comments
 (0)