class InventoryUtils
{

	public static function IsPart( attachmentSlotID : TweakDBID ) : Bool
	{
		return ( ( attachmentSlotID == T"AttachmentSlots.PowerModule" ) || ( attachmentSlotID == T"AttachmentSlots.Magazine" ) ) || ( attachmentSlotID == T"AttachmentSlots.Scope" );
	}

	public static function GetMods( const itemData : ref< InventoryItemData >, optional onlyGeneric : Bool ) : array< InventoryItemAttachments >
	{
		var i, allModsSize : Int32;
		var resultMods : array< InventoryItemAttachments >;
		var attachments : InventoryItemAttachments;
		allModsSize = InventoryItemData.GetAttachmentsSize( itemData );
		for( i = 0; i < allModsSize; i += 1 )
		{
			attachments = InventoryItemData.GetAttachment( itemData, i );
			if( !( InventoryUtils.IsPart( attachments.SlotID ) ) )
			{
				if( onlyGeneric )
				{
					if( attachments.SlotType != InventoryItemAttachmentType.Generic )
					{
						continue;
					}
				}
				resultMods.PushBack( attachments );
			}
		}
		return resultMods;
	}

	public static function GetParts( const itemData : ref< InventoryItemData > ) : array< InventoryItemAttachments >
	{
		var i, allModsSize : Int32;
		var resultParts : array< InventoryItemAttachments >;
		var attachments : InventoryItemAttachments;
		allModsSize = InventoryItemData.GetAttachmentsSize( itemData );
		for( i = 0; i < allModsSize; i += 1 )
		{
			attachments = InventoryItemData.GetAttachment( itemData, i );
			if( InventoryUtils.IsPart( attachments.SlotID ) )
			{
				resultParts.PushBack( attachments );
			}
		}
		return resultParts;
	}

	public static function GetPartType( attachmentData : InventoryItemAttachments ) : WeaponPartType
	{
		switch( attachmentData.SlotID )
		{
			case T"AttachmentSlots.PowerModule":
				return WeaponPartType.Silencer;
			case T"AttachmentSlots.Magazine":
				return WeaponPartType.Magazine;
			case T"AttachmentSlots.Scope":
				return WeaponPartType.Scope;
		}
		return WeaponPartType.Scope;
	}

	public static function GetInnerItemStatValueByType( item : gameItemData, slot : TweakDBID, stat : gamedataStatType ) : Float
	{
		var part : InnerItemData;
		item.GetItemPart( part, slot );
		return InnerItemData.GetStatValueByType( part, stat );
	}

}

enum WeaponPartType
{
	Scope = 0,
	Magazine = 1,
	Silencer = 2,
}

