Partial class for Weapon that returns the equipped Attachment matching a given AttachmentCategory by iterating the Attachments collection.
using SWB.Base.Attachments;
namespace SWB.Base;
public partial class Weapon
{
public Attachment GetActiveAttachmentForCategory( AttachmentCategory category )
{
foreach ( var attachment in Attachments )
{
if ( attachment.Category == category && attachment.Equipped )
return attachment;
}
return null;
}
}