You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs
+81-37Lines changed: 81 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -26,14 +26,14 @@ public class NetworkList<T> : NetworkVariableBase where T : unmanaged, IEquatabl
26
26
publiceventOnListChangedDelegateOnListChanged;
27
27
28
28
/// <summary>
29
-
/// Constructor method for <see cref="NetworkList"/>
29
+
/// Creates a <see cref="NetworkList{T}"/>
30
30
/// </summary>
31
31
publicNetworkList(){}
32
32
33
-
/// <inheritdoc/>
34
-
/// <param name="values"></param>
35
-
/// <param name="readPerm"></param>
36
-
/// <param name="writePerm"></param>
33
+
/// <inheritdoc cref="NetworkList{T}"/>
34
+
/// <param name="values">An optional collection of initial values to populate the list. If null, the list will start empty.</param>
35
+
/// <param name="readPerm">The read permission level for the network list. Determines who can read the list (e.g., server-only or everyone). Default is defined by DefaultReadPerm</param>
36
+
/// <param name="writePerm">The write permission level for the network list. Determines who can modify the list (e.g., server-only or specific clients). Default is defined by DefaultWritePerm.</param>
/// Returns an enumerator that iterates through the <see cref="NetworkList{T}" />.
411
+
/// </summary>
412
+
/// <returns>An enumerator for the <see cref="NetworkList{T}"/>.</returns>
410
413
publicIEnumerator<T>GetEnumerator()
411
414
{
412
415
returnm_List.GetEnumerator();
413
416
}
414
417
415
-
/// <inheritdoc />
418
+
/// <summary>
419
+
/// Adds an item to the end of the <see cref="NetworkList{T}"/>.
420
+
/// </summary>
421
+
/// <param name="item">The item to be added to the list.</param>
422
+
/// <remarks>
423
+
/// This method checks for write permissions before adding the item.
424
+
/// </remarks>
416
425
publicvoidAdd(Titem)
417
426
{
418
427
// check write permissions
@@ -434,7 +443,12 @@ public void Add(T item)
434
443
HandleAddListEvent(listEvent);
435
444
}
436
445
437
-
/// <inheritdoc />
446
+
/// <summary>
447
+
/// Removes all items from the <see cref="NetworkList{T}"/>.
448
+
/// </summary>
449
+
/// <remarks>
450
+
/// This method checks for write permissions before clearing the list.
451
+
/// </remarks>
438
452
publicvoidClear()
439
453
{
440
454
// check write permissions
@@ -454,14 +468,25 @@ public void Clear()
454
468
HandleAddListEvent(listEvent);
455
469
}
456
470
457
-
/// <inheritdoc />
471
+
/// <summary>
472
+
/// Determines whether the <see cref="NetworkList{T}"/> contains a specific value.
473
+
/// </summary>
474
+
/// <param name="item">The object to locate in the <see cref="NetworkList{T}"/>.</param>
475
+
/// <returns><see langword="true" /> if the <see cref="item"/> is found in the <see cref="NetworkList{T}"/>; otherwise, <see langword="false" />.</returns>
458
476
publicboolContains(Titem)
459
477
{
460
478
intindex=m_List.IndexOf(item);
461
479
returnindex!=-1;
462
480
}
463
481
464
-
/// <inheritdoc />
482
+
/// <summary>
483
+
/// Removes the first occurrence of a specific object from the <see cref="NetworkList{T}"/>.
484
+
/// </summary>
485
+
/// <remarks>
486
+
/// This method checks for write permissions before removing the item.
487
+
/// </remarks>
488
+
/// <param name="item">The object to remove from the list.</param>
489
+
/// <returns><see langword="true" /> if the item was successfully removed from the list; otherwise, <see langword="false" />.</returns>
465
490
publicboolRemove(Titem)
466
491
{
467
492
// check write permissions
@@ -488,16 +513,29 @@ public bool Remove(T item)
488
513
returntrue;
489
514
}
490
515
491
-
/// <inheritdoc />
516
+
/// <summary>
517
+
/// Gets the number of elements contained in the <see cref="NetworkList{T}"/>.
518
+
/// </summary>
492
519
publicintCount=>m_List.Length;
493
520
494
-
/// <inheritdoc />
521
+
/// <summary>
522
+
/// Determines the index of a specific <see cref="item"/> in the <see cref="NetworkList{T}"/>.
523
+
/// </summary>
524
+
/// <param name="item">The object to remove from the list.</param>
525
+
/// <returns>The index of the <see cref="item"/> if found in the list; otherwise, -1.</returns>
495
526
publicintIndexOf(Titem)
496
527
{
497
528
returnm_List.IndexOf(item);
498
529
}
499
530
500
-
/// <inheritdoc />
531
+
/// <summary>
532
+
/// Inserts <see cref="item"/> to the <see cref="NetworkList{T}"/> at the specified <see cref="index"/>.
533
+
/// </summary>
534
+
/// <remarks>
535
+
/// This method checks for write permissions before inserting the item.
536
+
/// </remarks>
537
+
/// <param name="index">The index at which the item should be inserted.</param>
538
+
/// <param name="item">The item to insert.</param>
501
539
publicvoidInsert(intindex,Titem)
502
540
{
503
541
// check write permissions
@@ -527,7 +565,13 @@ public void Insert(int index, T item)
527
565
HandleAddListEvent(listEvent);
528
566
}
529
567
530
-
/// <inheritdoc />
568
+
/// <summary>
569
+
/// Removes the <see cref="NetworkList{T}"/> item at the specified index.
570
+
/// </summary>
571
+
/// <remarks>
572
+
/// This method checks for write permissions before removing the item.
573
+
/// </remarks>
574
+
/// <param name="index">The index of the element to remove.</param>
531
575
publicvoidRemoveAt(intindex)
532
576
{
533
577
// check write permissions
@@ -550,7 +594,14 @@ public void RemoveAt(int index)
550
594
HandleAddListEvent(listEvent);
551
595
}
552
596
553
-
/// <inheritdoc />
597
+
/// <summary>
598
+
/// Gets or sets the element at the specified index in the <see cref="NetworkList{T}"/>.
599
+
/// </summary>
600
+
/// <remarks>
601
+
/// This method checks for write permissions before setting the value.
602
+
/// </remarks>
603
+
/// <param name="index">The zero-based index of the element to get or set.</param>
604
+
/// <returns>The element at the specified index.</returns>
"Unity.Netcode.NetworkList<T>: IEnumerator<T> GetEnumerator(): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
13
-
"Unity.Netcode.NetworkList<T>: void Add(T): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
14
-
"Unity.Netcode.NetworkList<T>: void Clear(): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
15
-
"Unity.Netcode.NetworkList<T>: bool Contains(T): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
16
-
"Unity.Netcode.NetworkList<T>: bool Remove(T): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
17
-
"Unity.Netcode.NetworkList<T>: Count: cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
18
-
"Unity.Netcode.NetworkList<T>: int IndexOf(T): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
19
-
"Unity.Netcode.NetworkList<T>: void Insert(int, T): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
20
-
"Unity.Netcode.NetworkList<T>: void RemoveAt(int): cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
21
-
"Unity.Netcode.NetworkList<T>: this[int]: cannot auto-inheritdoc (not an override or interface implementation); <inheritdoc> must specify 'cref'",
0 commit comments