Table of Contents

Class Player

Namespace
Shard.Gameplay.Universe.Players
Assembly
Shard.Gameplay.Universe.dll

Represents one accepted authenticated player login.

public sealed class Player : ICommandSender, IPermissionHolder
Inheritance
Player
Implements
Inherited Members

Properties

Id

Gets the authenticated player identifier.

public Guid Id { get; }

Property Value

Guid

Language

Gets the client's selected BCP-47 language.

public string Language { get; }

Property Value

string

Name

Gets the normalized player name accepted during setup.

public string Name { get; }

Property Value

string

Skin

Gets the validated Character Creator selection supplied by authentication.

public PlayerSkinSelection? Skin { get; }

Property Value

PlayerSkinSelection

WorldId

Gets the identifier of the world containing the player's currently active avatar, or null while the player is joining or disconnected.

public Guid? WorldId { get; }

Property Value

Guid?

Remarks

This is an observational snapshot, not proof that the Player remains in this World. World work must use InCurrentWorldAsync(PlayerAvatarAction) or InWorldAsync(World, PlayerAvatarAction).

Methods

HasPermission(string, bool)

Checks one permission for the authenticated player identifier.

public bool HasPermission(string permission, bool defaultValue)

Parameters

permission string
defaultValue bool

Returns

bool

The configured result or defaultValue when no service owns it.

InCurrentWorldAsync(PlayerAvatarAction)

Performs synchronous World work against the Player's exact current avatar.

public ValueTask<bool> InCurrentWorldAsync(PlayerAvatarAction action)

Parameters

action PlayerAvatarAction

Returns

ValueTask<bool>

true when the callback ran against the captured avatar.

Remarks

The exact World binding is captured when called and queued work never redirects after that binding ends. The Store and Entity are borrowed only for the callback. The callback must not retain them or perform asynchronous work. Expected lifecycle races return false. Admission failures and callback exceptions fault the returned value task.

InCurrentWorldAsync<TState>(TState, PlayerAvatarAction<TState>)

Performs synchronous World work with state against the exact current avatar.

public ValueTask<bool> InCurrentWorldAsync<TState>(TState state, PlayerAvatarAction<TState> action)

Parameters

state TState
action PlayerAvatarAction<TState>

Returns

ValueTask<bool>

Type Parameters

TState

InWorldAsync(World, PlayerAvatarAction)

Performs synchronous World work only in the exact expected loaded World.

public ValueTask<bool> InWorldAsync(World expectedWorld, PlayerAvatarAction action)

Parameters

expectedWorld World
action PlayerAvatarAction

Returns

ValueTask<bool>

true when the expected world and binding remained current.

Remarks

The expected World is a guard, not a routing source. Queued work runs only while the captured binding remains current. The callback must not retain the borrowed Store or Entity.

SendMessage(FormattedMessage)

Sends a localized protocol message to this player's exact active endpoint.

public void SendMessage(FormattedMessage message)

Parameters

message FormattedMessage

SendMessage(string)

Best-effort sends one chat message to this Player's exact active endpoint.

public void SendMessage(string message)

Parameters

message string

Remarks

A concurrent disconnect may reject or drop the message without failing the caller.

TryDisconnectForProtocolViolation()

public bool TryDisconnectForProtocolViolation()

Returns

bool

TrySend(IToClientPacket)

Attempts to send one targeted packet through this login's active connection.

public bool TrySend(IToClientPacket packet)

Parameters

packet IToClientPacket

Returns

bool

true when the endpoint accepted the packet.

Remarks

The packet is sent only through this Player's exact active endpoint. When the endpoint accepts it, the caller must not mutate the packet afterward.