Table of Contents

Class Role

Namespace
Exiled.API.Features.Roles
Assembly
Exiled.API.dll

Defines the class for role-related classes.

public abstract class Role : TypeCastObject<Role>, IWrapper<PlayerRoleBase>
Inheritance
Role
Implements
IWrapper<PlayerRoleBase>
Derived
Inherited Members
Extension Methods

Constructors

Role(PlayerRoleBase)

Initializes a new instance of the Role class.

protected Role(PlayerRoleBase baseRole)

Parameters

baseRole PlayerRoleBase

the base PlayerRoles.PlayerRoleBase.

Properties

ActiveTime

Gets the last time the Role was active.

public TimeSpan ActiveTime { get; }

Property Value

TimeSpan

Base

Gets the base PlayerRoles.PlayerRoleBase.

public PlayerRoleBase Base { get; }

Property Value

PlayerRoleBase

Color

Gets the UnityEngine.Color of this Role.

public Color Color { get; }

Property Value

Color

IsAlive

Gets a value indicating whether this role represents a living role.

public bool IsAlive { get; }

Property Value

bool

IsDead

Gets a value indicating whether this role represents a dead role.

public bool IsDead { get; }

Property Value

bool

IsValid

Gets a value indicating whether this role is still valid. This will only ever be false if the Role is stored and accessed at a later date.

public bool IsValid { get; }

Property Value

bool

LifeIdentifier

Gets the life identifier for the role.

public int LifeIdentifier { get; }

Property Value

int

Name

Gets the Role full name.

public string Name { get; }

Property Value

string

Owner

Gets the Player this role is referring to.

public virtual Player Owner { get; }

Property Value

Player

RandomSpawnLocation

Gets a random spawn position of this role.

public virtual SpawnLocation RandomSpawnLocation { get; }

Property Value

SpawnLocation

The spawn position.

Side

Gets the Side of this Role.

public Side Side { get; }

Property Value

Side

SpawnFlags

Gets the PlayerRoles.RoleSpawnFlags.

public RoleSpawnFlags SpawnFlags { get; }

Property Value

RoleSpawnFlags

SpawnReason

Gets the PlayerRoles.RoleChangeReason.

public RoleChangeReason SpawnReason { get; }

Property Value

RoleChangeReason

Team

Gets the PlayerRoles.Team of this Role.

public Team Team { get; }

Property Value

Team

Type

Gets the PlayerRoles.RoleTypeId of this Player.

public abstract RoleTypeId Type { get; }

Property Value

RoleTypeId

Methods

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Set(RoleTypeId, SpawnReason)

Sets the player's PlayerRoles.RoleTypeId.

public virtual void Set(RoleTypeId newRole, SpawnReason reason = SpawnReason.ForceClass)

Parameters

newRole RoleTypeId

The new PlayerRoles.RoleTypeId to be set.

reason SpawnReason

The SpawnReason defining why the player's role was changed.

Set(RoleTypeId, SpawnReason, RoleSpawnFlags)

Sets the player's PlayerRoles.RoleTypeId.

public virtual void Set(RoleTypeId newRole, SpawnReason reason, RoleSpawnFlags spawnFlags)

Parameters

newRole RoleTypeId

The new PlayerRoles.RoleTypeId to be set.

reason SpawnReason

The SpawnReason defining why the player's role was changed.

spawnFlags RoleSpawnFlags

The PlayerRoles.RoleSpawnFlags defining player spawn logic.

Set(RoleTypeId, RoleSpawnFlags)

Sets the player's PlayerRoles.RoleTypeId.

public virtual void Set(RoleTypeId newRole, RoleSpawnFlags spawnFlags)

Parameters

newRole RoleTypeId

The new PlayerRoles.RoleTypeId to be set.

spawnFlags RoleSpawnFlags

The PlayerRoles.RoleSpawnFlags defining player spawn logic.

ToString()

Returns the role in a human-readable format.

public override string ToString()

Returns

string

A string containing role-related data.

Operators

operator ==(Role, Role)

Returns whether 2 roles are the same.

public static bool operator ==(Role left, Role right)

Parameters

left Role

The role.

right Role

The other role.

Returns

bool

true if the values are equal.

operator ==(Role, RoleTypeId)

Returns whether the role has the same RoleTypeId as the given typeId.

public static bool operator ==(Role role, RoleTypeId typeId)

Parameters

role Role

The Role.

typeId RoleTypeId

The PlayerRoles.RoleTypeId.

Returns

bool

true if the values are equal.

operator ==(RoleTypeId, Role)

Returns whether the role has the same RoleTypeId as the given type.

public static bool operator ==(RoleTypeId type, Role role)

Parameters

type RoleTypeId

The PlayerRoles.RoleTypeId.

role Role

The Role.

Returns

bool

true if the values are equal.

implicit operator RoleTypeId(Role)

Converts a role to its appropriate PlayerRoles.RoleTypeId.

public static implicit operator RoleTypeId(Role role)

Parameters

role Role

The role.

Returns

RoleTypeId

operator !=(Role, Role)

Returns whether the two roles are different.

public static bool operator !=(Role left, Role right)

Parameters

left Role

The role.

right Role

The other role.

Returns

bool

true if the values are not equal.

operator !=(Role, RoleTypeId)

Returns whether the role has a different RoleTypeId as the given typeId.

public static bool operator !=(Role role, RoleTypeId typeId)

Parameters

role Role

The Role.

typeId RoleTypeId

The PlayerRoles.RoleTypeId.

Returns

bool

true if the values are not equal.

operator !=(RoleTypeId, Role)

Returns whether the role has a different RoleTypeId as the given type.

public static bool operator !=(RoleTypeId type, Role role)

Parameters

type RoleTypeId

The PlayerRoles.RoleTypeId.

role Role

The Role.

Returns

bool

true if the values are not equal.