Class Firearm
A wrapper class for InventorySystem.Items.Firearms.Firearm.
Implements
Inherited Members
Namespace: Exiled.API.Features.Items
Assembly: Exiled.API.dll
Syntax
public class Firearm : Item, IWrapper<ItemBase>, IWrapper<Firearm>
Constructors
| Improve this Doc View SourceFirearm(Firearm)
Initializes a new instance of the Firearm class.
Declaration
public Firearm(Firearm itemBase)
Parameters
Type | Name | Description |
---|---|---|
InventorySystem.Items.Firearms.Firearm | itemBase | The base InventorySystem.Items.Firearms.Firearm class. |
Properties
| Improve this Doc View SourceAiming
Gets a value indicating whether the firearm is being aimed.
Declaration
public bool Aiming { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Ammo
Gets or sets the amount of ammo in the firearm.
Declaration
public byte Ammo { get; set; }
Property Value
Type | Description |
---|---|
System.Byte |
AmmoType
Gets the AmmoType of the firearm.
Declaration
public AmmoType AmmoType { get; }
Property Value
Type | Description |
---|---|
AmmoType |
AttachmentIdentifiers
Gets the AttachmentIdentifiers of the firearm.
Declaration
public IEnumerable<AttachmentIdentifier> AttachmentIdentifiers { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<AttachmentIdentifier> |
Attachments
Gets the InventorySystem.Items.Firearms.Attachments.Components.Attachments of the firearm.
Declaration
public Attachment[] Attachments { get; }
Property Value
Type | Description |
---|---|
InventorySystem.Items.Firearms.Attachments.Components.Attachment[] |
AvailableAttachments
Declaration
public static IReadOnlyDictionary<FirearmType, AttachmentIdentifier[]> AvailableAttachments { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<FirearmType, AttachmentIdentifier[]> |
Base
Gets the InventorySystem.Items.Firearms.Firearm that this class is encapsulating.
Declaration
public Firearm Base { get; }
Property Value
Type | Description |
---|---|
InventorySystem.Items.Firearms.Firearm |
BaseCode
Gets the base code of the firearm.
Declaration
public uint BaseCode { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
BaseCodes
Declaration
public static IReadOnlyDictionary<FirearmType, uint> BaseCodes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<FirearmType, System.UInt32> |
CanSeeThroughDark
Gets a value indicating whether the firearm's flashlight module is enabled or NightVision is being used.
Declaration
public bool CanSeeThroughDark { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
FirearmType
Gets the FirearmType of the firearm.
Declaration
public FirearmType FirearmType { get; }
Property Value
Type | Description |
---|---|
FirearmType |
FireRate
Gets or sets the fire rate of the firearm, if it is an automatic weapon.
Declaration
public float FireRate { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
This property will not do anything if the firearm is not an automatic weapon.
See Also
| Improve this Doc View SourceFlashlightEnabled
Gets a value indicating whether the firearm's flashlight module is enabled.
Declaration
public bool FlashlightEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsAutomatic
Gets a value indicating whether or not the firearm is automatic.
Declaration
public bool IsAutomatic { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxAmmo
Gets or sets the max ammo for this firearm.
Declaration
public byte MaxAmmo { get; set; }
Property Value
Type | Description |
---|---|
System.Byte |
Remarks
Disruptor can't be used for MaxAmmo.
NightVisionEnabled
Gets a value indicating whether the firearm's NightVision is being used.
Declaration
public bool NightVisionEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
PlayerPreferences
Gets a System.Collections.Generic.Dictionary<TKey, TValue> which represents all the preferences for each Player.
Declaration
public static IReadOnlyDictionary<Player, Dictionary<FirearmType, AttachmentIdentifier[]>> PlayerPreferences { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<Player, System.Collections.Generic.Dictionary<FirearmType, AttachmentIdentifier[]>> |
Recoil
Gets or sets the recoil settings of the firearm, if it's an automatic weapon.
Declaration
public RecoilSettings Recoil { get; set; }
Property Value
Type | Description |
---|---|
CameraShaking.RecoilSettings |
Remarks
This property will not do anything if the firearm is not an automatic weapon.
See Also
| Improve this Doc View SourceRecoilPattern
Gets the firearm's InventorySystem.Items.Firearms.FirearmRecoilPattern. Will be null for non-automatic weapons.
Declaration
public FirearmRecoilPattern RecoilPattern { get; }
Property Value
Type | Description |
---|---|
InventorySystem.Items.Firearms.FirearmRecoilPattern |
Methods
| Improve this Doc View SourceAddAttachment(AttachmentIdentifier)
Adds a AttachmentIdentifier to the firearm.
Declaration
public void AddAttachment(AttachmentIdentifier identifier)
Parameters
Type | Name | Description |
---|---|---|
AttachmentIdentifier | identifier | 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.
Declaration
public void AddAttachment(AttachmentName attachmentName)
Parameters
Type | Name | Description |
---|---|---|
InventorySystem.Items.Firearms.Attachments.AttachmentName | attachmentName | The InventorySystem.Items.Firearms.Attachments.AttachmentName to add. |
AddAttachment(IEnumerable<AttachmentIdentifier>)
Adds a System.Collections.Generic.IEnumerable<T> of AttachmentIdentifier to the firearm.
Declaration
public void AddAttachment(IEnumerable<AttachmentIdentifier> identifiers)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<AttachmentIdentifier> | identifiers | The System.Collections.Generic.IEnumerable<T> of AttachmentIdentifier to add. |
AddAttachment(IEnumerable<AttachmentName>)
Adds a System.Collections.Generic.IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentName to the firearm.
Declaration
public void AddAttachment(IEnumerable<AttachmentName> attachmentNames)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<InventorySystem.Items.Firearms.Attachments.AttachmentName> | attachmentNames | The System.Collections.Generic.IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentName to add. |
AddPreference(Player, FirearmType, AttachmentIdentifier[])
Adds or replaces an existing preference to the PlayerPreferences.
Declaration
public void AddPreference(Player player, FirearmType itemType, AttachmentIdentifier[] attachments)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player of which must be added. |
FirearmType | itemType | The FirearmType to add. |
AttachmentIdentifier[] | attachments | The AttachmentIdentifier[] to add. |
AddPreference(Player, Dictionary<FirearmType, AttachmentIdentifier[]>)
Adds or replaces an existing preference to the PlayerPreferences.
Declaration
public void AddPreference(Player player, Dictionary<FirearmType, AttachmentIdentifier[]> preference)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player of which must be added. |
System.Collections.Generic.Dictionary<FirearmType, AttachmentIdentifier[]> | preference | The System.Collections.Generic.Dictionary<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add. |
AddPreference(Player, KeyValuePair<FirearmType, AttachmentIdentifier[]>)
Adds or replaces an existing preference to the PlayerPreferences.
Declaration
public void AddPreference(Player player, KeyValuePair<FirearmType, AttachmentIdentifier[]> preference)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player of which must be added. |
System.Collections.Generic.KeyValuePair<FirearmType, AttachmentIdentifier[]> | preference | The System.Collections.Generic.KeyValuePair<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add. |
AddPreference(IEnumerable<Player>, FirearmType, AttachmentIdentifier[])
Adds or replaces an existing preference to the PlayerPreferences.
Declaration
public void AddPreference(IEnumerable<Player> players, FirearmType type, AttachmentIdentifier[] attachments)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Player> | players | The System.Collections.Generic.IEnumerable<T> of Player of which must be added. |
FirearmType | type | The FirearmType to add. |
AttachmentIdentifier[] | attachments | The AttachmentIdentifier[] to add. |
AddPreference(IEnumerable<Player>, Dictionary<FirearmType, AttachmentIdentifier[]>)
Adds or replaces an existing preference to the PlayerPreferences.
Declaration
public void AddPreference(IEnumerable<Player> players, Dictionary<FirearmType, AttachmentIdentifier[]> preference)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Player> | players | The System.Collections.Generic.IEnumerable<T> of Player of which must be added. |
System.Collections.Generic.Dictionary<FirearmType, AttachmentIdentifier[]> | preference | The System.Collections.Generic.Dictionary<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add. |
AddPreference(IEnumerable<Player>, KeyValuePair<FirearmType, AttachmentIdentifier[]>)
Adds or replaces an existing preference to the PlayerPreferences.
Declaration
public void AddPreference(IEnumerable<Player> players, KeyValuePair<FirearmType, AttachmentIdentifier[]> preference)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Player> | players | The System.Collections.Generic.IEnumerable<T> of Player of which must be added. |
System.Collections.Generic.KeyValuePair<FirearmType, AttachmentIdentifier[]> | preference | The System.Collections.Generic.KeyValuePair<TKey, TValue> of FirearmType and AttachmentIdentifier[] to add. |
ClearAttachments()
Removes all attachments from the firearm.
Declaration
public void ClearAttachments()
ClearPreferences()
Clears all the existing preferences from PlayerPreferences.
Declaration
public void ClearPreferences()
ClearPreferences(Player)
Clears all the existing preferences from PlayerPreferences.
Declaration
public void ClearPreferences(Player player)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player of which must be cleared. |
ClearPreferences(IEnumerable<Player>)
Clears all the existing preferences from PlayerPreferences.
Declaration
public void ClearPreferences(IEnumerable<Player> players)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Player> | players | The System.Collections.Generic.IEnumerable<T> of Player of which must be cleared. |
Clone()
Clones current Firearm object.
Declaration
public override Item Clone()
Returns
Type | Description |
---|---|
Item | New Firearm object. |
Overrides
| Improve this Doc View SourceCreate(FirearmType)
Creates and returns a Firearm representing the provided FirearmType.
Declaration
public static Firearm Create(FirearmType type)
Parameters
Type | Name | Description |
---|---|---|
FirearmType | type | The type of firearm to create. |
Returns
Type | Description |
---|---|
Firearm | The newly created firearm. |
CreatePickup(Vector3, Quaternion, Boolean)
Declaration
public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default(Quaternion), bool spawn = true)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3 | position | The location to spawn the item. |
UnityEngine.Quaternion | rotation | The rotation of the item. |
System.Boolean | spawn | Whether the Pickup should be initially spawned. |
Returns
Type | Description |
---|---|
Pickup | The created Pickup. |
Overrides
| Improve this Doc View SourceGetAttachment(AttachmentIdentifier)
Gets a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified AttachmentIdentifier.
Declaration
public Attachment GetAttachment(AttachmentIdentifier identifier)
Parameters
Type | Name | Description |
---|---|---|
AttachmentIdentifier | identifier | The AttachmentIdentifier to check. |
Returns
Type | Description |
---|---|
InventorySystem.Items.Firearms.Attachments.Components.Attachment | The corresponding InventorySystem.Items.Firearms.Attachments.Components.Attachment. |
RemoveAttachment(AttachmentIdentifier)
Removes a AttachmentIdentifier from the firearm.
Declaration
public void RemoveAttachment(AttachmentIdentifier identifier)
Parameters
Type | Name | Description |
---|---|---|
AttachmentIdentifier | identifier | 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.
Declaration
public void RemoveAttachment(AttachmentName attachmentName)
Parameters
Type | Name | Description |
---|---|---|
InventorySystem.Items.Firearms.Attachments.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.
Declaration
public void RemoveAttachment(AttachmentSlot attachmentSlot)
Parameters
Type | Name | Description |
---|---|---|
InventorySystem.Items.Firearms.Attachments.AttachmentSlot | attachmentSlot | The InventorySystem.Items.Firearms.Attachments.AttachmentSlot to remove. |
RemoveAttachment(IEnumerable<AttachmentIdentifier>)
Removes a System.Collections.Generic.IEnumerable<T> of AttachmentIdentifier from the firearm.
Declaration
public void RemoveAttachment(IEnumerable<AttachmentIdentifier> identifiers)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<AttachmentIdentifier> | identifiers | The System.Collections.Generic.IEnumerable<T> of AttachmentIdentifier to remove. |
RemoveAttachment(IEnumerable<AttachmentName>)
Removes a list of InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified System.Collections.Generic.IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentName from the firearm.
Declaration
public void RemoveAttachment(IEnumerable<AttachmentName> attachmentNames)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<InventorySystem.Items.Firearms.Attachments.AttachmentName> | attachmentNames | The System.Collections.Generic.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 System.Collections.Generic.IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentSlot from the firearm.
Declaration
public void RemoveAttachment(IEnumerable<AttachmentSlot> attachmentSlots)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<InventorySystem.Items.Firearms.Attachments.AttachmentSlot> | attachmentSlots | The System.Collections.Generic.IEnumerable<T> of InventorySystem.Items.Firearms.Attachments.AttachmentSlot to remove. |
RemovePreference(Player, FirearmType)
Removes a preference from the PlayerPreferences if it already exists.
Declaration
public void RemovePreference(Player player, FirearmType type)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player of which must be removed. |
FirearmType | type | The FirearmType to remove. |
RemovePreference(Player, IEnumerable<FirearmType>)
Removes a preference from the PlayerPreferences if it already exists.
Declaration
public void RemovePreference(Player player, IEnumerable<FirearmType> types)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player of which must be removed. |
System.Collections.Generic.IEnumerable<FirearmType> | types | The System.Collections.Generic.IEnumerable<T> of FirearmType to remove. |
RemovePreference(IEnumerable<Player>, FirearmType)
Removes a preference from the PlayerPreferences if it already exists.
Declaration
public void RemovePreference(IEnumerable<Player> players, FirearmType type)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Player> | players | The System.Collections.Generic.IEnumerable<T> of Player of which must be removed. |
FirearmType | type | The FirearmType to remove. |
RemovePreference(IEnumerable<Player>, IEnumerable<FirearmType>)
Removes a preference from the PlayerPreferences if it already exists.
Declaration
public void RemovePreference(IEnumerable<Player> players, IEnumerable<FirearmType> types)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Player> | players | The System.Collections.Generic.IEnumerable<T> of Player of which must be removed. |
System.Collections.Generic.IEnumerable<FirearmType> | types | The System.Collections.Generic.IEnumerable<T> of FirearmType to remove. |
TryGetAttachment(AttachmentIdentifier, out Attachment)
Tries to get a InventorySystem.Items.Firearms.Attachments.Components.Attachment of the specified AttachmentIdentifier.
Declaration
public bool TryGetAttachment(AttachmentIdentifier identifier, out Attachment firearmAttachment)
Parameters
Type | Name | Description |
---|---|---|
AttachmentIdentifier | identifier | The AttachmentIdentifier to check. |
InventorySystem.Items.Firearms.Attachments.Components.Attachment | firearmAttachment | The corresponding InventorySystem.Items.Firearms.Attachments.Components.Attachment. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether or not 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.
Declaration
public bool TryGetAttachment(AttachmentName attachmentName, out Attachment firearmAttachment)
Parameters
Type | Name | Description |
---|---|---|
InventorySystem.Items.Firearms.Attachments.AttachmentName | attachmentName | The InventorySystem.Items.Firearms.Attachments.AttachmentName to check. |
InventorySystem.Items.Firearms.Attachments.Components.Attachment | firearmAttachment | The corresponding InventorySystem.Items.Firearms.Attachments.Components.Attachment. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether or not the firearm has the specified InventorySystem.Items.Firearms.Attachments.Components.Attachment. |