Class CustomItem
The Custom Item base class.
Inherited Members
Namespace: Exiled.CustomItems.API.Features
Assembly: Exiled.CustomItems.dll
Syntax
public abstract class CustomItem
Properties
| Improve this Doc View SourceDescription
Gets or sets the description of the item.
Declaration
public abstract string Description { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Id
Gets or sets the custom ItemID of the item.
Declaration
public abstract uint Id { get; set; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
Name
Gets or sets the name of the item.
Declaration
public abstract string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Registered
Gets the list of current Item Managers.
Declaration
public static HashSet<CustomItem> Registered { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.HashSet<CustomItem> |
Scale
Gets or sets the scale of the item.
Declaration
public virtual Vector3 Scale { get; set; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Vector3 |
ShouldMessageOnGban
Gets a value indicating whether or not this item causes things to happen that may be considered hacks, and thus be shown to global moderators as being present in a player's inventory when they gban them.
Declaration
[YamlIgnore]
public virtual bool ShouldMessageOnGban { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
SpawnProperties
Gets or sets the list of spawn locations and chances for each one.
Declaration
public abstract SpawnProperties SpawnProperties { get; set; }
Property Value
| Type | Description |
|---|---|
| SpawnProperties |
TrackedSerials
Gets the list of custom items inside players' inventory being tracked as the current item.
Declaration
[YamlIgnore]
public HashSet<int> TrackedSerials { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.HashSet<System.Int32> |
Type
Gets or sets the ItemType to use for this item.
Declaration
public virtual ItemType Type { get; set; }
Property Value
| Type | Description |
|---|---|
| ItemType |
Weight
Gets or sets the weight of the item.
Declaration
public abstract float Weight { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Methods
| Improve this Doc View SourceCheck(Item)
Checks the specified inventory item to see if it is a custom item.
Declaration
public virtual bool Check(Item item)
Parameters
| Type | Name | Description |
|---|---|---|
| Item | item | The Item to check. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it is a custom item. |
Check(Pickup)
Checks the specified pickup to see if it is a custom item.
Declaration
public virtual bool Check(Pickup pickup)
Parameters
| Type | Name | Description |
|---|---|---|
| Pickup | pickup | The Pickup to check. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it is a custom item. |
Check(Player)
Checks the specified player's current item to see if it is a custom item.
Declaration
public virtual bool Check(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player who's current item should be checked. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it is a custom item. |
Destroy()
Called when the item is unregistered.
Declaration
public virtual void Destroy()
Get(Int32)
Gets a CustomItem with a specific ID.
Declaration
[Obsolete("Use Get(uint) instead.", true)]
public static CustomItem Get(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | The CustomItem ID. |
Returns
| Type | Description |
|---|---|
| CustomItem | The CustomItem matching the search, null if not registered. |
Get(String)
Gets a CustomItem with a specific name.
Declaration
public static CustomItem Get(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The CustomItem name. |
Returns
| Type | Description |
|---|---|
| CustomItem | The CustomItem matching the search, null if not registered. |
Get(Type)
Gets a CustomItem with a specific type.
Declaration
public static CustomItem Get(Type t)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | t | The System.Type type. |
Returns
| Type | Description |
|---|---|
| CustomItem | The CustomItem matching the search, |
Get(UInt32)
Gets a CustomItem with a specific ID.
Declaration
public static CustomItem Get(uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | The CustomItem ID. |
Returns
| Type | Description |
|---|---|
| CustomItem | The CustomItem matching the search, null if not registered. |
Give(Player, Item, Boolean)
Gives an Item as a CustomItem to a Player.
Declaration
public virtual void Give(Player player, Item item, bool displayMessage = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player who will receive the item. |
| Item | item | The Item to be given. |
| System.Boolean | displayMessage | Indicates whether or not ShowPickedUpMessage(Player) will be called when the player receives the item. |
Give(Player, Pickup, Boolean)
Gives a InventorySystem.Items.Pickups.ItemPickupBase as a CustomItem to a Player.
Declaration
public virtual void Give(Player player, Pickup pickup, bool displayMessage = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player who will receive the item. |
| Pickup | pickup | The InventorySystem.Items.Pickups.ItemPickupBase to be given. |
| System.Boolean | displayMessage | Indicates whether or not ShowPickedUpMessage(Player) will be called when the player receives the item. |
Give(Player, Boolean)
Gives the CustomItem to a player.
Declaration
public virtual void Give(Player player, bool displayMessage = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player who will receive the item. |
| System.Boolean | displayMessage | Indicates whether or not ShowPickedUpMessage(Player) will be called when the player receives the item. |
Init()
Called when the item is registered.
Declaration
public virtual void Init()
OnAcquired(Player, Item, Boolean)
Called anytime the item enters a player's inventory by any means.
Declaration
protected virtual void OnAcquired(Player player, Item item, bool displayMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player acquiring the item. |
| Item | item | The Item being acquired. |
| System.Boolean | displayMessage | Whether or not the Pickup hint should be displayed. |
OnChanging(ChangingItemEventArgs)
Handles tracking items when they are selected in the player's inventory.
Declaration
protected virtual void OnChanging(ChangingItemEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| ChangingItemEventArgs | ev |
OnDropping(DroppingItemEventArgs)
Handles tracking items when they are dropped by a player.
Declaration
protected virtual void OnDropping(DroppingItemEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| DroppingItemEventArgs | ev |
OnOwnerChangingRole(OwnerChangingRoleEventArgs)
Handles tracking items when they a player changes their role.
Declaration
protected virtual void OnOwnerChangingRole(OwnerChangingRoleEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| OwnerChangingRoleEventArgs | ev |
OnOwnerDying(OwnerDyingEventArgs)
Handles making sure custom items are not "lost" when a player dies.
Declaration
protected virtual void OnOwnerDying(OwnerDyingEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| OwnerDyingEventArgs | ev |
OnOwnerEscaping(OwnerEscapingEventArgs)
Handles making sure custom items are not "lost" when a player escapes.
Declaration
protected virtual void OnOwnerEscaping(OwnerEscapingEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| OwnerEscapingEventArgs | ev |
OnOwnerHandcuffing(OwnerHandcuffingEventArgs)
Handles making sure custom items are not "lost" when being handcuffed.
Declaration
protected virtual void OnOwnerHandcuffing(OwnerHandcuffingEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| OwnerHandcuffingEventArgs | ev |
OnPickingUp(PickingUpItemEventArgs)
Handles tracking items when they are picked up by a player.
Declaration
protected virtual void OnPickingUp(PickingUpItemEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| PickingUpItemEventArgs | ev |
OnUpgrading(UpgradingEventArgs)
Handles making sure custom items are not affected by SCP-914.
Declaration
protected virtual void OnUpgrading(UpgradingEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| UpgradingEventArgs | ev |
OnUpgrading(UpgradingItemEventArgs)
Declaration
protected virtual void OnUpgrading(UpgradingItemEventArgs ev)
Parameters
| Type | Name | Description |
|---|---|---|
| UpgradingItemEventArgs | ev |
OnWaitingForPlayers()
Clears the lists of item uniqIDs and Pickups since any still in the list will be invalid.
Declaration
protected virtual void OnWaitingForPlayers()
RegisterItems(Boolean, Object)
Registers all the CustomItem's present in the current assembly.
Declaration
public static IEnumerable<CustomItem> RegisterItems(bool skipReflection = false, object overrideClass = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | skipReflection | Whether or not reflection is skipped (more efficient if you are not using your custom item classes as config objects). |
| System.Object | overrideClass | The class to search properties for, if different from the plugin's config class. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomItem> | A System.Collections.Generic.IEnumerable<T> of CustomItem which contains all registered CustomItem's. |
RegisterItems(IEnumerable<Type>, Boolean, Boolean, Object)
Registers all the CustomItem's present in the current assembly.
Declaration
public static IEnumerable<CustomItem> RegisterItems(IEnumerable<Type> targetTypes, bool isIgnored = false, bool skipReflection = false, object overrideClass = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Type> | targetTypes | The System.Collections.Generic.IEnumerable<T> of System.Type containing the target types. |
| System.Boolean | isIgnored | A value indicating whether the target types should be ignored. |
| System.Boolean | skipReflection | Whether or not reflection is skipped (more efficient if you are not using your custom item classes as config objects). |
| System.Object | overrideClass | The class to search properties for, if different from the plugin's config class. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomItem> | A System.Collections.Generic.IEnumerable<T> of CustomItem which contains all registered CustomItem's. |
ShowPickedUpMessage(Player)
Shows a message to the player upon picking up a custom item.
Declaration
protected virtual void ShowPickedUpMessage(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player who will be shown the message. |
ShowSelectedMessage(Player)
Shows a message to the player upon selecting a custom item.
Declaration
protected virtual void ShowSelectedMessage(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player who will be shown the message. |
Spawn(Player, Item, Player)
Spawns a Item as a CustomItem where a specific Player is, and optionally sets the previous owner.
Declaration
public virtual Pickup Spawn(Player player, Item item, Player previousOwner = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player position where the CustomItem will be spawned. |
| Item | item | The Item to be spawned as a CustomItem. |
| Player | previousOwner | The previous owner of the pickup, can be null. |
Returns
| Type | Description |
|---|---|
| Pickup | The Pickup of the spawned CustomItem. |
Spawn(Player, Player)
Spawns the CustomItem where a specific Player is, and optionally sets the previous owner.
Declaration
public virtual Pickup Spawn(Player player, Player previousOwner = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player position where the CustomItem will be spawned. |
| Player | previousOwner | The previous owner of the pickup, can be null. |
Returns
| Type | Description |
|---|---|
| Pickup | The Pickup of the spawned CustomItem. |
Spawn(IEnumerable<SpawnPoint>, UInt32)
Spawns CustomItems inside spawnPoints.
Declaration
public virtual uint Spawn(IEnumerable<SpawnPoint> spawnPoints, uint limit)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<SpawnPoint> | spawnPoints | The spawn points System.Collections.Generic.IEnumerable<T>. |
| System.UInt32 | limit | The spawn limit. |
Returns
| Type | Description |
|---|---|
| System.UInt32 | Returns the number of spawned items. |
Spawn(Single, Single, Single)
Spawns the CustomItem in a specific location.
Declaration
public virtual Pickup Spawn(float x, float y, float z)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | x | The x coordinate. |
| System.Single | y | The y coordinate. |
| System.Single | z | The z coordinate. |
Returns
| Type | Description |
|---|---|
| Pickup | The Pickup wrapper of the spawned CustomItem. |
Spawn(Single, Single, Single, Item)
Spawns a Item as a CustomItem in a specific location.
Declaration
public virtual Pickup Spawn(float x, float y, float z, Item item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | x | The x coordinate. |
| System.Single | y | The y coordinate. |
| System.Single | z | The z coordinate. |
| Item | item | The Item to be spawned as a CustomItem. |
Returns
| Type | Description |
|---|---|
| Pickup | The Pickup wrapper of the spawned CustomItem. |
Spawn(Vector3, Item, Player)
Spawns the CustomItem in a specific position.
Declaration
public virtual Pickup Spawn(Vector3 position, Item item, Player previousOwner = null)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Vector3 | position | The UnityEngine.Vector3 where the CustomItem will be spawned. |
| Item | item | The Item to be spawned as a CustomItem. |
| Player | previousOwner | The PreviousOwner of the item. Can be null. |
Returns
| Type | Description |
|---|---|
| Pickup | The Pickup of the spawned CustomItem. |
Spawn(Vector3, Player)
Spawns the CustomItem in a specific position.
Declaration
public virtual Pickup Spawn(Vector3 position, Player previousOwner = null)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Vector3 | position | The UnityEngine.Vector3 where the CustomItem will be spawned. |
| Player | previousOwner | The PreviousOwner of the item. Can be null. |
Returns
| Type | Description |
|---|---|
| Pickup | The Pickup of the spawned CustomItem. |
SpawnAll()
Spawns all items at their dynamic and static positions.
Declaration
public virtual void SpawnAll()
SubscribeEvents()
Called after the manager is initialized, to allow loading of special event handlers.
Declaration
protected virtual void SubscribeEvents()
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
TryGet(Item, out CustomItem)
Checks to see if this item is a custom item.
Declaration
public static bool TryGet(Item item, out CustomItem customItem)
Parameters
| Type | Name | Description |
|---|---|---|
| Item | item | The Item to check. |
| CustomItem | customItem | The CustomItem this item is. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the item is a custom item. |
TryGet(Pickup, out CustomItem)
Checks if this pickup is a custom item.
Declaration
public static bool TryGet(Pickup pickup, out CustomItem customItem)
Parameters
| Type | Name | Description |
|---|---|---|
| Pickup | pickup | The InventorySystem.Items.Pickups.ItemPickupBase to check. |
| CustomItem | customItem | The CustomItem this pickup is. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the pickup is a custom item. |
TryGet(Player, out CustomItem)
Tries to get the player's current CustomItem in their hand.
Declaration
public static bool TryGet(Player player, out CustomItem customItem)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to check. |
| CustomItem | customItem | The CustomItem in their hand. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the Player has a CustomItem in their hand or not. |
TryGet(Player, out IEnumerable<CustomItem>)
Tries to get the player's System.Collections.Generic.IEnumerable<T> of CustomItem.
Declaration
public static bool TryGet(Player player, out IEnumerable<CustomItem> customItems)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to check. |
| System.Collections.Generic.IEnumerable<CustomItem> | customItems | The player's System.Collections.Generic.IEnumerable<T> of CustomItem. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the Player has a CustomItem in their hand or not. |
TryGet(String, out CustomItem)
Tries to get a CustomItem with a specific name.
Declaration
public static bool TryGet(string name, out CustomItem customItem)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The CustomItem name to look for. |
| CustomItem | customItem | The found CustomItem, null if not registered. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the CustomItem was found or not. |
TryGet(Type, out CustomItem)
Tries to get a CustomItem with a specific type.
Declaration
public static bool TryGet(Type t, out CustomItem customItem)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | t | The System.Type of the item to look for. |
| CustomItem | customItem | The found CustomItem, null if not registered. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the CustomItem was found or not. |
TryGet(UInt32, out CustomItem)
Tries to get a CustomItem with a specific ID.
Declaration
public static bool TryGet(uint id, out CustomItem customItem)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | The CustomItem ID to look for. |
| CustomItem | customItem | The found CustomItem, null if not registered. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the CustomItem was found or not. |
TryGive(Player, String, Boolean)
Gives to a specific Player a specic CustomItem.
Declaration
public static bool TryGive(Player player, string name, bool displayMessage = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to give the item to. |
| System.String | name | The name of the CustomItem to give. |
| System.Boolean | displayMessage | Indicates a value whether ShowPickedUpMessage(Player) will be called when the player receives the CustomItem or not. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating if the player was given the CustomItem or not. |
TryGive(Player, Type, Boolean)
Gives to a specific Player a specic CustomItem.
Declaration
public static bool TryGive(Player player, Type t, bool displayMessage = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to give the item to. |
| System.Type | t | The System.Type of the item to give. |
| System.Boolean | displayMessage | Indicates a value whether ShowPickedUpMessage(Player) will be called when the player receives the CustomItem or not. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating if the player was given the CustomItem or not. |
TryGive(Player, UInt32, Boolean)
Gives to a specific Player a specic CustomItem.
Declaration
public static bool TryGive(Player player, uint id, bool displayMessage = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to give the item to. |
| System.UInt32 | id | The IDs of the CustomItem to give. |
| System.Boolean | displayMessage | Indicates a value whether ShowPickedUpMessage(Player) will be called when the player receives the CustomItem or not. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating if the player was given the CustomItem or not. |
TrySpawn(String, Vector3, out Pickup)
Tries to spawn a specific CustomItem at a specific UnityEngine.Vector3 position.
Declaration
public static bool TrySpawn(string name, Vector3 position, out Pickup pickup)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the CustomItem to spawn. |
| UnityEngine.Vector3 | position | The UnityEngine.Vector3 location to spawn the item. |
| Pickup | pickup | The InventorySystem.Items.Pickups.ItemPickupBase instance of the CustomItem. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the CustomItem was spawned or not. |
TrySpawn(UInt32, Vector3, out Pickup)
Tries to spawn a specific CustomItem at a specific UnityEngine.Vector3 position.
Declaration
public static bool TrySpawn(uint id, Vector3 position, out Pickup pickup)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | The ID of the CustomItem to spawn. |
| UnityEngine.Vector3 | position | The UnityEngine.Vector3 location to spawn the item. |
| Pickup | pickup | The InventorySystem.Items.Pickups.ItemPickupBase instance of the CustomItem. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns a value indicating whether the CustomItem was spawned or not. |
UnregisterItems()
Unregisters all the CustomItem's present in the current assembly.
Declaration
public static IEnumerable<CustomItem> UnregisterItems()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomItem> | A System.Collections.Generic.IEnumerable<T> of CustomItem which contains all unregistered CustomItem's. |
UnregisterItems(IEnumerable<CustomItem>, Boolean)
Unregisters all the CustomItem's present in the current assembly.
Declaration
public static IEnumerable<CustomItem> UnregisterItems(IEnumerable<CustomItem> targetItems, bool isIgnored = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<CustomItem> | targetItems | The System.Collections.Generic.IEnumerable<T> of CustomItem containing the target items. |
| System.Boolean | isIgnored | A value indicating whether the target items should be ignored. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomItem> | A System.Collections.Generic.IEnumerable<T> of CustomItem which contains all unregistered CustomItem's. |
UnregisterItems(IEnumerable<Type>, Boolean)
Unregisters all the CustomItem's present in the current assembly.
Declaration
public static IEnumerable<CustomItem> UnregisterItems(IEnumerable<Type> targetTypes, bool isIgnored = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Type> | targetTypes | The System.Collections.Generic.IEnumerable<T> of System.Type containing the target types. |
| System.Boolean | isIgnored | A value indicating whether the target types should be ignored. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomItem> | A System.Collections.Generic.IEnumerable<T> of CustomItem which contains all unregistered CustomItem's. |
UnsubscribeEvents()
Called when the manager is being destroyed, to allow unloading of special event handlers.
Declaration
protected virtual void UnsubscribeEvents()