Class CustomRole
The custom role base class.
Inheritance
Inherited Members
Namespace: Exiled.CustomRoles.API.Features
Assembly: Exiled.CustomRoles.dll
Syntax
public abstract class CustomRole
Properties
| Improve this Doc View SourceAbilityUsage
Gets or sets a System.String for the ability usage help sent to players in the player console.
Declaration
public virtual string AbilityUsage { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Ammo
Gets or sets the starting ammo for the role.
Declaration
public virtual Dictionary<AmmoType, ushort> Ammo { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary<AmmoType, System.UInt16> |
Broadcast
Gets or sets a value indicating broadcast that will be shown to the player.
Declaration
public virtual Broadcast Broadcast { get; set; }
Property Value
| Type | Description |
|---|---|
| Broadcast |
ConsoleMessage
Gets or sets a System.String for the console message given to players when they receive a role.
Declaration
public virtual string ConsoleMessage { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
CustomAbilities
Gets or sets a list of the roles custom abilities.
Declaration
public virtual List<CustomAbility> CustomAbilities { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<CustomAbility> |
CustomInfo
Gets or sets the CustomInfo of this role.
Declaration
public abstract string CustomInfo { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
CustomRoleFFMultiplier
Gets or sets a System.Collections.Generic.Dictionary<TKey, TValue> containing cached System.String and their System.Collections.Generic.Dictionary<TKey, TValue> which is cached Role with FF multiplier.
Declaration
public virtual Dictionary<RoleTypeId, float> CustomRoleFFMultiplier { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary<PlayerRoles.RoleTypeId, System.Single> |
Description
Gets or sets the description of this role.
Declaration
public abstract string Description { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DisplayCustomItemMessages
Gets or sets a value indicating whether players will receive a message for getting a custom item, when gaining it through the inventory config for this role.
Declaration
public virtual bool DisplayCustomItemMessages { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Id
Gets or sets the custom RoleID of the role.
Declaration
public abstract uint Id { get; set; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
IgnoreSpawnSystem
Gets or sets a value indicating whether the spawn system is ignored for this role or not.
Declaration
public virtual bool IgnoreSpawnSystem { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Inventory
Gets or sets the starting inventory for the role.
Declaration
public virtual List<string> Inventory { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.String> |
KeepInventoryOnSpawn
Gets or sets a value indicating whether players keep their current inventory when gaining this role.
Declaration
public virtual bool KeepInventoryOnSpawn { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
KeepPositionOnSpawn
Gets or sets a value indicating whether players keep their current position when gaining this role.
Declaration
public virtual bool KeepPositionOnSpawn { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
KeepRoleOnChangingRole
Gets or sets a value indicating whether players keep this Custom Role when they switch roles: Class-D -> Scientist for example.
Declaration
public virtual bool KeepRoleOnChangingRole { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
KeepRoleOnDeath
Gets or sets a value indicating whether players keep this role when they die.
Declaration
public virtual bool KeepRoleOnDeath { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
MaxHealth
Gets or sets the max Health for the role.
Declaration
public abstract int MaxHealth { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Name
Gets or sets the name of this role.
Declaration
public abstract string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Registered
Gets a list of all registered custom roles.
Declaration
public static HashSet<CustomRole> Registered { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.HashSet<CustomRole> |
RemovalKillsPlayer
Gets or sets a value indicating whether players die when this role is removed.
Declaration
public virtual bool RemovalKillsPlayer { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Role
Gets or sets the PlayerRoles.RoleTypeId to spawn this role as.
Declaration
public virtual RoleTypeId Role { get; set; }
Property Value
| Type | Description |
|---|---|
| PlayerRoles.RoleTypeId |
Scale
Gets or sets a value indicating the Player's size.
Declaration
public virtual Vector3 Scale { get; set; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Vector3 |
SpawnChance
Gets or sets a value indicating the Spawn Chance of the Role.
Declaration
public virtual float SpawnChance { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
SpawnProperties
Gets or sets the possible spawn locations for this role.
Declaration
public virtual SpawnProperties SpawnProperties { get; set; }
Property Value
| Type | Description |
|---|---|
| SpawnProperties |
TrackedPlayers
Gets all of the players currently set to this role.
Declaration
[YamlIgnore]
public HashSet<Player> TrackedPlayers { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.HashSet<Player> |
Methods
| Improve this Doc View SourceAddRole(Player)
Handles setup of the role, including spawn location, inventory and registering event handlers and add FF rules.
Declaration
public virtual void AddRole(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to add the role to. |
Check(Player)
Checks if the given player has this role.
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 role. |
Destroy()
Destroys this role manager.
Declaration
public virtual void Destroy()
ForceSyncSetPlayerFriendlyFire(CustomRole, Player)
Force sync CustomRole Friendly Fire with Player (Set to).
Declaration
public static void ForceSyncSetPlayerFriendlyFire(CustomRole roleToSync, Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| CustomRole | roleToSync | CustomRole to sync with player. |
| Player | player | Player Player to add custom role to. |
Get(String)
Gets a CustomRole by name.
Declaration
public static CustomRole Get(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the role to get. |
Returns
| Type | Description |
|---|---|
| CustomRole | The role, or null if it doesn't exist. |
Get(Type)
Gets a CustomRole by type.
Declaration
public static CustomRole Get(Type t)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | t | The System.Type to get. |
Returns
| Type | Description |
|---|---|
| CustomRole | The role, or null if it doesn't exist. |
Get(UInt32)
Gets a CustomRole by ID.
Declaration
public static CustomRole Get(uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | The ID of the role to get. |
Returns
| Type | Description |
|---|---|
| CustomRole | The role, or null if it doesn't exist. |
GetSpawnPosition()
Gets a random UnityEngine.Vector3 from SpawnProperties.
Declaration
protected Vector3 GetSpawnPosition()
Returns
| Type | Description |
|---|---|
| UnityEngine.Vector3 | The chosen spawn location. |
Init()
Initializes this role manager.
Declaration
public virtual void Init()
RegisterRoles(Boolean, Object)
Registers all the CustomRole's present in the current assembly.
Declaration
public static IEnumerable<CustomRole> RegisterRoles(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<CustomRole> | A System.Collections.Generic.IEnumerable<T> of CustomRole which contains all registered CustomRole's. |
RegisterRoles(Boolean, Object, Boolean, Assembly)
Registers all the CustomRole's present in the current assembly.
Declaration
public static IEnumerable<CustomRole> RegisterRoles(bool skipReflection = false, object overrideClass = null, bool inheritAttributes = true, Assembly assembly = 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. |
| System.Boolean | inheritAttributes | Whether or not inherited attributes should be taken into account for registration. |
| System.Reflection.Assembly | assembly | Assembly which is calling this method. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomRole> | A System.Collections.Generic.IEnumerable<T> of CustomRole which contains all registered CustomRole's. |
RegisterRoles(IEnumerable<Type>, Boolean, Boolean, Object)
Registers all the CustomRole's present in the current assembly.
Declaration
public static IEnumerable<CustomRole> RegisterRoles(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<CustomRole> | A System.Collections.Generic.IEnumerable<T> of CustomRole which contains all registered CustomRole's. |
RemoveRole(Player)
Removes the role from a specific player and FF rules.
Declaration
public virtual void RemoveRole(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to remove the role from. |
RoleAdded(Player)
Called after the role has been added to the player.
Declaration
protected virtual void RoleAdded(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player the role was added to. |
RoleRemoved(Player)
Called 1 frame before the role is removed from the player.
Declaration
protected virtual void RoleRemoved(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player the role was removed from. |
SetFriendlyFire(RoleTypeId, Single)
Tries to add PlayerRoles.RoleTypeId to CustomRole FriendlyFire rules.
Declaration
public void SetFriendlyFire(RoleTypeId roleToAdd, float ffMult)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerRoles.RoleTypeId | roleToAdd | Role to add. |
| System.Single | ffMult | Friendly fire multiplier. |
SetFriendlyFire(KeyValuePair<RoleTypeId, Single>)
Wrapper to call SetFriendlyFire(RoleTypeId, Single).
Declaration
public void SetFriendlyFire(KeyValuePair<RoleTypeId, float> roleFF)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.KeyValuePair<PlayerRoles.RoleTypeId, System.Single> | roleFF | Role with FF to add even if it exists. |
ShowBroadcast(Player)
Shows the spawn broadcast to the player.
Declaration
protected virtual void ShowBroadcast(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to show the message to. |
ShowMessage(Player)
Shows the spawn message to the player.
Declaration
protected virtual void ShowMessage(Player player)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to show the message to. |
SubscribeEvents()
Called when the role is initialized to setup internal events.
Declaration
protected virtual void SubscribeEvents()
SyncPlayerFriendlyFire(CustomRole, Player, Boolean)
ResyncCustomRole Friendly Fire with Player (Append, or Overwrite).
Declaration
public static void SyncPlayerFriendlyFire(CustomRole roleToSync, Player player, bool overwrite = false)
Parameters
| Type | Name | Description |
|---|---|---|
| CustomRole | roleToSync | CustomRole to sync with player. |
| Player | player | Player Player to add custom role to. |
| System.Boolean | overwrite | System.Boolean whether to force sync (Overwriting previous information). |
TryAddFriendlyFire(RoleTypeId, Single)
Tries to add PlayerRoles.RoleTypeId to CustomRole FriendlyFire rules.
Declaration
public bool TryAddFriendlyFire(RoleTypeId roleToAdd, float ffMult)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerRoles.RoleTypeId | roleToAdd | Role to add. |
| System.Single | ffMult | Friendly fire multiplier. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the item was able to be added. |
TryAddFriendlyFire(Dictionary<RoleTypeId, Single>, Boolean)
Tries to add PlayerRoles.RoleTypeId to CustomRole FriendlyFire rules.
Declaration
public bool TryAddFriendlyFire(Dictionary<RoleTypeId, float> ffRules, bool overwrite = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.Dictionary<PlayerRoles.RoleTypeId, System.Single> | ffRules | Roles to add with friendly fire values. |
| System.Boolean | overwrite | Whether to overwrite current values if they exist. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the item was able to be added. |
TryAddFriendlyFire(KeyValuePair<RoleTypeId, Single>)
Tries to add PlayerRoles.RoleTypeId to CustomRole FriendlyFire rules.
Declaration
public bool TryAddFriendlyFire(KeyValuePair<RoleTypeId, float> pairedRoleFF)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.KeyValuePair<PlayerRoles.RoleTypeId, System.Single> | pairedRoleFF | Role FF multiplier to add. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the item was able to be added. |
TryAddItem(Player, String)
Tries to add an item to the player's inventory by name.
Declaration
protected bool TryAddItem(Player player, string itemName)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The Player to try giving the item to. |
| System.String | itemName | The name of the item to try adding. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether or not the item was able to be added. |
TryGet(Player, out IReadOnlyCollection<CustomRole>)
Tries to get a System.Collections.Generic.IReadOnlyCollection<T> of the specified Player's CustomRoles.
Declaration
public static bool TryGet(Player player, out IReadOnlyCollection<CustomRole> customRoles)
Parameters
| Type | Name | Description |
|---|---|---|
| Player | player | The player to check. |
| System.Collections.Generic.IReadOnlyCollection<CustomRole> | customRoles | The custom roles the player has. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the player has custom roles. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | If the player is null. |
TryGet(String, out CustomRole)
Tries to get a CustomRole by name.
Declaration
public static bool TryGet(string name, out CustomRole customRole)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the role to get. |
| CustomRole | customRole | The custom role. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the role exists. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | If the name is null or an empty string. |
TryGet(Type, out CustomRole)
Tries to get a CustomRole by name.
Declaration
public static bool TryGet(Type t, out CustomRole customRole)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | t | The System.Type of the role to get. |
| CustomRole | customRole | The custom role. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the role exists. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | If the name is null or an empty string. |
TryGet(UInt32, out CustomRole)
Tries to get a CustomRole by
Declaration
public static bool TryGet(uint id, out CustomRole customRole)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | id | The ID of the role to get. |
| CustomRole | customRole | The custom role. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the role exists. |
UnregisterRoles()
Unregisters all the CustomRole's present in the current assembly.
Declaration
public static IEnumerable<CustomRole> UnregisterRoles()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomRole> | A System.Collections.Generic.IEnumerable<T> of CustomRole which contains all unregistered CustomRole's. |
UnregisterRoles(IEnumerable<CustomRole>, Boolean)
Unregisters all the CustomRole's present in the current assembly.
Declaration
public static IEnumerable<CustomRole> UnregisterRoles(IEnumerable<CustomRole> targetRoles, bool isIgnored = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<CustomRole> | targetRoles | The System.Collections.Generic.IEnumerable<T> of CustomRole containing the target roles. |
| System.Boolean | isIgnored | A value indicating whether the target roles should be ignored. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<CustomRole> | A System.Collections.Generic.IEnumerable<T> of CustomRole which contains all unregistered CustomRole's. |
UnregisterRoles(IEnumerable<Type>, Boolean)
Unregisters all the CustomRole's present in the current assembly.
Declaration
public static IEnumerable<CustomRole> UnregisterRoles(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<CustomRole> | A System.Collections.Generic.IEnumerable<T> of CustomRole which contains all unregistered CustomRole's. |
UnsubscribeEvents()
Called when the role is destroyed to unsubscribe internal event handlers.
Declaration
protected virtual void UnsubscribeEvents()