Class CustomItem
- Namespace
- Exiled.CustomItems.API.Features
- Assembly
- Exiled.CustomItems.dll
The Custom Item base class.
public abstract class CustomItem
- Inheritance
-
CustomItem
- Derived
- Inherited Members
- Extension Methods
Properties
Description
Gets or sets the description of the item.
public abstract string Description { get; set; }
Property Value
Id
Gets or sets the custom ItemID of the item.
public abstract uint Id { get; set; }
Property Value
Name
Gets or sets the name of the item.
public abstract string Name { get; set; }
Property Value
Registered
Gets the list of current Item Managers.
public static HashSet<CustomItem> Registered { get; }
Property Value
Scale
Gets or sets the scale of the item.
public virtual Vector3 Scale { get; set; }
Property Value
- Vector3
ShouldMessageOnGban
Gets a value indicating whether 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.
[YamlIgnore]
public virtual bool ShouldMessageOnGban { get; }
Property Value
SpawnProperties
Gets or sets the list of spawn locations and chances for each one.
public abstract SpawnProperties? SpawnProperties { get; set; }
Property Value
TrackedSerials
Gets the list of custom items inside players' inventory being tracked as the current item.
[YamlIgnore]
public HashSet<int> TrackedSerials { get; }
Property Value
Type
Gets or sets the ItemType to use for this item.
public virtual ItemType Type { get; set; }
Property Value
- ItemType
Weight
Gets or sets the weight of the item.
public abstract float Weight { get; set; }
Property Value
Methods
Check(Item?)
Checks the specified inventory item to see if it is a custom item.
public virtual bool Check(Item? item)
Parameters
Returns
- bool
True if it is a custom item.
Check(Pickup?)
Checks the specified pickup to see if it is a custom item.
public virtual bool Check(Pickup? pickup)
Parameters
Returns
- bool
True if it is a custom item.
Check(Player?)
Checks the specified player's current item to see if it is a custom item.
public virtual bool Check(Player? player)
Parameters
Returns
- bool
True if it is a custom item.
Destroy()
Called when the item is unregistered.
public virtual void Destroy()
Get(string)
Gets a CustomItem with a specific name.
public static CustomItem? Get(string name)
Parameters
name
stringThe CustomItem name.
Returns
- CustomItem
The CustomItem matching the search, null if not registered.
Get(Type)
Retrieves a collection of CustomItem instances that match a specified type.
public static IEnumerable<CustomItem> Get(Type t)
Parameters
Returns
- IEnumerable<CustomItem>
An IEnumerable<T> containing all registered CustomItem of the specified type.
Get(uint)
Gets a CustomItem with a specific ID.
public static CustomItem? Get(uint id)
Parameters
id
uintThe CustomItem ID.
Returns
- CustomItem
The CustomItem matching the search, null if not registered.
Give(Player, Item, bool)
Gives an Item as a CustomItem to a Player.
public virtual void Give(Player player, Item item, bool displayMessage = true)
Parameters
player
PlayerThe Player who will receive the item.
item
ItemThe Item to be given.
displayMessage
boolIndicates whether ShowPickedUpMessage(Player) will be called when the player receives the item.
Give(Player, Pickup, bool)
Gives a InventorySystem.Items.Pickups.ItemPickupBase as a CustomItem to a Player.
public virtual void Give(Player player, Pickup pickup, bool displayMessage = true)
Parameters
player
PlayerThe Player who will receive the item.
pickup
PickupThe InventorySystem.Items.Pickups.ItemPickupBase to be given.
displayMessage
boolIndicates whether ShowPickedUpMessage(Player) will be called when the player receives the item.
Give(Player, bool)
Gives the CustomItem to a player.
public virtual void Give(Player player, bool displayMessage = true)
Parameters
player
PlayerThe Player who will receive the item.
displayMessage
boolIndicates whether ShowPickedUpMessage(Player) will be called when the player receives the item.
Init()
Called when the item is registered.
public virtual void Init()
OnAcquired(Player, Item, bool)
Called anytime the item enters a player's inventory by any means.
protected virtual void OnAcquired(Player player, Item item, bool displayMessage)
Parameters
player
PlayerThe Player acquiring the item.
item
ItemThe Item being acquired.
displayMessage
boolWhether the Pickup hint should be displayed.
OnChanging(ChangingItemEventArgs)
Handles tracking items when they are selected in the player's inventory.
protected virtual void OnChanging(ChangingItemEventArgs ev)
Parameters
OnDropping(DroppingItemEventArgs)
Handles tracking items when they are dropped by a player.
[Obsolete("Use OnDroppingItem instead.", false)]
protected virtual void OnDropping(DroppingItemEventArgs ev)
Parameters
OnDroppingAmmo(DroppingAmmoEventArgs)
Handles tracking when player requests drop of item which ItemType equals to the ItemType specified by CustomItem.
protected virtual void OnDroppingAmmo(DroppingAmmoEventArgs ev)
Parameters
OnDroppingItem(DroppingItemEventArgs)
Handles tracking items when they are dropped by a player.
protected virtual void OnDroppingItem(DroppingItemEventArgs ev)
Parameters
OnOwnerChangingRole(OwnerChangingRoleEventArgs)
Handles tracking items when they a player changes their role.
protected virtual void OnOwnerChangingRole(OwnerChangingRoleEventArgs ev)
Parameters
OnOwnerDying(OwnerDyingEventArgs)
Handles making sure custom items are not "lost" when a player dies.
protected virtual void OnOwnerDying(OwnerDyingEventArgs ev)
Parameters
OnOwnerEscaping(OwnerEscapingEventArgs)
Handles making sure custom items are not "lost" when a player escapes.
protected virtual void OnOwnerEscaping(OwnerEscapingEventArgs ev)
Parameters
OnOwnerHandcuffing(OwnerHandcuffingEventArgs)
Handles making sure custom items are not "lost" when being handcuffed.
protected virtual void OnOwnerHandcuffing(OwnerHandcuffingEventArgs ev)
Parameters
OnPickingUp(PickingUpItemEventArgs)
Handles tracking items when they are picked up by a player.
protected virtual void OnPickingUp(PickingUpItemEventArgs ev)
Parameters
OnUpgrading(UpgradingEventArgs)
Handles making sure custom items are not affected by SCP-914.
protected virtual void OnUpgrading(UpgradingEventArgs ev)
Parameters
OnUpgrading(UpgradingItemEventArgs)
Handles making sure custom items are not affected by SCP-914.
protected virtual void OnUpgrading(UpgradingItemEventArgs ev)
Parameters
OnWaitingForPlayers()
Clears the lists of item uniqIDs and Pickups since any still in the list will be invalid.
protected virtual void OnWaitingForPlayers()
RegisterItems(bool, object?)
Registers all the CustomItem's present in the current assembly.
public static IEnumerable<CustomItem> RegisterItems(bool skipReflection = false, object? overrideClass = null)
Parameters
skipReflection
boolWhether reflection is skipped (more efficient if you are not using your custom item classes as config objects).
overrideClass
objectThe class to search properties for, if different from the plugin's config class.
Returns
- IEnumerable<CustomItem>
A IEnumerable<T> of CustomItem which contains all registered CustomItem's.
RegisterItems(IEnumerable<Type>, bool, bool, object?)
Registers all the CustomItem's present in the current assembly.
public static IEnumerable<CustomItem> RegisterItems(IEnumerable<Type> targetTypes, bool isIgnored = false, bool skipReflection = false, object? overrideClass = null)
Parameters
targetTypes
IEnumerable<Type>The IEnumerable<T> of Type containing the target types.
isIgnored
boolA value indicating whether the target types should be ignored.
skipReflection
boolWhether reflection is skipped (more efficient if you are not using your custom item classes as config objects).
overrideClass
objectThe class to search properties for, if different from the plugin's config class.
Returns
- IEnumerable<CustomItem>
A IEnumerable<T> of CustomItem which contains all registered CustomItem's.
ShowPickedUpMessage(Player)
Shows a message to the player upon picking up a custom item.
protected virtual void ShowPickedUpMessage(Player player)
Parameters
ShowSelectedMessage(Player)
Shows a message to the player upon selecting a custom item.
protected virtual void ShowSelectedMessage(Player player)
Parameters
Spawn(Player, Item, Player?)
Spawns a Item as a CustomItem where a specific Player is, and optionally sets the previous owner.
public virtual Pickup? Spawn(Player player, Item item, Player? previousOwner = null)
Parameters
player
PlayerThe Player position where the CustomItem will be spawned.
item
ItemThe Item to be spawned as a CustomItem.
previousOwner
PlayerThe previous owner of the pickup, can be null.
Returns
- Pickup
The Pickup of the spawned CustomItem.
Spawn(Player, Player?)
Spawns the CustomItem where a specific Player is, and optionally sets the previous owner.
public virtual Pickup? Spawn(Player player, Player? previousOwner = null)
Parameters
player
PlayerThe Player position where the CustomItem will be spawned.
previousOwner
PlayerThe previous owner of the pickup, can be null.
Returns
- Pickup
The Pickup of the spawned CustomItem.
Spawn(IEnumerable<SpawnPoint>, uint)
Spawns CustomItems inside spawnPoints
.
public virtual uint Spawn(IEnumerable<SpawnPoint> spawnPoints, uint limit)
Parameters
spawnPoints
IEnumerable<SpawnPoint>The spawn points IEnumerable<T>.
limit
uintThe spawn limit.
Returns
- uint
Returns the number of spawned items.
Spawn(float, float, float)
Spawns the CustomItem in a specific location.
public virtual Pickup? Spawn(float x, float y, float z)
Parameters
Returns
- Pickup
The Pickup wrapper of the spawned CustomItem.
Spawn(float, float, float, Item)
Spawns a Item as a CustomItem in a specific location.
public virtual Pickup? Spawn(float x, float y, float z, Item item)
Parameters
x
floatThe x coordinate.
y
floatThe y coordinate.
z
floatThe z coordinate.
item
ItemThe Item to be spawned as a CustomItem.
Returns
- Pickup
The Pickup wrapper of the spawned CustomItem.
Spawn(Vector3, Item, Player?)
Spawns the CustomItem in a specific position.
public virtual Pickup? Spawn(Vector3 position, Item item, Player? previousOwner = null)
Parameters
position
Vector3The UnityEngine.Vector3 where the CustomItem will be spawned.
item
ItemThe Item to be spawned as a CustomItem.
previousOwner
PlayerThe PreviousOwner of the item. Can be null.
Returns
- Pickup
The Pickup of the spawned CustomItem.
Spawn(Vector3, Player?)
Spawns the CustomItem in a specific position.
public virtual Pickup? Spawn(Vector3 position, Player? previousOwner = null)
Parameters
position
Vector3The UnityEngine.Vector3 where the CustomItem will be spawned.
previousOwner
PlayerThe PreviousOwner of the item. Can be null.
Returns
- Pickup
The Pickup of the spawned CustomItem.
SpawnAll()
Spawns all items at their dynamic and static positions.
public virtual void SpawnAll()
SubscribeEvents()
Called after the manager is initialized, to allow loading of special event handlers.
protected virtual void SubscribeEvents()
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TryGet(Item, out CustomItem?)
Checks to see if this item is a custom item.
public static bool TryGet(Item item, out CustomItem? customItem)
Parameters
item
ItemThe Item to check.
customItem
CustomItemThe CustomItem this item is.
Returns
- bool
True if the item is a custom item.
TryGet(Pickup, out CustomItem?)
Checks if this pickup is a custom item.
public static bool TryGet(Pickup pickup, out CustomItem? customItem)
Parameters
pickup
PickupThe InventorySystem.Items.Pickups.ItemPickupBase to check.
customItem
CustomItemThe CustomItem this pickup is.
Returns
- bool
True if the pickup is a custom item.
TryGet(Player, out CustomItem?)
Tries to get the player's current CustomItem in their hand.
public static bool TryGet(Player player, out CustomItem? customItem)
Parameters
player
PlayerThe Player to check.
customItem
CustomItemThe CustomItem in their hand.
Returns
- bool
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 IEnumerable<T> of CustomItem.
public static bool TryGet(Player player, out IEnumerable<CustomItem>? customItems)
Parameters
player
PlayerThe Player to check.
customItems
IEnumerable<CustomItem>The player's IEnumerable<T> of CustomItem.
Returns
- bool
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.
public static bool TryGet(string name, out CustomItem? customItem)
Parameters
name
stringThe CustomItem name to look for.
customItem
CustomItemThe found CustomItem, null if not registered.
Returns
- bool
Returns a value indicating whether the CustomItem was found.
TryGet(Type, out IEnumerable<CustomItem>)
Attempts to retrieve a collection of CustomItem instances of a specified type.
public static bool TryGet(Type t, out IEnumerable<CustomItem> customItems)
Parameters
t
TypeThe Type of the item to look for.
customItems
IEnumerable<CustomItem>An output parameter that will contain the found CustomItem instances, or an empty collection if none are registered.
Returns
- bool
A boolean value indicating whether any CustomItem instances of the specified type were found.
TryGet(uint, out CustomItem?)
Tries to get a CustomItem with a specific ID.
public static bool TryGet(uint id, out CustomItem? customItem)
Parameters
id
uintThe CustomItem ID to look for.
customItem
CustomItemThe found CustomItem, null if not registered.
Returns
- bool
Returns a value indicating whether the CustomItem was found.
TryGive(Player, string, bool)
Gives to a specific Player a specic CustomItem.
public static bool TryGive(Player player, string name, bool displayMessage = true)
Parameters
player
PlayerThe Player to give the item to.
name
stringThe name of the CustomItem to give.
displayMessage
boolIndicates a value whether ShowPickedUpMessage(Player) will be called when the player receives the CustomItem or not.
Returns
- bool
Returns a value indicating if the player was given the CustomItem or not.
TryGive(Player, uint, bool)
Gives to a specific Player a specic CustomItem.
public static bool TryGive(Player player, uint id, bool displayMessage = true)
Parameters
player
PlayerThe Player to give the item to.
id
uintThe IDs of the CustomItem to give.
displayMessage
boolIndicates a value whether ShowPickedUpMessage(Player) will be called when the player receives the CustomItem or not.
Returns
- bool
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.
public static bool TrySpawn(string name, Vector3 position, out Pickup? pickup)
Parameters
name
stringThe name of the CustomItem to spawn.
position
Vector3The UnityEngine.Vector3 location to spawn the item.
pickup
PickupThe InventorySystem.Items.Pickups.ItemPickupBase instance of the CustomItem.
Returns
- bool
Returns a value indicating whether the CustomItem was spawned.
TrySpawn(uint, Vector3, out Pickup?)
Tries to spawn a specific CustomItem at a specific UnityEngine.Vector3 position.
public static bool TrySpawn(uint id, Vector3 position, out Pickup? pickup)
Parameters
id
uintThe ID of the CustomItem to spawn.
position
Vector3The UnityEngine.Vector3 location to spawn the item.
pickup
PickupThe InventorySystem.Items.Pickups.ItemPickupBase instance of the CustomItem.
Returns
- bool
Returns a value indicating whether the CustomItem was spawned.
UnregisterItems()
Unregisters all the CustomItem's present in the current assembly.
public static IEnumerable<CustomItem> UnregisterItems()
Returns
- IEnumerable<CustomItem>
A IEnumerable<T> of CustomItem which contains all unregistered CustomItem's.
UnregisterItems(IEnumerable<CustomItem>, bool)
Unregisters all the CustomItem's present in the current assembly.
public static IEnumerable<CustomItem> UnregisterItems(IEnumerable<CustomItem> targetItems, bool isIgnored = false)
Parameters
targetItems
IEnumerable<CustomItem>The IEnumerable<T> of CustomItem containing the target items.
isIgnored
boolA value indicating whether the target items should be ignored.
Returns
- IEnumerable<CustomItem>
A IEnumerable<T> of CustomItem which contains all unregistered CustomItem's.
UnregisterItems(IEnumerable<Type>, bool)
Unregisters all the CustomItem's present in the current assembly.
public static IEnumerable<CustomItem> UnregisterItems(IEnumerable<Type> targetTypes, bool isIgnored = false)
Parameters
targetTypes
IEnumerable<Type>The IEnumerable<T> of Type containing the target types.
isIgnored
boolA value indicating whether the target types should be ignored.
Returns
- IEnumerable<CustomItem>
A 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.
protected virtual void UnsubscribeEvents()