Partial Weapon class source file that provides attachment lookup. It iterates the weapon's Attachments and returns the first one that matches a given AttachmentCategory and is marked equipped, 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;
}
}