Skip to content

Commit ec8041d

Browse files
committed
Bunch of API additions
1 parent 86f224c commit ec8041d

File tree

5 files changed

+77
-27
lines changed

5 files changed

+77
-27
lines changed

com.unity.netcode.gameobjects/Runtime/Messaging/CustomMessageManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ public void SendUnnamedMessage(ulong clientId, FastBufferWriter messageBuffer, N
139139
/// <summary>
140140
/// Delegate used to handle named messages
141141
/// </summary>
142+
/// <param name="senderClientId">The client identifier of the message sender</param>
143+
/// <param name="messagePayload">The buffer containing the message data to be read</param>
142144
public delegate void HandleNamedMessageDelegate(ulong senderClientId, FastBufferReader messagePayload);
143145

144146
private Dictionary<ulong, HandleNamedMessageDelegate> m_NamedMessageHandlers32 = new Dictionary<ulong, HandleNamedMessageDelegate>();

com.unity.netcode.gameobjects/Runtime/Messaging/RpcAttributes.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,29 @@ public enum RpcDelivery
2525
public class RpcAttribute : Attribute
2626
{
2727
// Must match the set of parameters below
28+
/// <summary>
29+
/// Parameters that define the behavior of an RPC
30+
/// </summary>
2831
public struct RpcAttributeParams
2932
{
33+
/// <summary>
34+
/// The delivery method for the RPC
35+
/// </summary>
3036
public RpcDelivery Delivery;
37+
38+
/// <summary>
39+
/// When true, only the owner of the object can execute this RPC
40+
/// </summary>
3141
public bool RequireOwnership;
42+
43+
/// <summary>
44+
/// When true, local execution of the RPC is deferred until the next network tick
45+
/// </summary>
3246
public bool DeferLocal;
47+
48+
/// <summary>
49+
/// When true, allows the RPC target to be overridden at runtime
50+
/// </summary>
3351
public bool AllowTargetOverride;
3452
}
3553

@@ -38,10 +56,26 @@ public struct RpcAttributeParams
3856
/// Type of RPC delivery method
3957
/// </summary>
4058
public RpcDelivery Delivery = RpcDelivery.Reliable;
59+
60+
/// <summary>
61+
/// When true, only the owner of the object can execute this RPC
62+
/// </summary>
4163
public bool RequireOwnership;
64+
65+
/// <summary>
66+
/// When true, local execution of the RPC is deferred until the next network tick
67+
/// </summary>
4268
public bool DeferLocal;
69+
70+
/// <summary>
71+
/// When true, allows the RPC target to be overridden at runtime
72+
/// </summary>
4373
public bool AllowTargetOverride;
4474

75+
/// <summary>
76+
/// Initializes a new instance of the RpcAttribute with the specified target
77+
/// </summary>
78+
/// <param name="target">The target for this RPC</param>
4579
public RpcAttribute(SendTo target)
4680
{
4781
}
@@ -60,8 +94,14 @@ private RpcAttribute()
6094
[AttributeUsage(AttributeTargets.Method)]
6195
public class ServerRpcAttribute : RpcAttribute
6296
{
97+
/// <summary>
98+
/// When true, only the owner of the NetworkObject can invoke this ServerRpc
99+
/// </summary>
63100
public new bool RequireOwnership;
64101

102+
/// <summary>
103+
/// Initializes a new instance of ServerRpcAttribute configured to target the server
104+
/// </summary>
65105
public ServerRpcAttribute() : base(SendTo.Server)
66106
{
67107

@@ -75,6 +115,9 @@ public ServerRpcAttribute() : base(SendTo.Server)
75115
[AttributeUsage(AttributeTargets.Method)]
76116
public class ClientRpcAttribute : RpcAttribute
77117
{
118+
/// <summary>
119+
/// Initializes a new instance of ClientRpcAttribute configured to target all non-server clients
120+
/// </summary>
78121
public ClientRpcAttribute() : base(SendTo.NotServer)
79122
{
80123

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33

44
namespace Unity.Netcode
55
{
6+
/// <summary>
7+
/// Defines timing constraints for network variable updates
8+
/// </summary>
69
public struct NetworkVariableUpdateTraits
710
{
11+
/// <summary>
12+
/// 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.
13+
/// </summary>
814
[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.")]
915
public float MinSecondsBetweenUpdates;
1016

17+
/// <summary>
18+
/// 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.
19+
/// </summary>
1120
[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.")]
1221
public float MaxSecondsBetweenUpdates;
1322
}
@@ -40,6 +49,10 @@ public abstract class NetworkVariableBase : IDisposable
4049
// this NetworkVariableBase property instance will not update until the last session time used.
4150
internal bool HasBeenInitialized { get; private set; }
4251

52+
/// <summary>
53+
/// Gets the NetworkBehaviour instance associated with this network variable
54+
/// </summary>
55+
/// <returns>The NetworkBehaviour that owns this network variable</returns>
4356
public NetworkBehaviour GetBehaviour()
4457
{
4558
return m_NetworkBehaviour;
@@ -97,7 +110,7 @@ public void Initialize(NetworkBehaviour networkBehaviour)
97110
if (!m_NetworkBehaviour.NetworkObject.NetworkManagerOwner)
98111
{
99112
// Exit early if there has yet to be a NetworkManagerOwner assigned
100-
// to the NetworkObject. This is ok because Initialize is invoked
113+
// to the NetworkObject. This is ok because Initialize is invoked
101114
// multiple times until it is considered "initialized".
102115
return;
103116
}
@@ -240,6 +253,9 @@ internal void UpdateLastSentTime()
240253
LastUpdateSent = m_NetworkBehaviour.NetworkManager.NetworkTimeSystem.LocalTime;
241254
}
242255

256+
/// <summary>
257+
/// Marks the associated NetworkBehaviour as dirty, indicating it needs synchronization
258+
/// </summary>
243259
protected void MarkNetworkBehaviourDirty()
244260
{
245261
if (m_NetworkBehaviour == null)
@@ -374,7 +390,7 @@ internal ulong OwnerClientId()
374390
/// This should be always invoked (client & server) to assure the previous values are set
375391
/// !! IMPORTANT !!
376392
/// When a server forwards delta updates to connected clients, it needs to preserve the previous dirty value(s)
377-
/// until it is done serializing all valid NetworkVariable field deltas (relative to each client). This is invoked
393+
/// until it is done serializing all valid NetworkVariable field deltas (relative to each client). This is invoked
378394
/// after it is done forwarding the deltas at the end of the <see cref="NetworkVariableDeltaMessage.Handle(ref NetworkContext)"/> method.
379395
/// </summary>
380396
internal virtual void PostDeltaRead()

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ public NetworkEndpoint ListenEndPoint
358358
}
359359
}
360360

361+
/// <summary>
362+
/// Gets whether the configured server address is an IPv6 address
363+
/// </summary>
364+
/// <value>
365+
/// True if the Address property contains a valid IPv6 address, false if it's empty or an IPv4 address
366+
/// </value>
361367
public bool IsIpv6 => !string.IsNullOrEmpty(Address) && ParseNetworkEndpoint(Address, Port, true).Family == NetworkFamily.Ipv6;
362368
}
363369

pvpExceptions.json

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,25 @@
1212
},
1313
"PVP-151-1": {
1414
"errors": [
15-
"Unity.Netcode.NetworkConfig: Prefabs: undocumented",
15+
"Unity.Netcode.NetworkConfig: Prefabs: undocumented",
16+
1617
"Unity.Netcode.ConnectionEventData: EventType: undocumented",
18+
1719
"Unity.Netcode.RpcException: undocumented",
1820
"Unity.Netcode.RpcException: .ctor(string): undocumented",
21+
1922
"Unity.Netcode.NetworkManager: void NetworkUpdate(NetworkUpdateStage): undocumented",
2023
"Unity.Netcode.NetworkManager.ReanticipateDelegate: undocumented",
24+
2125
"Unity.Netcode.NetworkObject: NetworkBehaviour GetNetworkBehaviourAtOrderIndex(ushort): undocumented",
2226
"Unity.Netcode.NetworkObject.VisibilityDelegate: missing <returns>",
2327
"Unity.Netcode.NetworkObject.SpawnDelegate: missing <returns>",
24-
"Unity.Netcode.CustomMessagingManager.HandleNamedMessageDelegate: missing <param name=\"senderClientId\">",
25-
"Unity.Netcode.CustomMessagingManager.HandleNamedMessageDelegate: missing <param name=\"messagePayload\">",
28+
2629
"Unity.Netcode.GenerateSerializationForGenericParameterAttribute: .ctor(int): undocumented",
30+
2731
"Unity.Netcode.GenerateSerializationForTypeAttribute: .ctor(Type): undocumented",
28-
"Unity.Netcode.RpcAttribute: RequireOwnership: undocumented",
29-
"Unity.Netcode.RpcAttribute: DeferLocal: undocumented",
30-
"Unity.Netcode.RpcAttribute: AllowTargetOverride: undocumented",
31-
"Unity.Netcode.RpcAttribute: .ctor(SendTo): undocumented",
32-
"Unity.Netcode.RpcAttribute.RpcAttributeParams: undocumented",
33-
"Unity.Netcode.RpcAttribute.RpcAttributeParams: Delivery: undocumented",
34-
"Unity.Netcode.RpcAttribute.RpcAttributeParams: RequireOwnership: undocumented",
35-
"Unity.Netcode.RpcAttribute.RpcAttributeParams: DeferLocal: undocumented",
36-
"Unity.Netcode.RpcAttribute.RpcAttributeParams: AllowTargetOverride: undocumented",
37-
"Unity.Netcode.ServerRpcAttribute: RequireOwnership: undocumented",
38-
"Unity.Netcode.ServerRpcAttribute: .ctor(): undocumented",
39-
"Unity.Netcode.ClientRpcAttribute: .ctor(): undocumented",
40-
"Unity.Netcode.StaleDataHandling: undocumented",
41-
"Unity.Netcode.StaleDataHandling: Ignore: undocumented",
42-
"Unity.Netcode.StaleDataHandling: Reanticipate: undocumented",
32+
4333
"Unity.Netcode.NetworkList<T>: void Finalize(): undocumented",
44-
"Unity.Netcode.NetworkVariableUpdateTraits: undocumented",
45-
"Unity.Netcode.NetworkVariableUpdateTraits: MinSecondsBetweenUpdates: undocumented",
46-
"Unity.Netcode.NetworkVariableUpdateTraits: MaxSecondsBetweenUpdates: undocumented",
47-
"Unity.Netcode.NetworkVariableBase: NetworkBehaviour GetBehaviour(): undocumented",
48-
"Unity.Netcode.NetworkVariableBase: void MarkNetworkBehaviourDirty(): undocumented",
49-
"Unity.Netcode.NetworkSceneManager: void SetClientSynchronizationMode(LoadSceneMode): XML is not well-formed: Expected an end tag for element 'summary'",
50-
"Unity.Netcode.Transports.UTP.UnityTransport.ConnectionAddressData: IsIpv6: undocumented",
5134

5235
"Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: undocumented",
5336
"Unity.Netcode.TestHelpers.Runtime.ObjectNameIdentifier: void OnNetworkSpawn(): undocumented",

0 commit comments

Comments
 (0)