diff --git a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs index 7c3cb964af..250f092d74 100644 --- a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs +++ b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs @@ -31,6 +31,9 @@ public class NetworkConfig [Tooltip("When set, NetworkManager will automatically create and spawn the assigned player prefab. This can be overridden by adding it to the NetworkPrefabs list and selecting override.")] public GameObject PlayerPrefab; + /// + /// The collection of network prefabs available for spawning across the network. + /// [SerializeField] public NetworkPrefabs Prefabs = new NetworkPrefabs(); diff --git a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs index 9cc2158cc1..5b02d51dea 100644 --- a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs +++ b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefab.cs @@ -57,6 +57,11 @@ public class NetworkPrefab /// public GameObject OverridingTargetPrefab; + /// + /// Compares this NetworkPrefab with another to determine equality. + /// + /// The NetworkPrefab to compare against. + /// True if all fields match between the two NetworkPrefabs, false otherwise. public bool Equals(NetworkPrefab other) { return Override == other.Override && @@ -66,6 +71,12 @@ public bool Equals(NetworkPrefab other) OverridingTargetPrefab == other.OverridingTargetPrefab; } + /// + /// Gets the GlobalObjectIdHash of the source prefab based on the current override settings. + /// + /// The hash value identifying the source prefab. + /// Thrown when required prefab references are missing or invalid. + /// Thrown when Override has an invalid value. public uint SourcePrefabGlobalObjectIdHash { get @@ -98,6 +109,12 @@ public uint SourcePrefabGlobalObjectIdHash } } + /// + /// Gets the GlobalObjectIdHash of the target prefab when using prefab overrides. + /// + /// The hash value identifying the target prefab, or 0 if no override is set. + /// Thrown when required prefab references are missing or invalid. + /// Thrown when Override has an invalid value. public uint TargetPrefabGlobalObjectIdHash { get @@ -122,6 +139,11 @@ public uint TargetPrefabGlobalObjectIdHash } } + /// + /// Validates the NetworkPrefab configuration to ensure all required fields are properly set. + /// + /// Optional index used for error reporting when validating lists of prefabs. + /// True if the NetworkPrefab is valid and ready for use, false otherwise. public bool Validate(int index = -1) { NetworkObject networkObject; @@ -224,6 +246,10 @@ public bool Validate(int index = -1) return true; } + /// + /// Returns a string representation of this NetworkPrefab's source and target hash values. + /// + /// A string containing the source and target hash values. public override string ToString() { return $"{{SourceHash: {SourceHashToOverride}, TargetHash: {TargetPrefabGlobalObjectIdHash}}}"; diff --git a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs index 42758f7e78..aea5cda9c7 100644 --- a/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs +++ b/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkPrefabs.cs @@ -34,11 +34,14 @@ public class NetworkPrefabs /// This is used for the legacy way of spawning NetworkPrefabs with an override when manually instantiating and spawning. /// To handle multiple source NetworkPrefab overrides that all point to the same target NetworkPrefab use /// - /// or + /// or . /// [NonSerialized] public Dictionary OverrideToNetworkPrefab = new Dictionary(); + /// + /// Gets the read-only list of all registered network prefabs. + /// public IReadOnlyList Prefabs => m_Prefabs; [NonSerialized] @@ -62,14 +65,16 @@ private void RemoveTriggeredByNetworkPrefabList(NetworkPrefab networkPrefab) m_Prefabs.Remove(networkPrefab); } + /// + /// Destructor that cleans up network prefab resources. + /// ~NetworkPrefabs() { Shutdown(); } /// - /// Deregister from add and remove events - /// Clear the list + /// Deregister from add and remove events and clear the events. /// internal void Shutdown() { @@ -84,6 +89,7 @@ internal void Shutdown() /// Processes the if one is present for use during runtime execution, /// else processes . /// + /// When true, logs warnings about invalid prefabs that are removed during initialization. public void Initialize(bool warnInvalid = true) { m_Prefabs.Clear(); @@ -154,11 +160,12 @@ public void Initialize(bool warnInvalid = true) } /// - /// Add a new NetworkPrefab instance to the list + /// Add a new NetworkPrefab instance to the list. /// + /// The to add. + /// True if the prefab was successfully added, false if it was invalid or already registered /// - /// The framework does not synchronize this list between clients. Any runtime changes must be handled manually. - /// + /// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
/// Any modifications made here are not persisted. Permanent configuration changes should be done /// through the scriptable object property. ///
@@ -175,11 +182,11 @@ public bool Add(NetworkPrefab networkPrefab) } /// - /// Remove a NetworkPrefab instance from the list + /// Remove a NetworkPrefab instance from the list. /// + /// The to remove. /// - /// The framework does not synchronize this list between clients. Any runtime changes must be handled manually. - /// + /// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
/// Any modifications made here are not persisted. Permanent configuration changes should be done /// through the scriptable object property. ///
@@ -197,11 +204,11 @@ public void Remove(NetworkPrefab prefab) } /// - /// Remove a NetworkPrefab instance with matching from the list + /// Remove a NetworkPrefab instance with matching from the list. /// + /// The to match against for removal. /// - /// The framework does not synchronize this list between clients. Any runtime changes must be handled manually. - /// + /// The framework does not synchronize this list between clients. Any runtime changes must be handled manually.
/// Any modifications made here are not persisted. Permanent configuration changes should be done /// through the scriptable object property. ///
@@ -232,10 +239,10 @@ public void Remove(GameObject prefab) } /// - /// Check if the given GameObject is present as a prefab within the list + /// Check if the given GameObject is present as a prefab within the list. /// - /// The prefab to check - /// Whether or not the prefab exists + /// The prefab to check. + /// True if the prefab exists or false if it does not. public bool Contains(GameObject prefab) { for (int i = 0; i < m_Prefabs.Count; i++) @@ -251,10 +258,10 @@ public bool Contains(GameObject prefab) } /// - /// Check if the given NetworkPrefab is present within the list + /// Check if the given NetworkPrefab is present within the list. /// - /// The prefab to check - /// Whether or not the prefab exists + /// The prefab to check. + /// True if the prefab exists or false if it does not. public bool Contains(NetworkPrefab prefab) { for (int i = 0; i < m_Prefabs.Count; i++) @@ -269,7 +276,7 @@ public bool Contains(NetworkPrefab prefab) } /// - /// Configures for the given + /// Configures for the given . /// private bool AddPrefabRegistration(NetworkPrefab networkPrefab) { diff --git a/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs b/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs index fb56d762e5..13747b78f6 100644 --- a/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs @@ -11,7 +11,7 @@ namespace Unity.Netcode { /// - /// The connection event type set within to signify the type of connection event notification received. + /// The connection event type set within to signify the type of connection event notification received. /// /// /// is returned as a parameter of the event notification. @@ -60,14 +60,16 @@ public enum ConnectionEvent /// public struct ConnectionEventData { + /// + /// The type of connection event that occurred. + /// public ConnectionEvent EventType; /// - /// The client ID for the client that just connected + /// The client ID for the client that just connected.
/// For the and - /// events on the client side, this will be LocalClientId. - /// On the server side, this will be the ID of the client that just connected. - /// + /// events on the client side, this will be LocalClientId.
+ /// On the server side, this will be the ID of the client that just connected.
/// For the and /// events on the client side, this will be the client ID assigned by the server to the remote peer. ///
@@ -83,10 +85,10 @@ public struct ConnectionEventData /// /// The NGO connection manager handles: - /// - Client Connections - /// - Client Approval - /// - Processing s. - /// - Client Disconnection + /// - Client Connections.
+ /// - Client Approval.
+ /// - Processing s.
+ /// - Client Disconnection.
///
public sealed class NetworkConnectionManager { @@ -99,7 +101,7 @@ public sealed class NetworkConnectionManager /// /// When disconnected from the server, the server may send a reason. If a reason was sent, this property will - /// tell client code what the reason was. It should be queried after the OnClientDisconnectCallback is called + /// tell client code what the reason was. It should be queried after the OnClientDisconnectCallback is called. /// public string DisconnectReason { get; internal set; } @@ -226,8 +228,8 @@ internal void InvokeOnPeerDisconnectedCallback(ulong clientId) public event Action OnTransportFailure; /// - /// Is true when a server or host is listening for connections. - /// Is true when a client is connecting or connected to a network session. + /// Is true when a server or host is listening for connections.
+ /// Is true when a client is connecting or connected to a network session.
/// Is false when not listening, connecting, or connected. ///
public bool IsListening { get; internal set; } @@ -247,7 +249,7 @@ internal void InvokeOnPeerDisconnectedCallback(ulong clientId) /// /// Use and to add or remove - /// Use to internally access the pending client dictionary + /// Use to internally access the pending client dictionary. /// private Dictionary m_PendingClients = new Dictionary(); @@ -257,7 +259,7 @@ internal void InvokeOnPeerDisconnectedCallback(ulong clientId) /// /// Client-Side: - /// Starts the client-side approval timeout coroutine + /// Starts the client-side approval timeout coroutine. /// /// internal void StartClientApprovalCoroutine(ulong clientId) @@ -281,7 +283,7 @@ internal void StopClientApprovalCoroutine() /// /// Server-Side: - /// Handles the issue with populating NetworkManager.PendingClients + /// Handles the issue with populating . /// internal void AddPendingClient(ulong clientId) { @@ -297,7 +299,7 @@ internal void AddPendingClient(ulong clientId) /// /// Server-Side: - /// Handles the issue with depopulating NetworkManager.PendingClients + /// Handles the issue with depopulating . /// internal void RemovePendingClient(ulong clientId) { @@ -310,7 +312,7 @@ internal void RemovePendingClient(ulong clientId) } /// - /// Used to generate client identifiers + /// Used to generate client identifiers. /// private ulong m_NextClientId = 1; @@ -357,7 +359,7 @@ internal ulong ClientIdToTransportId(ulong clientId) } /// - /// Gets the networkId of the server + /// Gets the networkId of the server. /// internal ulong ServerTransportId => GetServerTransportId(); @@ -379,7 +381,7 @@ private ulong GetServerTransportId() } /// - /// Handles cleaning up the transport id/client id tables after receiving a disconnect event from transport + /// Handles cleaning up the transport id/client id tables after receiving a disconnect event from transport. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] internal ulong TransportIdCleanUp(ulong transportId) @@ -416,10 +418,10 @@ internal void PollAndHandleNetworkEvents() } /// - /// Event driven NetworkTransports (like UnityTransport) NetworkEvent handling + /// Event driven NetworkTransports (like UnityTransport) NetworkEvent handling. /// /// - /// Polling NetworkTransports invoke this directly + /// Polling NetworkTransports invoke this directly. /// internal void HandleNetworkEvent(NetworkEvent networkEvent, ulong transportClientId, ArraySegment payload, float receiveTime) { @@ -598,7 +600,7 @@ internal void TransportFailureEventHandler(bool duringStart = false) /// /// Client-Side: - /// Upon transport connecting, the client will send a connection request + /// Upon transport connecting, the client will send a connection request. /// private void SendConnectionRequest() { @@ -629,7 +631,7 @@ private void SendConnectionRequest() } /// - /// Approval time out coroutine + /// Approval time out coroutine. /// private IEnumerator ApprovalTimeout(ulong clientId) { @@ -704,7 +706,7 @@ private IEnumerator ApprovalTimeout(ulong clientId) /// /// Server-Side: - /// Handles approval while processing a client connection request + /// Handles approval while processing a client connection request. /// internal void ApproveConnection(ref ConnectionRequestMessage connectionRequestMessage, ref NetworkContext context) { @@ -723,7 +725,7 @@ internal void ApproveConnection(ref ConnectionRequestMessage connectionRequestMe /// /// Server-Side: - /// Processes pending approvals and removes any stale pending clients + /// Processes pending approvals and removes any stale pending clients. /// internal void ProcessPendingApprovals() { @@ -760,10 +762,11 @@ internal void ProcessPendingApprovals() } /// - /// Server Side: Handles the approval of a client + /// Server Side: + /// Handles the approval of a client. /// /// - /// This will spawn the player prefab as well as start client synchronization if is enabled + /// This will spawn the player prefab as well as start client synchronization if is enabled. /// internal void HandleConnectionApproval(ulong ownerClientId, NetworkManager.ConnectionApprovalResponse response) { @@ -883,10 +886,10 @@ internal void HandleConnectionApproval(ulong ownerClientId, NetworkManager.Conne } /// - /// Spawns the newly approved player + /// Spawns the newly approved player. /// - /// new player client identifier - /// the prefab GlobalObjectIdHash value for this player + /// new player client identifier. + /// the prefab GlobalObjectIdHash value for this player. internal void ApprovedPlayerSpawn(ulong clientId, uint playerPrefabHash) { foreach (var clientPair in ConnectedClients) @@ -915,7 +918,7 @@ internal void ApprovedPlayerSpawn(ulong clientId, uint playerPrefabHash) /// /// Server-Side: - /// Creates a new and handles updating the associated + /// Creates a new and handles updating the associated. /// connected clients lists. /// internal NetworkClient AddClient(ulong clientId) @@ -941,7 +944,7 @@ internal NetworkClient AddClient(ulong clientId) /// /// Server-Side: - /// Invoked when a client is disconnected from a server-host + /// Invoked when a client is disconnected from a server-host. /// internal void OnClientDisconnectFromServer(ulong clientId) { @@ -1064,7 +1067,7 @@ internal void OnClientDisconnectFromServer(ulong clientId) /// /// Server-Side: - /// Invoked when disconnecting a remote client + /// Invoked when disconnecting a remote client. /// internal void DisconnectRemoteClient(ulong clientId) { @@ -1103,9 +1106,9 @@ internal void DisconnectClient(ulong clientId, string reason = null) } /// - /// Should be invoked when starting a server-host or client + /// Should be invoked when starting a server-host or client. /// - /// + /// The that is initializing this instance. internal void Initialize(NetworkManager networkManager) { // Prepare for a new session @@ -1130,7 +1133,7 @@ internal void Initialize(NetworkManager networkManager) } /// - /// Should be called when shutting down the NetworkManager + /// Should be called when shutting down the NetworkManager. /// internal void Shutdown() { diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs index f534351a1b..7ce31f5871 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs @@ -6,8 +6,15 @@ namespace Unity.Netcode { + /// + /// Exception thrown when an RPC (Remote Procedure Call) encounters an error during execution. + /// public class RpcException : Exception { + /// + /// Initializes a new instance of the RpcException class with a specified error message. + /// + /// The message that describes the error. public RpcException(string message) : base(message) { @@ -15,7 +22,7 @@ public RpcException(string message) : base(message) } /// - /// The base class to override to write network code. Inherits MonoBehaviour + /// The base class to override to write network code. Inherits from . /// public abstract class NetworkBehaviour : MonoBehaviour { diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs index b539491533..47840f91d8 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs @@ -44,6 +44,7 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem #pragma warning restore IDE1006 // restore naming rule violation check + /// public void NetworkUpdate(NetworkUpdateStage updateStage) { switch (updateStage) @@ -294,6 +295,10 @@ public event Action OnTransportFailure remove => ConnectionManager.OnTransportFailure -= value; } + /// + /// Delegate for handling network state reanticipation events. + /// + /// The most recent round-trip time measurement in seconds between client and server. public delegate void ReanticipateDelegate(double lastRoundTripTime); /// diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs index 47eca79f97..3a5a1984c0 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs @@ -385,29 +385,31 @@ private GlobalObjectId GetGlobalId() public bool SpawnWithObservers = true; /// - /// Delegate type for checking visibility + /// Delegate type for checking visibility. /// - /// The clientId to check visibility for + /// The clientId being checked for visibility. + /// True if the object should be visible to the specified client and false if it should not. public delegate bool VisibilityDelegate(ulong clientId); /// - /// Delegate invoked when the netcode needs to know if the object should be visible to a client, if null it will assume true + /// Delegate invoked when the netcode needs to know if the object should be visible to a client, if null it will assume true. /// public VisibilityDelegate CheckObjectVisibility = null; /// - /// Delegate type for checking spawn options + /// Delegate type for checking spawn options. /// - /// The clientId to check spawn options for + /// The clientId being checked for visibility. + /// True if the object should be visible to the specified client and false if it should not. public delegate bool SpawnDelegate(ulong clientId); /// - /// Delegate invoked when the netcode needs to know if it should include the transform when spawning the object, if null it will assume true + /// Delegate invoked when the netcode needs to know if it should include the transform when spawning the object, if null it will assume true. /// public SpawnDelegate IncludeTransformWhenSpawning = null; /// - /// Whether or not to destroy this object if it's owner is destroyed. + /// Whether or not to destroy this object if it's owner is destroyed.
/// If true, the objects ownership will be given to the server. ///
public bool DontDestroyWithOwner; @@ -1601,6 +1603,11 @@ internal ushort GetNetworkBehaviourOrderIndex(NetworkBehaviour instance) return 0; } + /// + /// Gets a NetworkBehaviour component at the specified index in this object's NetworkBehaviour list. + /// + /// The zero-based index of the NetworkBehaviour to retrieve. + /// The NetworkBehaviour at the specified index, or null if the index is out of bounds. public NetworkBehaviour GetNetworkBehaviourAtOrderIndex(ushort index) { if (index >= ChildNetworkBehaviours.Count) diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs index 98c344fa19..d9cfeb5a16 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs @@ -19,14 +19,14 @@ internal CustomMessagingManager(NetworkManager networkManager) } /// - /// Delegate used for incoming unnamed messages + /// Delegate used for incoming unnamed messages. /// - /// The clientId that sent the message - /// The stream containing the message data + /// The clientId that sent the message. + /// The stream containing the message data. public delegate void UnnamedMessageDelegate(ulong clientId, FastBufferReader reader); /// - /// Event invoked when unnamed messages arrive + /// Event invoked when unnamed messages arrive. /// public event UnnamedMessageDelegate OnUnnamedMessage; @@ -46,21 +46,21 @@ internal void InvokeUnnamedMessage(ulong clientId, FastBufferReader reader, int } /// - /// Sends unnamed message to all clients + /// Sends unnamed message to all clients. /// - /// The message stream containing the data - /// The delivery type (QoS) to send data with + /// The message stream containing the data. + /// The delivery type (QoS) used to send the data. public void SendUnnamedMessageToAll(FastBufferWriter messageBuffer, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced) { SendUnnamedMessage(m_NetworkManager.ConnectedClientsIds, messageBuffer, networkDelivery); } /// - /// Sends unnamed message to a list of clients + /// Sends unnamed message to a list of clients. /// - /// The clients to send to, sends to everyone if null - /// The message stream containing the data - /// The delivery type (QoS) to send data with + /// The clients to send to, sends to everyone if null. + /// The message stream containing the data. + /// The delivery type (QoS) used to send the data. public void SendUnnamedMessage(IReadOnlyList clientIds, FastBufferWriter messageBuffer, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced) { if (!m_NetworkManager.IsServer) @@ -103,11 +103,11 @@ public void SendUnnamedMessage(IReadOnlyList clientIds, FastBufferWriter } /// - /// Sends a unnamed message to a specific client + /// Sends a unnamed message to a specific client. /// - /// The client to send the message to - /// The message stream containing the data - /// The delivery type (QoS) to send data with + /// The client identifier to send the message to. + /// The message stream containing the data. + /// The delivery type (QoS) used to send the data. public void SendUnnamedMessage(ulong clientId, FastBufferWriter messageBuffer, NetworkDelivery networkDelivery = NetworkDelivery.ReliableSequenced) { ValidateMessageSize(messageBuffer, networkDelivery, isNamed: false); @@ -137,8 +137,10 @@ public void SendUnnamedMessage(ulong clientId, FastBufferWriter messageBuffer, N } /// - /// Delegate used to handle named messages + /// Delegate used to handle named messages. /// + /// The client identifier of the message sender. + /// The buffer containing the message data to be read. public delegate void HandleNamedMessageDelegate(ulong senderClientId, FastBufferReader messagePayload); private Dictionary m_NamedMessageHandlers32 = new Dictionary(); diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs index a102f3666e..7a1515b664 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForGenericParameterAttribute.cs @@ -74,6 +74,10 @@ public class GenerateSerializationForGenericParameterAttribute : Attribute { internal int ParameterIndex; + /// + /// Initializes a new instance of the attribute. + /// + /// The zero-based index of the generic parameter that should be serialized. public GenerateSerializationForGenericParameterAttribute(int parameterIndex) { ParameterIndex = parameterIndex; diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs index 81e55c00df..40581ba192 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/GenerateSerializationForTypeAttribute.cs @@ -18,6 +18,10 @@ public class GenerateSerializationForTypeAttribute : Attribute { internal Type Type; + /// + /// Initializes a new instance of the attribute. + /// + /// The type that should have serialization code generated for it. public GenerateSerializationForTypeAttribute(Type type) { Type = type; diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs index acb6289b5b..081c4aeea5 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs @@ -3,17 +3,17 @@ namespace Unity.Netcode { /// - /// RPC delivery types + /// RPC delivery types. /// public enum RpcDelivery { /// - /// Reliable delivery + /// Reliable delivery. /// Reliable = 0, /// - /// Unreliable delivery + /// Unreliable delivery. /// Unreliable } @@ -25,23 +25,57 @@ public enum RpcDelivery public class RpcAttribute : Attribute { // Must match the set of parameters below + /// + /// Parameters that define the behavior of an RPC. + /// public struct RpcAttributeParams { + /// + /// The delivery method for the RPC. + /// public RpcDelivery Delivery; + + /// + /// When true, only the owner of the object can execute this RPC. + /// public bool RequireOwnership; + + /// + /// When true, local execution of the RPC is deferred until the next network tick. + /// public bool DeferLocal; + + /// + /// When true, allows the RPC target to be overridden at runtime. + /// public bool AllowTargetOverride; } // Must match the fields in RemoteAttributeParams /// - /// Type of RPC delivery method + /// Type of RPC delivery method. /// public RpcDelivery Delivery = RpcDelivery.Reliable; + + /// + /// When true, only the owner of the object can execute this RPC. + /// public bool RequireOwnership; + + /// + /// When true, local execution of the RPC is deferred until the next network tick. + /// public bool DeferLocal; + + /// + /// When true, allows the RPC target to be overridden at runtime. + /// public bool AllowTargetOverride; + /// + /// Initializes a new instance of the RpcAttribute with the specified target. + /// + /// The target for this RPC public RpcAttribute(SendTo target) { } @@ -60,8 +94,14 @@ private RpcAttribute() [AttributeUsage(AttributeTargets.Method)] public class ServerRpcAttribute : RpcAttribute { + /// + /// When true, only the owner of the NetworkObject can invoke this ServerRpc. + /// public new bool RequireOwnership; + /// + /// Initializes a new instance of ServerRpcAttribute configured to target the server. + /// public ServerRpcAttribute() : base(SendTo.Server) { @@ -75,6 +115,9 @@ public ServerRpcAttribute() : base(SendTo.Server) [AttributeUsage(AttributeTargets.Method)] public class ClientRpcAttribute : RpcAttribute { + /// + /// Initializes a new instance of ClientRpcAttribute configured to target all non-server clients. + /// public ClientRpcAttribute() : base(SendTo.NotServer) { diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs index 7eb1a18009..82837df0f0 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/RpcParams.cs @@ -3,147 +3,210 @@ namespace Unity.Netcode { + /// + /// Specifies how RPC messages should be handled in terms of local execution timing. + /// public enum LocalDeferMode { + /// + /// Uses the default behavior for RPC message handling. + /// Default, + + /// + /// Defers the local execution of the RPC until the next network tick. + /// Defer, + + /// + /// Executes the RPC immediately on the local client without waiting for network synchronization. + /// SendImmediate } + /// - /// Generic RPC + /// Generic RPC. Defines parameters for sending Remote Procedure Calls (RPCs) in the network system. /// public struct RpcSendParams { + /// + /// Specifies the target that will receive this RPC. + /// public BaseRpcTarget Target; + /// + /// Controls how the RPC is handled for local execution timing. + /// public LocalDeferMode LocalDeferMode; + /// + /// Implicitly converts a BaseRpcTarget to RpcSendParams. + /// + /// The RPC target to convert. + /// A new RpcSendParams instance with the specified target. public static implicit operator RpcSendParams(BaseRpcTarget target) => new RpcSendParams { Target = target }; + + /// + /// Implicitly converts a LocalDeferMode to RpcSendParams. + /// + /// The defer mode to convert. + /// A new RpcSendParams instance with the specified defer mode. public static implicit operator RpcSendParams(LocalDeferMode deferMode) => new RpcSendParams { LocalDeferMode = deferMode }; } /// - /// The receive parameters for server-side remote procedure calls + /// The receive parameters for server-side remote procedure calls. /// public struct RpcReceiveParams { /// - /// Server-Side RPC - /// The client identifier of the sender + /// Server-Side RPC
+ /// The client identifier of the sender. ///
public ulong SenderClientId; } /// - /// Server-Side RPC - /// Can be used with any sever-side remote procedure call - /// Note: typically this is use primarily for the + /// Server-Side RPC
+ /// Can be used with any sever-side remote procedure call.
///
+ /// + /// Note: typically this is use primarily for the . + /// public struct RpcParams { /// - /// The server RPC send parameters (currently a place holder) + /// The server RPC send parameters (currently a place holder). /// public RpcSendParams Send; /// - /// The client RPC receive parameters provides you with the sender's identifier + /// The client RPC receive parameters provides you with the sender's identifier. /// public RpcReceiveParams Receive; + /// + /// Implicitly converts RpcSendParams to RpcParams. + /// + /// The send parameters to convert. + /// A new RpcParams instance with the specified send parameters. public static implicit operator RpcParams(RpcSendParams send) => new RpcParams { Send = send }; + + /// + /// Implicitly converts a BaseRpcTarget to RpcParams. + /// + /// The RPC target to convert. + /// A new RpcParams instance with the specified target in its send parameters. public static implicit operator RpcParams(BaseRpcTarget target) => new RpcParams { Send = new RpcSendParams { Target = target } }; + + /// + /// Implicitly converts a LocalDeferMode to RpcParams. + /// + /// The defer mode to convert. + /// A new RpcParams instance with the specified defer mode in its send parameters. public static implicit operator RpcParams(LocalDeferMode deferMode) => new RpcParams { Send = new RpcSendParams { LocalDeferMode = deferMode } }; + + /// + /// Implicitly converts RpcReceiveParams to RpcParams. + /// + /// The receive parameters to convert. + /// A new RpcParams instance with the specified receive parameters. public static implicit operator RpcParams(RpcReceiveParams receive) => new RpcParams { Receive = receive }; } /// - /// Server-Side RPC - /// Place holder. + /// Server-Side RPC
+ /// Place holder.
/// Note: Clients always send to one destination when sending RPCs to the server - /// so this structure is a place holder + /// so this structure is a place holder. ///
public struct ServerRpcSendParams { } /// - /// The receive parameters for server-side remote procedure calls + /// The receive parameters for server-side remote procedure calls. /// public struct ServerRpcReceiveParams { /// - /// Server-Side RPC - /// The client identifier of the sender + /// Server-Side RPC
+ /// The client identifier of the sender. ///
public ulong SenderClientId; } /// /// Server-Side RPC - /// Can be used with any sever-side remote procedure call - /// Note: typically this is use primarily for the + /// Can be used with any sever-side remote procedure call. /// + /// + /// Note: typically this is use primarily for the . + /// public struct ServerRpcParams { /// - /// The server RPC send parameters (currently a place holder) + /// The server RPC send parameters (currently a place holder). /// public ServerRpcSendParams Send; /// - /// The client RPC receive parameters provides you with the sender's identifier + /// The client RPC receive parameters provides you with the sender's identifier. /// public ServerRpcReceiveParams Receive; } /// - /// Client-Side RPC + /// Client-Side RPC
/// The send parameters, when sending client RPCs, provides you wil the ability to - /// target specific clients as a managed or unmanaged list: + /// target specific clients as a managed or unmanaged list:
/// and ///
public struct ClientRpcSendParams { /// - /// IEnumerable version of target id list - use either this OR TargetClientIdsNativeArray - /// Note: Even if you provide a value type such as NativeArray, enumerating it will cause boxing. - /// If you want to avoid boxing, use TargetClientIdsNativeArray + /// IEnumerable version of target id list - use either this OR TargetClientIdsNativeArray.
+ /// Note: Even if you provide a value type such as NativeArray, enumerating it will cause boxing.
+ /// If you want to avoid boxing, use TargetClientIdsNativeArray. ///
public IReadOnlyList TargetClientIds; /// - /// NativeArray version of target id list - use either this OR TargetClientIds + /// NativeArray version of target id list - use either this OR TargetClientIds.
/// This option avoids any GC allocations but is a bit trickier to use. ///
public NativeArray? TargetClientIdsNativeArray; } /// - /// Client-Side RPC - /// Place holder. - /// Note: Server will always be the sender, so this structure is a place holder + /// Client-Side RPC
+ /// Place holder.
///
+ /// + /// Note: Server will always be the sender, so this structure is a place holder. + /// public struct ClientRpcReceiveParams { } /// - /// Client-Side RPC - /// Can be used with any client-side remote procedure call + /// Client-Side RPC
+ /// Can be used with any client-side remote procedure call.
+ ///
+ /// /// Note: Typically this is used primarily for sending to a specific list - /// of clients as opposed to the default (all). + /// of clients as opposed to the default (all).
/// - ///
+ /// public struct ClientRpcParams { /// - /// The client RPC send parameters provides you with the ability to send to a specific list of clients + /// The client RPC send parameters provides you with the ability to send to a specific list of clients. /// public ClientRpcSendParams Send; /// - /// The client RPC receive parameters (currently a place holder) + /// The client RPC receive parameters (currently a place holder). /// public ClientRpcReceiveParams Receive; } diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs index 94625722e3..f9a92f050d 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/AnticipatedNetworkVariable.cs @@ -4,10 +4,21 @@ namespace Unity.Netcode { - + /// + /// Defines how anticipated network variables handle authoritative updates that are older than the current anticipated state. + /// public enum StaleDataHandling { + /// + /// Ignores authoritative updates that are older than the current anticipated state. + /// The anticipated value will not be replaced until a newer authoritative update is received. + /// Ignore, + + /// + /// Applies authoritative updates even if they are older than the current anticipated state. + /// This triggers reanticipation to calculate a new anticipated value based on the authoritative state. + /// Reanticipate } @@ -85,6 +96,12 @@ public class AnticipatedNetworkVariable : NetworkVariableBase #pragma warning restore IDE0001 public StaleDataHandling StaleDataHandling; + /// + /// Delegate for handling changes in the authoritative value. + /// + /// The network variable that changed. + /// The previous value before the change. + /// The new value after the change. public delegate void OnAuthoritativeValueChangedDelegate(AnticipatedNetworkVariable variable, in T previousValue, in T newValue); /// @@ -121,6 +138,9 @@ public void ResetAnticipation() private AnticipatedObject m_AnticipatedObject; + /// + /// Initializes the network variable, setting up initial values and registering with the anticipation system. + /// public override void OnInitialize() { m_AuthoritativeValue.Initialize(m_NetworkBehaviour); @@ -133,6 +153,10 @@ public override void OnInitialize() } } + /// + /// Checks if the current value has changed enough from its last synchronized value to warrant a new network update. + /// + /// True if the value should be synchronized or false if it should not. public override bool ExceedsDirtinessThreshold() { return m_AuthoritativeValue.ExceedsDirtinessThreshold(); @@ -157,7 +181,7 @@ public override bool ExceedsDirtinessThreshold() /// Indicates whether this variable currently needs /// reanticipation. If this is true, the anticipated value /// has been overwritten by the authoritative value from the - /// server; the previous anticipated value is stored in + /// server; the previous anticipated value is stored in . /// public bool ShouldReanticipate { @@ -177,7 +201,7 @@ public bool ShouldReanticipate /// Sets the current value of the variable on the expectation that the authority will set the variable /// to the same value within one network round trip (i.e., in response to an RPC). /// - /// The anticipated value that is expected to be confirmed by the authority + /// The anticipated value that is expected to be confirmed by the authority. public void Anticipate(T value) { if (m_NetworkBehaviour.NetworkManager.ShutdownInProgress || !m_NetworkBehaviour.NetworkManager.IsListening) @@ -197,8 +221,8 @@ public void Anticipate(T value) #pragma warning disable IDE0001 /// - /// Retrieves or sets the underlying authoritative value. - /// Note that only a client or server with write permissions to this variable may set this value. + /// Retrieves or sets the underlying authoritative value.
+ /// Note that only a client or server with write permissions to this variable may set this value.
/// When this variable has been anticipated, this value will alawys return the most recent authoritative /// state, which is updated even if is . ///
@@ -227,10 +251,19 @@ public T AuthoritativeValue /// See , , , and so on /// for examples. /// + /// The authoritative value to interpolate from. + /// The anticipated value to interpolate to. + /// The interpolation factor between 0 and 1. + /// The interpolated value. public delegate T SmoothDelegate(T authoritativeValue, T anticipatedValue, float amount); private SmoothDelegate m_SmoothDelegate = null; + /// + /// Initializes a new instance of the AnticipatedNetworkVariable class. + /// + /// The initial value for the network variable. Defaults to the type's default value if not specified. + /// Determines how the variable handles authoritative updates that are older than the current anticipated state. Defaults to StaleDataHandling.Ignore. public AnticipatedNetworkVariable(T value = default, StaleDataHandling staleDataHandling = StaleDataHandling.Ignore) : base() @@ -242,6 +275,9 @@ public AnticipatedNetworkVariable(T value = default, }; } + /// + /// Updates the smooth interpolation state if active. + /// public void Update() { if (m_CurrentSmoothTime < m_SmoothDuration) @@ -253,6 +289,7 @@ public void Update() } } + /// public override void Dispose() { if (m_IsDisposed) @@ -302,6 +339,9 @@ public override void Dispose() } } + /// + /// Finalizer that ensures proper cleanup of network variable resources. + /// ~AnticipatedNetworkVariable() { Dispose(); @@ -334,9 +374,9 @@ private void OnValueChangedInternal(T previousValue, T newValue) /// Interpolate this variable from to over of /// real time. The duration uses , so it is affected by . /// - /// The starting value for the interpolation - /// The target value to interpolate towards - /// The duration of the interpolation in seconds + /// The starting value for the interpolation. + /// The target value to interpolate towards. + /// The duration of the interpolation in seconds. /// A delegate that defines how the interpolation should be performed between the two values. It provides a function to interpolate between two values based on a percentage. public void Smooth(in T from, in T to, float durationSeconds, SmoothDelegate how) { @@ -357,26 +397,31 @@ public void Smooth(in T from, in T to, float durationSeconds, SmoothDelegate how m_HasSmoothValues = true; } + /// public override bool IsDirty() { return m_AuthoritativeValue.IsDirty(); } + /// public override void ResetDirty() { m_AuthoritativeValue.ResetDirty(); } + /// public override void WriteDelta(FastBufferWriter writer) { m_AuthoritativeValue.WriteDelta(writer); } + /// public override void WriteField(FastBufferWriter writer) { m_AuthoritativeValue.WriteField(writer); } + /// public override void ReadField(FastBufferReader reader) { m_AuthoritativeValue.ReadField(reader); @@ -384,6 +429,7 @@ public override void ReadField(FastBufferReader reader) NetworkVariableSerialization.Duplicate(m_AnticipatedValue, ref m_PreviousAnticipatedValue); } + /// public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta) { m_AuthoritativeValue.ReadDelta(reader, keepDirtyDelta); diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs index eaf06bbb67..ef8f526cc4 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs @@ -5,9 +5,9 @@ namespace Unity.Netcode { /// - /// Event based NetworkVariable container for syncing Lists + /// Event based NetworkVariable container for syncing Lists. /// - /// The type for the list + /// The type for the list. [GenerateSerializationForGenericParameter(0)] public class NetworkList : NetworkVariableBase where T : unmanaged, IEquatable { @@ -15,18 +15,18 @@ public class NetworkList : NetworkVariableBase where T : unmanaged, IEquatabl private NativeList> m_DirtyEvents = new NativeList>(64, Allocator.Persistent); /// - /// Delegate type for list changed event + /// Delegate type for list changed event. /// - /// Struct containing information about the change event + /// Struct containing information about the change event. public delegate void OnListChangedDelegate(NetworkListEvent changeEvent); /// - /// The callback to be invoked when the list gets changed + /// The callback to be invoked when the list gets changed. /// public event OnListChangedDelegate OnListChanged; /// - /// Creates a + /// Constructor for . /// public NetworkList() { } @@ -49,6 +49,9 @@ public NetworkList(IEnumerable values = default, } } + /// + /// The destructor for . + /// ~NetworkList() { Dispose(); diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs index 5df83215b1..cb5fe9e2b3 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariable.cs @@ -22,10 +22,23 @@ public class NetworkVariable : NetworkVariableBase /// public OnValueChangedDelegate OnValueChanged; + /// + /// Delegate that determines if the difference between two values exceeds a threshold for network synchronization + /// + /// The previous value to compare against + /// The new value to compare + /// True if the difference exceeds the threshold and should be synchronized, false otherwise public delegate bool CheckExceedsDirtinessThresholdDelegate(in T previousValue, in T newValue); + /// + /// Delegate instance for checking if value changes exceed the dirtiness threshold + /// public CheckExceedsDirtinessThresholdDelegate CheckExceedsDirtinessThreshold; + /// + /// Determines if the current value has changed enough from its previous value to warrant network synchronization + /// + /// True if the value should be synchronized, false otherwise public override bool ExceedsDirtinessThreshold() { if (CheckExceedsDirtinessThreshold != null && m_HasPreviousValue) @@ -36,6 +49,9 @@ public override bool ExceedsDirtinessThreshold() return true; } + /// + /// Initializes the NetworkVariable by setting up initial and previous values + /// public override void OnInitialize() { base.OnInitialize(); @@ -90,7 +106,7 @@ public void Reset(T value = default) // The introduction of standard .NET collections caused an issue with permissions since there is no way to detect changes in the // collection without doing a full comparison. While this approach does consume more memory per collection instance, it is the // lowest risk approach to resolving the issue where a client with no write permissions could make changes to a collection locally - // which can cause a myriad of issues. + // which can cause a myriad of issues. private protected T m_InternalOriginalValue; private protected T m_PreviousValue; @@ -135,11 +151,12 @@ public virtual T Value /// Invoke this method to check if a collection's items are dirty. /// The default behavior is to exit early if the is already dirty. /// + /// when true, this check will force a full item collection check even if the NetworkVariable is already dirty + /// True if the variable is dirty and needs synchronization, false if clean or client lacks write permissions /// /// This is to be used as a way to check if a containing a managed collection has any changees to the collection items.
/// If you invoked this when a collection is dirty, it will not trigger the unless you set forceCheck param to true.
///
- /// when true, this check will force a full item collection check even if the NetworkVariable is already dirty public bool CheckDirtyState(bool forceCheck = false) { var isDirty = base.IsDirty(); @@ -178,6 +195,7 @@ internal ref T RefValue() return ref m_InternalValue; } + /// public override void Dispose() { if (m_IsDisposed) @@ -208,6 +226,9 @@ public override void Dispose() m_PreviousValue = default; } + /// + /// Finalizer that ensures proper cleanup of resources + /// ~NetworkVariable() { Dispose(); @@ -320,7 +341,7 @@ public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta) /// This should be always invoked (client & server) to assure the previous values are set /// !! IMPORTANT !! /// When a server forwards delta updates to connected clients, it needs to preserve the previous dirty value(s) - /// until it is done serializing all valid NetworkVariable field deltas (relative to each client). This is invoked + /// until it is done serializing all valid NetworkVariable field deltas (relative to each client). This is invoked /// after it is done forwarding the deltas at the end of the method. /// internal override void PostDeltaRead() diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs index 377fadeee0..8b86d356ad 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableBase.cs @@ -3,11 +3,20 @@ namespace Unity.Netcode { + /// + /// Defines timing constraints for network variable updates + /// public struct NetworkVariableUpdateTraits { + /// + /// The minimum amount of time that must pass between sending updates. If this amount of time has not passed since the last update, dirtiness will be ignored. + /// [Tooltip("The minimum amount of time that must pass between sending updates. If this amount of time has not passed since the last update, dirtiness will be ignored.")] public float MinSecondsBetweenUpdates; + /// + /// The maximum amount of time that a variable can be dirty without sending an update. If this amount of time has passed since the last update, an update will be sent even if the dirtiness threshold has not been met. + /// [Tooltip("The maximum amount of time that a variable can be dirty without sending an update. If this amount of time has passed since the last update, an update will be sent even if the dirtiness threshold has not been met.")] public float MaxSecondsBetweenUpdates; } @@ -40,6 +49,10 @@ public abstract class NetworkVariableBase : IDisposable // this NetworkVariableBase property instance will not update until the last session time used. internal bool HasBeenInitialized { get; private set; } + /// + /// Gets the instance associated with this network variable + /// + /// The that owns this network variable public NetworkBehaviour GetBehaviour() { return m_NetworkBehaviour; @@ -240,6 +253,9 @@ internal void UpdateLastSentTime() LastUpdateSent = m_NetworkBehaviour.NetworkManager.NetworkTimeSystem.LocalTime; } + /// + /// Marks the associated as dirty, indicating it needs synchronization + /// protected void MarkNetworkBehaviourDirty() { if (m_NetworkBehaviour == null) diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs b/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs index 7127279cda..9fac4ac58a 100644 --- a/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs +++ b/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs @@ -28,6 +28,10 @@ public abstract class NetworkTransport : MonoBehaviour /// /// Delegate for transport network events /// + /// The type of network event that occurred. + /// The ID of the client associated with this event. + /// The data payload received with this event. + /// The time when this event was received. public delegate void TransportEventDelegate(NetworkEvent eventType, ulong clientId, ArraySegment payload, float receiveTime); /// diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs index 2665214c9f..bdd21e1f2e 100644 --- a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs +++ b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs @@ -384,6 +384,9 @@ public NetworkEndpoint ListenEndPoint /// /// Returns true if the end point address is of type . /// + /// + /// True if the Address property contains a valid IPv6 address, false if it's empty or an IPv4 address. + /// public bool IsIpv6 => !string.IsNullOrEmpty(Address) && NetworkEndpoint.TryParse(Address, Port, out NetworkEndpoint _, NetworkFamily.Ipv6); } diff --git a/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs b/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs index 3669c36f16..5e63e2384f 100644 --- a/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs +++ b/com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTestHelpers.cs @@ -421,11 +421,11 @@ private static void SceneManagerValidationAndTestRunnerInitialization(NetworkMan /// /// Starts NetworkManager instances created by the Create method. /// - /// Whether or not to create a Host instead of Server - /// The Server NetworkManager - /// The Clients NetworkManager - /// called immediately after server is started and before client(s) are started - /// + /// Whether or not to create a Host instead of Server. + /// The Server NetworkManager. + /// The Clients NetworkManager. + /// called immediately after server is started and before client(s) are started. + /// True if the network instances were started successfully, throws InvalidOperationException if already started. public static bool Start(bool host, NetworkManager server, NetworkManager[] clients, BeforeClientStartCallback callback = null) { if (s_IsStarted) @@ -616,10 +616,10 @@ public static IEnumerator WaitForClientConnected(NetworkManager client, ResultWr /// /// Similar to WaitForClientConnected, this waits for multiple clients to be connected. /// - /// The clients to be connected - /// The result. If null, it will automatically assert< + /// Array of clients to wait for. + /// The result. If null, it will automatically assert. /// Maximum time in seconds to wait for the object to be found. - /// + /// An IEnumerator that yields until all clients are connected or timeout is reached. public static IEnumerator WaitForClientsConnected(NetworkManager[] clients, ResultWrapper result = null, float timeout = DefaultTimeout) { // Make sure none are the host client diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs b/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs index 3912448423..f953f01ccf 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/Components/BufferDataValidationComponent.cs @@ -54,7 +54,7 @@ private void Start() /// /// Returns back whether the test has completed the total number of iterations /// - /// + /// True if the test has exceeded maximum buffer size or has already failed. False if the test is yet to complete and has not failed. public bool IsTestComplete() { if (m_CurrentBufferSize > MaximumBufferSize || TestFailed) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs index 2a9a1b052e..20e60ee5f0 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableBaseInitializesWhenPersisted.cs @@ -333,7 +333,10 @@ public void Initialize(NetworkManager networkManager) /// /// This validates that the instances persisted to the next test set and persisted - /// between network sessions + /// between network sessions. + /// + /// The minimum number of times each instance should have been spawned. + /// True if all instances meet the minimum spawn count requirement or false if they do not. public bool ValidateInstanceSpawnCount(int minCount) { // First pass we should have no instances diff --git a/pvpExceptions.json b/pvpExceptions.json index 6a7fc8d678..03a2cee707 100644 --- a/pvpExceptions.json +++ b/pvpExceptions.json @@ -10,104 +10,8 @@ "Failed to find a suitable OpenCL device, baking cannot use GPU lightmapper." ] }, - "PVP-150-1": { - "errors": [ - "Unity.Netcode.TestHelpers.Runtime.NetcodeIntegrationTestHelpers: bool Start(bool, NetworkManager, NetworkManager[], BeforeClientStartCallback): empty tag", - "Unity.Netcode.TestHelpers.Runtime.NetcodeIntegrationTestHelpers: IEnumerator WaitForClientsConnected(NetworkManager[], ResultWrapper, float): XML is not well-formed: An identifier was expected", - "Unity.Netcode.RuntimeTests.BufferDataValidationComponent: bool IsTestComplete(): empty tag", - "Unity.Netcode.RuntimeTests.NetworkVariableBaseInitializesWhenPersisted.PrefabInstanceHandler: bool ValidateInstanceSpawnCount(int): XML is not well-formed: Expected an end tag for element 'summary'" - ] - }, "PVP-151-1": { "errors": [ - "Unity.Netcode.NetworkConfig: Prefabs: undocumented", - "Unity.Netcode.NetworkPrefab: bool Equals(NetworkPrefab): undocumented", - "Unity.Netcode.NetworkPrefab: SourcePrefabGlobalObjectIdHash: undocumented", - "Unity.Netcode.NetworkPrefab: TargetPrefabGlobalObjectIdHash: undocumented", - "Unity.Netcode.NetworkPrefab: bool Validate(int): undocumented", - "Unity.Netcode.NetworkPrefab: string ToString(): undocumented", - "Unity.Netcode.NetworkPrefabs: Prefabs: undocumented", - "Unity.Netcode.NetworkPrefabs: void Finalize(): undocumented", - "Unity.Netcode.NetworkPrefabs: void Initialize(bool): missing ", - "Unity.Netcode.NetworkPrefabs: bool Add(NetworkPrefab): missing ", - "Unity.Netcode.NetworkPrefabs: bool Add(NetworkPrefab): missing ", - "Unity.Netcode.NetworkPrefabs: void Remove(NetworkPrefab): missing ", - "Unity.Netcode.NetworkPrefabs: void Remove(GameObject): missing ", - "Unity.Netcode.ConnectionEventData: EventType: undocumented", - "Unity.Netcode.RpcException: undocumented", - "Unity.Netcode.RpcException: .ctor(string): undocumented", - "Unity.Netcode.NetworkManager: void NetworkUpdate(NetworkUpdateStage): undocumented", - "Unity.Netcode.NetworkManager.ReanticipateDelegate: undocumented", - "Unity.Netcode.NetworkObject: NetworkBehaviour GetNetworkBehaviourAtOrderIndex(ushort): undocumented", - "Unity.Netcode.NetworkObject.VisibilityDelegate: missing ", - "Unity.Netcode.NetworkObject.SpawnDelegate: missing ", - "Unity.Netcode.CustomMessagingManager.HandleNamedMessageDelegate: missing ", - "Unity.Netcode.CustomMessagingManager.HandleNamedMessageDelegate: missing ", - "Unity.Netcode.GenerateSerializationForGenericParameterAttribute: .ctor(int): undocumented", - "Unity.Netcode.GenerateSerializationForTypeAttribute: .ctor(Type): undocumented", - "Unity.Netcode.RpcAttribute: RequireOwnership: undocumented", - "Unity.Netcode.RpcAttribute: DeferLocal: undocumented", - "Unity.Netcode.RpcAttribute: AllowTargetOverride: undocumented", - "Unity.Netcode.RpcAttribute: .ctor(SendTo): undocumented", - "Unity.Netcode.RpcAttribute.RpcAttributeParams: undocumented", - "Unity.Netcode.RpcAttribute.RpcAttributeParams: Delivery: undocumented", - "Unity.Netcode.RpcAttribute.RpcAttributeParams: RequireOwnership: undocumented", - "Unity.Netcode.RpcAttribute.RpcAttributeParams: DeferLocal: undocumented", - "Unity.Netcode.RpcAttribute.RpcAttributeParams: AllowTargetOverride: undocumented", - "Unity.Netcode.ServerRpcAttribute: RequireOwnership: undocumented", - "Unity.Netcode.ServerRpcAttribute: .ctor(): undocumented", - "Unity.Netcode.ClientRpcAttribute: .ctor(): undocumented", - "Unity.Netcode.LocalDeferMode: undocumented", - "Unity.Netcode.LocalDeferMode: Default: undocumented", - "Unity.Netcode.LocalDeferMode: Defer: undocumented", - "Unity.Netcode.LocalDeferMode: SendImmediate: undocumented", - "Unity.Netcode.RpcSendParams: Target: undocumented", - "Unity.Netcode.RpcSendParams: LocalDeferMode: undocumented", - "Unity.Netcode.RpcSendParams: RpcSendParams op_Implicit(BaseRpcTarget): undocumented", - "Unity.Netcode.RpcSendParams: RpcSendParams op_Implicit(LocalDeferMode): undocumented", - "Unity.Netcode.RpcParams: RpcParams op_Implicit(RpcSendParams): undocumented", - "Unity.Netcode.RpcParams: RpcParams op_Implicit(BaseRpcTarget): undocumented", - "Unity.Netcode.RpcParams: RpcParams op_Implicit(LocalDeferMode): undocumented", - "Unity.Netcode.RpcParams: RpcParams op_Implicit(RpcReceiveParams): undocumented", - "Unity.Netcode.StaleDataHandling: undocumented", - "Unity.Netcode.StaleDataHandling: Ignore: undocumented", - "Unity.Netcode.StaleDataHandling: Reanticipate: undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void OnInitialize(): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: bool ExceedsDirtinessThreshold(): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: .ctor(T, StaleDataHandling): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void Update(): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void Dispose(): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void Finalize(): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: bool IsDirty(): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void ResetDirty(): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void WriteDelta(FastBufferWriter): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void WriteField(FastBufferWriter): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void ReadField(FastBufferReader): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable: void ReadDelta(FastBufferReader, bool): undocumented", - "Unity.Netcode.AnticipatedNetworkVariable.OnAuthoritativeValueChangedDelegate: undocumented", - "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ", - "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ", - "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ", - "Unity.Netcode.AnticipatedNetworkVariable.SmoothDelegate: missing ", - "Unity.Netcode.NetworkList: void Finalize(): undocumented", - "Unity.Netcode.NetworkVariable: CheckExceedsDirtinessThreshold: undocumented", - "Unity.Netcode.NetworkVariable: bool ExceedsDirtinessThreshold(): undocumented", - "Unity.Netcode.NetworkVariable: void OnInitialize(): undocumented", - "Unity.Netcode.NetworkVariable: bool CheckDirtyState(bool): missing ", - "Unity.Netcode.NetworkVariable: void Dispose(): undocumented", - "Unity.Netcode.NetworkVariable: void Finalize(): undocumented", - "Unity.Netcode.NetworkVariable.CheckExceedsDirtinessThresholdDelegate: undocumented", - "Unity.Netcode.NetworkVariableUpdateTraits: undocumented", - "Unity.Netcode.NetworkVariableUpdateTraits: MinSecondsBetweenUpdates: undocumented", - "Unity.Netcode.NetworkVariableUpdateTraits: MaxSecondsBetweenUpdates: undocumented", - "Unity.Netcode.NetworkVariableBase: NetworkBehaviour GetBehaviour(): undocumented", - "Unity.Netcode.NetworkVariableBase: void MarkNetworkBehaviourDirty(): undocumented", - "Unity.Netcode.NetworkSceneManager: void SetClientSynchronizationMode(LoadSceneMode): XML is not well-formed: Expected an end tag for element 'summary'", - "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ", - "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ", - "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ", - "Unity.Netcode.NetworkTransport.TransportEventDelegate: missing ", - "Unity.Netcode.Transports.UTP.UnityTransport.ConnectionAddressData: IsIpv6: undocumented", "Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: undocumented", "Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: void OnNetworkSpawn(): undocumented", "Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: void RegisterAndLabelNetworkObject(): undocumented",