Skip to content

Commit 36832f1

Browse files
committed
Add GetHitbox with many overloads and summaries
1 parent 9f1f807 commit 36832f1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

engine/Sandbox.Engine/Scene/Components/Game/ModelHitboxes.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,58 @@ public void UpdatePositions()
161161

162162
internal readonly List<Hitbox> Hitboxes = new();
163163

164+
/// <summary>
165+
/// Adds a hitbox to the models hitbox list
166+
/// </summary>
167+
/// <param name="hitbox"></param>
164168
public void AddHitbox( Hitbox hitbox )
165169
{
166170
Hitboxes.Add( hitbox );
167171
}
168172

173+
/// <summary>
174+
/// Removes a hitbox from the models hitbox list.
175+
/// </summary>
176+
/// <param name="hitbox"></param>
169177
public void RemoveHitbox( Hitbox hitbox )
170178
{
171179
Hitboxes.Remove( hitbox );
172180
}
173181

182+
/// <summary>
183+
/// Returns every hitbox on this model.
184+
/// </summary>
185+
/// <returns></returns>
174186
public IReadOnlyList<Hitbox> GetHitboxes() => Hitboxes;
175187

188+
/// <summary>
189+
/// Retrieves the hitbox associated with the bone index.
190+
/// </summary>
191+
/// <param name="boneIndex">The bone index to retrieve.</param>
192+
/// <returns>null if no matching hitbox is found.</returns>
193+
public Hitbox GetHitbox( int boneIndex ) => Hitboxes.FirstOrDefault( x => x.Bone.Index == boneIndex );
194+
195+
/// <summary>
196+
/// Retrieves the hitbox associated with the specified bone.
197+
/// </summary>
198+
/// <param name="bone">The bone for which to find the corresponding hitbox.</param>
199+
/// <returns>null if no matching hitbox is found.</returns>
200+
public Hitbox GetHitbox( BoneCollection.Bone bone ) => Hitboxes.FirstOrDefault( x => x.Bone == bone );
201+
202+
/// <summary>
203+
/// Retrieves the hitbox associated with the specified bone name.
204+
/// </summary>
205+
/// <param name="boneName">The name of the bone for which to retrieve the hitbox.</param>
206+
/// <returns>null if no matching hitbox is found.</returns>
207+
public Hitbox GetHitbox( string boneName ) => Hitboxes.FirstOrDefault( x => x.Bone.Name == boneName );
208+
209+
/// <summary>
210+
/// Retrieves the hitbox associated with the specified physics body.
211+
/// </summary>
212+
/// <param name="physicsBody">The physics body for which to find the corresponding hitbox.</param>
213+
/// <returns>null if no matching hitbox is found.</returns>
214+
public Hitbox GetHitbox( PhysicsBody physicsBody ) => Hitboxes.FirstOrDefault( x => x.Body == physicsBody );
215+
176216
/// <summary>
177217
/// The gameobject tags have changed, update collision tags on the target objects
178218
/// </summary>

0 commit comments

Comments
 (0)