Skip to content

Commit e8b8a45

Browse files
style
Adding XML API documentation.
1 parent 43fbc5f commit e8b8a45

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

com.unity.netcode.gameobjects/Runtime/Components/RigidbodyContactEventManager.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,70 @@
66

77
namespace Unity.Netcode.Components
88
{
9+
/// <summary>
10+
/// Information a <see cref="Rigidbody"/> returns to <see cref="RigidbodyContactEventManager"/> via <see cref="IContactEventHandlerWithInfo.GetContactEventHandlerInfo"/> <br />
11+
/// if the <see cref="Rigidbody"/> registers itself with <see cref="IContactEventHandlerWithInfo"/> as opposed to <see cref="IContactEventHandler"/>.
12+
/// </summary>
913
public struct ContactEventHandlerInfo
1014
{
15+
/// <summary>
16+
/// When set to true, the <see cref="RigidbodyContactEventManager"/> will include non-Rigidbody based contact events.<br />
17+
/// When the <see cref="RigidbodyContactEventManager"/> invokes the <see cref="IContactEventHandler.ContactEvent"/> it will return null in place <br />
18+
/// of the collidingBody parameter if the contact event occurred with a collider that is not registered with the <see cref="RigidbodyContactEventManager"/>.
19+
/// </summary>
1120
public bool ProvideNonRigidBodyContactEvents;
21+
/// <summary>
22+
/// When set to true, the <see cref="RigidbodyContactEventManager"/> will prioritize invoking <see cref="IContactEventHandler.ContactEvent(ulong, Vector3, Rigidbody, Vector3, bool, Vector3)"/> <br /></br>
23+
/// if it is the 2nd colliding body in the contact pair being processed. With distributed authority, setting this value to true when a <see cref="NetworkObject"/> is owned by the local client <br />
24+
/// will assure <see cref="IContactEventHandler.ContactEvent(ulong, Vector3, Rigidbody, Vector3, bool, Vector3)"/> is only invoked on the authoritative side.
25+
/// </summary>
1226
public bool HasContactEventPriority;
1327
}
1428

29+
/// <summary>
30+
/// Default implementation required to register a <see cref="Rigidbody"/> with a <see cref="RigidbodyContactEventManager"/> instance.
31+
/// </summary>
32+
/// <remarks>
33+
/// Recommended to implement this method on a <see cref="NetworkBehaviour"/> component
34+
/// </remarks>
1535
public interface IContactEventHandler
1636
{
37+
/// <summary>
38+
/// Should return a <see cref="Rigidbody"/>.
39+
/// </summary>
1740
Rigidbody GetRigidbody();
1841

42+
/// <summary>
43+
/// Invoked by the <see cref="RigidbodyContactEventManager"/> instance.
44+
/// </summary>
45+
/// <param name="eventId">A unique contact event identifier.</param>
46+
/// <param name="averagedCollisionNormal">The average normal of the collision between two colliders.</param>
47+
/// <param name="collidingBody">If not null, this will be a registered <see cref="Rigidbody"/> that was part of the collision contact event.</param>
48+
/// <param name="contactPoint">The world space location of the contact event.</param>
49+
/// <param name="hasCollisionStay">Will be set if this is a collision stay contact event (i.e. it is not the first contact event and continually has contact)</param>
50+
/// <param name="averagedCollisionStayNormal">The average normal of the collision stay contact over time.</param>
1951
void ContactEvent(ulong eventId, Vector3 averagedCollisionNormal, Rigidbody collidingBody, Vector3 contactPoint, bool hasCollisionStay = false, Vector3 averagedCollisionStayNormal = default);
2052
}
2153

54+
/// <summary>
55+
/// This is an extended version of <see cref="IContactEventHandler"/> and can be used to register a <see cref="Rigidbody"/> with a <see cref="RigidbodyContactEventManager"/> instance. <br />
56+
/// This provides additional <see cref="ContactEventHandlerInfo"/> information to the <see cref="RigidbodyContactEventManager"/> for each set of contact events it is processing.
57+
/// </summary>
2258
public interface IContactEventHandlerWithInfo : IContactEventHandler
2359
{
60+
/// <summary>
61+
/// Invoked by <see cref="RigidbodyContactEventManager"/> for each set of contact events it is processing (prior to processing).
62+
/// </summary>
63+
/// <returns><see cref="ContactEventHandlerInfo"/></returns>
2464
ContactEventHandlerInfo GetContactEventHandlerInfo();
2565
}
2666

67+
/// <summary>
68+
/// Add this component to an in-scene placed GameObject to provide faster collision event processing between <see cref="Rigidbody"/> instances and optionally static colliders.
69+
/// <see cref="IContactEventHandler"/> <br />
70+
/// <see cref="IContactEventHandlerWithInfo"/> <br />
71+
/// <see cref="ContactEventHandlerInfo"/> <br />
72+
/// </summary>
2773
[AddComponentMenu("Netcode/Rigidbody Contact Event Manager")]
2874
public class RigidbodyContactEventManager : MonoBehaviour
2975
{
@@ -61,6 +107,15 @@ private void OnEnable()
61107
Instance = this;
62108
}
63109

110+
/// <summary>
111+
/// Any <see cref="IContactEventHandler"/> implementation can register a <see cref="Rigidbody"/> to be handled by this <see cref="RigidbodyContactEventManager"/> instance.
112+
/// </summary>
113+
/// <remarks>
114+
/// You should enable <see cref="Collider.providesContacts"/> for each <see cref="Collider"/> associated with the <see cref="Rigidbody"/> being registered.<br/>
115+
/// You can enable this during run time or within the editor's inspector view.
116+
/// </remarks>
117+
/// <param name="contactEventHandler"><see cref="IContactEventHandler"/> or <see cref="IContactEventHandlerWithInfo"/></param>
118+
/// <param name="register">true to register and false to remove from being registered</param>
64119
public void RegisterHandler(IContactEventHandler contactEventHandler, bool register = true)
65120
{
66121
var rigidbody = contactEventHandler.GetRigidbody();

0 commit comments

Comments
 (0)