Table of Contents

Class Firearm

Namespace
Exiled.API.Features.Items
Assembly
Exiled.API.dll

A wrapper class for InventorySystem.Items.Firearms.Firearm.

public class Firearm : Item, IWrapper<ItemBase>, IWrapper<Firearm>
Inheritance
Firearm
Implements
IWrapper<ItemBase>
IWrapper<Firearm>
Inherited Members
Extension Methods

Constructors

Firearm(Firearm)

Initializes a new instance of the Firearm class.

public Firearm(Firearm itemBase)

Parameters

itemBase Firearm

The base InventorySystem.Items.Firearms.Firearm class.

Properties

Aiming

Gets a value indicating whether the firearm is being aimed.

public bool Aiming { get; }

Property Value

bool

AmmoDrain

Gets or sets a ammo drain per shoot.

public int AmmoDrain { get; set; }

Property Value

int

Remarks

Always 1 by default. Applied on a high layer nether basegame ammo controllers.

AmmoType

Gets the AmmoType of the firearm.

public AmmoType AmmoType { get; }

Property Value

AmmoType

AttachmentIdentifiers

Gets the AttachmentIdentifiers of the firearm.

public IEnumerable<AttachmentIdentifier> AttachmentIdentifiers { get; }

Property Value

IEnumerable<AttachmentIdentifier>

Attachments

Gets the InventorySystem.Items.Firearms.Attachments.Components.Attachments of the firearm.

public Attachment[] Attachments { get; }

Property Value

Attachment[]

AvailableAttachments

Gets a Dictionary<TKey, TValue> of ItemType and AttachmentIdentifier[] which contains all available attachments for all firearms.

public static IReadOnlyDictionary<FirearmType, AttachmentIdentifier[]> AvailableAttachments { get; }

Property Value

IReadOnlyDictionary<FirearmType, AttachmentIdentifier[]>

BarrelAmmo

Gets or sets the amount of ammo in the firearm barrel.

public int BarrelAmmo { get; set; }

Property Value

int

Remarks

not working for Revolver and ParticleDisruptor.

BarrelMagazine

Gets a barrel magazine for current firearm.

public BarrelMagazine BarrelMagazine { get; }

Property Value

BarrelMagazine

Remarks

null for Revolver and ParticleDisruptor.

Base

Gets the InventorySystem.Items.Firearms.Firearm that this class is encapsulating.

public Firearm Base { get; }

Property Value

Firearm

BaseCode

Gets the base code of the firearm.

public uint BaseCode { get; }

Property Value

uint

BaseCodes

Gets a Dictionary<TKey, TValue> which contains all the base codes expressed in FirearmType and uint.

public static IReadOnlyDictionary<FirearmType, uint> BaseCodes { get; }

Property Value

IReadOnlyDictionary<FirearmType, uint>

CanSeeThroughDark

Gets a value indicating whether the firearm's flashlight module is enabled or NightVision is being used.

public bool CanSeeThroughDark { get; }

Property Value

bool

Damage

Gets or sets the damage for this firearm.

public float Damage { get; set; }

Property Value

float

DamageFalloffDistance

Gets or sets how much fast the value drop over the distance.

public float DamageFalloffDistance { get; set; }

Property Value

float

EffectiveDamage

Gets the damage for this firearm with attachement modifier.

public float EffectiveDamage { get; }

Property Value

float

EffectiveInaccuracy

Gets the inaccuracy for this firearm with attachement modifier.

public float EffectiveInaccuracy { get; }

Property Value

float

EffectivePenetration

Gets the penetration for this firearm with attachement modifier.

public float EffectivePenetration { get; }

Property Value

float

FirearmType

Gets the FirearmType of the firearm.

public FirearmType FirearmType { get; }

Property Value

FirearmType

FlashlightEnabled

Gets a value indicating whether the firearm's flashlight module is enabled.

public bool FlashlightEnabled { get; }

Property Value

bool

HitscanHitregModule

Gets a primaty magazine for current firearm.

public HitscanHitregModuleBase HitscanHitregModule { get; }

Property Value

HitscanHitregModuleBase

Inaccuracy

Gets or sets the inaccuracy for this firearm.

public float Inaccuracy { get; set; }

Property Value

float

IsAutomatic

Gets a value indicating whether the firearm is automatic.

public bool IsAutomatic { get; }

Property Value

bool

IsReloading

Gets a value indicating whether the weapon is reloading.

public bool IsReloading { get; }

Property Value

bool

MagazineAmmo

Gets or sets the amount of ammo in the firearm magazine.

public int MagazineAmmo { get; set; }

Property Value

int

MaxBarrelAmmo

Gets or sets the amount of max ammo in the firearm barrel.

public int MaxBarrelAmmo { get; set; }

Property Value

int

Remarks

not working for Revolver and ParticleDisruptor.

MaxMagazineAmmo

Gets or sets the max ammo for this firearm.

public int MaxMagazineAmmo { get; set; }

Property Value

int

NightVisionEnabled

Gets a value indicating whether the firearm's NightVision is being used.

public bool NightVisionEnabled { get; }

Property Value

bool

Penetration

Gets or sets the penetration for this firearm.

public float Penetration { get; set; }

Property Value

float

PlayerPreferences

Gets a Dictionary<TKey, TValue> which represents all the preferences for each Player.

public static IReadOnlyDictionary<Player, Dictionary<FirearmType, AttachmentIdentifier[]>> PlayerPreferences { get; }

Property Value

IReadOnlyDictionary<Player, Dictionary<FirearmType, AttachmentIdentifier[]>>

PrimaryMagazine

Gets a primaty magazine for current firearm.

public PrimaryMagazine PrimaryMagazine { get; }

Property Value

PrimaryMagazine

Recoil

Gets or sets the recoil settings of the firearm, if it's an automatic weapon.

public RecoilSettings Recoil { get; set; }

Property Value

RecoilSettings

Remarks

This property will not do anything if the firearm is not an automatic weapon.

See Also

TotalAmmo

Gets the total amount of ammo in the firearm.

public int TotalAmmo { get; }

Property Value

int

TotalMaxAmmo

Gets the total amount of ammo in the firearm.

public int TotalMaxAmmo { get; }

Property Value

int

Methods

AddAttachment(AttachmentIdentifier)

Adds a AttachmentIdentifier to the firearm.

public void AddAttachment(AttachmentIdentifier identifier)

Parameters

identifier AttachmentIdentifier

The AttachmentIdentifier to add.

AddAttachment(AttachmentName)

Adds a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified InventorySystem.Items.Firearms.Attachments.AttachmentName to the firearm.

public void AddAttachment(AttachmentName attachmentName)

Parameters

attachmentName AttachmentName

The InventorySystem.Items.Firearms.Attachments.AttachmentName to add.

AddAttachment(IEnumerable<AttachmentIdentifier>)

Adds a IEnumerable<T> of AttachmentIdentifier to the firearm.

public void AddAttachment(IEnumerable<AttachmentIdentifier> identifiers)

Parameters

identifiers IEnumerable<AttachmentIdentifier>

The IEnumerable<T> of AttachmentIdentifier to add.

AddAttachment(IEnumerable<AttachmentName>)

Adds a IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentName to the firearm.

public void AddAttachment(IEnumerable<AttachmentName> attachmentNames)

Parameters

attachmentNames IEnumerable<AttachmentName>

The IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentName to add.

AddPreference(Player, FirearmType, AttachmentIdentifier[])

Adds or replaces an existing preference to the PlayerPreferences.

public void AddPreference(Player player, FirearmType itemType, AttachmentIdentifier[] attachments)

Parameters

player Player

The Player of which must be added.

itemType FirearmType

The FirearmType to add.

attachments AttachmentIdentifier[]

The AttachmentIdentifier[] to add.

AddPreference(Player, Dictionary<FirearmType, AttachmentIdentifier[]>)

Adds or replaces an existing preference to the PlayerPreferences.

public void AddPreference(Player player, Dictionary<FirearmType, AttachmentIdentifier[]> preference)

Parameters

player Player

The Player of which must be added.

preference Dictionary<FirearmType, AttachmentIdentifier[]>

The Dictionary<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add.

AddPreference(Player, KeyValuePair<FirearmType, AttachmentIdentifier[]>)

Adds or replaces an existing preference to the PlayerPreferences.

public void AddPreference(Player player, KeyValuePair<FirearmType, AttachmentIdentifier[]> preference)

Parameters

player Player

The Player of which must be added.

preference KeyValuePair<FirearmType, AttachmentIdentifier[]>

The KeyValuePair<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add.

AddPreference(IEnumerable<Player>, FirearmType, AttachmentIdentifier[])

Adds or replaces an existing preference to the PlayerPreferences.

public void AddPreference(IEnumerable<Player> players, FirearmType type, AttachmentIdentifier[] attachments)

Parameters

players IEnumerable<Player>

The IEnumerable<T> of Player of which must be added.

type FirearmType

The FirearmType to add.

attachments AttachmentIdentifier[]

The AttachmentIdentifier[] to add.

AddPreference(IEnumerable<Player>, Dictionary<FirearmType, AttachmentIdentifier[]>)

Adds or replaces an existing preference to the PlayerPreferences.

public void AddPreference(IEnumerable<Player> players, Dictionary<FirearmType, AttachmentIdentifier[]> preference)

Parameters

players IEnumerable<Player>

The IEnumerable<T> of Player of which must be added.

preference Dictionary<FirearmType, AttachmentIdentifier[]>

The Dictionary<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add.

AddPreference(IEnumerable<Player>, KeyValuePair<FirearmType, AttachmentIdentifier[]>)

Adds or replaces an existing preference to the PlayerPreferences.

public void AddPreference(IEnumerable<Player> players, KeyValuePair<FirearmType, AttachmentIdentifier[]> preference)

Parameters

players IEnumerable<Player>

The IEnumerable<T> of Player of which must be added.

preference KeyValuePair<FirearmType, AttachmentIdentifier[]>

The KeyValuePair<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add.

ClearAttachments()

Removes all attachments from the firearm.

public void ClearAttachments()

ClearPreferences()

Clears all the existing preferences from PlayerPreferences.

public void ClearPreferences()

ClearPreferences(Player)

Clears all the existing preferences from PlayerPreferences.

public void ClearPreferences(Player player)

Parameters

player Player

The Player of which must be cleared.

ClearPreferences(IEnumerable<Player>)

Clears all the existing preferences from PlayerPreferences.

public void ClearPreferences(IEnumerable<Player> players)

Parameters

players IEnumerable<Player>

The IEnumerable<T> of Player of which must be cleared.

Clone()

Clones current Firearm object.

public override Item Clone()

Returns

Item

New Firearm object.

Create(FirearmType)

Creates and returns a Firearm representing the provided FirearmType.

public static Firearm Create(FirearmType type)

Parameters

type FirearmType

The type of firearm to create.

Returns

Firearm

The newly created firearm.

GetAttachment(AttachmentIdentifier)

Gets a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified AttachmentIdentifier.

public Attachment GetAttachment(AttachmentIdentifier identifier)

Parameters

identifier AttachmentIdentifier

The AttachmentIdentifier to check.

Returns

Attachment

The corresponding InventorySystem.Items.Firearms.Attachments.Components.Attachment.

Reload()

Reloads current Firearm.

public void Reload()

Remarks

For specific reloading logic you also can use NormalMagazine for avaible weapons.

RemoveAttachment(AttachmentIdentifier)

Removes a AttachmentIdentifier from the firearm.

public void RemoveAttachment(AttachmentIdentifier identifier)

Parameters

identifier AttachmentIdentifier

The AttachmentIdentifier to remove.

RemoveAttachment(AttachmentName)

Removes a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified InventorySystem.Items.Firearms.Attachments.AttachmentName from the firearm.

public void RemoveAttachment(AttachmentName attachmentName)

Parameters

attachmentName AttachmentName

The InventorySystem.Items.Firearms.Attachments.AttachmentName to remove.

RemoveAttachment(AttachmentSlot)

Removes a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified InventorySystem.Items.Firearms.Attachments.AttachmentSlot from the firearm.

public void RemoveAttachment(AttachmentSlot attachmentSlot)

Parameters

attachmentSlot AttachmentSlot

The InventorySystem.Items.Firearms.Attachments.AttachmentSlot to remove.

RemoveAttachment(IEnumerable<AttachmentIdentifier>)

Removes a IEnumerable<T> of AttachmentIdentifier from the firearm.

public void RemoveAttachment(IEnumerable<AttachmentIdentifier> identifiers)

Parameters

identifiers IEnumerable<AttachmentIdentifier>

The IEnumerable<T> of AttachmentIdentifier to remove.

RemoveAttachment(IEnumerable<AttachmentName>)

Removes a list of InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentName from the firearm.

public void RemoveAttachment(IEnumerable<AttachmentName> attachmentNames)

Parameters

attachmentNames IEnumerable<AttachmentName>

The IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentName to remove.

RemoveAttachment(IEnumerable<AttachmentSlot>)

Removes a list of InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentSlot from the firearm.

public void RemoveAttachment(IEnumerable<AttachmentSlot> attachmentSlots)

Parameters

attachmentSlots IEnumerable<AttachmentSlot>

The IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentSlot to remove.

RemovePreference(Player, FirearmType)

Removes a preference from the PlayerPreferences if it already exists.

public void RemovePreference(Player player, FirearmType type)

Parameters

player Player

The Player of which must be removed.

type FirearmType

The FirearmType to remove.

RemovePreference(Player, IEnumerable<FirearmType>)

Removes a preference from the PlayerPreferences if it already exists.

public void RemovePreference(Player player, IEnumerable<FirearmType> types)

Parameters

player Player

The Player of which must be removed.

types IEnumerable<FirearmType>

The IEnumerable<T> of FirearmType to remove.

RemovePreference(IEnumerable<Player>, FirearmType)

Removes a preference from the PlayerPreferences if it already exists.

public void RemovePreference(IEnumerable<Player> players, FirearmType type)

Parameters

players IEnumerable<Player>

The IEnumerable<T> of Player of which must be removed.

type FirearmType

The FirearmType to remove.

RemovePreference(IEnumerable<Player>, IEnumerable<FirearmType>)

Removes a preference from the PlayerPreferences if it already exists.

public void RemovePreference(IEnumerable<Player> players, IEnumerable<FirearmType> types)

Parameters

players IEnumerable<Player>

The IEnumerable<T> of Player of which must be removed.

types IEnumerable<FirearmType>

The IEnumerable<T> of FirearmType to remove.

TryGetAttachment(AttachmentIdentifier, out Attachment)

Tries to get a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified AttachmentIdentifier.

public bool TryGetAttachment(AttachmentIdentifier identifier, out Attachment firearmAttachment)

Parameters

identifier AttachmentIdentifier

The AttachmentIdentifier to check.

firearmAttachment Attachment

The corresponding InventorySystem.Items.Firearms.Attachments.Components.Attachment.

Returns

bool

A value indicating whether the firearm has the specified InventorySystem.Items.Firearms.Attachments.Components.Attachment.

TryGetAttachment(AttachmentName, out Attachment)

Tries to get a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified InventorySystem.Items.Firearms.Attachments.AttachmentName.

public bool TryGetAttachment(AttachmentName attachmentName, out Attachment firearmAttachment)

Parameters

attachmentName AttachmentName

The InventorySystem.Items.Firearms.Attachments.AttachmentName to check.

firearmAttachment Attachment

The corresponding InventorySystem.Items.Firearms.Attachments.Components.Attachment.

Returns

bool

A value indicating whether the firearm has the specified InventorySystem.Items.Firearms.Attachments.Components.Attachment.