Partial Weapon class file, provides attachment lookup. It iterates the weapon's Attachments list and returns the first equipped attachment matching a given AttachmentCategory, otherwise returns null.
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;
}
}