Skip to content

Commit 6aa6f15

Browse files
update
Removing all of the original prefab registration flow, per request within unified PR, to remove the code on the unified side that this code depends on.
1 parent af086a8 commit 6aa6f15

3 files changed

Lines changed: 0 additions & 104 deletions

File tree

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ public override bool Initialize(string defaultWorldName)
6464
}
6565

6666
networkManager.NetcodeWorld = (NetcodeWorld)LastCreatedWorld;
67-
#if UNIFIED_NGO_REGISTERS_PREFABS
68-
if (networkManager.NetworkConfig.Prefabs.HasPendingGhostPrefabs)
69-
{
70-
if (networkManager.LogLevel <= LogLevel.Developer)
71-
{
72-
NetworkLog.LogInfo($"[{nameof(UnifiedBootstrap)}] Registering hybrid prefabs...");
73-
}
74-
networkManager.NetworkConfig.Prefabs.RegisterGhostPrefabs(networkManager);
75-
}
76-
#endif
7767
}
7868
else
7969
{

com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ public class NetworkPrefabs
4747
[NonSerialized]
4848
private List<NetworkPrefab> m_Prefabs = new List<NetworkPrefab>();
4949

50-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
51-
[NonSerialized]
52-
internal Dictionary<uint, NetworkPrefab> PrefabTable = new Dictionary<uint, NetworkPrefab>();
53-
#endif
54-
5550
[NonSerialized]
5651
private List<NetworkPrefab> m_RuntimeAddedPrefabs = new List<NetworkPrefab>();
5752

@@ -62,18 +57,12 @@ private void AddTriggeredByNetworkPrefabList(NetworkPrefab networkPrefab)
6257
// Don't add this to m_RuntimeAddedPrefabs
6358
// This prefab is now in the PrefabList, so if we shutdown and initialize again, we'll pick it up from there.
6459
m_Prefabs.Add(networkPrefab);
65-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
66-
PrefabTable.TryAdd(networkPrefab.SourcePrefabGlobalObjectIdHash, networkPrefab);
67-
#endif
6860
}
6961
}
7062

7163
private void RemoveTriggeredByNetworkPrefabList(NetworkPrefab networkPrefab)
7264
{
7365
m_Prefabs.Remove(networkPrefab);
74-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
75-
PrefabTable.Remove(networkPrefab.SourcePrefabGlobalObjectIdHash);
76-
#endif
7766
}
7867

7968
/// <summary>
@@ -106,9 +95,6 @@ public void Initialize(bool warnInvalid = true)
10695
{
10796
m_Prefabs.Clear();
10897
NetworkPrefabsLists.RemoveAll(x => x == null);
109-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
110-
PrefabTable.Clear();
111-
#endif
11298
foreach (var list in NetworkPrefabsLists)
11399
{
114100
list.OnAdd += AddTriggeredByNetworkPrefabList;
@@ -141,16 +127,10 @@ public void Initialize(bool warnInvalid = true)
141127
if (AddPrefabRegistration(networkPrefab))
142128
{
143129
m_Prefabs.Add(networkPrefab);
144-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
145-
PrefabTable.TryAdd(networkPrefab.SourcePrefabGlobalObjectIdHash, networkPrefab);
146-
#endif
147130
}
148131
else
149132
{
150133
removeList?.Add(networkPrefab);
151-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
152-
PrefabTable.Remove(networkPrefab.SourcePrefabGlobalObjectIdHash);
153-
#endif
154134
}
155135
}
156136

@@ -159,16 +139,10 @@ public void Initialize(bool warnInvalid = true)
159139
if (AddPrefabRegistration(networkPrefab))
160140
{
161141
m_Prefabs.Add(networkPrefab);
162-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
163-
PrefabTable.TryAdd(networkPrefab.SourcePrefabGlobalObjectIdHash, networkPrefab);
164-
#endif
165142
}
166143
else
167144
{
168145
removeList?.Add(networkPrefab);
169-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
170-
PrefabTable.Remove(networkPrefab.SourcePrefabGlobalObjectIdHash);
171-
#endif
172146
}
173147
}
174148

@@ -201,9 +175,6 @@ public bool Add(NetworkPrefab networkPrefab)
201175
{
202176
m_Prefabs.Add(networkPrefab);
203177
m_RuntimeAddedPrefabs.Add(networkPrefab);
204-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
205-
PrefabTable.TryAdd(networkPrefab.SourcePrefabGlobalObjectIdHash, networkPrefab);
206-
#endif
207178
return true;
208179
}
209180

@@ -231,9 +202,6 @@ public void Remove(NetworkPrefab prefab)
231202
m_RuntimeAddedPrefabs.Remove(prefab);
232203
OverrideToNetworkPrefab.Remove(prefab.TargetPrefabGlobalObjectIdHash);
233204
NetworkPrefabOverrideLinks.Remove(prefab.SourcePrefabGlobalObjectIdHash);
234-
#if UNIFIED_NETCODE && UNIFIED_NGO_REGISTERS_PREFABS
235-
PrefabTable.Remove(prefab.SourcePrefabGlobalObjectIdHash);
236-
#endif
237205
}
238206

239207
/// <summary>
@@ -311,50 +279,6 @@ public bool Contains(NetworkPrefab prefab)
311279

312280
#if UNIFIED_NETCODE
313281
internal bool HasGhostPrefabs { get; private set; }
314-
315-
#if UNIFIED_NGO_REGISTERS_PREFABS
316-
/// <summary>
317-
/// TODO: Either keep or remove prior to freeze.
318-
/// Leaving this here in case we have to control when things get registered.
319-
/// </summary>
320-
internal bool HasPendingGhostPrefabs { get; private set; }
321-
private List<NetworkPrefab> m_PendingGhostRegistration = new List<NetworkPrefab>();
322-
/// <summary>
323-
/// UNIFIED-POC<br />
324-
/// Hybrid NetworkObject-Ghost Prefab Registration<br />
325-
/// </summary>
326-
/// <remarks>
327-
/// When <see cref="NetworkObject.HasGhost"/> is true, <see cref="NetworkPrefab"/>s
328-
/// will mark themselves as having a ghost during <see cref="NetworkPrefab.Validate(int)"/>.
329-
/// After validation, if a network prefab's <see cref="NetworkPrefab.HasGhost"/> value is
330-
/// set, then it is added to <see cref="m_PendingGhostRegistration"/>.
331-
/// Within <see cref="NetworkManager.NetworkUpdate(NetworkUpdateStage)"/> during the <see cref="NetworkUpdateStage.EarlyUpdate"/>,
332-
/// if <see cref="HasPendingGhostPrefabs"/> is true then <see cref="RegisterGhostPrefabs(NetworkManager)"/> will be invoked.
333-
/// This will repeat until the hosted single world instance is created.
334-
/// </remarks>
335-
/// <param name="networkManager"></param>
336-
internal void RegisterGhostPrefabs(NetworkManager networkManager)
337-
{
338-
if (!HasPendingGhostPrefabs)
339-
{
340-
Debug.LogWarning($"Should not be invoking!");
341-
return;
342-
}
343-
var isHost = networkManager.IsHost;
344-
for (int i = m_PendingGhostRegistration.Count - 1; i >= 0; i--)
345-
{
346-
var networkPrefab = m_PendingGhostRegistration[i];
347-
348-
// Returns false if the single world is not available yet
349-
if (NetCode.Netcode.RegisterPrefabSingleWorld(networkPrefab.Prefab, isHost, networkManager.NetcodeWorld))
350-
{
351-
Debug.Log($"[{nameof(NetworkPrefabs)}][{nameof(RegisterGhostPrefabs)}] Registered hybrid spawned object: {networkPrefab.Prefab.name}");
352-
m_PendingGhostRegistration.RemoveAt(i);
353-
}
354-
}
355-
HasPendingGhostPrefabs = m_PendingGhostRegistration.Count > 0;
356-
}
357-
#endif
358282
#endif
359283

360284

@@ -380,11 +304,6 @@ private bool AddPrefabRegistration(NetworkPrefab networkPrefab)
380304
if (networkPrefab.HasGhost)
381305
{
382306
HasGhostPrefabs = true;
383-
384-
#if UNIFIED_NGO_REGISTERS_PREFABS
385-
HasPendingGhostPrefabs = true;
386-
m_PendingGhostRegistration.TryAdd(networkPrefab);
387-
#endif
388307
}
389308
#endif
390309

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -421,19 +421,6 @@ public void AddNetworkPrefab(GameObject prefab)
421421
{
422422
m_NetworkManager.DeferredMessageManager.ProcessTriggers(IDeferredNetworkMessageManager.TriggerType.OnAddPrefab, networkObject.GlobalObjectIdHash);
423423
}
424-
425-
#if UNIFIED_NGO_REGISTERS_PREFABS
426-
if (m_NetworkManager.IsListening)
427-
{
428-
var ghost = prefab.GetComponent<GhostAdapter>();
429-
if (ghost)
430-
{
431-
m_NetworkManager.InitializeNetcodeWorld();
432-
NetCode.Netcode.RegisterPrefabSingleWorld(prefab, m_NetworkManager.IsHost,
433-
m_NetworkManager.NetcodeWorld);
434-
}
435-
}
436-
#endif
437424
}
438425

439426
/// <summary>

0 commit comments

Comments
 (0)