Class PlayerService
public class PlayerService
- Inheritance
-
PlayerService
- Inherited Members
Methods
GetAllCachedUsers()
Gets all cached users from the player cache.
public static IEnumerable<Entity> GetAllCachedUsers()
Returns
- IEnumerable<Entity>
An enumerable collection of all cached user entities.
GetAllCachedUsersAsPlayer()
Gets all cached users from the player cache.
public static IEnumerable<Player> GetAllCachedUsersAsPlayer()
Returns
- IEnumerable<Player>
An enumerable collection of all cached users as Player objects.
GetCachedUsersOnline()
Gets all online users from the cached player data.
public static IEnumerable<Entity> GetCachedUsersOnline()
Returns
- IEnumerable<Entity>
An enumerable collection of online user entities from cache.
GetCachedUsersOnlineAsPlayer()
Gets all online players from the cached player data.
public static IEnumerable<Player> GetCachedUsersOnlineAsPlayer()
Returns
- IEnumerable<Player>
An enumerable collection of online players from cache.
GetUsersOnline()
Gets all online users from the game's entity system.
public static IEnumerable<Entity> GetUsersOnline()
Returns
- IEnumerable<Entity>
An enumerable collection of online user entities.
PlayerFromChar(Entity)
Creates a new Player instance from the provided character entity.
public static Player PlayerFromChar(Entity entity)
Parameters
entity
EntityThe character entity to create the player from.
Returns
- Player
A new Player instance initialized with the specified character entity.
PlayerFromData(PlayerData)
Creates a new Player instance from the provided PlayerData.
public static Player PlayerFromData(PlayerData data)
Parameters
data
PlayerDataThe PlayerData containing the player information.
Returns
- Player
A new Player instance initialized with the character entity from the PlayerData.
PlayerFromUser(User)
Creates a new Player instance from the provided User.
public static Player PlayerFromUser(User user)
Parameters
user
UserThe User to create the player from.
Returns
- Player
A new Player instance initialized with the user's local character entity.
TryFindByName(string, out Player)
Attempts to find a player by their character name.
public static bool TryFindByName(string name, out Player player)
Parameters
name
stringThe character name to search for.
player
PlayerWhen this method returns, contains the player associated with the specified name, if found; otherwise, null.
Returns
- bool
true if a player with the specified name was found; otherwise, false.
TryFindByName(string, out PlayerData)
Attempts to find a player by their character name.
[Obsolete("This method is deprecated and will be removed in a future version. Use TryFindByName(string, out Player) instead.")]
public static bool TryFindByName(string name, out PlayerData playerData)
Parameters
name
stringThe character name to search for.
playerData
PlayerDataWhen this method returns, contains the player data associated with the specified name, if found; otherwise, the default value.
Returns
- bool
true if a player with the specified name was found; otherwise, false.
TryFindByName(FixedString64Bytes, out Player)
Attempts to find a player by their character name using a FixedString64Bytes.
public static bool TryFindByName(FixedString64Bytes name, out Player player)
Parameters
name
FixedString64BytesThe character name as FixedString64Bytes to search for.
player
PlayerWhen this method returns, contains the player associated with the specified name, if found; otherwise, null.
Returns
- bool
true if a player with the specified name was found; otherwise, false.
TryFindByName(FixedString64Bytes, out PlayerData)
Attempts to find a player by their character name using a FixedString64Bytes.
[Obsolete("This method is deprecated and will be removed in a future version. Use TryFindByName(string, out Player) instead.")]
public static bool TryFindByName(FixedString64Bytes name, out PlayerData playerData)
Parameters
name
FixedString64BytesThe character name as FixedString64Bytes to search for.
playerData
PlayerDataWhen this method returns, contains the player data associated with the specified name, if found; otherwise, the default value.
Returns
- bool
true if a player with the specified name was found; otherwise, false.
TryFindByNetworkId(NetworkId, out Entity)
Attempts to find a user entity by their network ID.
[Obsolete("This method is deprecated and will be removed in a future version. Use TryFindByNetworkId(networkId, out Player) instead.")]
public static bool TryFindByNetworkId(NetworkId networkId, out Entity userEntity)
Parameters
networkId
NetworkIdThe network ID to search for.
userEntity
EntityWhen this method returns, contains the user entity associated with the specified network ID, if found; otherwise, Entity.Null.
Returns
- bool
true if a user entity with the specified network ID was found; otherwise, false.
TryFindByNetworkId(NetworkId, out Player)
Attempts to find a player by their network ID.
public static bool TryFindByNetworkId(NetworkId networkId, out Player player)
Parameters
networkId
NetworkIdThe network ID to search for.
player
PlayerWhen this method returns, contains the player associated with the specified network ID, if found; otherwise, null.
Returns
- bool
true if a player with the specified network ID was found; otherwise, false.
TryFindBySteam(ulong, out Player)
Attempts to find a player by their Steam ID.
public static bool TryFindBySteam(ulong steamId, out Player player)
Parameters
steamId
ulongThe Steam ID to search for.
player
PlayerWhen this method returns, contains the player associated with the specified Steam ID, if found; otherwise, null.
Returns
- bool
true if a player with the specified Steam ID was found; otherwise, false.
TryFindBySteam(ulong, out PlayerData)
Attempts to find a player by their Steam ID.
[Obsolete("This method is deprecated and will be removed in a future version. Use TryFindBySteam(ulong, out Player) instead.")]
public static bool TryFindBySteam(ulong steamId, out PlayerData playerData)
Parameters
steamId
ulongThe Steam ID to search for.
playerData
PlayerDataWhen this method returns, contains the player data associated with the specified Steam ID, if found; otherwise, the default value.
Returns
- bool
true if a player with the specified Steam ID was found; otherwise, false.