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
typeItemTypeThe 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
typeFirearmTypeThe FirearmType to iterate over.
codeuintThe 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
identifiersIEnumerable<AttachmentIdentifier>The IEnumerable<T> of AttachmentIdentifier to compute.
Returns
GetBaseCode(FirearmType)
Gets the base code of the specified FirearmType.
public static uint GetBaseCode(this FirearmType type)
Parameters
typeFirearmTypeThe 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
typeItemTypeThe 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
typeItemTypeThe 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
typeItemTypeThe 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
typeItemTypeThe ItemType.
Returns
- T
The InventorySystem.Items.ItemBase casted to
T, or null if not found or couldn't be casted.
Type Parameters
TThe 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
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
typeFirearmTypeThe 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
typeProjectileTypeThe 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
itemsIEnumerable<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
itemFirearmTypeThe 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
typeItemTypeThe 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
typeItemTypeThe 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
typeFirearmTypeThe 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
firearmFirearmWeapon to check.
attachmentAttachmentNameAttachment to check.
Returns
- bool
trueif weapon has the specified attachment. Otherwise,false.
IsAmmo(ItemType)
Check if an item is an ammo.
public static bool IsAmmo(this ItemType item)
Parameters
itemItemTypeThe 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
typeItemTypeThe item to be checked.
Returns
- bool
Returns whether the ItemType is an armor.
IsCustomKeycard(ItemType)
Checks if an ItemType is a custom keycard.
public static bool IsCustomKeycard(this ItemType type)
Parameters
typeItemTypeThe item to be checked.
Returns
- bool
Returns where the ItemType is a custom keycard.
Remarks
This just signifies whether the ItemType represents a keycard that has modifiable properties.
IsKeycard(ItemType)
Check if an item is a keycard.
public static bool IsKeycard(this ItemType type)
Parameters
typeItemTypeThe 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
typeItemTypeThe 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
typeItemTypeThe 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
typeItemTypeThe 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
typeItemTypeThe 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 checkNonFirearm = true)
Parameters
typeItemTypeThe item to be checked.
checkNonFirearmboolIndicates whether the MicroHID and Jailbird 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
typeFirearmTypeThe FirearmType to iterate over.
codeuintThe uint value which represents the attachments code to check.
identifiersIEnumerable<AttachmentIdentifier>The attachments present on the specified FirearmType.
Returns
- bool
true if the specified FirearmType is a weapon.