Class ItemExtensions
A set of extensions for ItemType.
Inheritance
Inherited Members
Namespace: Exiled.API.Extensions
Assembly: Exiled.API.dll
Syntax
public static class ItemExtensions
Methods
| Improve this Doc View SourceGetAmmoType(ItemType)
Converts a valid ammo ItemType into an AmmoType.
Declaration
public static AmmoType GetAmmoType(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The ItemType to convert. |
Returns
Type | Description |
---|---|
AmmoType | The ammo type of the given item type. |
GetAttachmentIdentifiers(FirearmType, UInt32)
Gets all AttachmentIdentifiers present on a FirearmType.
Declaration
public static IEnumerable<AttachmentIdentifier> GetAttachmentIdentifiers(this FirearmType type, uint code)
Parameters
Type | Name | Description |
---|---|---|
FirearmType | type | The FirearmType to iterate over. |
System.UInt32 | code | The System.UInt32 value which represents the attachments code to check. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<AttachmentIdentifier> | A System.Collections.Generic.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 System.Collections.Generic.IEnumerable<T> of AttachmentIdentifier.
Declaration
public static uint GetAttachmentsCode(this IEnumerable<AttachmentIdentifier> identifiers)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<AttachmentIdentifier> | identifiers | The System.Collections.Generic.IEnumerable<T> of AttachmentIdentifier to compute. |
Returns
Type | Description |
---|---|
System.UInt32 | A System.UInt32 value that represents the attachments code. |
GetBaseCode(FirearmType)
Gets the base code of the specified FirearmType.
Declaration
public static uint GetBaseCode(this FirearmType type)
Parameters
Type | Name | Description |
---|---|---|
FirearmType | type | The FirearmType to check. |
Returns
Type | Description |
---|---|
System.UInt32 | The corresponding base code. |
GetCategory(ItemType)
Gets the ItemCategory of the specified ItemType.
Declaration
public static ItemCategory GetCategory(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The ItemType to check. |
Returns
Type | Description |
---|---|
ItemCategory | ItemCategory of the specified ItemType. |
GetFirearmType(ItemType)
Converts a valid firearm ItemType into a FirearmType.
Declaration
public static FirearmType GetFirearmType(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The ItemType to convert. |
Returns
Type | Description |
---|---|
FirearmType | The firearm type of the given item. |
GetItemBase(ItemType)
Given an ItemType, returns the matching InventorySystem.Items.ItemBase.
Declaration
public static ItemBase GetItemBase(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The ItemType. |
Returns
Type | Description |
---|---|
InventorySystem.Items.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
.
Declaration
public static T GetItemBase<T>(this ItemType type)
where T : ItemBase
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The ItemType. |
Returns
Type | Description |
---|---|
T | The InventorySystem.Items.ItemBase casted to |
Type Parameters
Name | Description |
---|---|
T | The type to cast the InventorySystem.Items.ItemBase to. |
GetItemType(AmmoType)
Converts an AmmoType into it's corresponding ItemType.
Declaration
public static ItemType GetItemType(this AmmoType type)
Parameters
Type | Name | Description |
---|---|---|
AmmoType | type | The AmmoType to convert. |
Returns
Type | Description |
---|---|
ItemType | The Item type of the specified ammo. |
GetItemType(FirearmType)
Converts a FirearmType into it's corresponding ItemType.
Declaration
public static ItemType GetItemType(this FirearmType type)
Parameters
Type | Name | Description |
---|---|---|
FirearmType | type | The FirearmType to convert. |
Returns
Type | Description |
---|---|
ItemType | The Item type of the specified firearm. |
GetItemType(ProjectileType)
Converts a ProjectileType into the corresponding ItemType.
Declaration
public static ItemType GetItemType(this ProjectileType type)
Parameters
Type | Name | Description |
---|---|---|
ProjectileType | type | The ProjectileType to convert. |
Returns
Type | Description |
---|---|
ItemType | The Item type of the specified grenade. |
GetItemTypes(IEnumerable<Item>)
Converts a System.Collections.Generic.IEnumerable<T> of Items into the corresponding System.Collections.Generic.IEnumerable<T> of ItemTypes.
Declaration
public static IEnumerable<ItemType> GetItemTypes(this IEnumerable<Item> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Item> | items | The items to convert. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ItemType> | A new System.Collections.Generic.List<T> of ItemTypes. |
GetMaxAmmo(FirearmType)
Gets the maximum ammo of a weapon.
Declaration
public static byte GetMaxAmmo(this FirearmType item)
Parameters
Type | Name | Description |
---|---|---|
FirearmType | item | The weapon that you want to get maximum of. |
Returns
Type | Description |
---|---|
System.Byte | Returns the maximum. |
GetPickupBase(ItemType)
Given an ItemType, returns the matching InventorySystem.Items.Pickups.ItemPickupBase.
Declaration
public static ItemPickupBase GetPickupBase(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The ItemType. |
Returns
Type | Description |
---|---|
InventorySystem.Items.Pickups.ItemPickupBase | The InventorySystem.Items.Pickups.ItemPickupBase, or null if not found. |
GetProjectileType(ItemType)
Converts a valid projectile ItemType into a ProjectileType.
Declaration
public static ProjectileType GetProjectileType(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The ItemType to convert. |
Returns
Type | Description |
---|---|
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.
Declaration
public static AmmoType GetWeaponAmmoType(this FirearmType type)
Parameters
Type | Name | Description |
---|---|---|
FirearmType | type | The FirearmType to convert. |
Returns
Type | Description |
---|---|
AmmoType | The given weapon's AmmoType. |
IsAmmo(ItemType)
Check if an ItemType is an ammo.
Declaration
public static bool IsAmmo(this ItemType item)
Parameters
Type | Name | Description |
---|---|---|
ItemType | item | The item to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the ItemType is an ammo or not. |
IsArmor(ItemType)
Check if a ItemType is an armor item.
Declaration
public static bool IsArmor(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The item to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether or not the ItemType is an armor. |
IsKeycard(ItemType)
Check if an ItemType is a keycard.
Declaration
public static bool IsKeycard(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The item to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether or not the ItemType is a keycard. |
IsMedical(ItemType)
Check if an ItemType is a medical item.
Declaration
public static bool IsMedical(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The item to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether or not the ItemType is a medical item. |
IsScp(ItemType)
Check if an ItemType is an SCP.
Declaration
public static bool IsScp(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The item to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether or not the ItemType is an SCP. |
IsThrowable(ItemType)
Check if an ItemType is a throwable item.
Declaration
public static bool IsThrowable(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The item to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether or not the ItemType is a throwable item. |
IsUtility(ItemType)
Check if an ItemType is a utility item.
Declaration
public static bool IsUtility(this ItemType type)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The item to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether or not the ItemType is an utilty item. |
IsWeapon(ItemType, Boolean)
Check if an ItemType is a weapon.
Declaration
public static bool IsWeapon(this ItemType type, bool checkMicro = true)
Parameters
Type | Name | Description |
---|---|---|
ItemType | type | The item to be checked. |
System.Boolean | checkMicro | Indicates whether the MicroHID item should be taken into account or not. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the ItemType is a weapon or not. |
TryGetAttachments(FirearmType, UInt32, out IEnumerable<AttachmentIdentifier>)
Tries to get all AttachmentIdentifiers present on a FirearmType.
Declaration
public static bool TryGetAttachments(this FirearmType type, uint code, out IEnumerable<AttachmentIdentifier> identifiers)
Parameters
Type | Name | Description |
---|---|---|
FirearmType | type | The FirearmType to iterate over. |
System.UInt32 | code | The System.UInt32 value which represents the attachments code to check. |
System.Collections.Generic.IEnumerable<AttachmentIdentifier> | identifiers | The attachments present on the specified FirearmType. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified FirearmType is a weapon. |