Skip to content

Commit 57b50af

Browse files
committed
Added more XML documentation and updated API reference
1 parent 57f0575 commit 57b50af

File tree

91 files changed

+491
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+491
-244
lines changed

MLAPI/Attributes/SyncedVar.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,5 @@ public class SyncedVar : Attribute
1212
/// The method name to invoke when the SyncVar get's updated.
1313
/// </summary>
1414
public string hook;
15-
16-
public SyncedVar()
17-
{
18-
19-
}
2015
}
2116
}

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,39 @@ private void OnEnable()
118118
}
119119

120120
internal bool networkedStartInvoked = false;
121+
/// <summary>
122+
/// Gets called when message handlers are ready to be registered and the networking is setup
123+
/// </summary>
121124
public virtual void NetworkStart()
122125
{
123126

124127
}
125-
128+
/// <summary>
129+
/// Gets called when the local client gains ownership of this object
130+
/// </summary>
126131
public virtual void OnGainedOwnership()
127132
{
128133

129134
}
130-
135+
/// <summary>
136+
/// Gets called when we loose ownership of this object
137+
/// </summary>
131138
public virtual void OnLostOwnership()
132139
{
133140

134141
}
135-
136-
protected void RegisterMessageHandler(string name, Action<int, byte[]> action)
142+
/// <summary>
143+
/// Registers a message handler
144+
/// </summary>
145+
/// <param name="name">The MessageType to register</param>
146+
/// <param name="action">The callback to get invoked whenever a message is received</param>
147+
/// <returns>HandlerId for the messageHandler that can be used to deregister the messageHandler</returns>
148+
protected int RegisterMessageHandler(string name, Action<int, byte[]> action)
137149
{
138150
if (!MessageManager.messageTypes.ContainsKey(name))
139151
{
140152
Debug.LogWarning("MLAPI: The messageType " + name + " is not registered");
141-
return;
153+
return -1;
142154
}
143155
ushort messageType = MessageManager.messageTypes[name];
144156
ushort behaviourOrder = networkedObject.GetOrderIndex(this);
@@ -148,14 +160,20 @@ protected void RegisterMessageHandler(string name, Action<int, byte[]> action)
148160
if (networkedObject.targetMessageActions[behaviourOrder].ContainsKey(messageType))
149161
{
150162
Debug.LogWarning("MLAPI: Each NetworkedBehaviour can only register one callback per instance per message type");
151-
return;
163+
return -1;
152164
}
153165

154166
networkedObject.targetMessageActions[behaviourOrder].Add(messageType, action);
155167
int counter = MessageManager.AddIncomingMessageHandler(name, action, networkId);
156168
registeredMessageHandlers.Add(name, counter);
169+
return counter;
157170
}
158171

172+
/// <summary>
173+
/// Deregisters a given message handler
174+
/// </summary>
175+
/// <param name="name">The MessageType to deregister</param>
176+
/// <param name="counter">The messageHandlerId to deregister</param>
159177
protected void DeregisterMessageHandler(string name, int counter)
160178
{
161179
MessageManager.RemoveIncomingMessageHandler(name, counter, networkId);

MLAPI/MonoBehaviours/Prototyping/NetworkedAnimator.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ namespace MLAPI.MonoBehaviours.Prototyping
1010
[AddComponentMenu("MLAPI/NetworkedAnimator")]
1111
public class NetworkedAnimator : NetworkedBehaviour
1212
{
13+
/// <summary>
14+
/// Is proximity enabled
15+
/// </summary>
1316
public bool EnableProximity = false;
17+
/// <summary>
18+
/// The proximity range
19+
/// </summary>
1420
public float ProximityRange = 50f;
1521

1622
[SerializeField]
@@ -25,14 +31,20 @@ public class NetworkedAnimator : NetworkedBehaviour
2531
private int transitionHash;
2632
private float sendTimer;
2733

34+
35+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
2836
// tracking - these should probably move to a Preview component. -- Comment from HLAPI. Needs clarification
2937
public string param0;
3038
public string param1;
3139
public string param2;
3240
public string param3;
3341
public string param4;
3442
public string param5;
43+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
3544

45+
/// <summary>
46+
/// Gets or sets the animator component used for syncing the animations
47+
/// </summary>
3648
public Animator animator
3749
{
3850
get { return _animator; }
@@ -42,7 +54,11 @@ public Animator animator
4254
ResetParameterOptions();
4355
}
4456
}
45-
57+
/// <summary>
58+
/// TODO
59+
/// </summary>
60+
/// <param name="index"></param>
61+
/// <param name="value"></param>
4662
public void SetParameterAutoSend(int index, bool value)
4763
{
4864
if (value)
@@ -54,7 +70,11 @@ public void SetParameterAutoSend(int index, bool value)
5470
parameterSendBits &= (uint)(~(1 << index));
5571
}
5672
}
57-
73+
/// <summary>
74+
/// TODO
75+
/// </summary>
76+
/// <param name="index"></param>
77+
/// <returns></returns>
5878
public bool GetParameterAutoSend(int index)
5979
{
6080
return (parameterSendBits & (uint)(1 << index)) != 0;
@@ -68,13 +88,19 @@ private bool sendMessagesAllowed
6888
}
6989
}
7090

91+
/// <summary>
92+
/// Registers message handlers
93+
/// </summary>
7194
public override void NetworkStart()
7295
{
7396
RegisterMessageHandler("MLAPI_HandleAnimationMessage", HandleAnimMsg);
7497
RegisterMessageHandler("MLAPI_HandleAnimationParameterMessage", HandleAnimParamsMsg);
7598
RegisterMessageHandler("MLAPI_HandleAnimationTriggerMessage", HandleAnimTriggerMsg);
7699
}
77100

101+
/// <summary>
102+
/// TODO
103+
/// </summary>
78104
public void ResetParameterOptions()
79105
{
80106
Debug.Log("ResetParameterOptions");
@@ -377,11 +403,19 @@ private void ReadParameters(BinaryReader reader, bool autoSend)
377403
}
378404
}
379405

406+
/// <summary>
407+
/// TODO
408+
/// </summary>
409+
/// <param name="triggerName"></param>
380410
public void SetTrigger(string triggerName)
381411
{
382412
SetTrigger(Animator.StringToHash(triggerName));
383413
}
384414

415+
/// <summary>
416+
/// TODO
417+
/// </summary>
418+
/// <param name="hash"></param>
385419
public void SetTrigger(int hash)
386420
{
387421
if (isLocalPlayer || isOwner)

MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,27 @@ namespace MLAPI.MonoBehaviours.Prototyping
1212
public class NetworkedNavMeshAgent : NetworkedBehaviour
1313
{
1414
private NavMeshAgent agent;
15+
/// <summary>
16+
/// Is proximity enabled
17+
/// </summary>
1518
public bool EnableProximity = false;
19+
/// <summary>
20+
/// The proximity range
21+
/// </summary>
1622
public float ProximityRange = 50f;
23+
/// <summary>
24+
/// The delay in seconds between corrections
25+
/// </summary>
1726
public float CorrectionDelay = 3f;
1827
//TODO rephrase.
28+
/// <summary>
29+
/// The percentage to lerp on corrections
30+
/// </summary>
1931
[Tooltip("Everytime a correction packet is recieved. This is the percentage (between 0 & 1) that we will move towards the goal.")]
2032
public float DriftCorrectionPercentage = 0.1f;
33+
/// <summary>
34+
/// Should we warp on destination change
35+
/// </summary>
2136
public bool WarpOnDestinationChange = false;
2237

2338
private static byte[] stateUpdateBuffer = new byte[36];
@@ -28,6 +43,9 @@ private void Awake()
2843
agent = GetComponent<NavMeshAgent>();
2944
}
3045

46+
/// <summary>
47+
/// Registers message handlers
48+
/// </summary>
3149
public override void NetworkStart()
3250
{
3351
if (isClient)

MLAPI/MonoBehaviours/Prototyping/NetworkedTransform.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,37 @@ namespace MLAPI.MonoBehaviours.Prototyping
99
[AddComponentMenu("MLAPI/NetworkedTransform")]
1010
public class NetworkedTransform : NetworkedBehaviour
1111
{
12+
/// <summary>
13+
/// Sends per second
14+
/// </summary>
1215
[Range(0f, 120f)]
1316
public float SendsPerSecond = 20;
17+
/// <summary>
18+
/// Is the sends per second assumed to be the same across all instances
19+
/// </summary>
1420
[Tooltip("This assumes that the SendsPerSecond is synced across clients")]
1521
public bool AssumeSyncedSends = true;
22+
/// <summary>
23+
/// Enable interpolation
24+
/// </summary>
1625
[Tooltip("This requires AssumeSyncedSends to be true")]
1726
public bool InterpolatePosition = true;
27+
/// <summary>
28+
/// The distance before snaping to the position
29+
/// </summary>
1830
[Tooltip("The transform will snap if the distance is greater than this distance")]
1931
public float SnapDistance = 10f;
32+
/// <summary>
33+
/// Should the server interpolate
34+
/// </summary>
2035
public bool InterpolateServer = true;
36+
/// <summary>
37+
/// The min meters to move before a send is sent
38+
/// </summary>
2139
public float MinMeters = 0.15f;
40+
/// <summary>
41+
/// The min degrees to rotate before a send it sent
42+
/// </summary>
2243
public float MinDegrees = 1.5f;
2344
private float timeForLerp;
2445
private float lerpT;
@@ -30,8 +51,13 @@ public class NetworkedTransform : NetworkedBehaviour
3051
private float lastSendTime;
3152
private Vector3 lastSentPos;
3253
private Quaternion lastSentRot;
33-
54+
/// <summary>
55+
/// Should proximity be enabled
56+
/// </summary>
3457
public bool EnableProximity = false;
58+
/// <summary>
59+
/// The distance to use for proximity
60+
/// </summary>
3561
[Tooltip("If enable proximity is turned on, on clients within this range will be recieving position updates from the server")]
3662
public float ProximityRange = 50;
3763

@@ -48,7 +74,10 @@ private void OnValidate()
4874
if (MinMeters < 0)
4975
MinMeters = 0;
5076
}
51-
77+
78+
/// <summary>
79+
/// Registers message handlers
80+
/// </summary>
5281
public override void NetworkStart()
5382
{
5483
if (isServer)

MLAPI/NetworkingManagerComponents/DiffieHellman.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public byte[] GetSharedSecret(byte[] pK)
7979
}
8080
}
8181

82-
public static class DHHelper
82+
internal static class DHHelper
8383
{
84-
public static byte[] ToArray(this IntX v)
84+
internal static byte[] ToArray(this IntX v)
8585
{
8686
v.GetInternalState(out uint[] digits, out bool negative);
8787
byte[] b = DigitConverter.ToBytes(digits);
@@ -90,15 +90,15 @@ public static byte[] ToArray(this IntX v)
9090
b1[b.Length] = (byte)(negative ? 1 : 0);
9191
return b1;
9292
}
93-
public static IntX FromArray(byte[] b)
93+
internal static IntX FromArray(byte[] b)
9494
{
9595
if (b.Length == 0) return new IntX();
9696
byte[] b1 = new byte[b.Length - 1];
9797
Array.Copy(b, b1, b1.Length);
9898
uint[] u = DigitConverter.FromBytes(b1);
9999
return new IntX(u, b[b.Length - 1]==1);
100100
}
101-
public static bool BitAt(this uint[] data, long index) => (data[index / 32] & (1 << (int)(index % 32))) != 0;
102-
public static IntX Abs(this IntX i) => i < 0 ? -i : i;
101+
internal static bool BitAt(this uint[] data, long index) => (data[index / 32] & (1 << (int)(index % 32))) != 0;
102+
internal static IntX Abs(this IntX i) => i < 0 ? -i : i;
103103
}
104104
}

MLAPI/NetworkingManagerComponents/LagCompensationManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace MLAPI.NetworkingManagerComponents
1111
/// </summary>
1212
public static class LagCompensationManager
1313
{
14-
public static List<TrackedObject> SimulationObjects = new List<TrackedObject>();
14+
internal static List<TrackedObject> SimulationObjects = new List<TrackedObject>();
1515

1616
/// <summary>
1717
/// Turns time back a given amount of seconds, invokes an action and turns it back

0 commit comments

Comments
 (0)