Skip to content

Commit ad36f93

Browse files
chore: change ghostadapter to ghostobject (#4105)
* update Changing GhostAdapter to GhostObject * update More GhostAdapter to GhostObject changes
1 parent 92d8bb9 commit ad36f93

7 files changed

Lines changed: 33 additions & 33 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ public class NetworkObjectEditor : UnityEditor.Editor
2929

3030
#if UNIFIED_NETCODE
3131
/// <summary>
32-
/// Register for the GhostAdapter removal event.
32+
/// Register for the GhostObject removal event.
3333
/// </summary>
3434
[InitializeOnLoadMethod]
3535
private static void OnApplicationStart()
3636
{
37-
GhostAdapterEditor.OnGhostAdapterPreRemoval = OnGhostAdapterPreRemoval;
37+
GhostObjectEditor.OnGhostObjectPreRemoval = OnGhostObjectPreRemoval;
3838
}
3939

4040
/// <summary>
41-
/// Callback to remove the GhostBehaviours prior to removing GhostAdapter.
41+
/// Callback to remove the GhostBehaviours prior to removing GhostObject.
4242
/// </summary>
43-
/// <param name="gameObject">The <see cref="GameObject"/> with the <see cref="GhostAdapter"/> component being removed.</param>
44-
private static void OnGhostAdapterPreRemoval(GameObject gameObject)
43+
/// <param name="gameObject">The <see cref="GameObject"/> with the <see cref="GhostObject"/> component being removed.</param>
44+
private static void OnGhostObjectPreRemoval(GameObject gameObject)
4545
{
4646
var ghostBehaviours = gameObject.GetComponentsInChildren<GhostBehaviour>();
4747
for (int i = ghostBehaviours.Length - 1; i >= 0; i--)
4848
{
4949
DestroyImmediate(ghostBehaviours[i], true);
5050
}
5151
var networkObject = gameObject.GetComponent<NetworkObject>();
52-
networkObject.GhostAdapter = null;
52+
networkObject.GhostObject = null;
5353
networkObject.HasGhost = false;
5454
networkObject.HadBridge = true;
5555
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ namespace Unity.Netcode
1111
/// specific to the N4E-spawned hybrid prefab instance that has the matching <see cref="NetworkObjectId"/>.
1212
/// </summary>
1313

14-
[DefaultExecutionOrder(GhostAdapterExecutionOrder.ExecutionOrder + 1)]
14+
[DefaultExecutionOrder(GhostObjectExecutionOrder.ExecutionOrder + 1)]
1515
//BREAK --- Fix this on UNIFIED side 1st
1616
public partial class NetworkObjectBridge : GhostBehaviour
1717
{
1818
// DefaultExecutionOrder
19-
// TODO: Define a const for the value used on GhostAdapter and use that value
20-
// to set the execution order so if it changes on GhostAdapter it updates here.
19+
// TODO: Define a const for the value used on GhostObject and use that value
20+
// to set the execution order so if it changes on GhostObject it updates here.
2121
#if UNITY_EDITOR
2222
private void OnValidate()
2323
{
2424
hideFlags = HideFlags.HideInInspector;
2525

26-
var ghostAdapter = GetComponent<GhostAdapter>();
26+
var ghostAdapter = GetComponent<GhostObject>();
2727
if (ghostAdapter == null)
2828
{
2929
return;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class NetworkClient
5252
/// <summary>
5353
/// The ClientId of the NetworkClient
5454
/// </summary>
55-
public ulong ClientId;
55+
public ulong ClientId { get; internal set; }
5656

5757
/// <summary>
5858
/// The PlayerObject of the Client

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ private void CheckForInScenePlaced()
365365
#if UNIFIED_NETCODE
366366
[HideInInspector]
367367
[SerializeField]
368-
internal GhostAdapter GhostAdapter;
368+
internal GhostObject GhostObject;
369369

370370
[HideInInspector]
371371
[SerializeField]
@@ -388,16 +388,16 @@ private void OnApplicationUpdate()
388388
internal void UnifiedValidation()
389389
{
390390
NetworkObjectBridge = GetComponent<NetworkObjectBridge>();
391-
GhostAdapter = GetComponent<GhostAdapter>();
391+
GhostObject = GetComponent<GhostObject>();
392392

393-
HasGhost = GhostAdapter != null;
393+
HasGhost = GhostObject != null;
394394
if (HasGhost)
395395
{
396396
//TODO: Needs to be validated once develop-2.0.0 is merged.
397397
if (InScenePlaced)
398398
{
399399
Debug.LogError($"This experimental version of NGO does not support hybrid in-scene placed objects.");
400-
Destroy(GhostAdapter);
400+
Destroy(GhostObject);
401401
HasGhost = false;
402402
return;
403403
}
@@ -420,7 +420,7 @@ public void ApplyScale(Vector3 scale)
420420
{
421421
if (HasGhost)
422422
{
423-
GhostAdapter.ApplyPostTransformMatrixScale(scale);
423+
GhostObject.ApplyPostTransformMatrixScale(scale);
424424
}
425425
}
426426
#endif
@@ -3043,7 +3043,7 @@ internal bool InitializeChildNetworkBehaviours()
30433043
{
30443044
#if COM_UNITY_MODULES_PHYSICS || COM_UNITY_MODULES_PHYSICS2D
30453045
// TODO-UNIFIED: This needs to be updated to make it "opt-in".
3046-
// If the GhostAdapter is not configured for prediction but is still using a Rigidbody, then go ahead and remove it on
3046+
// If the GhostObject is not configured for prediction but is still using a Rigidbody, then go ahead and remove it on
30473047
// the client side to improve performance by default.
30483048
// TODO-UNIFIED: Determine if recent unified physics updates does not require checking for prediction.
30493049
if (NetworkRigidbodies != null)
@@ -3084,8 +3084,8 @@ internal bool InitializeChildNetworkBehaviours()
30843084
#if UNIFIED_NETCODE_DESTROY
30853085
// When hybrid spawning, the transform is synchronized by the GhostObject.
30863086
// As a convenience, we remove and destroy all NetworkTransforms.
3087-
// TODO-Parenting-Related-Area: We need to replicate this functionality in a GhostAdapter
3088-
// Possibly use a "Synchronize" property and display only on children of a root parent GhostAdapter.
3087+
// TODO-Parenting-Related-Area: We need to replicate this functionality in a GhostObject
3088+
// Possibly use a "Synchronize" property and display only on children of a root parent GhostObject.
30893089
if (NetworkTransforms != null)
30903090
{
30913091
NetworkManager.Log.Warning(new Logging.Context(LogLevel.Developer, $"[]{name} Hybrid spawned objects do not support {nameof(NetworkTransform)} and " +
@@ -3896,7 +3896,7 @@ private void OnDisable()
38963896
Debug.Log("Disabled!");
38973897
if (IsSpawned || HasGhost)
38983898
{
3899-
if (HasGhost && GhostAdapter.IsPrefab())
3899+
if (HasGhost && GhostObject.IsPrefab())
39003900
{
39013901
return;
39023902
}
@@ -3933,7 +3933,7 @@ private void InitGhost()
39333933
return;
39343934
}
39353935

3936-
if (!HasGhost || !NetworkObjectBridge || GhostAdapter.IsPrefab())
3936+
if (!HasGhost || !NetworkObjectBridge || GhostObject.IsPrefab())
39373937
{
39383938
// Nothing to register
39393939
return;
@@ -3944,7 +3944,7 @@ private void InitGhost()
39443944
{
39453945
Debug.Log($"[{nameof(NetworkObject)}] GhostBridge {name} detected and instantiated.");
39463946
}
3947-
if (GhostAdapter.WasInitialized && NetworkObjectBridge.NetworkObjectId.Value != 0)
3947+
if (GhostObject.WasInitialized && NetworkObjectBridge.NetworkObjectId.Value != 0)
39483948
{
39493949
NetworkManager.SpawnManager.GhostSpawnManager.RegisterGhostBridge(NetworkObjectBridge.NetworkObjectId.Value, this);
39503950
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void Handle(ref NetworkContext context)
125125
#if UNIFIED_NETCODE
126126
if (networkObject.HasGhost)
127127
{
128-
// Handles the GhostAdapter side of things for parenting
128+
// Handles the GhostObject side of things for parenting
129129
networkObject.NetworkObjectBridge.HybridParentUpdate(Scale);
130130
}
131131
else

com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2781,7 +2781,7 @@ internal void PopulateScenePlacedObjects(Scene sceneToFilterBy, bool clearSceneP
27812781

27822782
// We check to make sure the NetworkManager instance is the same one to be "NetcodeIntegrationTestHelpers" compatible and filter the list on a per-scene basis (for additive scenes)
27832783
#if UNIFIED_NETCODE
2784-
// TODO: When we solve for GhostAdapter in-scene placed.
2784+
// TODO: When we solve for GhostObject in-scene placed.
27852785
if (!networkObjectInstance.HasGhost && networkObjectInstance.NetworkManagerOwner == NetworkManager && networkObjectInstance.isActiveAndEnabled)
27862786
#else
27872787
if (networkObjectInstance.NetworkManagerOwner == NetworkManager && networkObjectInstance.isActiveAndEnabled)

com.unity.netcode.gameobjects/Tests/Runtime/TestHelpers/NetcodeIntegrationTest.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ public IEnumerator SetUp()
733733
#if UNIFIED_NETCODE
734734
private void RegisterPendingGhost(NetworkObject networkObject, ulong networkObjectId)
735735
{
736-
var ghost = networkObject.GetComponent<GhostAdapter>();
737-
Assert.IsNotNull(ghost, $"[RegisterPendingGhost][NetworkObject-{networkObjectId}] Has no {nameof(GhostAdapter)}!");
736+
var ghost = networkObject.GetComponent<GhostObject>();
737+
Assert.IsNotNull(ghost, $"[RegisterPendingGhost][NetworkObject-{networkObjectId}] Has no {nameof(GhostObject)}!");
738738
foreach (var networkManager in m_NetworkManagers)
739739
{
740740
// If the world matches, then register the instance with this NetworkManager's spawn manager.
@@ -1837,9 +1837,9 @@ protected void DestroySceneNetworkObjects()
18371837
{
18381838
#if UNIFIED_NETCODE
18391839
// Handle removing the prefab reference and destroying it
1840-
// and then destroying the ghostAdapter prior to destroying
1840+
// and then destroying the GhostObject prior to destroying
18411841
// a hybrid prefab.
1842-
var ghostAdapter = networkObject.GetComponent<GhostAdapter>();
1842+
var ghostAdapter = networkObject.GetComponent<GhostObject>();
18431843
if (ghostAdapter != null)
18441844
{
18451845
if (ghostAdapter.prefabReference != null)
@@ -2423,10 +2423,10 @@ protected GameObject CreateHybridPrefab(string baseName, bool moveToDDOL = true)
24232423

24242424
// When adding a Hybrid/Ghost prefab:
24252425
// - We disabled the GameObject prior to adding the GhostPrefabReference (so IsPrefab() == true).
2426-
// - Add the GhostAdapter and GhostPrefabReference
2426+
// - Add the GhostObject and GhostPrefabReference
24272427
// - Then set it back to active.
24282428
gameObject.SetActive(false);
2429-
var adapter = gameObject.AddComponent<GhostAdapter>();
2429+
var adapter = gameObject.AddComponent<GhostObject>();
24302430
// Mark the reference as post processing to avoid registering this instance automatically.
24312431
GhostPrefabReference.s_IsPostProcessing = true;
24322432
adapter.prefabReference = ScriptableObject.CreateInstance<GhostPrefabReference>();
@@ -2443,7 +2443,7 @@ protected GameObject CreateHybridPrefab(string baseName, bool moveToDDOL = true)
24432443
// with the dependency to prediction manual test).
24442444
adapter.SupportedGhostModes = GhostModeMask.Interpolated;
24452445

2446-
// Once done with setting up the GhostAdapter, we can set it back to active in the hierarchy
2446+
// Once done with setting up the GhostObject, we can set it back to active in the hierarchy
24472447
gameObject.SetActive(true);
24482448

24492449
// GhostBehaviours that are part of a prefab will not invoke Ghost.InternalAcquireEntityReference
@@ -2455,12 +2455,12 @@ protected GameObject CreateHybridPrefab(string baseName, bool moveToDDOL = true)
24552455

24562456
// NetworkObject Ghost specific settings
24572457
no.HasGhost = true;
2458-
no.GhostAdapter = adapter;
2458+
no.GhostObject = adapter;
24592459
no.HadBridge = true;
24602460
no.NetworkObjectBridge = bridge;
24612461

24622462
// Disable transform synchronization for NetworkObject serialization
2463-
// since that is handled by the GhostAdapter.
2463+
// since that is handled by the GhostObject.
24642464
no.SynchronizeTransform = false;
24652465

24662466
// Turn it into a test prefab

0 commit comments

Comments
 (0)