Table of Contents

Class ItemExtensions

Namespace
Exiled.API.Extensions
Assembly
Exiled.API.dll

A set of extensions for ItemType.

public static class ItemExtensions
Inheritance
ItemExtensions
Inherited Members

Methods

GetAmmoType(ItemType)

Converts a valid ammo ItemType into an AmmoType.

public static AmmoType GetAmmoType(this ItemType type)

Parameters

type ItemType

The ItemType to convert.

Returns

AmmoType

The ammo type of the given item type.

GetAttachmentIdentifiers(FirearmType, uint)

Gets all AttachmentIdentifiers present on a FirearmType.

public static IEnumerable<AttachmentIdentifier> GetAttachmentIdentifiers(this FirearmType type, uint code)

Parameters

type FirearmType

The FirearmType to iterate over.

code uint

The uint value which represents the attachments code to check.

Returns

IEnumerable<AttachmentIdentifier>

A IEnumerable<T> of AttachmentIdentifier value which represents all the attachments present on the specified ItemType.

GetAttachmentsCode(IEnumerable<AttachmentIdentifier>)

Gets the value resulting from the sum of all elements within a specific IEnumerable<T> of AttachmentIdentifier.

public static uint GetAttachmentsCode(this IEnumerable<AttachmentIdentifier> identifiers)

Parameters

identifiers IEnumerable<AttachmentIdentifier>

The IEnumerable<T> of AttachmentIdentifier to compute.

Returns

uint

A uint value that represents the attachments code.

GetBaseCode(FirearmType)

Gets the base code of the specified FirearmType.

public static uint GetBaseCode(this FirearmType type)

Parameters

type FirearmType

The FirearmType to check.

Returns

uint

The corresponding base code.

GetCategory(ItemType)

Gets the ItemCategory of the specified ItemType.

public static ItemCategory GetCategory(this ItemType type)

Parameters

type ItemType

The ItemType to check.

Returns

ItemCategory

ItemCategory of the specified ItemType.

GetFirearmType(ItemType)

Converts a valid firearm ItemType into a FirearmType.

public static FirearmType GetFirearmType(this ItemType type)

Parameters

type ItemType

The ItemType to convert.

Returns

FirearmType

The firearm type of the given item.

GetItemBase(ItemType)

Given an ItemType, returns the matching InventorySystem.Items.ItemBase.

public static ItemBase GetItemBase(this ItemType type)

Parameters

type ItemType

The ItemType.

Returns

ItemBase

The InventorySystem.Items.ItemBase, or null if not found.

GetItemBase<T>(ItemType)

Given an ItemType, returns the matching InventorySystem.Items.ItemBase, casted to T.

public static T GetItemBase<T>(this ItemType type) where T : ItemBase

Parameters

type ItemType

The ItemType.

Returns

T

The InventorySystem.Items.ItemBase casted to T, or null if not found or couldn't be casted.

Type Parameters

T

The type to cast the InventorySystem.Items.ItemBase to.

GetItemType(AmmoType)

Converts an AmmoType into it's corresponding ItemType.

public static ItemType GetItemType(this AmmoType type)

Parameters

type AmmoType

The AmmoType to convert.

Returns

ItemType

The Item type of the specified ammo.

GetItemType(FirearmType)

Converts a FirearmType into it's corresponding ItemType.

public static ItemType GetItemType(this FirearmType type)

Parameters

type FirearmType

The FirearmType to convert.

Returns

ItemType

The Item type of the specified firearm.

GetItemType(ProjectileType)

Converts a ProjectileType into the corresponding ItemType.

public static ItemType GetItemType(this ProjectileType type)

Parameters

type ProjectileType

The ProjectileType to convert.

Returns

ItemType

The Item type of the specified grenade.

GetItemTypes(IEnumerable<Item>)

Converts a IEnumerable<T> of Items into the corresponding IEnumerable<T> of ItemTypes.

public static IEnumerable<ItemType> GetItemTypes(this IEnumerable<Item> items)

Parameters

items IEnumerable<Item>

The items to convert.

Returns

IEnumerable<ItemType>

A new List<T> of ItemTypes.

GetMaxAmmo(FirearmType)

Gets the maximum ammo of a weapon.

public static int GetMaxAmmo(this FirearmType item)

Parameters

item FirearmType

The weapon that you want to get maximum of.

Returns

int

Returns the maximum.

GetPickupBase(ItemType)

Given an ItemType, returns the matching InventorySystem.Items.Pickups.ItemPickupBase.

public static ItemPickupBase GetPickupBase(this ItemType type)

Parameters

type ItemType

The ItemType.

Returns

ItemPickupBase

The InventorySystem.Items.Pickups.ItemPickupBase, or null if not found.

GetProjectileType(ItemType)

Converts a valid projectile ItemType into a ProjectileType.

public static ProjectileType GetProjectileType(this ItemType type)

Parameters

type ItemType

The ItemType to convert.

Returns

ProjectileType

The projectile type of the given item type, or None if the provided item type is not a projectile.

GetWeaponAmmoType(FirearmType)

Returns the AmmoType of the weapon is using.

public static AmmoType GetWeaponAmmoType(this FirearmType type)

Parameters

type FirearmType

The FirearmType to convert.

Returns

AmmoType

The given weapon's AmmoType.

HasAttachment(Firearm, AttachmentName)

Checks if the specified Firearm has the specified InventorySystem.Items.Firearms.Attachments.AttachmentName.

public static bool HasAttachment(this Firearm firearm, AttachmentName attachment)

Parameters

firearm Firearm

Weapon to check.

attachment AttachmentName

Attachment to check.

Returns

bool

true if weapon has the specified attachment. Otherwise, false.

IsAmmo(ItemType)

Check if an item is an ammo.

public static bool IsAmmo(this ItemType item)

Parameters

item ItemType

The item to be checked.

Returns

bool

Returns whether the ItemType is an ammo.

IsArmor(ItemType)

Check if a ItemType is an armor item.

public static bool IsArmor(this ItemType type)

Parameters

type ItemType

The item to be checked.

Returns

bool

Returns whether the ItemType is an armor.

IsKeycard(ItemType)

Check if an item is a keycard.

public static bool IsKeycard(this ItemType type)

Parameters

type ItemType

The item to be checked.

Returns

bool

Returns whether the ItemType is a keycard.

IsMedical(ItemType)

Check if an item is a medical item.

public static bool IsMedical(this ItemType type)

Parameters

type ItemType

The item to be checked.

Returns

bool

Returns whether the ItemType is a medical item.

IsScp(ItemType)

Check if an item is an SCP.

public static bool IsScp(this ItemType type)

Parameters

type ItemType

The item to be checked.

Returns

bool

Returns whether the ItemType is an SCP.

IsThrowable(ItemType)

Check if an item is a throwable item.

public static bool IsThrowable(this ItemType type)

Parameters

type ItemType

The item to be checked.

Returns

bool

Returns whether the ItemType is a throwable item.

IsUtility(ItemType)

Check if an item is a utility item.

public static bool IsUtility(this ItemType type)

Parameters

type ItemType

The item to be checked.

Returns

bool

Returns whether the ItemType is an utilty item.

IsWeapon(ItemType, bool)

Check if an item is a weapon.

public static bool IsWeapon(this ItemType type, bool checkMicro = true)

Parameters

type ItemType

The item to be checked.

checkMicro bool

Indicates whether the MicroHID item should be taken into account.

Returns

bool

Returns whether the ItemType is a weapon.

TryGetAttachments(FirearmType, uint, out IEnumerable<AttachmentIdentifier>)

Tries to get all AttachmentIdentifiers present on a FirearmType.

public static bool TryGetAttachments(this FirearmType type, uint code, out IEnumerable<AttachmentIdentifier> identifiers)

Parameters

type FirearmType

The FirearmType to iterate over.

code uint

The uint value which represents the attachments code to check.

identifiers IEnumerable<AttachmentIdentifier>

The attachments present on the specified FirearmType.

Returns

bool

true if the specified FirearmType is a weapon.