Skip to content

Commit 802e183

Browse files
committed
NetworkVariable corrections and added inheritdocs when API is override
1 parent 9b6be08 commit 802e183

File tree

4 files changed

+34
-60
lines changed

4 files changed

+34
-60
lines changed

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,7 @@ private void ProcessSmoothing()
286286
// TODO: This does not handle OnFixedUpdate
287287
// This requires a complete overhaul in this class to switch between using
288288
// NetworkRigidbody's position and rotation values.
289-
/// <summary>
290-
/// Processes updates for the network transform, including smoothing interpolation
291-
/// </summary>
289+
/// <inheritdoc/>
292290
public override void OnUpdate()
293291
{
294292
ProcessSmoothing();
@@ -425,9 +423,7 @@ protected internal override void InternalOnNetworkPostSpawn()
425423
}
426424
}
427425

428-
/// <summary>
429-
/// Called when the NetworkObject is spawned to initialize network transform functionality
430-
/// </summary>
426+
/// <inheritdoc/>
431427
public override void OnNetworkSpawn()
432428
{
433429
if (NetworkManager.DistributedAuthorityMode)
@@ -451,9 +447,7 @@ public override void OnNetworkSpawn()
451447
NetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
452448
}
453449

454-
/// <summary>
455-
/// Called when the NetworkObject is despawned to cleanup network transform resources
456-
/// </summary>
450+
/// <inheritdoc/>
457451
public override void OnNetworkDespawn()
458452
{
459453
if (m_AnticipatedObject != null)
@@ -468,9 +462,7 @@ public override void OnNetworkDespawn()
468462
base.OnNetworkDespawn();
469463
}
470464

471-
/// <summary>
472-
/// Called when the component is being destroyed to perform final cleanup
473-
/// </summary>
465+
/// <inheritdoc/>
474466
public override void OnDestroy()
475467
{
476468
if (m_AnticipatedObject != null)
@@ -522,30 +514,22 @@ public void Smooth(TransformState from, TransformState to, float durationSeconds
522514
m_CurrentSmoothTime = 0;
523515
}
524516

525-
/// <summary>
526-
/// Called before the transform state is updated with new network data
527-
/// </summary>
517+
/// <inheritdoc/>
528518
protected override void OnBeforeUpdateTransformState()
529519
{
530520
// this is called when new data comes from the server
531521
m_LastAuthorityUpdateCounter = NetworkManager.AnticipationSystem.LastAnticipationAck;
532522
m_OutstandingAuthorityChange = true;
533523
}
534524

535-
/// <summary>
536-
/// Called when new transform state data is received from the network
537-
/// </summary>
538-
/// <param name="oldState">The previous network transform state</param>
539-
/// <param name="newState">The new network transform state to apply</param>
525+
/// <inheritdoc/>
540526
protected override void OnNetworkTransformStateUpdated(ref NetworkTransformState oldState, ref NetworkTransformState newState)
541527
{
542528
base.OnNetworkTransformStateUpdated(ref oldState, ref newState);
543529
ApplyAuthoritativeState();
544530
}
545531

546-
/// <summary>
547-
/// Called after the transform has been updated with new values
548-
/// </summary>
532+
/// <inheritdoc/>
549533
protected override void OnTransformUpdated()
550534
{
551535
if (CanCommitToTransform || m_AnticipatedObject == null)

com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@ public void Update()
284284
}
285285
}
286286

287-
/// <summary>
288-
/// Releases all resources used by this network variable
289-
/// </summary>
287+
/// <inheritdoc/>
290288
public override void Dispose()
291289
{
292290
if (m_IsDisposed)
@@ -391,57 +389,39 @@ public void Smooth(in T from, in T to, float durationSeconds, SmoothDelegate how
391389
m_HasSmoothValues = true;
392390
}
393391

394-
/// <summary>
395-
/// Checks if the variable has been modified since the last network synchronization
396-
/// </summary>
397-
/// <returns>True if the variable needs to be synchronized, false otherwise</returns>
392+
/// <inheritdoc/>
398393
public override bool IsDirty()
399394
{
400395
return m_AuthoritativeValue.IsDirty();
401396
}
402397

403-
/// <summary>
404-
/// Resets the dirty state after network synchronization
405-
/// </summary>
398+
/// <inheritdoc/>
406399
public override void ResetDirty()
407400
{
408401
m_AuthoritativeValue.ResetDirty();
409402
}
410403

411-
/// <summary>
412-
/// Writes only the changes in the variable's value to the network stream
413-
/// </summary>
414-
/// <param name="writer">Buffer to write the delta to</param>
404+
/// <inheritdoc/>
415405
public override void WriteDelta(FastBufferWriter writer)
416406
{
417407
m_AuthoritativeValue.WriteDelta(writer);
418408
}
419409

420-
/// <summary>
421-
/// Writes the complete state of the variable to the network stream
422-
/// </summary>
423-
/// <param name="writer">Buffer to write the field to</param>
410+
/// <inheritdoc/>
424411
public override void WriteField(FastBufferWriter writer)
425412
{
426413
m_AuthoritativeValue.WriteField(writer);
427414
}
428415

429-
/// <summary>
430-
/// Reads the complete state of the variable from the network stream
431-
/// </summary>
432-
/// <param name="reader">Buffer to read the field from</param>
416+
/// <inheritdoc/>
433417
public override void ReadField(FastBufferReader reader)
434418
{
435419
m_AuthoritativeValue.ReadField(reader);
436420
NetworkVariableSerialization<T>.Duplicate(m_AuthoritativeValue.Value, ref m_AnticipatedValue);
437421
NetworkVariableSerialization<T>.Duplicate(m_AnticipatedValue, ref m_PreviousAnticipatedValue);
438422
}
439423

440-
/// <summary>
441-
/// Reads changes in the variable's value from the network stream
442-
/// </summary>
443-
/// <param name="reader">Buffer to read the delta from</param>
444-
/// <param name="keepDirtyDelta">Whether to maintain the dirty state after reading</param>
424+
/// <inheritdoc/>
445425
public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
446426
{
447427
m_AuthoritativeValue.ReadDelta(reader, keepDirtyDelta);

com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,23 @@ public class NetworkVariable<T> : NetworkVariableBase
2222
/// </summary>
2323
public OnValueChangedDelegate OnValueChanged;
2424

25+
/// <summary>
26+
/// Delegate that determines if the difference between two values exceeds a threshold for network synchronization
27+
/// </summary>
28+
/// <param name="previousValue">The previous value to compare against</param>
29+
/// <param name="newValue">The new value to compare</param>
30+
/// <returns>True if the difference exceeds the threshold and should be synchronized, false otherwise</returns>
2531
public delegate bool CheckExceedsDirtinessThresholdDelegate(in T previousValue, in T newValue);
2632

33+
/// <summary>
34+
/// Delegate instance for checking if value changes exceed the dirtiness threshold
35+
/// </summary>
2736
public CheckExceedsDirtinessThresholdDelegate CheckExceedsDirtinessThreshold;
2837

38+
/// <summary>
39+
/// Determines if the current value has changed enough from its previous value to warrant network synchronization
40+
/// </summary>
41+
/// <returns>True if the value should be synchronized, false otherwise</returns>
2942
public override bool ExceedsDirtinessThreshold()
3043
{
3144
if (CheckExceedsDirtinessThreshold != null && m_HasPreviousValue)
@@ -36,6 +49,9 @@ public override bool ExceedsDirtinessThreshold()
3649
return true;
3750
}
3851

52+
/// <summary>
53+
/// Initializes the NetworkVariable by setting up initial and previous values
54+
/// </summary>
3955
public override void OnInitialize()
4056
{
4157
base.OnInitialize();
@@ -178,6 +194,7 @@ internal ref T RefValue()
178194
return ref m_InternalValue;
179195
}
180196

197+
/// <inheritdoc/>
181198
public override void Dispose()
182199
{
183200
if (m_IsDisposed)
@@ -211,6 +228,9 @@ public override void Dispose()
211228
base.Dispose();
212229
}
213230

231+
/// <summary>
232+
/// Finalizer that ensures proper cleanup of resources
233+
/// </summary>
214234
~NetworkVariable()
215235
{
216236
Dispose();

pvpExceptions.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@
2727

2828
"Unity.Netcode.NetworkList<T>: void Finalize(): undocumented",
2929

30-
"Unity.Netcode.NetworkVariable<T>: CheckExceedsDirtinessThreshold: undocumented",
31-
"Unity.Netcode.NetworkVariable<T>: bool ExceedsDirtinessThreshold(): undocumented",
32-
"Unity.Netcode.NetworkVariable<T>: void OnInitialize(): undocumented",
33-
"Unity.Netcode.NetworkVariable<T>: bool CheckDirtyState(bool): missing <returns>",
34-
"Unity.Netcode.NetworkVariable<T>: void Dispose(): undocumented",
35-
"Unity.Netcode.NetworkVariable<T>: void Finalize(): undocumented",
36-
"Unity.Netcode.NetworkVariable<T>.CheckExceedsDirtinessThresholdDelegate: undocumented",
37-
3830
"Unity.Netcode.NetworkVariableUpdateTraits: undocumented",
3931
"Unity.Netcode.NetworkVariableUpdateTraits: MinSecondsBetweenUpdates: undocumented",
4032
"Unity.Netcode.NetworkVariableUpdateTraits: MaxSecondsBetweenUpdates: undocumented",
@@ -49,8 +41,6 @@
4941
"Unity.Netcode.UserNetworkVariableSerialization<T>.WriteDeltaDelegate: missing <param name=\"previousValue\">",
5042
"Unity.Netcode.UserNetworkVariableSerialization<T>.DuplicateValueDelegate: missing <param name=\"duplicatedValue\">",
5143

52-
"Unity.Netcode.NetworkSpawnManager: void Finalize(): undocumented",
53-
5444
"Unity.Netcode.NetworkTransport.TransportEventDelegate: missing <param name=\"eventType\">",
5545
"Unity.Netcode.NetworkTransport.TransportEventDelegate: missing <param name=\"clientId\">",
5646
"Unity.Netcode.NetworkTransport.TransportEventDelegate: missing <param name=\"payload\">",

0 commit comments

Comments
 (0)