Skip to content

docs: [2.X] fixes of PVP exceptions #3225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 24, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,24 @@ public class AnticipatedNetworkTransform : NetworkTransform
internal override bool HideInterpolateValue => true;
#endif

/// <summary>
/// Represents a complete transform state for network synchronization and anticipation
/// </summary>
public struct TransformState
{
/// <summary>
/// The position component of the transform state in world space coordinates.
/// </summary>
public Vector3 Position;

/// <summary>
/// The rotation component of the transform state as a quaternion.
/// </summary>
public Quaternion Rotation;

/// <summary>
/// The scale component of the transform state in local space.
/// </summary>
public Vector3 Scale;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ internal BaseRpcTarget(NetworkManager manager)
}

/// <summary>
/// Can be used to provide additional lock checks before disposing the target.
/// Verifies the target can be disposed based on its lock state.
/// </summary>
/// <exception cref="Exception">The exception thrown if the target is still locked when disposed.</exception>
/// <exception cref="Exception">Thrown when attempting to dispose a locked temporary RPC target</exception>
protected void CheckLockBeforeDispose()
{
if (m_Locked)
Expand All @@ -41,7 +41,7 @@ protected void CheckLockBeforeDispose()
}

/// <summary>
/// Invoked when the target is disposed.
/// Releases resources used by the RPC target.
/// </summary>
public abstract void Dispose();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public class NetworkList<T> : NetworkVariableBase where T : unmanaged, IEquatabl
public delegate void OnListChangedDelegate(NetworkListEvent<T> changeEvent);

/// <summary>
/// The callback to be invoked when the list gets changed
/// Creates A NetworkList/>
/// </summary>
public event OnListChangedDelegate OnListChanged;

/// <summary>
/// Constructor method for <see cref="NetworkList"/>
/// Constructor method for <see cref="NetworkList{T}"/>
/// </summary>
public NetworkList() { }

Expand Down Expand Up @@ -132,7 +132,7 @@ public override void WriteDelta(FastBufferWriter writer)
}
}

/// <inheritdoc cref="NetworkVariable{T}.Writeield"/>
/// <inheritdoc cref="NetworkVariable{T}.WriteField"/>
public override void WriteField(FastBufferWriter writer)
{
writer.WriteValueSafe((ushort)m_List.Length);
Expand All @@ -158,12 +158,12 @@ public override void ReadField(FastBufferReader reader)
/// <inheritdoc cref="NetworkVariable{T}.ReadDelta"/>
public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
{
/// This is only invoked by <see cref="NetworkVariableDeltaMessage"/> and the only time
/// keepDirtyDelta is set is when it is the server processing. To be able to handle previous
/// versions, we use IsServer to keep the dirty states received and the keepDirtyDelta to
/// actually mark this as dirty and add it to the list of <see cref="NetworkObject"/>s to
/// be updated. With the forwarding of deltas being handled by <see cref="NetworkVariableDeltaMessage"/>,
/// once all clients have been forwarded the dirty events, we clear them by invoking <see cref="PostDeltaRead"/>.
// This is only invoked by <see cref="NetworkVariableDeltaMessage"/> and the only time
// keepDirtyDelta is set is when it is the server processing. To be able to handle previous
// versions, we use IsServer to keep the dirty states received and the keepDirtyDelta to
// actually mark this as dirty and add it to the list of <see cref="NetworkObject"/>s to
// be updated. With the forwarding of deltas being handled by <see cref="NetworkVariableDeltaMessage"/>,
// once all clients have been forwarded the dirty events, we clear them by invoking <see cref="PostDeltaRead"/>.
var isServer = m_NetworkManager.IsServer;
reader.ReadValueSafe(out ushort deltaCount);
for (int i = 0; i < deltaCount; i++)
Expand Down Expand Up @@ -406,13 +406,22 @@ internal override void PostDeltaRead()
}
}

/// <inheritdoc cref="NetworkVariable{T}.GetEnumerator"/>
/// <summary>
/// Returns an enumerator that iterates through the <see cref="NetworkList{T}" />.
/// </summary>
/// <returns>An enumerator for the <see cref="NetworkList{T}"/>.</returns>
public IEnumerator<T> GetEnumerator()
{
return m_List.GetEnumerator();
}

/// <inheritdoc cref="NetworkVariable{T}.Add"/>
/// <summary>
/// Adds an item to the end of the <see cref="NetworkList{T}"/>.
/// </summary>
/// <param name="item">The item to be added to the list.</param>
/// <remarks>
/// This method checks for write permissions before adding the item.
/// </remarks>
public void Add(T item)
{
// check write permissions
Expand All @@ -434,7 +443,12 @@ public void Add(T item)
HandleAddListEvent(listEvent);
}

/// <inheritdoc cref="NetworkVariable{T}.Clear"/>
/// <summary>
/// Removes all items from the <see cref="NetworkList{T}"/>.
/// </summary>
/// <remarks>
/// This method checks for write permissions before clearing the list.
/// </remarks>
public void Clear()
{
// check write permissions
Expand All @@ -454,14 +468,25 @@ public void Clear()
HandleAddListEvent(listEvent);
}

/// <inheritdoc cref="NetworkVariable{T}.Contains"/>
/// <summary>
/// Determines whether the <see cref="NetworkList{T}"/> contains a specific value.
/// </summary>
/// <param name="item">The object to locate in the <see cref="NetworkList{T}"/>.</param>
/// <returns><see langword="true" /> if the <see cref="item"/> is found in the <see cref="NetworkList{T}"/>; otherwise, <see langword="false" />.</returns>
public bool Contains(T item)
{
int index = m_List.IndexOf(item);
return index != -1;
}

/// <inheritdoc cref="NetworkVariable{T}.Remove"/>
/// <summary>
/// Removes the first occurrence of a specific object from the NetworkList.
/// </summary>
/// <remarks>
/// This method checks for write permissions before removing the item.
/// </remarks>
/// <param name="item">The object to remove from the list.</param>
/// <returns><see langword="true" /> if the item was successfully removed from the list; otherwise, <see langword="false" />.</returns>
public bool Remove(T item)
{
// check write permissions
Expand All @@ -488,16 +513,29 @@ public bool Remove(T item)
return true;
}

/// <inheritdoc cref="NetworkVariable{T}.Count"/>
/// <summary>
/// Gets the number of elements contained in the <see cref="NetworkList{T}"/>.
/// </summary>
public int Count => m_List.Length;

/// <inheritdoc cref="NetworkVariable{T}.IndexOf"/>
/// <summary>
/// Determines the index of a specific <see cref="item"/> in the <see cref="NetworkList{T}"/>.
/// </summary>
/// <param name="item">The object to remove from the list.</param>
/// <returns>The index of the <see cref="item"/> if found in the list; otherwise, -1.</returns>
public int IndexOf(T item)
{
return m_List.IndexOf(item);
}

/// <inheritdoc cref="NetworkVariable{T}.Insert"/>
/// <summary>
/// Inserts <see cref="item"/> to the <see cref="NetworkList{T}"/> at the specified <see cref="index"/>.
/// </summary>
/// <remarks>
/// This method checks for write permissions before inserting the item.
/// </remarks>
/// <param name="index">The index at which the item should be inserted.</param>
/// <param name="item">The item to insert.</param>
public void Insert(int index, T item)
{
// check write permissions
Expand Down Expand Up @@ -527,7 +565,13 @@ public void Insert(int index, T item)
HandleAddListEvent(listEvent);
}

/// <inheritdoc cref="NetworkVariable{T}.RemoveAt"/>
/// <summary>
/// Removes the <see cref="NetworkList{T}"/> item at the specified <see cref="index"/>.
/// </summary>
/// <remarks>
/// This method checks for write permissions before removing the item.
/// </remarks>
/// <param name="index">The index of the element to remove.</param>
public void RemoveAt(int index)
{
// check write permissions
Expand All @@ -549,9 +593,14 @@ public void RemoveAt(int index)
HandleAddListEvent(listEvent);
}



/// <inheritdoc cref="NetworkVariable{T}.this"/>
/// <summary>
/// Gets or sets the element at the specified index in the <see cref="NetworkList{T}"/>.
/// </summary>
/// <remarks>
/// This method checks for write permissions before setting the value.
/// </remarks>
/// <param name="index">The zero-based index of the element to get or set.</param>
/// <value>The element at the specified index.</value>
public T this[int index]
{
get => m_List[index];
Expand Down Expand Up @@ -587,7 +636,7 @@ private void HandleAddListEvent(NetworkListEvent<T> listEvent)
}

/// <summary>
/// This is actually unused left-over from a previous interface
/// This method should not be used. It is left over from a previous interface
/// </summary>
public int LastModifiedTick
{
Expand Down