Class CustomAbility
The custom ability base class.
Inherited Members
Namespace: Exiled.CustomRoles.API.Features
Assembly: Exiled.CustomRoles.dll
Syntax
public abstract class CustomAbility
Constructors
| Improve this Doc View SourceCustomAbility()
Initializes a new instance of the CustomAbility class.
Declaration
public CustomAbility()
Properties
| Improve this Doc View SourceAbilityType
Gets the System.Type for this ability.
Declaration
public string AbilityType { get; }
Property Value
Type | Description |
---|---|
System.String |
Description
Gets or sets the description of the ability.
Declaration
public abstract string Description { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Name
Gets or sets the name of the ability.
Declaration
public abstract string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Players
Gets all players who have this ability.
Declaration
[YamlIgnore]
public HashSet<Player> Players { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.HashSet<Player> |
Registered
Gets a list of all registered custom abilities.
Declaration
public static HashSet<CustomAbility> Registered { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.HashSet<CustomAbility> |
Methods
| Improve this Doc View SourceAbilityAdded(Player)
Called when the ability is first added to the player.
Declaration
protected virtual void AbilityAdded(Player player)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player using the ability. |
AbilityRemoved(Player)
Called when the ability is being removed.
Declaration
protected virtual void AbilityRemoved(Player player)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player using the ability. |
AddAbility(Player)
Adds this ability to the player.
Declaration
public void AddAbility(Player player)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player to give the ability to. |
Check(Player)
Checks to see if the specified player has this ability.
Declaration
public virtual bool Check(Player player)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if the player has this ability. |
Destroy()
Destroys this ability.
Declaration
public void Destroy()
Get(String)
Gets a CustomAbility by name.
Declaration
public static CustomAbility Get(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the ability to get. |
Returns
Type | Description |
---|---|
CustomAbility | The ability, or null if it doesn't exist. |
Get(Type)
Gets a CustomAbility by type.
Declaration
public static CustomAbility Get(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the ability to get. |
Returns
Type | Description |
---|---|
CustomAbility | The type, or null if it doesn't exist. |
Init()
Initializes this ability.
Declaration
public void Init()
RegisterAbilities(Boolean, Object)
Registers all the CustomAbility's present in the current assembly.
Declaration
public static IEnumerable<CustomAbility> RegisterAbilities(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<CustomAbility> | A System.Collections.Generic.IEnumerable<T> of CustomAbility which contains all registered CustomAbility's. |
RegisterAbilities(IEnumerable<Type>, Boolean, Boolean, Object)
Registers all the CustomAbility's present in the current assembly.
Declaration
public static IEnumerable<CustomAbility> RegisterAbilities(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<CustomAbility> | A System.Collections.Generic.IEnumerable<T> of CustomAbility which contains all registered CustomAbility's. |
RemoveAbility(Player)
Removes this ability from the player.
Declaration
public void RemoveAbility(Player player)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The Player to remove this ability from. |
SubscribeEvents()
Loads the internal event handlers for the ability.
Declaration
protected virtual void SubscribeEvents()
TryGet(String, out CustomAbility)
Tries to get a CustomAbility by name.
Declaration
public static bool TryGet(string name, out CustomAbility customAbility)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the ability to get. |
CustomAbility | customAbility | The custom ability. |
Returns
Type | Description |
---|---|
System.Boolean | True if the ability exists. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If the name is null or an empty string. |
TryGet(Type, out CustomAbility)
Tries to get a CustomAbility by type.
Declaration
public static bool TryGet(Type type, out CustomAbility customAbility)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the ability to get. |
CustomAbility | customAbility | The custom ability. |
Returns
Type | Description |
---|---|
System.Boolean | True if the ability exists, otherwise false. |
UnregisterAbilities()
Unregisters all the CustomAbility's present in the current assembly.
Declaration
public static IEnumerable<CustomAbility> UnregisterAbilities()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<CustomAbility> | A System.Collections.Generic.IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's. |
UnregisterAbilities(IEnumerable<CustomAbility>, Boolean)
Unregisters all the CustomAbility's present in the current assembly.
Declaration
public static IEnumerable<CustomAbility> UnregisterAbilities(IEnumerable<CustomAbility> targetAbilities, bool isIgnored = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<CustomAbility> | targetAbilities | The System.Collections.Generic.IEnumerable<T> of CustomAbility containing the target roles. |
System.Boolean | isIgnored | A value indicating whether the target abilities should be ignored. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<CustomAbility> | A System.Collections.Generic.IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's. |
UnregisterAbilities(IEnumerable<Type>, Boolean)
Unregisters all the CustomAbility's present in the current assembly.
Declaration
public static IEnumerable<CustomAbility> UnregisterAbilities(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<CustomAbility> | A System.Collections.Generic.IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's. |
UnsubscribeEvents()
Unloads the internal event handlers for the ability.
Declaration
protected virtual void UnsubscribeEvents()