Class CustomAbility
- Namespace
- Exiled.CustomRoles.API.Features
- Assembly
- Exiled.CustomRoles.dll
The custom ability base class.
public abstract class CustomAbility
- Inheritance
-
CustomAbility
- Derived
- Inherited Members
- Extension Methods
Constructors
CustomAbility()
Initializes a new instance of the CustomAbility class.
public CustomAbility()
Properties
AbilityType
Gets the Type for this ability.
public string AbilityType { get; }
Property Value
Description
Gets or sets the description of the ability.
public abstract string Description { get; set; }
Property Value
Name
Gets or sets the name of the ability.
public abstract string Name { get; set; }
Property Value
Players
Gets all players who have this ability.
[YamlIgnore]
public HashSet<Player> Players { get; }
Property Value
Registered
Gets a list of all registered custom abilities.
public static HashSet<CustomAbility> Registered { get; }
Property Value
Methods
AbilityAdded(Player)
Called when the ability is first added to the player.
protected virtual void AbilityAdded(Player player)
Parameters
AbilityRemoved(Player)
Called when the ability is being removed.
protected virtual void AbilityRemoved(Player player)
Parameters
AddAbility(Player)
Adds this ability to the player.
public void AddAbility(Player player)
Parameters
Check(Player)
Checks to see if the specified player has this ability.
public virtual bool Check(Player player)
Parameters
Returns
- bool
True if the player has this ability.
Destroy()
Destroys this ability.
public void Destroy()
Get(string)
Gets a CustomAbility by name.
public static CustomAbility? Get(string name)
Parameters
namestringThe name of the ability to get.
Returns
- CustomAbility
The ability, or null if it doesn't exist.
Get(Type)
Gets a CustomAbility by type.
public static CustomAbility? Get(Type type)
Parameters
typeTypeThe type of the ability to get.
Returns
- CustomAbility
The type, or null if it doesn't exist.
Init()
Initializes this ability.
public void Init()
RegisterAbilities(bool)
Registers all the CustomAbility's present in the current assembly.
public static IEnumerable<CustomAbility> RegisterAbilities(bool byAttribute = false)
Parameters
byAttributeboolWhether to register by attribute.
Returns
- IEnumerable<CustomAbility>
A IEnumerable<T> of CustomAbility which contains all registered CustomAbility's.
Remarks
This is just a dumbed down version of RegisterAbilities(bool, object?) for QoL, if you actually use CustomAbilityAttribute, do not use this overload.
RegisterAbilities(bool, object?)
Registers all the CustomAbility's present in the current assembly.
public static IEnumerable<CustomAbility> RegisterAbilities(bool skipReflection = false, object? overrideClass = null)
Parameters
skipReflectionboolWhether reflection is skipped (more efficient if you are not using your custom item classes as config objects).
overrideClassobjectThe class to search properties for, if different from the plugin's config class.
Returns
- IEnumerable<CustomAbility>
A IEnumerable<T> of CustomAbility which contains all registered CustomAbility's.
RegisterAbilities(IEnumerable<Type>, bool, bool, object?)
Registers all the CustomAbility's present in the current assembly.
public static IEnumerable<CustomAbility> RegisterAbilities(IEnumerable<Type> targetTypes, bool isIgnored = false, bool skipReflection = false, object? overrideClass = null)
Parameters
targetTypesIEnumerable<Type>The IEnumerable<T> of Type containing the target types.
isIgnoredboolA value indicating whether the target types should be ignored.
skipReflectionboolWhether reflection is skipped (more efficient if you are not using your custom item classes as config objects).
overrideClassobjectThe class to search properties for, if different from the plugin's config class.
Returns
- IEnumerable<CustomAbility>
A IEnumerable<T> of CustomAbility which contains all registered CustomAbility's.
RemoveAbility(Player)
Removes this ability from the player.
public void RemoveAbility(Player player)
Parameters
SubscribeEvents()
Loads the internal event handlers for the ability.
protected virtual void SubscribeEvents()
TryGet(string, out CustomAbility?)
Tries to get a CustomAbility by name.
public static bool TryGet(string name, out CustomAbility? customAbility)
Parameters
namestringThe name of the ability to get.
customAbilityCustomAbilityThe custom ability.
Returns
- bool
True if the ability exists.
Exceptions
- ArgumentNullException
If the name is null or an empty string.
TryGet(Type, out CustomAbility?)
Tries to get a CustomAbility by type.
public static bool TryGet(Type type, out CustomAbility? customAbility)
Parameters
typeTypeThe type of the ability to get.
customAbilityCustomAbilityThe custom ability.
Returns
- bool
True if the ability exists, otherwise false.
UnregisterAbilities()
Unregisters all the CustomAbility's present in the current assembly.
public static IEnumerable<CustomAbility> UnregisterAbilities()
Returns
- IEnumerable<CustomAbility>
A IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's.
UnregisterAbilities(IEnumerable<CustomAbility>, bool)
Unregisters all the CustomAbility's present in the current assembly.
public static IEnumerable<CustomAbility> UnregisterAbilities(IEnumerable<CustomAbility> targetAbilities, bool isIgnored = false)
Parameters
targetAbilitiesIEnumerable<CustomAbility>The IEnumerable<T> of CustomAbility containing the target roles.
isIgnoredboolA value indicating whether the target abilities should be ignored.
Returns
- IEnumerable<CustomAbility>
A IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's.
UnregisterAbilities(IEnumerable<Type>, bool)
Unregisters all the CustomAbility's present in the current assembly.
public static IEnumerable<CustomAbility> UnregisterAbilities(IEnumerable<Type> targetTypes, bool isIgnored = false)
Parameters
targetTypesIEnumerable<Type>The IEnumerable<T> of Type containing the target types.
isIgnoredboolA value indicating whether the target types should be ignored.
Returns
- IEnumerable<CustomAbility>
A IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's.
UnsubscribeEvents()
Unloads the internal event handlers for the ability.
protected virtual void UnsubscribeEvents()